Skip to content

[lldb][Docs] Add equivalents of GDB's "skip" to command map #120740

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 3 commits into from
Jan 6, 2025

Conversation

DavidSpickett
Copy link
Collaborator

@DavidSpickett DavidSpickett commented Dec 20, 2024

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Skipping-Over-Functions-and-Files.html

We can't emulate all the features of that command but we can skip a function by name with some extra steps.

As far as I know this only matches function name unlike GDB that can filter on file and line and so on:

target.process.thread.step-avoid-regexp -- A regular expression defining functions step-in won't stop in.

It's likely it's got some corner cases that don't work, maybe inlining, but it doesn't seem worth going into it here.

I don't think we can chain lldb interpreter commands, so I have shown the steps separately.

I have also mentioned thread step-in and its alias sif. Which were new to me too.

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Skipping-Over-Functions-and-Files.html

We can't emulate all the features of that command but we can
skip a function by name with some extra steps.

As far as I know this only matches function name unlike GDB
that can filter on file and line and so on:
```
target.process.thread.step-avoid-regexp -- A regular expression defining functions step-in won't stop in.
```

It's likely it's got some corner cases that don't work, maybe
inlining, but it doesn't seem worth going into it here.

I don't think we can chain lldb interpreter commands, so I
have shown the steps separately.
@llvmbot
Copy link
Member

llvmbot commented Dec 20, 2024

@llvm/pr-subscribers-lldb

Author: David Spickett (DavidSpickett)

Changes

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Skipping-Over-Functions-and-Files.html

We can't emulate all the features of that command but we can skip a function by name with some extra steps.

As far as I know this only matches function name unlike GDB that can filter on file and line and so on:

target.process.thread.step-avoid-regexp -- A regular expression defining functions step-in won't stop in.

It's likely it's got some corner cases that don't work, maybe inlining, but it doesn't seem worth going into it here.

I don't think we can chain lldb interpreter commands, so I have shown the steps separately.


Full diff: https://github.com/llvm/llvm-project/pull/120740.diff

1 Files Affected:

  • (modified) lldb/docs/use/map.rst (+17)
diff --git a/lldb/docs/use/map.rst b/lldb/docs/use/map.rst
index fe9c3f53022fad..cb1c266078679e 100644
--- a/lldb/docs/use/map.rst
+++ b/lldb/docs/use/map.rst
@@ -235,6 +235,23 @@ Do a source level single step in the currently selected thread
   (lldb) step
   (lldb) s
 
+Ignore a function when doing a source level single step in
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+.. code-block:: shell
+
+  (gdb) skip abc
+  Function abc will be skipped when stepping.
+
+.. code-block:: shell
+
+  (lldb) settings show target.process.thread.step-avoid-regexp
+  target.process.thread.step-avoid-regexp (regex) = ^std::
+  (lldb) settings set target.process.thread.step-avoid-regexp (^std::)|(^abc)
+
+Get the default value, make it into a capture group, then add another capture
+group for the new function name.
+
 Do a source level single step over in the currently selected thread
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 

@DavidSpickett
Copy link
Collaborator Author

And you could make a custom command to do this of course, but my goal here is not to do that. I was just asked by someone whether we had anything at all like this and the command map is the first place I always check.

@kastiglione
Copy link
Contributor

Should this also mention sif? When I want to skip one or more functions when stepping, I run sif desiredFunction.

@DavidSpickett
Copy link
Collaborator Author

Should this also mention sif?

I just learned that it exists, so yes!

@DavidSpickett DavidSpickett changed the title [lldb][Docs] Add equivalent of GDB's "skip" to command map [lldb][Docs] Add equivalents of GDB's "skip" to command map Dec 20, 2024
@kastiglione
Copy link
Contributor

for anyone interested: I override s to take an optional argument, so that it behaves like sif. In my .lldbinit:

command unalias s
command regex s
s/^$/step/
s/(.+)/sif %1/

Copy link
Contributor

@kastiglione kastiglione left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@DavidSpickett DavidSpickett merged commit b0c0a14 into llvm:main Jan 6, 2025
8 checks passed
@DavidSpickett DavidSpickett deleted the lldb-skip branch January 6, 2025 09:17
@jimingham
Copy link
Collaborator

This isn't directly relevant, but internally lldb has a "ShouldStopHere" mechanism that was meant to be extendable. Currently all the behaviors like the "library & regex avoid" settings are implemented in the DefaultShouldStopHere, but it wouldn't be terribly hard to add a more capable mechanism here, or even add a Python affordance so people could write their own logic.

paulhuggett pushed a commit to paulhuggett/llvm-project that referenced this pull request Jan 7, 2025
)

https://sourceware.org/gdb/current/onlinedocs/gdb.html/Skipping-Over-Functions-and-Files.html

We can't emulate all the features of that command but we can skip a
function by name with some extra steps.

As far as I know this only matches function name unlike GDB that can
filter on file and line and so on:
```
target.process.thread.step-avoid-regexp -- A regular expression defining functions step-in won't stop in.
```
It's likely it's got some corner cases that don't work, maybe inlining,
but it doesn't seem worth going into it here.

I don't think we can chain lldb interpreter commands, so I have shown
the steps separately.

I have also mentioned `thread step-in` and its alias `sif`. Which were
new to me too.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants