Re: Exception and GetLastError()



Hi,

look at code blow
////////////////////
try
{
blah blah blah
}catch(...)
{
DWORD dw = GetLastError()
}
////////////////////

Does it make sence to call GetLastError() in catch block?
In my opinion, I dont think it's necesary do like above, but could sure
about it.

Try to avoid general catch(...)-handlers as you only blindly hide
program faults. Take crashes as a chance to find the reason for the
error and fix it. If you want to catch any error to do some error
logging you should put a throw; at the end of the catch block so that
the exception is rethrown and a debugger or DrWatson can catch an
report it, e.g. as a mini dump. If you have debug symbols for all your
modules you might find the cause of the error by opening such a mini
dump in a debugger.

mimi dump?
Could you please give a sample about this?

Take a look at http://www.microsoft.com/whdc/devtools/debugging/default.mspx to get information about the debugging SDK.
Mini dumps are snap shots of parts of a processes memory, like the call stacks of the current threads and maybe also parts of the heap.

DrWatson does write those dumps. Use drwtsn32 -i to set it as debugger and drwtsn32 to configure some parameters like which directory to use to write the dump files to.

Those dump files (usually with an extension of dmp, mdmp, udmp or hdmp) can be loaded with windbg from the debugging sdk so that you can analyze the state of a process when an exception occurs.

You can also use MiniDumpWriteDump to create dump files programmatically. It is alos describer in the debugging SDK.

Those dumps depend heavily on debug symbols, so be sure to create all modules (dll, ocx and exes) with debugging symbols (pdb files). Microsoft provides them with their public symbol server (also described in the debugging sdk).

--
SvenC

.



Relevant Pages

  • Re: Crashdump Win2k Server
    ... I'm afraid that mini dump is too limited to analyze and obtain enough ... I suggest that you config "Write debugging information" to Complete memory ...
    (microsoft.public.windows.server.general)
  • Re: WER and managed minidumps
    ... debugger is only looking for native symbols. ... VS2005 debugger always works in native mode when debugging dumps. ... you should use SOS extension in Immediate ... (though note that the information contained in a dump created with WER ...
    (microsoft.public.vsnet.debugging)
  • Re: Memory.dmp
    ... >>The computer has rebooted from a bugcheck. ... >>How can i found out what causes the reboot? ... This means the dump contains ... > code and has to be analyzed using a debugging program. ...
    (microsoft.public.win2000.general)
  • [PATCH 09/44 take 2] [UBI] debug unit header
    ... * the GNU General Public License for more details. ... * UBI debugging unit. ... The debugging prints may also be directed to the console. ... * @vtr: the object to dump ...
    (Linux-Kernel)
  • Re: [Bug #13319] Page allocation failures with b43 and p54usb
    ... "enable it blah blah blah\n"); ... I don't see how that's different from enabling debugging on all caches ... * The maximum amount of metadata added to a slab when debugging is enabled. ...
    (Linux-Kernel)