You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a scripted way to re-present a stop location (#158128)
This patch adds the notion of "Facade" locations which can be reported
from a ScriptedResolver instead of the actual underlying breakpoint
location for the breakpoint. Also add a "was_hit" method to the scripted
resolver that allows the breakpoint to say which of these "Facade"
locations was hit, and "get_location_description" to provide a
description for the facade locations.
I apologize in advance for the size of the patch. Almost all of what's
here was necessary to (a) make the feature testable and (b) not break
any of the current behavior.
The motivation for this feature is given in the "Providing Facade
Locations" section that I added to the python-reference.rst so I won't
repeat it here.
rdar://152112327
Copy file name to clipboardExpand all lines: lldb/docs/use/tutorials/creating-custom-breakpoints.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,4 +125,48 @@ you can use for this purpose. Your __init__ function gets passed this
125
125
SBStructuredData object. This API also allows you to directly provide the list
126
126
of Modules and the list of CompileUnits that will make up the SearchFilter. If
127
127
you pass in empty lists, the breakpoint will use the default "search
128
-
everywhere,accept everything" filter.
128
+
everywhere,accept everything" filter.
129
+
130
+
### Providing Facade Locations:
131
+
132
+
The breakpoint resolver interface also allows you to present a separate set
133
+
of locations for the breakpoint than the ones that actually implement the
134
+
breakpoint in the target.
135
+
136
+
An example use case for this is if you are providing a debugging interface for a
137
+
library that implements an interpreter for a language lldb can't debug. But
138
+
while debugging that library at the level of the implementation language (e.g. C/C++, etc)
139
+
you would like to offer the ability to "stop when a line in a source language
140
+
file is executed".
141
+
142
+
You can do this if you know where new lines of code are dispatched in the
143
+
interpreter. You would set a breakpoint there, and then look at the state
144
+
when that breakpoint is hit to see if it is dispatching the source file and
145
+
line that were requested, and stop appropriately.
146
+
147
+
Facade breakpoint locations are intended to make a more natural presentation
148
+
of that sort of feature. The idea is that you would make a custom breakpoint
149
+
resolver that sets actual locations in the places of interest in the interpreter.
150
+
151
+
Then your resolver would add "facade locations" that represent the places in the
152
+
interpreted code that you want the breakpoint to stop at, using SBBreakpoint::AddFacadeLocation.
153
+
When lldb describes the breakpoint, it will only show the Facade locations.
154
+
Since facade breakpoint location's description is customizable, you can make these
155
+
locations more descriptive. And when the "real" location is hit, lldb will call the
156
+
"was_hit" method of your resolver. That will return the facade location you
157
+
consider to have been hit this time around, or if you return None, the breakpoint
158
+
will be considered not to have been hit.
159
+
160
+
Note, this feature is also useful if you don't intend to present facade
161
+
locations since it essentially provides a scripted breakpoint condition. Every
162
+
time one of the locations in your breakpoint is hit, you can run the code in
163
+
your "was_hit" to determine whether to consider the breakpoint hit or not, and
164
+
return the location you were passed in if you want it to be a hit, and None if not.
165
+
166
+
The Facade location adds these optional affordances to the Resolver class:
167
+
168
+
| Name | Arguments | Description|
169
+
|-------|-----------|------------|
170
+
|`was_hit`|`frame`:`lldb.SBFrame``bp_loc`:`lldb.SBBreakpointLocation`| This will get called when one of the "real" locations set by your resolver is hit. `frame` is the stack frame that hit this location. `bp_loc` is the real location that was hit. Return either the facade location that you want to consider hit on this stop, or None if you don't consider any of your facade locations to have been hit. |
171
+
|`get_location_description`|`bp_loc`:`lldb.SBBreakpointLocation``desc_level`:`lldb.DescriptionLevel``bp_loc` is the facade location to describe.| Use this to provide a helpful description of each facade location. ``desc_level`` is the level of description requested. The Brief description is printed when the location is hit. Full is printed for `break list` and Verbose for `break list -v`.|
0 commit comments