473,461 Members | 1,501 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Debug/Inspect without breakpoint

Consider the following simple class:

public class ClassA
{
public static string VAR = "hello";
}

public void MethodA()
{
while(true)
{
Thread.sleep(1000);
Console.WriteLine("oi");
}
}
Assume that MethodA has been called already. If we debug this process and
put a breakpoint at Console.WriteLine( ), we can easily determine the value
of VAR. However, I can only seem to do this when the breakpoint gets hit.
I'm thinking there must be a way to determine what the current value of VAR
is *without* the breakpoint. If I use the Command Window - Immediate, and
do

ClassA.VAR

I get 'The expression cannot be evaluated while in run mode.'

Obviously I can make my program hit a breakpoint by doing something but it
would be cleaner if I could just inspect any static class variable without
having to place a breakpoint.

Wal
Nov 16 '05 #1
4 2002
Wal,

Surely the obvious problem with this is that if your program is not as a
break point, or paused as a result of stepping from a break point, then the
application is running...

From the IDE's point of view, if the application is currently running,
what's to stop VAR from changing while you're trying to evaluate it?
"Wal Turner" <vo****@hotmail.com> wrote in message
news:ux*************@TK2MSFTNGP14.phx.gbl...
Consider the following simple class:

public class ClassA
{
public static string VAR = "hello";
}

public void MethodA()
{
while(true)
{
Thread.sleep(1000);
Console.WriteLine("oi");
}
}
Assume that MethodA has been called already. If we debug this process and
put a breakpoint at Console.WriteLine( ), we can easily determine the
value of VAR. However, I can only seem to do this when the breakpoint gets
hit. I'm thinking there must be a way to determine what the current value
of VAR is *without* the breakpoint. If I use the Command Window -
Immediate, and do

ClassA.VAR

I get 'The expression cannot be evaluated while in run mode.'

Obviously I can make my program hit a breakpoint by doing something but it
would be cleaner if I could just inspect any static class variable without
having to place a breakpoint.

Wal

Nov 16 '05 #2
Well, the only situation that I can kind of relate to, is when using
something like Direct3D where you want to track something like the
framerate. I usually set up some sort of onscreen trace message that
will interactively change as the application runs so I can inspect its
value at run-time.

A few conditional compile statements and it makes management of this
super easy

#if DEBUG
Trace.Write(this.FPS)
#endif

Hope that helps,
Joel Martinez
http://www.onetug.org - Orlando .NET User Group
http://www.codecube.net - Blog

"Wal Turner" <vo****@hotmail.com> wrote in message news:<ux*************@TK2MSFTNGP14.phx.gbl>...
Consider the following simple class:

public class ClassA
{
public static string VAR = "hello";
}

public void MethodA()
{
while(true)
{
Thread.sleep(1000);
Console.WriteLine("oi");
}
}
Assume that MethodA has been called already. If we debug this process and
put a breakpoint at Console.WriteLine( ), we can easily determine the value
of VAR. However, I can only seem to do this when the breakpoint gets hit.
I'm thinking there must be a way to determine what the current value of VAR
is *without* the breakpoint. If I use the Command Window - Immediate, and
do

ClassA.VAR

I get 'The expression cannot be evaluated while in run mode.'

Obviously I can make my program hit a breakpoint by doing something but it
would be cleaner if I could just inspect any static class variable without
having to place a breakpoint.

Wal

Nov 16 '05 #3
Correct, the application is running....but suppose the application in
question shows some unexpected behaviour, (not an error per se) and you want
to expect some variables, lets say a static class array, which you knew
wouldnt be changing (even if it was doesnt matter)...the only way you'd be
able to 'get in' to inspect it is to have a breakpoint hit! The
information of the array is obviously stored in memory somewhere but i see
it as a limitation that you can't inspect it without having a breakpoint.

I suppose its not *that* difficult to get around...you just have a thread
that constantly loops and does nothing that you can put a breakpoint on and
get a 'hold' of the application. Not that pretty

Wal

----- Original Message -----
From: "Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Wednesday, November 17, 2004 8:06 PM
Subject: Re: Debug/Inspect without breakpoint

Wal,

Surely the obvious problem with this is that if your program is not as a
break point, or paused as a result of stepping from a break point, then
the application is running...

From the IDE's point of view, if the application is currently running,
what's to stop VAR from changing while you're trying to evaluate it?
"Wal Turner" <vo****@hotmail.com> wrote in message
news:ux*************@TK2MSFTNGP14.phx.gbl...
Consider the following simple class:

public class ClassA
{
public static string VAR = "hello";
}

public void MethodA()
{
while(true)
{
Thread.sleep(1000);
Console.WriteLine("oi");
}
}
Assume that MethodA has been called already. If we debug this process and
put a breakpoint at Console.WriteLine( ), we can easily determine the
value of VAR. However, I can only seem to do this when the breakpoint
gets hit. I'm thinking there must be a way to determine what the current
value of VAR is *without* the breakpoint. If I use the Command Window -
Immediate, and do

ClassA.VAR

I get 'The expression cannot be evaluated while in run mode.'

Obviously I can make my program hit a breakpoint by doing something but
it would be cleaner if I could just inspect any static class variable
without having to place a breakpoint.

Wal


Nov 16 '05 #4
Wal,

The way you'd monitor this sort of thing is logging (or tracing) the
variables you want to monitor to disk (or to another window). By providing a
brief description around the variable log, you'll be able to see a run
history of your application after it's finished. This will allow you to look
at any variable you wish, at any point in the application without stopping
it.

If you place timestamps into your log you can record when the problems occur
and line them up with the log times to find out if the variables change
etc...

It's also useful for monitoring which code paths were executed and which
were not reached.

Dan.
"Wal Turner" <vo****@hotmail.com> wrote in message
news:uO*************@TK2MSFTNGP14.phx.gbl...
Correct, the application is running....but suppose the application in
question shows some unexpected behaviour, (not an error per se) and you
want
to expect some variables, lets say a static class array, which you knew
wouldnt be changing (even if it was doesnt matter)...the only way you'd be
able to 'get in' to inspect it is to have a breakpoint hit! The
information of the array is obviously stored in memory somewhere but i see
it as a limitation that you can't inspect it without having a breakpoint.

I suppose its not *that* difficult to get around...you just have a thread
that constantly loops and does nothing that you can put a breakpoint on
and
get a 'hold' of the application. Not that pretty

Wal

----- Original Message -----
From: "Dan Bass" <danielbass [at] postmaster [dot] co [dot] uk>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Wednesday, November 17, 2004 8:06 PM
Subject: Re: Debug/Inspect without breakpoint

Wal,

Surely the obvious problem with this is that if your program is not as a
break point, or paused as a result of stepping from a break point, then
the application is running...

From the IDE's point of view, if the application is currently running,
what's to stop VAR from changing while you're trying to evaluate it?
"Wal Turner" <vo****@hotmail.com> wrote in message
news:ux*************@TK2MSFTNGP14.phx.gbl...
Consider the following simple class:

public class ClassA
{
public static string VAR = "hello";
}

public void MethodA()
{
while(true)
{
Thread.sleep(1000);
Console.WriteLine("oi");
}
}
Assume that MethodA has been called already. If we debug this process
and put a breakpoint at Console.WriteLine( ), we can easily determine
the value of VAR. However, I can only seem to do this when the
breakpoint gets hit. I'm thinking there must be a way to determine what
the current value of VAR is *without* the breakpoint. If I use the
Command Window - Immediate, and do

ClassA.VAR

I get 'The expression cannot be evaluated while in run mode.'

Obviously I can make my program hit a breakpoint by doing something but
it would be cleaner if I could just inspect any static class variable
without having to place a breakpoint.

Wal



Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Amaury | last post by:
Hello, When debugging C extensions, I find the most difficult is to detect that an object is Py_DECREF'ed when it should not. And when you find yourself with an invalid object, it's a nightmare...
3
by: Vi | last post by:
Hi, I have a very weird problem. Have anyone encounter this and how do you solve it? For example, I have 20 line of code (example only, no real sense) 0 1 for(int i=0;i<NoOfMatches;i++) {...
8
by: Davy | last post by:
Hi all, I use VC and gcc/gdb to compile and debug C/C++ files. But I found some of the debug version of the compiled files are too large to be run in a small RAM. Can I compile C/C++ Debug...
4
by: emma middlebrook | last post by:
I have a question regarding asserting ... here's some code: string GetAssertMessage() { ... prepare a message string and return it... } void SomeMethod() { ...
0
by: High and dRy | last post by:
Print debug messages at the beginning of all the methods with the method name and the argument values and at the end with the return values. Is it possible to do the in C# without writing debug...
3
by: c0uch | last post by:
the first and third methods are in a usercontrol object. txtValue is a TextBox the float.parse in the if statement on line 3 always works fine. the second float.parse in the third method is...
5
by: asdf | last post by:
Hello, I was enjoying working in VS for half a year without any problems and now I cannot debug anymore. Without any really reason my Studio tells me that the page that I want to debug has - No...
6
by: Boni | last post by:
Dear all, I have following problem. I created a static libruary (mylib.lib). I compiled it with Multithreaded DLL runtime in release mode. Now I want to give out this library. But users who...
5
by: kmilburn | last post by:
Please help.. I can't debug ASP.NET 1.1 application. I also have ASP.NET 2.0 installed. Running aspnet_regiis -lv produces: =====================================================...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.