stack trace in exception

This is a discussion on stack trace in exception within the Windows Programming forums, part of the Platform Specific Boards category; Hello everyone, Here is the !pe output from WinDbg when there is an exception. It shows exactly the function name ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    stack trace in exception

    Hello everyone,


    Here is the !pe output from WinDbg when there is an exception. It shows exactly the function name where exception occurs.

    My question is, how to show the line in the source code which triggers the exception?

    Here is WinDbg output.

    0:000> !pe
    Exception object: 0000000002651ac0
    Exception type: System.Exception
    Message: Hello Exception Debug
    InnerException: <none>
    StackTrace (generated):
    SP IP Function
    000000000012EFF0 00000642801501F4 TestDebug!TestDebug.Program.foo()+0x64
    000000000012F030 000006428015014D TestDebug!TestDebug.Program.Main(System.String[])+0x2d

    StackTraceString: <none>
    HResult: 80131500


    thanks in advance,
    George

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Looks like 100 (0x64) bytes into the function foo(). As to what line number that is, I'd view a mixed source and assembly listing and see what turns up at [roughly - stack trace is not always 100% accurate, so the suspect could be one or three instructions above where it's reported from] 100 bytes into the function.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks Mats,


    I am very interested in your solution. Any idea about how to get the source code for the 100bytes of the function?

    Quote Originally Posted by matsp View Post
    Looks like 100 (0x64) bytes into the function foo(). As to what line number that is, I'd view a mixed source and assembly listing and see what turns up at [roughly - stack trace is not always 100% accurate, so the suspect could be one or three instructions above where it's reported from] 100 bytes into the function.

    --
    Mats

    regards,
    George

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Just look at the disassembly. The "u" command will list assembly code. If the function is relatively short, "u function" or "u address" will be fine. If it's a long function, there's a way to limit the number of lines disassembled - I can't quite remember what that is, but if you do "help u" it will show you the information of that command.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Lame null append cause buffer to crash
    By cmoo in forum C Programming
    Replies: 8
    Last Post: 12-29-2008, 03:27 AM
  2. stack and pointer problem
    By ramaadhitia in forum C Programming
    Replies: 2
    Last Post: 09-12-2006, 12:41 AM
  3. Question about a stack using array of pointers
    By Ricochet in forum C++ Programming
    Replies: 6
    Last Post: 11-17-2003, 10:12 PM
  4. error trying to compile stack program
    By KristTlove in forum C++ Programming
    Replies: 2
    Last Post: 11-03-2003, 06:27 PM
  5. Stack Program Here
    By Troll_King in forum C Programming
    Replies: 7
    Last Post: 10-15-2001, 06:36 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21