Add a new -a / --address argument to image show-unwind to get the

unwind instructions for a function/symbol which contains that
address.

Update the unwind_diagnose.py script to use this instead of doing
image show-unwind by name to avoid cases where there are multiple
name definitions.

llvm-svn: 180079
This commit is contained in:
Jason Molenda 2013-04-23 04:30:57 +00:00
parent 8ed67139c4
commit 535ab8601f
2 changed files with 88 additions and 63 deletions

View File

@ -182,6 +182,9 @@ def unwind_diagnose(debugger, command, result, dict):
print ""
print "Unwind instructions for %s, frame %d" % (frame.GetFunctionName(), frame.GetFrameID())
print ""
if lldb_major > 300 or (lldb_major == 300 and lldb_minor >= 20):
debugger.HandleCommand('image show-unwind -a "0x%x"' % frame.GetPC())
else:
debugger.HandleCommand('image show-unwind -n "%s"' % frame.GetFunctionName())
def create_unwind_diagnose_options():

View File

@ -3474,17 +3474,22 @@ public:
switch (short_option)
{
case 'a':
{
ExecutionContext exe_ctx (m_interpreter.GetExecutionContext());
m_type = eLookupTypeAddress;
m_addr = Args::StringToUInt64(option_arg, LLDB_INVALID_ADDRESS);
m_addr = Args::StringToAddress(&exe_ctx, option_arg, LLDB_INVALID_ADDRESS, &error);
if (m_addr == LLDB_INVALID_ADDRESS)
error.SetErrorStringWithFormat ("invalid address string '%s'", option_arg);
break;
}
case 'n':
{
m_str = option_arg;
m_type = eLookupTypeFunctionOrSymbol;
break;
}
}
return error;
}
@ -3573,12 +3578,29 @@ protected:
return false;
}
SymbolContextList sc_list;
if (m_options.m_type == eLookupTypeFunctionOrSymbol)
{
SymbolContextList sc_list;
size_t num_matches;
ConstString function_name (m_options.m_str.c_str());
num_matches = target->GetImages().FindFunctions (function_name, eFunctionNameTypeAuto, true, false, true, sc_list);
target->GetImages().FindFunctions (function_name, eFunctionNameTypeAuto, true, false, true, sc_list);
}
else if (m_options.m_type == eLookupTypeAddress && target)
{
Address addr;
if (target->GetSectionLoadList().ResolveLoadAddress (m_options.m_addr, addr))
{
SymbolContext sc;
ModuleSP module_sp (addr.GetModule());
module_sp->ResolveSymbolContextForAddress (addr, eSymbolContextEverything, sc);
if (sc.function || sc.symbol)
{
sc_list.Append(sc);
}
}
}
size_t num_matches = sc_list.GetSize();
for (uint32_t idx = 0; idx < num_matches; idx++)
{
SymbolContext sc;
@ -3645,7 +3667,6 @@ protected:
result.GetOutputStream().Printf ("\n");
}
}
return result.Succeeded();
}
@ -3655,7 +3676,8 @@ protected:
OptionDefinition
CommandObjectTargetModulesShowUnwind::CommandOptions::g_option_table[] =
{
{ LLDB_OPT_SET_1, true, "name", 'n', required_argument, NULL, 0, eArgTypeFunctionName, "Lookup a function or symbol by name in one or more target modules."},
{ LLDB_OPT_SET_1, false, "name", 'n', required_argument, NULL, 0, eArgTypeFunctionName, "Show unwind instructions for a function or symbol name."},
{ LLDB_OPT_SET_2, false, "address", 'a', required_argument, NULL, 0, eArgTypeAddressOrExpression, "Show unwind instructions for a function or symbol containing an address"},
{ 0, false, NULL, 0, 0, NULL, 0, eArgTypeNone, NULL }
};