How to put a breakpoint at the end of a function in windbg, so that I dont need to edit it even if some lines have been added/deleted in the source?
Asked Answered
H

3

6

I need to log some data when some functions are hit, both at the start of execution and and the end of it. While i have no problem with putting breakpoints at the start of the functions(using bu [module]!functionname, I dont know how to put a breakpoint at the end of a function, SUCH THAT i dont need to edit the breakpoint everytime i add/delete somelines from the file/function. I'm sure its a very common scenario, just that I dont know how its done !! Can anyone elucidate ?

Heterolysis answered 2/4, 2010 at 10:31 Comment(0)
W
7

You can use the breakpoint at the start of the function to setup the breakpoint at the return address. Like this:

bu [module]!functionname "bp /1 @$ra \".echo Exit functionname ; g\"; .echo Enter functionname; g"

Caveat: this may not work if an exception is thrown in the function.

Witha answered 17/4, 2010 at 21:23 Comment(0)
C
1

Here is what you are exactly looking for

Get function return values and profiling information in .NET using Windbg

It is explained how to set a break-point on function return

The same is applicable for native code also.

Hope this helps.

Cannae answered 2/4, 2010 at 12:30 Comment(1)
URL is broken - I've checked your "posts" page, and there isn't anything with this title there either...Gatian
T
1

you can use pt command ,which means step to next Return. for example when you hit your function at the begin, enter only pt command will hit the code at wherever return was called.

Tetany answered 25/5, 2016 at 1:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.