Added function name types to allow us to set breakpoints by name more
intelligently. The four name types we currently have are:
eFunctionNameTypeFull = (1 << 1), // The function name.
// For C this is the same as just the name of the function
// For C++ this is the demangled version of the mangled name.
// For ObjC this is the full function signature with the + or
// - and the square brackets and the class and selector
eFunctionNameTypeBase = (1 << 2), // The function name only, no namespaces or arguments and no class
// methods or selectors will be searched.
eFunctionNameTypeMethod = (1 << 3), // Find function by method name (C++) with no namespace or arguments
eFunctionNameTypeSelector = (1 << 4) // Find function by selector name (ObjC) names
this allows much more flexibility when setting breakoints:
(lldb) breakpoint set --name main --basename
(lldb) breakpoint set --name main --fullname
(lldb) breakpoint set --name main --method
(lldb) breakpoint set --name main --selector
The default:
(lldb) breakpoint set --name main
will inspect the name "main" and look for any parens, or if the name starts
with "-[" or "+[" and if any are found then a full name search will happen.
Else a basename search will be the default.
Fixed some command option structures so not all options are required when they
shouldn't be.
Cleaned up the breakpoint output summary.
Made the "image lookup --address <addr>" output much more verbose so it shows
all the important symbol context results. Added a GetDescription method to
many of the SymbolContext objects for the more verbose output.
git-svn-id: https://llvm.org/svn/llvm-project/llvdb/trunk@107075 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Commands/CommandObjectBreakpoint.cpp b/source/Commands/CommandObjectBreakpoint.cpp
index 01d29fb..830fbec 100644
--- a/source/Commands/CommandObjectBreakpoint.cpp
+++ b/source/Commands/CommandObjectBreakpoint.cpp
@@ -52,6 +52,7 @@
m_column (0),
m_ignore_inlines (false),
m_func_name (),
+ m_func_name_type_mask (0),
m_func_regexp (),
m_modules (),
m_load_addr(),
@@ -70,31 +71,28 @@
lldb::OptionDefinition
CommandObjectBreakpointSet::CommandOptions::g_option_table[] =
{
- { LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, "<shlib-name>",
+ { LLDB_OPT_SET_ALL, false, "shlib", 's', required_argument, NULL, CommandCompletions::eModuleCompletion, "<shlib-name>",
"Set the breakpoint only in this shared library (can use this option multiple times for multiple shlibs)."},
- { LLDB_OPT_SET_ALL, false, "ignore_inlines", 'i', no_argument, NULL, 0, NULL,
- "Ignore inlined subroutines when setting the breakppoint." },
-
- { LLDB_OPT_SET_ALL, false, "ignore_count", 'k', required_argument, NULL, 0, NULL,
+ { LLDB_OPT_SET_ALL, false, "ignore_count", 'k', required_argument, NULL, 0, "<n>",
"Set the number of times this breakpoint is sKipped before stopping." },
- { LLDB_OPT_SET_ALL, false, "thread_index", 'x', required_argument, NULL, NULL, "<thread_index>",
+ { LLDB_OPT_SET_ALL, false, "thread_index", 'x', required_argument, NULL, NULL, "<thread_index>",
"The breakpoint stops only for the thread whose indeX matches this argument."},
- { LLDB_OPT_SET_ALL, false, "thread_id", 't', required_argument, NULL, NULL, "<thread_id>",
+ { LLDB_OPT_SET_ALL, false, "thread_id", 't', required_argument, NULL, NULL, "<thread_id>",
"The breakpoint stops only for the thread whose TID matches this argument."},
- { LLDB_OPT_SET_ALL, false, "thread_name", 'T', required_argument, NULL, NULL, "<thread_name>",
+ { LLDB_OPT_SET_ALL, false, "thread_name", 'T', required_argument, NULL, NULL, "<thread_name>",
"The breakpoint stops only for the thread whose thread name matches this argument."},
- { LLDB_OPT_SET_ALL, false, "queue_name", 'q', required_argument, NULL, NULL, "<queue_name>",
+ { LLDB_OPT_SET_ALL, false, "queue_name", 'q', required_argument, NULL, NULL, "<queue_name>",
"The breakpoint stops only for threads in the queue whose name is given by this argument."},
- { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "<filename>",
+ { LLDB_OPT_SET_1, false, "file", 'f', required_argument, NULL, CommandCompletions::eSourceFileCompletion, "<filename>",
"Set the breakpoint by source location in this particular file."},
- { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, "<linenum>",
+ { LLDB_OPT_SET_1, true, "line", 'l', required_argument, NULL, 0, "<linenum>",
"Set the breakpoint by source location at this particular line."},
// Comment out this option for the moment, as we don't actually use it, but will in the future.
@@ -102,12 +100,24 @@
// { 0, false, "column", 'c', required_argument, NULL, "<column>",
// "Set the breakpoint by source location at this particular column."},
- { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, "<address>",
+ { LLDB_OPT_SET_2, true, "address", 'a', required_argument, NULL, 0, "<address>",
"Set the breakpoint by address, at the specified address."},
- { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, "<function-name>",
+ { LLDB_OPT_SET_3, true, "name", 'n', required_argument, NULL, CommandCompletions::eSymbolCompletion, "<name>",
"Set the breakpoint by function name." },
+ { LLDB_OPT_SET_3, false, "basename", 'b', no_argument, NULL, 0, NULL,
+ "Used in conjuction with --name <name> to search function basenames." },
+
+ { LLDB_OPT_SET_3, false, "fullname", 'F', no_argument, NULL, 0, NULL,
+ "Used in conjuction with --name <name> to search fully qualified function names. For C++ this means namespaces and all arguemnts, and for Objective C this means a full function prototype with class and selector." },
+
+ { LLDB_OPT_SET_3, false, "selector", 'S', no_argument, NULL, 0, NULL,
+ "Used in conjuction with --name <name> to search objective C selector names." },
+
+ { LLDB_OPT_SET_3, false, "method", 'm', no_argument, NULL, 0, NULL,
+ "Used in conjuction with --name <name> to search objective C selector C++ method names." },
+
{ LLDB_OPT_SET_4, true, "func_regex", 'r', required_argument, NULL, 0, "<regular-expression>",
"Set the breakpoint by function name, evaluating a regular-expression to find the function name(s)." },
@@ -140,21 +150,39 @@
case 'c':
m_column = Args::StringToUInt32 (option_arg, 0);
break;
+
case 'f':
m_filename = option_arg;
break;
- case 'i':
- m_ignore_inlines = true;
- break;
+
case 'l':
m_line_num = Args::StringToUInt32 (option_arg, 0);
break;
+
case 'n':
m_func_name = option_arg;
break;
+
+ case 'b':
+ m_func_name_type_mask |= eFunctionNameTypeBase;
+ break;
+
+ case 'F':
+ m_func_name_type_mask |= eFunctionNameTypeFull;
+ break;
+
+ case 'S':
+ m_func_name_type_mask |= eFunctionNameTypeSelector;
+ break;
+
+ case 'm':
+ m_func_name_type_mask |= eFunctionNameTypeMethod;
+ break;
+
case 'r':
m_func_regexp = option_arg;
break;
+
case 's':
{
m_modules.push_back (std::string (option_arg));
@@ -204,8 +232,8 @@
m_filename.clear();
m_line_num = 0;
m_column = 0;
- m_ignore_inlines = false;
m_func_name.clear();
+ m_func_name_type_mask = 0;
m_func_regexp.clear();
m_load_addr = LLDB_INVALID_ADDRESS;
m_modules.clear();
@@ -357,32 +385,50 @@
case eSetTypeAddress: // Breakpoint by address
bp = target->CreateBreakpoint (m_options.m_load_addr, false).get();
break;
+
case eSetTypeFunctionName: // Breakpoint by function name
- if (use_module)
{
- for (int i = 0; i < num_modules; ++i)
+ uint32_t name_type_mask = m_options.m_func_name_type_mask;
+
+ if (name_type_mask == 0)
{
- module.SetFile(m_options.m_modules[i].c_str());
- bp = target->CreateBreakpoint (&module, m_options.m_func_name.c_str()).get();
- if (bp)
- {
- StreamString &output_stream = result.GetOutputStream();
- output_stream.Printf ("Breakpoint created: ");
- bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
- output_stream.EOL();
- result.SetStatus (eReturnStatusSuccessFinishResult);
- }
+
+ if (m_options.m_func_name.find('(') != std::string::npos ||
+ m_options.m_func_name.find("-[") == 0 ||
+ m_options.m_func_name.find("+[") == 0)
+ name_type_mask |= eFunctionNameTypeFull;
else
+ name_type_mask |= eFunctionNameTypeBase;
+ }
+
+
+ if (use_module)
+ {
+ for (int i = 0; i < num_modules; ++i)
{
- result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n",
- m_options.m_modules[i].c_str());
- result.SetStatus (eReturnStatusFailed);
+ module.SetFile(m_options.m_modules[i].c_str());
+ bp = target->CreateBreakpoint (&module, m_options.m_func_name.c_str(), name_type_mask, Breakpoint::Exact).get();
+ if (bp)
+ {
+ StreamString &output_stream = result.GetOutputStream();
+ output_stream.Printf ("Breakpoint created: ");
+ bp->GetDescription(&output_stream, lldb::eDescriptionLevelBrief);
+ output_stream.EOL();
+ result.SetStatus (eReturnStatusSuccessFinishResult);
+ }
+ else
+ {
+ result.AppendErrorWithFormat("Breakpoint creation failed: No breakpoint created in module '%s'.\n",
+ m_options.m_modules[i].c_str());
+ result.SetStatus (eReturnStatusFailed);
+ }
}
}
+ else
+ bp = target->CreateBreakpoint (NULL, m_options.m_func_name.c_str(), name_type_mask, Breakpoint::Exact).get();
}
- else
- bp = target->CreateBreakpoint (NULL, m_options.m_func_name.c_str()).get();
break;
+
case eSetTypeFunctionRegexp: // Breakpoint by regular expression function name
{
RegularExpression regexp(m_options.m_func_regexp.c_str());
@@ -412,6 +458,7 @@
bp = target->CreateBreakpoint (NULL, regexp).get();
}
break;
+
default:
break;
}
diff --git a/source/Commands/CommandObjectBreakpoint.h b/source/Commands/CommandObjectBreakpoint.h
index 92bea69..20f2c3b 100644
--- a/source/Commands/CommandObjectBreakpoint.h
+++ b/source/Commands/CommandObjectBreakpoint.h
@@ -98,10 +98,11 @@
// Instance variables to hold the values for command options.
std::string m_filename;
- unsigned int m_line_num;
- unsigned int m_column;
+ uint32_t m_line_num;
+ uint32_t m_column;
bool m_ignore_inlines;
std::string m_func_name;
+ uint32_t m_func_name_type_mask;
std::string m_func_regexp;
lldb::addr_t m_load_addr;
STLStringArray m_modules;
diff --git a/source/Commands/CommandObjectCall.cpp b/source/Commands/CommandObjectCall.cpp
index a2cbc05..12281b3 100644
--- a/source/Commands/CommandObjectCall.cpp
+++ b/source/Commands/CommandObjectCall.cpp
@@ -295,7 +295,7 @@
lldb::OptionDefinition
CommandObjectCall::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, true, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."},
+{ LLDB_OPT_SET_1, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."},
{ LLDB_OPT_SET_1, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."},
{ LLDB_OPT_SET_1, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable verbose debug logging of the expression parsing and evaluation."},
{ LLDB_OPT_SET_1, false, "noexecute", 'n', no_argument, NULL, 0, "no execute", "Only JIT and copy the wrapper & arguments, but don't execute."},
diff --git a/source/Commands/CommandObjectDisassemble.cpp b/source/Commands/CommandObjectDisassemble.cpp
index c2abeee..c5fbbea 100644
--- a/source/Commands/CommandObjectDisassemble.cpp
+++ b/source/Commands/CommandObjectDisassemble.cpp
@@ -389,7 +389,9 @@
{
SymbolContextList sc_list;
- if (target->GetImages().FindFunctions(name, sc_list))
+ if (target->GetImages().FindFunctions(name,
+ eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector,
+ sc_list))
{
Disassemble (interpreter, result, disassembler, sc_list);
}
diff --git a/source/Commands/CommandObjectExpression.cpp b/source/Commands/CommandObjectExpression.cpp
index 7ddd3a1..e98303c 100644
--- a/source/Commands/CommandObjectExpression.cpp
+++ b/source/Commands/CommandObjectExpression.cpp
@@ -456,7 +456,7 @@
lldb::OptionDefinition
CommandObjectExpression::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_ALL, true, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."},
+{ LLDB_OPT_SET_ALL, false, "language", 'l', required_argument, NULL, 0, "[c|c++|objc|objc++]", "Sets the language to use when parsing the expression."},
{ LLDB_OPT_SET_ALL, false, "format", 'f', required_argument, NULL, 0, "[ [bool|b] | [bin] | [char|c] | [oct|o] | [dec|i|d|u] | [hex|x] | [float|f] | [cstr|s] ]", "Specify the format that the expression output should use."},
{ LLDB_OPT_SET_ALL, false, "debug", 'g', no_argument, NULL, 0, NULL, "Enable verbose debug logging of the expression parsing and evaluation."},
{ LLDB_OPT_SET_ALL, false, "use-ir", 'i', no_argument, NULL, 0, NULL, "[Temporary] Instructs the expression evaluator to use IR instead of ASTs."},
diff --git a/source/Commands/CommandObjectImage.cpp b/source/Commands/CommandObjectImage.cpp
index 38a04ec..cb717c4 100644
--- a/source/Commands/CommandObjectImage.cpp
+++ b/source/Commands/CommandObjectImage.cpp
@@ -227,9 +227,12 @@
strm.Printf("0x%llx: ", addr);
ExecutionContextScope *exe_scope = interpreter.GetDebugger().GetExecutionContext().GetBestExecutionContextScope();
- if (so_addr.Dump (&strm, exe_scope, Address::DumpStyleSectionNameOffset))
- strm.PutCString(": ");
+ strm.IndentMore();
+ strm.Indent (" Address: ");
+ so_addr.Dump (&strm, exe_scope, Address::DumpStyleSectionNameOffset);
+ strm.EOL();
so_addr.Dump (&strm, exe_scope, Address::DumpStyleResolvedDescription);
+ strm.IndentLess();
return true;
}
@@ -347,7 +350,7 @@
else
{
ConstString function_name(name);
- num_matches = symbol_vendor->FindFunctions(function_name, true, sc_list);
+ num_matches = symbol_vendor->FindFunctions(function_name, eFunctionNameTypeBase | eFunctionNameTypeFull | eFunctionNameTypeMethod | eFunctionNameTypeSelector, true, sc_list);
}
if (num_matches)
diff --git a/source/Commands/CommandObjectThread.cpp b/source/Commands/CommandObjectThread.cpp
index bf4843d..0fd53fe 100644
--- a/source/Commands/CommandObjectThread.cpp
+++ b/source/Commands/CommandObjectThread.cpp
@@ -619,8 +619,8 @@
lldb::OptionDefinition
CommandObjectThreadStepWithTypeAndScope::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, true, "avoid_no_debug", 'a', required_argument, NULL, 0, "<avoid_no_debug>", "Should step-in step over functions with no debug information"},
-{ LLDB_OPT_SET_1, true, "run_mode", 'm', required_argument, g_tri_running_mode, 0, "<run_mode>", "Determine how to run other threads while stepping this one"},
+{ LLDB_OPT_SET_1, false, "avoid_no_debug", 'a', required_argument, NULL, 0, "<avoid_no_debug>", "Should step-in step over functions with no debug information"},
+{ LLDB_OPT_SET_1, false, "run_mode", 'm', required_argument, g_tri_running_mode, 0, "<run_mode>", "Determine how to run other threads while stepping this one"},
{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL }
};
@@ -1060,9 +1060,9 @@
lldb::OptionDefinition
CommandObjectThreadUntil::CommandOptions::g_option_table[] =
{
-{ LLDB_OPT_SET_1, true, "frame", 'f', required_argument, NULL, 0, "<frame>", "Frame index for until operation - defaults to 0"},
-{ LLDB_OPT_SET_1, true, "thread", 't', required_argument, NULL, 0, "<thread>", "Thread index for the thread for until operation"},
-{ LLDB_OPT_SET_1, true, "run_mode", 'm', required_argument, g_duo_running_mode, 0, "<run_mode>", "Determine how to run other threads while stepping this one"},
+{ LLDB_OPT_SET_1, false, "frame", 'f', required_argument, NULL, 0, "<frame>", "Frame index for until operation - defaults to 0"},
+{ LLDB_OPT_SET_1, false, "thread", 't', required_argument, NULL, 0, "<thread>", "Thread index for the thread for until operation"},
+{ LLDB_OPT_SET_1, false, "run_mode",'m', required_argument, g_duo_running_mode, 0, "<run_mode>","Determine how to run other threads while stepping this one"},
{ 0, false, NULL, 0, 0, NULL, 0, NULL, NULL }
};