Discussion:
VS6 VC++ console app: debug problems where program does not crash
(too old to reply)
j.a. harriman
2005-12-13 20:17:02 UTC
Permalink
Hi,
I am very new to using ADPLUS and WinDbg, so I am hoping for several
options/replies.

I have a console app (multithreaded) which is started by a *.cmd file that
is coded to restart if program goes down as we are 24x7, etc. The program
has logic to error & alert operations if it was in the middle of processing.

Both issues are intermittent, though frequent, i.e. weekly or daily.

The first issue is that the program goes down cleanly (no AVs or Dr Watson
dumps). Through conventional logging, I am getting close to where it is
going down (thread #s are part of log).

The second issue is where we read a record in from disk, do a db lookup (via
ODBC) based on the variables retrieved from the file's record. When the db
lookup is done, the program errors that it cannot find the db record because
the variables (which were pop. by the file's record) are blank.

Can WinDbg be used to debug these types of scenarios on a "live" program -
w/out interfering with the program? If so, how? What information would I be
looking for?

Would I use ADPLUS with some sort of break points to create a dump file? If
so, how?

Any and all ideas would be appreciated.
Thanks. Jeff
Yuan Ren[MSFT]
2005-12-14 07:15:48 UTC
Permalink
Hi Jeff,

Welcome to MSDN Newsgroup!

Currently I am looking for somebody who could help you on it. We will reply
here with more information as soon as possible. If you have any more
concerns on it, please feel free to post here.

Best Regards,

Yuan Ren [MSFT]
Microsoft Community Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.
Jeffrey Tan[MSFT]
2005-12-15 08:27:47 UTC
Permalink
Hi Jeff,

Sorry for letting you wait for so long.

Yes, windbg and the tools it takes are suitable for debugging existing
product level application. But before using the windbg or ADPlus to do the
debugging(on an acitve application or crash dump), we should setup the
symbols for the system dll first, this is critical. For more information,
please refer to the link below:
"Using a Symbol Server"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/htm
l/vxtskusingasymbolserver.asp

For the first scenario, there can be many conditions causing the
application existing cleanly. First, we must ensure there is really no
exceptions causing the application existing unexpected, this may be caused
by handled exception. So if you are not sure of, you can open first chance
exception in the debugger.(That is stop always, not stop when it is not
handled). Actually, I suspect how you are sure that there are no
exceptions/crash in the application, I suggest you use ADPlus to monitor
the applicaiton crash, like this:
Adplus.vbs -crash -p [PID] -o C:\test

Then when the application crashes(or exceptions genreate), ADPlus will
create a dump for the application. It will generate exception for both
first chance and second chance exception. For more information, please see
ADPlus->ADPlus Modes of Operation-> Crash Mode section in windbg help for
more information.

At last, we can load the dump file in the Windbg to analysis the root
cause. Below article is a good start about using windbg commands:
"A word for windbg"
http://mtaulty.com/blog/(5bogl5ub0i0w3m5555lie545)/archive/2004/08/03/608.as
px

For the second issue, I am not sure I understand it very well. What does
"program errors" mean? Does it mean unhandled exceptions? If so, I think we
can still use an ADPlus or windbg to debug this exception.(ADPlus is just a
script that lauches the cdb.exe and attaching on certain process).

Note: ADPlush crahs mode is doing invasive attaching, so the process is
terminated when the debugger is detached, and it will have to be restarted.
This is by design. Windbg now supports Noninvasive debugging, however, the
function is limited, please search "Noninvasive Debugging (User Mode)" in
windbg help.

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
j.a. harriman
2005-12-15 16:16:02 UTC
Permalink
Jeffrey,

Thanks for the info.

For the first scenario do I need to specify -FullOnFirst as a paramter to
ADPLUS? i.e.:
ADPLUS -Crash -FullOnFirst -p <PID> -o <Output dir>

Also, what happens if a user does not perform a CTRL+C when the dump occurs?

As for the second issue, I am waiting for this event to occur again, as I've
added additional conventional logging. I will need to provide further
clarification of the issue. I should have something by Monday 12/19/2005.

On a side note, can a config file be created to use break points as follows:

some_function()
{
int x = 0;
int y = -999;

x = y;
// do some more stuff
return();
}

Can I write the config file to cause the program to create a dump when x
changes, but still have the program keep running (g) and not "go down"?

The idea being, that if I suspect that a variable is being overwritten
(changed) unexpectedly and I want to trap it's contents changing.

If this is possible, is it also possible to determine what overwrote the
variable in WinDbg?

I am gathering as much info/examples/tutorials on WinDbg as I can from many
sources, such as Code Project and others sites, as well as John Robbin's
Bugslayer columns from MSJ, now MSDN Magazine, to learn as much as I can.

Thanks. Jeff
Post by Yuan Ren[MSFT]
Hi Jeff,
Sorry for letting you wait for so long.
Yes, windbg and the tools it takes are suitable for debugging existing
product level application. But before using the windbg or ADPlus to do the
debugging(on an acitve application or crash dump), we should setup the
symbols for the system dll first, this is critical. For more information,
"Using a Symbol Server"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsdebug/htm
l/vxtskusingasymbolserver.asp
For the first scenario, there can be many conditions causing the
application existing cleanly. First, we must ensure there is really no
exceptions causing the application existing unexpected, this may be caused
by handled exception. So if you are not sure of, you can open first chance
exception in the debugger.(That is stop always, not stop when it is not
handled). Actually, I suspect how you are sure that there are no
exceptions/crash in the application, I suggest you use ADPlus to monitor
Adplus.vbs -crash -p [PID] -o C:\test
Then when the application crashes(or exceptions genreate), ADPlus will
create a dump for the application. It will generate exception for both
first chance and second chance exception. For more information, please see
ADPlus->ADPlus Modes of Operation-> Crash Mode section in windbg help for
more information.
At last, we can load the dump file in the Windbg to analysis the root
"A word for windbg"
http://mtaulty.com/blog/(5bogl5ub0i0w3m5555lie545)/archive/2004/08/03/608.as
px
For the second issue, I am not sure I understand it very well. What does
"program errors" mean? Does it mean unhandled exceptions? If so, I think we
can still use an ADPlus or windbg to debug this exception.(ADPlus is just a
script that lauches the cdb.exe and attaching on certain process).
Note: ADPlush crahs mode is doing invasive attaching, so the process is
terminated when the debugger is detached, and it will have to be restarted.
This is by design. Windbg now supports Noninvasive debugging, however, the
function is limited, please search "Noninvasive Debugging (User Mode)" in
windbg help.
Hope this helps
Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights
Jeffrey Tan[MSFT]
2005-12-16 07:12:08 UTC
Permalink
Hi Jeff,

Thanks for your feedback.

I am not sure of if you want the full dump on the first chance exception.
You can find the difference between minidump and fulldump in
Debuggers->Crash Dump Files->User-Mode Dump Files->->Varieties of User-Mode
Dump Files.
Normally, minidump does not contain the heap information. I think we can
first only take minidump on first chance exception, then we can filter
several of these possible exceptions. Then take full dump for the most
possible exceptions.(we can specify the needed dump exception in config
file)

For the write dump on access variable x scenario, I do not think we can do
this. Yes, we can use 'ba' command to do some custom action when certain
memory address is accessed, however, the memory location of variable 'x'
will change from time to time. So we can not get this done. For more
information about how to do custom action when a global/static variable is
accessed, you can refer to the link below:
http://groups.google.com/group/microsoft.public.win32.programmer.kernel/tree
/browse_frm/thread/6be3672918684011/54f751fad98b3dd9?rnum=1&hl=zh-CN&q=%22Je
ffrey+Tan%22+kernel+xp+embeded&_done=%2Fgroup%2Fmicrosoft.public.win32.progr
ammer.kernel%2Fbrowse_frm%2Fthread%2F6be3672918684011%2F959f6c73d8bc3fb4%3Fl
nk%3Dst%26q%3D%22Jeffrey+Tan%22+kernel+xp+embeded%26rnum%3D1%26hl%3Dzh-CN%26
#doc_dbbbc5d8c0e4ecdd

Actually, for local variable, its lifetime is fixed in this function, so I
think we may write the debug output or log file when the variable is
accessed in the function code

Hope this helps

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Jeffrey Tan[MSFT]
2005-12-16 07:16:33 UTC
Permalink
Additionally, ADPlus config file gives us very complex and rich control
over the dump action. You can get the syntax and sample about the config
file in:
Extra Tools->ADPlus->Running ADPlus->ADPlus Configuration Files in windbg
help.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Continue reading on narkive:
Loading...