aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Commands/CommandObjectThread.cpp
diff options
context:
space:
mode:
authorSlava Gurevich <sgurevich@gmail.com>2022-08-15 01:51:49 -0700
committerSlava Gurevich <sgurevich@gmail.com>2022-08-16 15:30:25 -0700
commit461b410159426fdc6da77e0fb653737e04e0ebe9 (patch)
tree9cf0057d2eefd2bb63ca7401511016c193030441 /lldb/source/Commands/CommandObjectThread.cpp
parentb217a78720f10ed739c39a2d74a54ef492a4cd29 (diff)
downloadllvm-461b410159426fdc6da77e0fb653737e04e0ebe9.zip
llvm-461b410159426fdc6da77e0fb653737e04e0ebe9.tar.gz
llvm-461b410159426fdc6da77e0fb653737e04e0ebe9.tar.bz2
[LLDB][NFC] Fix optons parsing and misc. reliability in CommandObjectThread
* Improve reliability by checking return results for calls to FindLineEntryByAddress() * Fix broken option parsing in SetOptionValue() Differential Revision: https://reviews.llvm.org/D131983
Diffstat (limited to 'lldb/source/Commands/CommandObjectThread.cpp')
-rw-r--r--lldb/source/Commands/CommandObjectThread.cpp31
1 files changed, 21 insertions, 10 deletions
diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp
index 5d7f3c1..1e317d8 100644
--- a/lldb/source/Commands/CommandObjectThread.cpp
+++ b/lldb/source/Commands/CommandObjectThread.cpp
@@ -62,15 +62,13 @@ public:
const int short_option = m_getopt_table[option_idx].val;
switch (short_option) {
- case 'c': {
- int32_t input_count = 0;
- if (option_arg.getAsInteger(0, m_count)) {
+ case 'c':
+ if (option_arg.getAsInteger(0, m_count) || (m_count < 0)) {
m_count = UINT32_MAX;
error.SetErrorStringWithFormat(
"invalid integer value for option '%c'", short_option);
- } else if (input_count < 0)
- m_count = UINT32_MAX;
- } break;
+ }
+ break;
case 's':
if (option_arg.getAsInteger(0, m_start))
error.SetErrorStringWithFormat(
@@ -1004,8 +1002,15 @@ protected:
AddressRange fun_addr_range = sc.function->GetAddressRange();
Address fun_start_addr = fun_addr_range.GetBaseAddress();
- line_table->FindLineEntryByAddress(fun_start_addr, function_start,
- &index_ptr);
+
+ if (!line_table->FindLineEntryByAddress(fun_start_addr, function_start,
+ &index_ptr)) {
+ result.AppendErrorWithFormat(
+ "Failed to find line entry by address for "
+ "frame %u of thread id %" PRIu64 ".\n",
+ m_options.m_frame_idx, thread->GetID());
+ return false;
+ }
Address fun_end_addr(fun_start_addr.GetSection(),
fun_start_addr.GetOffset() +
@@ -1013,8 +1018,14 @@ protected:
bool all_in_function = true;
- line_table->FindLineEntryByAddress(fun_end_addr, function_start,
- &end_ptr);
+ if (!line_table->FindLineEntryByAddress(fun_end_addr, function_start,
+ &end_ptr)) {
+ result.AppendErrorWithFormat(
+ "Failed to find line entry by address for "
+ "frame %u of thread id %" PRIu64 ".\n",
+ m_options.m_frame_idx, thread->GetID());
+ return false;
+ }
// Since not all source lines will contribute code, check if we are
// setting the breakpoint on the exact line number or the nearest