-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Add a scripted way to re-present a stop location #158128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b5a0c08
Add a way for scripted breakpoint resolvers to present
jimingham 5001e68
Formatting.
jimingham 8630c4c
Merge branch 'main' into facade-locations
jimingham 7ca81ba
Document the TypeDisplay enum.
jimingham a539254
No dangling else's.
jimingham 0d4dfb5
Use num_locs to detect wrap around rather than hard-coding 5.
jimingham 8ca0800
more formatting
jimingham 31fbd56
Merge branch 'main' into facade-locations
jimingham e207a54
Move the documentation to the new location and convert to markdown.
jimingham 1dfcb05
Implement Jonas's review suggestions.
jimingham 740e734
Formatting
jimingham File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,12 @@ namespace lldb_private { | |
|
||
class BreakpointLocation | ||
: public std::enable_shared_from_this<BreakpointLocation> { | ||
friend class BreakpointSite; | ||
friend class BreakpointLocationList; | ||
friend class Breakpoint; | ||
friend class Process; | ||
friend class StopInfoBreakpoint; | ||
|
||
public: | ||
~BreakpointLocation(); | ||
|
||
|
@@ -55,16 +61,39 @@ class BreakpointLocation | |
|
||
Target &GetTarget(); | ||
|
||
/// This is a programmatic version of a breakpoint "condition". When a | ||
/// breakpoint is hit, WasHit will get called before the synchronous | ||
/// ShouldStop callback is run, and if it returns an empty | ||
/// BreakpointLocationSP, lldb will act as if that breakpoint wasn't hit. | ||
/// | ||
/// \param[in] context | ||
/// The context at the stop point | ||
/// | ||
/// \return | ||
/// This will return the breakpoint location that was hit on this stop. | ||
/// If there was no facade location this will be the original location. | ||
/// If the shared pointer is empty, then we'll treat it as if the | ||
/// breakpoint was not hit. | ||
lldb::BreakpointLocationSP WasHit(StoppointCallbackContext *context); | ||
|
||
/// Determines whether we should stop due to a hit at this breakpoint | ||
/// location. | ||
/// | ||
/// Side Effects: This may evaluate the breakpoint condition, and run the | ||
/// callback. So this command may do a considerable amount of work. | ||
/// | ||
/// \param[in] context | ||
/// The context at the stop point | ||
/// | ||
/// \param[out] facade_loc_sp | ||
/// If this stop should be attributed not to the location that was hit, but | ||
/// to a facade location, it will be returned in this facade_loc_sp. | ||
/// | ||
/// \return | ||
/// \b true if this breakpoint location thinks we should stop, | ||
/// \b false otherwise. | ||
bool ShouldStop(StoppointCallbackContext *context); | ||
bool ShouldStop(StoppointCallbackContext *context, | ||
lldb::BreakpointLocationSP &facade_loc_sp); | ||
|
||
// The next section deals with various breakpoint options. | ||
|
||
|
@@ -292,11 +321,6 @@ class BreakpointLocation | |
} | ||
|
||
protected: | ||
friend class BreakpointSite; | ||
friend class BreakpointLocationList; | ||
friend class Process; | ||
friend class StopInfoBreakpoint; | ||
|
||
/// Set the breakpoint site for this location to \a bp_site_sp. | ||
/// | ||
/// \param[in] bp_site_sp | ||
|
@@ -346,9 +370,11 @@ class BreakpointLocation | |
// Constructors and Destructors | ||
// | ||
// Only the Breakpoint can make breakpoint locations, and it owns them. | ||
|
||
/// Constructor. | ||
/// | ||
/// \param[in] loc_id | ||
/// The location id of the new location. | ||
/// | ||
/// \param[in] owner | ||
/// A back pointer to the breakpoint that owns this location. | ||
/// | ||
|
@@ -359,10 +385,26 @@ class BreakpointLocation | |
/// The thread for which this breakpoint location is valid, or | ||
/// LLDB_INVALID_THREAD_ID if it is valid for all threads. | ||
/// | ||
BreakpointLocation(lldb::break_id_t bid, Breakpoint &owner, | ||
BreakpointLocation(lldb::break_id_t loc_id, Breakpoint &owner, | ||
const Address &addr, lldb::tid_t tid, | ||
bool check_for_resolver = true); | ||
|
||
/// This is the constructor for locations with no address. Currently this is | ||
/// just used for Facade locations. | ||
/// | ||
/// \param[in] loc_id | ||
/// The location id of the new location. | ||
/// | ||
/// \param[in] owner | ||
/// A back pointer to the breakpoint that owns this location. | ||
/// | ||
/// | ||
public: | ||
BreakpointLocation(lldb::break_id_t loc_id, Breakpoint &owner); | ||
bool IsValid() const { return m_is_valid; } | ||
bool IsFacade() const { return m_is_facade; } | ||
|
||
private: | ||
// Data members: | ||
bool m_should_resolve_indirect_functions; | ||
bool m_is_reexported; | ||
|
@@ -390,6 +432,17 @@ class BreakpointLocation | |
/// location was given somewhere in the virtual inlined call stack since the | ||
/// Address always resolves to the lowest entry in the stack. | ||
std::optional<LineEntry> m_preferred_line_entry; | ||
bool m_is_valid = true; /// Because Facade locations don't have sites | ||
/// we can't use the presence of the site to mean | ||
/// this breakpoint is valid, but must manage | ||
/// the state directly. | ||
bool m_is_facade = false; /// Facade locations aren't directly triggered | ||
/// and don't have a breakpoint site. They are | ||
/// a useful fiction when you want to represent | ||
/// the stop location as something lldb can't | ||
/// naturally stop at. | ||
|
||
|
||
void SetInvalid() { m_is_valid = false; } | ||
|
||
void SetShouldResolveIndirectFunctions(bool do_resolve) { | ||
m_should_resolve_indirect_functions = do_resolve; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like how you give a conceptual explanation of the feature here but I think it would be great we could add a little tutorial to show what workflow this feature enables. I'd just take your test example and run the user through it.
I also think we have to add a
ScriptedBreakpointResolver
base class to the lldb python module and document it like we do for other Scripted Extensions, that way you could just link to the auto-generated extension page so it always stay up-to-date.Lastly, I think we should break down the python-reference page into subpages targeting specific topics. I think that'd improve discoverability and readability. I can take of that part :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a ScriptedBreakpointResolver Python base class is a general improvement to the ScriptedBreakpointResolver system, and while that seems like a fine improvement, it isn't germane to this patch, nor does this patch make it any easier or harder to add that python base class. That seems more appropriate for a follow-on patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do the base class as a follow-up