[all-commits] [llvm/llvm-project] af0094: [lldb] Fix `thread backtrace --count` (#83602)
Jonas Devlieghere via All-commits
all-commits at lists.llvm.org
Fri Mar 1 11:07:09 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: af009451ec439593554f03bc714e46ad2cd41738
https://github.com/llvm/llvm-project/commit/af009451ec439593554f03bc714e46ad2cd41738
Author: Jonas Devlieghere <jonas at devlieghere.com>
Date: 2024-03-01 (Fri, 01 Mar 2024)
Changed paths:
M lldb/source/Commands/CommandObjectThread.cpp
M lldb/source/Commands/Options.td
A lldb/test/Shell/Commands/command-thread-backtrace.test
Log Message:
-----------
[lldb] Fix `thread backtrace --count` (#83602)
The help output for `thread backtrace` specifies that you can pass -1 to
`--count` to display all the frames.
```
-c <count> ( --count <count> )
How many frames to display (-1 for all)
```
However, that doesn't work:
```
(lldb) thread backtrace --count -1
error: invalid integer value for option 'c'
```
The problem is that we store the option value as an unsigned and the
code to parse the string correctly rejects it. There's two ways to fix
this:
1. Make `m_count` a signed value so that it accepts negative values and
appease the parser. The function that prints the frames takes an
unsigned so a negative value will just become a really large positive
value, which is what the current implementation relies on.
2. Keep `m_count` unsigned and instead use 0 the magic value to show all
frames. I don't really see a point in not showing any frames at all,
plus that's already broken (`error: error displaying backtrace for
thread: "0x0001"`).
This patch implements (2) and at the same time improve the error
reporting so that we print the invalid value when we cannot parse it.
rdar://123881767
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list