473,770 Members | 2,120 Online
Bytes | Software Development & Data Engineering Community
+ 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(10 00);
Console.WriteLi ne("oi");
}
}
Assume that MethodA has been called already. If we debug this process and
put a breakpoint at Console.WriteLi ne( ), 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 2028
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******** *****@TK2MSFTNG P14.phx.gbl...
Consider the following simple class:

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

public void MethodA()
{
while(true)
{
Thread.sleep(10 00);
Console.WriteLi ne("oi");
}
}
Assume that MethodA has been called already. If we debug this process and
put a breakpoint at Console.WriteLi ne( ), 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(thi s.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******* ******@TK2MSFTN GP14.phx.gbl>.. .
Consider the following simple class:

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

public void MethodA()
{
while(true)
{
Thread.sleep(10 00);
Console.WriteLi ne("oi");
}
}
Assume that MethodA has been called already. If we debug this process and
put a breakpoint at Console.WriteLi ne( ), 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.publi c.dotnet.langua ges.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******** *****@TK2MSFTNG P14.phx.gbl...
Consider the following simple class:

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

public void MethodA()
{
while(true)
{
Thread.sleep(10 00);
Console.WriteLi ne("oi");
}
}
Assume that MethodA has been called already. If we debug this process and
put a breakpoint at Console.WriteLi ne( ), 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******** *****@TK2MSFTNG P14.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.publi c.dotnet.langua ges.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******** *****@TK2MSFTNG P14.phx.gbl...
Consider the following simple class:

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

public void MethodA()
{
while(true)
{
Thread.sleep(10 00);
Console.WriteLi ne("oi");
}
}
Assume that MethodA has been called already. If we debug this process
and put a breakpoint at Console.WriteLi ne( ), 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
2406
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 to find where the error occured! Normally tools like Purify are good to find this kind of memory errors, but they are of no use with python's own memory allocator. That's why I recompiled python (on Windows) in debug mode after
3
1554
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++) { 2
8
2698
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 partially? Something like: fileA.c fileB.c And I can compile fileA.c with debug info and compile fileB.c without debug info?
4
4531
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
1325
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 messages in each functions. May be use Emit or something. Is there any tool out there that could instrument my methods with a pre and post statements ? Thanks, ~Saurabh
3
3340
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 quirky: if the program just runs it will always break on that line, vc# 2005 beta2 shows txtValue.Text as null at this point. However, if I put a breakpoint on the first float.parse (on line 3), and then step out until i reach the second float.parse,...
5
2947
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 symbols loaded. I use VS v1.7.3088 and .NET framework v1.1.4322 SP1. I work with ASP.NET using VB and I'm trying to set a breakpoint on the ascx.vb file.
6
2279
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 use it should be able to debug their programs (i.e. compile their programs in debug mode Multithreaded DLL DEBUG runtime ). But at link time following warning is shown and prog crashes. Do I have to
5
1495
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: ===================================================== C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322>aspnet_regiis -lv 1.1.4322.0 Valid C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\asp net_isapi.dll
0
9618
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9906
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.