This is an archive of the discontinued LLVM Phabricator instance.

Generate an event when a pending breakpoint binds
ClosedPublic

Authored by ki.stfu on Apr 6 2015, 3:24 PM.

Details

Summary

This checkin sends an MI event when a module is loaded that causes a pending breakpoint to bind to it's real address in the target. This allows breakpoints to be set before the process is launched, and the target address of the BP to be discovered when the module loads, prior to the breakpoint being hit.

Patch from chuckr@microsoft.com

Diff Detail

Repository
rL LLVM

Event Timeline

ChuckR updated this revision to Diff 23298.Apr 6 2015, 3:24 PM
ChuckR retitled this revision from to Generate an event when a pending breakpoint binds.
ChuckR updated this object.
ChuckR edited the test plan for this revision. (Show Details)
ChuckR added reviewers: abidh, jingham.
ChuckR edited the test plan for this revision. (Show Details)
ChuckR added a subscriber: Unknown Object (MLST).
ChuckR edited the test plan for this revision. (Show Details)Apr 6 2015, 3:27 PM

Can we print address of the resolved bp?

What do you mean? It is printed:

breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100000f4d",func="main",file="main.cpp",fullname="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/main.cpp",line="15",pending=["main.cpp:15"],times="0",original-location="main.cpp:15"}

What do you mean? It is printed:

breakpoint-modified,bkpt={number="1",type="breakpoint",disp="keep",enabled="y",addr="0x0000000100000f4d",func="main",file="main.cpp",fullname="/Users/chuckr/llama/llvm/tools/lldb/test/tools/lldb-mi/main.cpp",line="15",pending=["main.cpp:15"],times="0",original-location="main.cpp:15"}

Ok. I just didn't see the addr field in test plan.

ki.stfu accepted this revision.Apr 7 2015, 1:26 PM
ki.stfu added a reviewer: ki.stfu.

Lgtm

This revision is now accepted and ready to land.Apr 7 2015, 1:26 PM
ChuckR added a comment.Apr 8 2015, 2:32 PM

Do I need more sign off to get this checked in?

Do I need more sign off to get this checked in?

No. I can commit it for you if you want, ok?

ChuckR added a comment.Apr 8 2015, 2:56 PM

That would be perfect, thanks.

jingham edited edge metadata.Apr 8 2015, 2:59 PM

This looks fine. Your description of the patch doesn't use terminology in quite the same way as lldb does. This isn't an MI event, it is just a regular lldb event. There really aren't MI events. That's not terribly important, except if you were to think that these are only used by MI...

Also, just to be clear, lldb breakpoints are either never or always pending depending on how you look at it. In lldb itself we only call a breakpoint "pending" if it has no locations (i.e. the breakpoint specification hasn't yet matched any real location in the program.) Also, breakpoints never stop resolving themselves in lldb.

So for instance, suppose you set a breakpoint by function name on Foo. If it exists in your main executable, then before you run it that location will be added to the breakpoint (and an eBreakpointEventTypeLocationsAdded event will be generated.) That location will have an address, but it will be the address of Foo in the binary, which may or may not be where it will get loaded. This is an interesting point in the life of the breakpoint, since once you have a location, resolved or not, you can put conditions and commands on it, and enable or disable it. In that sense, this is a more interesting event than "resolved".

When you run your program and the location gets a real address in memory, a breakpoint site will be created and all the locations will bind to it - and with your patch a eBreakpointEventTypeLocationsResolved event will be generated for each location at that real address.

Then if another shared library gets loaded which also has a function Foo, another location will be created, and bound to it's physical address, and you will now get two events, eBreakpointEventTypeLocationsAdded and eBreakpointEventTypeLocationsResolved. Etc. as more libraries are loaded. And of course, if the library is unloaded, the location's physical address will become invalid and the site will get destroyed. However, the location will stay around waiting for the library to get loaded again. Locations only go away when a changed version of a binary is loaded which causes the locations to change.

It doesn't look like there is a "location unresolved" event, but if you are reporting location resolution, you might want to report unresolution or whatever is a good word for that...

Anyway, in itself this change looks fine to me, but I just wanted to explain how the system works in case you also want to handle location changed and/or unresolved as well in the MI.

Jim

ChuckR added a comment.Apr 8 2015, 4:34 PM

Thank you for the information.

You will see this resolved event when you make a new breakpoint after the process is running as well as when a pre-existing breakpoint gets a location on load. So you should be able to write an MI test that sets a breakpoint and then makes sure you emit the breakpoint-modified event that arises from the site being added to the location that's been found for it.

ki.stfu commandeered this revision.Apr 9 2015, 4:27 AM
ki.stfu edited reviewers, added: ChuckR; removed: ki.stfu.
This revision now requires review to proceed.Apr 9 2015, 4:27 AM
ki.stfu updated this object.Apr 9 2015, 4:28 AM
ki.stfu edited edge metadata.
ki.stfu updated this revision to Diff 23474.Apr 9 2015, 4:29 AM

Rebase against ToT

This revision was automatically updated to reflect the committed changes.