-
Notifications
You must be signed in to change notification settings - Fork 15.2k
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 1 commit
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -248,6 +248,23 @@ class Breakpoint : public std::enable_shared_from_this<Breakpoint>, | |
| /// Returns a pointer to the new location. | ||
| lldb::BreakpointLocationSP AddLocation(const Address &addr, | ||
| bool *new_location = nullptr); | ||
| /// Add a `facade` location to the breakpoint's collection of facade locations. | ||
| /// This is only meant to be called by the breakpoint's resolver. | ||
| /// Facade locations are placeholders that a scripted breakpoint can use to | ||
| /// represent the stop locations provided by the breakpoint. The scripted | ||
| /// breakpoint should record the id of the facade location, and provide | ||
| /// the description of the location in the GetDescription method | ||
| /// To emulate hitting a facade location, the breakpoint's WasHit should | ||
| /// return the ID of the facade that was "hit". | ||
| /// | ||
| /// \param[out] new_location | ||
| /// Set to \b true if a new location was created, to \b false if there | ||
| /// already was a location at this Address. | ||
| /// \return | ||
| /// Returns a pointer to the new location. | ||
| lldb::BreakpointLocationSP AddFacadeLocation(); | ||
|
|
||
| lldb::BreakpointLocationSP GetFacadeLocationByID(lldb::break_id_t); | ||
|
|
||
| /// Find a breakpoint location by Address. | ||
| /// | ||
|
|
@@ -268,27 +285,36 @@ class Breakpoint : public std::enable_shared_from_this<Breakpoint>, | |
| /// there is no breakpoint location at that address. | ||
| lldb::break_id_t FindLocationIDByAddress(const Address &addr); | ||
|
|
||
| /// Find a breakpoint location for a given breakpoint location ID. | ||
| /// Find a breakpoint location for a given breakpoint location ID. If there | ||
| /// are Facade Locations in the breakpoint, the facade locations will be | ||
| /// searched instead of the "real" ones. | ||
| /// | ||
| /// \param[in] bp_loc_id | ||
| /// The ID specifying the location. | ||
| /// | ||
| /// \param[in] use_facade | ||
| /// If \b true, then prefer facade locations over "real" ones if they exist. | ||
| /// | ||
| /// \return | ||
| /// Returns a shared pointer to the location with ID \a bp_loc_id. The | ||
| /// pointer | ||
| /// in the shared pointer will be nullptr if there is no location with that | ||
| /// ID. | ||
| lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id); | ||
| lldb::BreakpointLocationSP FindLocationByID(lldb::break_id_t bp_loc_id, bool use_facade = true); | ||
|
|
||
| /// Get breakpoint locations by index. | ||
| /// | ||
| /// \param[in] index | ||
| /// The location index. | ||
| /// | ||
| /// \param[in] use_facade | ||
| /// If \b true, then prefer facade locations over "real" ones if they exist. | ||
| /// | ||
| /// \return | ||
| /// Returns a shared pointer to the location with index \a | ||
| /// index. The shared pointer might contain nullptr if \a index is | ||
| /// greater than then number of actual locations. | ||
| lldb::BreakpointLocationSP GetLocationAtIndex(size_t index); | ||
| lldb::BreakpointLocationSP GetLocationAtIndex(size_t index, bool use_facade = true); | ||
|
|
||
| /// Removes all invalid breakpoint locations. | ||
| /// | ||
|
|
@@ -409,9 +435,12 @@ class Breakpoint : public std::enable_shared_from_this<Breakpoint>, | |
| /// Return the number of breakpoint locations that have resolved to actual | ||
| /// breakpoint sites. | ||
| /// | ||
| /// \param[in] use_facade | ||
| /// If \b true, then prefer facade locations over "real" ones if they exist. | ||
| /// | ||
| /// \return | ||
| /// The number locations resolved breakpoint sites. | ||
| size_t GetNumResolvedLocations() const; | ||
| size_t GetNumResolvedLocations(bool use_facade = true) const; | ||
|
|
||
| /// Return whether this breakpoint has any resolved locations. | ||
| /// | ||
|
|
@@ -421,9 +450,12 @@ class Breakpoint : public std::enable_shared_from_this<Breakpoint>, | |
|
|
||
| /// Return the number of breakpoint locations. | ||
| /// | ||
| /// \param[in] use_facade | ||
| /// If \b true, then prefer facade locations over "real" ones if they exist. | ||
| /// | ||
| /// \return | ||
| /// The number breakpoint locations. | ||
| size_t GetNumLocations() const; | ||
| size_t GetNumLocations(bool use_facade = true) const; | ||
|
|
||
| /// Put a description of this breakpoint into the stream \a s. | ||
| /// | ||
|
|
@@ -529,6 +561,20 @@ class Breakpoint : public std::enable_shared_from_this<Breakpoint>, | |
| m_name_list.erase(name_to_remove); | ||
| } | ||
|
|
||
| enum TypeDisplay { | ||
|
||
| eDisplayFacade = 1, | ||
| eDisplayReal = 1 << 1, | ||
| eDisplayHeader = 1 << 2 | ||
| }; | ||
|
|
||
| void GetDescriptionForType(Stream *s, lldb::DescriptionLevel level, | ||
| uint8_t display_type, bool show_locations); | ||
|
|
||
| bool HasFacadeLocations() { | ||
| return m_facade_locations.GetSize() != 0; | ||
| } | ||
|
|
||
|
|
||
| public: | ||
| bool MatchesName(const char *name) { | ||
| return m_name_list.find(name) != m_name_list.end(); | ||
|
|
@@ -657,6 +703,8 @@ class Breakpoint : public std::enable_shared_from_this<Breakpoint>, | |
| BreakpointOptions m_options; // Settable breakpoint options | ||
| BreakpointLocationList | ||
| m_locations; // The list of locations currently found for this breakpoint. | ||
| BreakpointLocationCollection m_facade_locations; | ||
|
|
||
| std::string m_kind_description; | ||
| bool m_resolve_indirect_symbols; | ||
|
|
||
|
|
||
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
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
ScriptedBreakpointResolverbase 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