There are now to new "settings set" variables that live in each debugger

instance:

settings set frame-format <string>
settings set thread-format <string>

This allows users to control the information that is seen when dumping
threads and frames. The default values are set such that they do what they
used to do prior to changing over the the user defined formats.

This allows users with terminals that can display color to make different
items different colors using the escape control codes. A few alias examples
that will colorize your thread and frame prompts are:

settings set frame-format 'frame #${frame.index}: \033[0;33m${frame.pc}\033[0m{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{ \033[0;35mat \033[1;35m${line.file.basename}:${line.number}}\033[0m\n'

settings set thread-format 'thread #${thread.index}: \033[1;33mtid\033[0;33m = ${thread.id}\033[0m{, \033[0;33m${frame.pc}\033[0m}{ \033[1;4;36m${module.file.basename}\033[0;36m ${function.name}{${function.pc-offset}}\033[0m}{, \033[1;35mstop reason\033[0;35m = ${thread.stop-reason}\033[0m}{, \033[1;36mname = \033[0;36m${thread.name}\033[0m}{, \033[1;32mqueue = \033[0;32m${thread.queue}}\033[0m\n'

A quick web search for "colorize terminal output" should allow you to see what
you can do to make your output look like you want it.

The "settings set" commands above can of course be added to your ~/.lldbinit
file for permanent use.

Changed the pure virtual 
    void ExecutionContextScope::Calculate (ExecutionContext&);
To:
    void ExecutionContextScope::CalculateExecutionContext (ExecutionContext&);
    
I did this because this is a class that anything in the execution context
heirarchy inherits from and "target->Calculate (exe_ctx)" didn't always tell
you what it was really trying to do unless you look at the parameter.

llvm-svn: 115485
This commit is contained in:
Greg Clayton 2010-10-04 01:05:56 +00:00
parent 120804afae
commit 0603aa9dc8
26 changed files with 297 additions and 167 deletions

View File

@ -93,7 +93,41 @@ public:
m_prompt.assign ("(lldb) ");
BroadcastPromptChange (m_instance_name, m_prompt.c_str());
}
const char *
GetFrameFormat() const
{
return m_frame_format.c_str();
}
bool
SetFrameFormat(const char *frame_format)
{
if (frame_format && frame_format[0])
{
m_frame_format.assign (frame_format);
return true;
}
return false;
}
const char *
GetThreadFormat() const
{
return m_thread_format.c_str();
}
bool
SetThreadFormat(const char *thread_format)
{
if (thread_format && thread_format[0])
{
m_thread_format.assign (thread_format);
return true;
}
return false;
}
lldb::ScriptLanguage
GetScriptLanguage() const
{
@ -138,6 +172,12 @@ protected:
static const ConstString &
PromptVarName ();
static const ConstString &
GetFrameFormatName ();
static const ConstString &
GetThreadFormatName ();
static const ConstString &
ScriptLangVarName ();
@ -151,6 +191,8 @@ private:
uint32_t m_term_width;
std::string m_prompt;
std::string m_frame_format;
std::string m_thread_format;
lldb::ScriptLanguage m_script_lang;
bool m_use_external_editor;
};

View File

@ -63,7 +63,7 @@ public:
/// in.
//------------------------------------------------------------------
virtual void
Calculate (ExecutionContext &exe_ctx) = 0;
CalculateExecutionContext (ExecutionContext &exe_ctx) = 0;
};
} // namespace lldb_private

View File

@ -1589,7 +1589,7 @@ public:
CalculateStackFrame ();
virtual void
Calculate (ExecutionContext &exe_ctx);
CalculateExecutionContext (ExecutionContext &exe_ctx);
lldb::ProcessSP
GetSP ();

View File

@ -161,7 +161,7 @@ public:
CalculateStackFrame ();
virtual void
Calculate (ExecutionContext &exe_ctx);
CalculateExecutionContext (ExecutionContext &exe_ctx);
protected:
//------------------------------------------------------------------

View File

@ -102,6 +102,9 @@ public:
const char *
Disassemble ();
void
DumpUsingSettingsFormat (Stream *strm);
void
Dump (Stream *strm, bool show_frame_index, bool show_fullpaths);
@ -142,7 +145,7 @@ public:
CalculateStackFrame ();
virtual void
Calculate (ExecutionContext &exe_ctx);
CalculateExecutionContext (ExecutionContext &exe_ctx);
lldb::StackFrameSP
GetSP ();

View File

@ -402,6 +402,11 @@ public:
return m_section_load_list;
}
static Target *
GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr,
const SymbolContext *sc_ptr);
//------------------------------------------------------------------
// lldb::ExecutionContextScope pure virtual functions
//------------------------------------------------------------------
@ -418,7 +423,7 @@ public:
CalculateStackFrame ();
virtual void
Calculate (ExecutionContext &exe_ctx);
CalculateExecutionContext (ExecutionContext &exe_ctx);
PathMappingList &
GetImageSearchPathList ();

View File

@ -287,11 +287,7 @@ public:
ClearStackFrames ();
void
DumpInfo (Stream &strm,
bool show_stop_reason,
bool show_name,
bool show_queue,
uint32_t frame_idx);// = UINT32_MAX);
DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx);
//------------------------------------------------------------------
// Thread Plan Providers:
@ -613,7 +609,7 @@ public:
CalculateStackFrame ();
virtual void
Calculate (ExecutionContext &exe_ctx);
CalculateExecutionContext (ExecutionContext &exe_ctx);
lldb::StackFrameSP
GetStackFrameSPForStackFramePtr (StackFrame *stack_frame_ptr);

View File

@ -395,7 +395,7 @@ SBFrame::GetDescription (SBStream &description)
if (m_opaque_sp)
{
description.ref();
m_opaque_sp->Dump (description.get(), true, false);
m_opaque_sp->DumpUsingSettingsFormat (description.get());
}
else
description.Printf ("No value");

View File

@ -431,9 +431,9 @@ SBTarget::Disassemble (lldb::addr_t start_addr, lldb::addr_t end_addr, const cha
ExecutionContext exe_ctx;
if (process)
process->Calculate(exe_ctx);
process->CalculateExecutionContext(exe_ctx);
else
m_opaque_sp->Calculate(exe_ctx);
m_opaque_sp->CalculateExecutionContext(exe_ctx);
if (end_addr == LLDB_INVALID_ADDRESS || end_addr < start_addr)
range.SetByteSize( DEFAULT_DISASM_BYTE_SIZE);
@ -484,9 +484,9 @@ SBTarget::Disassemble (const char *function_name, const char *module_name)
process = NULL;
if (process)
process->Calculate(exe_ctx);
process->CalculateExecutionContext(exe_ctx);
else
m_opaque_sp->Calculate(exe_ctx);
m_opaque_sp->CalculateExecutionContext(exe_ctx);
StreamFile out_stream (out);

View File

@ -419,7 +419,7 @@ SBThread::GetDescription (SBStream &description)
{
if (m_opaque_sp)
{
m_opaque_sp->DumpInfo (description.ref(), true, true, true, LLDB_INVALID_INDEX32);
m_opaque_sp->DumpUsingSettingsFormat (description.ref(), LLDB_INVALID_INDEX32);
description.Printf (" %d frames, (instance name: %s)", GetNumFrames(),
m_opaque_sp->GetInstanceName().AsCString());
}

View File

@ -70,14 +70,10 @@ public:
// char '#'
while (pos != commands.end())
{
bool remove_string = false;
size_t non_space = pos->find_first_not_of (k_space_characters);
if (non_space == std::string::npos)
remove_string = true; // Empty line
else if ((*pos)[non_space] == '#')
remove_string = true; // Comment line that starts with '#'
if (remove_string)
// Check for empty line or comment line (lines whose first
// non-space character is a '#')
if (non_space == std::string::npos || (*pos)[non_space] == '#')
pos = commands.erase(pos);
else
++pos;

View File

@ -71,7 +71,7 @@ public:
ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
if (exe_ctx.frame)
{
exe_ctx.frame->Dump (&result.GetOutputStream(), true, false);
exe_ctx.frame->DumpUsingSettingsFormat (&result.GetOutputStream());
result.GetOutputStream().EOL();
result.SetStatus (eReturnStatusSuccessFinishResult);
}

View File

@ -80,13 +80,7 @@ lldb_private::DisplayThreadInfo
}
else
{
thread->DumpInfo (strm,
true, // Dump the stop reason?
true, // Dump the thread name?
true, // Dump the queue name?
0); // Display context info for stack frame zero
strm.EOL();
thread->DumpUsingSettingsFormat (strm, 0);
}
return true;
@ -164,12 +158,7 @@ lldb_private::DisplayFramesForExecutionContext
if (num_frames == 0)
return 0;
thread->DumpInfo (strm,
true, // Dump the stop reason?
true, // Dump the thread name?
true, // Dump the queue name?
num_frames > 1 ? UINT32_MAX : first_frame); // Dump info for the first stack frame if we are showing only on frame
strm.EOL();
thread->DumpUsingSettingsFormat (strm, num_frames > 1 ? UINT32_MAX : first_frame);
strm.IndentMore();
StackFrameSP frame_sp;
@ -224,8 +213,7 @@ lldb_private::DisplayFrameForExecutionContext
if (show_frame_info)
{
strm.Indent();
frame->Dump (&strm, true, false);
strm.EOL();
frame->DumpUsingSettingsFormat (&strm);
}
SymbolContext sc (frame->GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry));

View File

@ -140,7 +140,7 @@ ReadAddress (ExecutionContextScope *exe_scope, const Address &address, uint32_t
if (success)
{
ExecutionContext exe_ctx;
exe_scope->Calculate(exe_ctx);
exe_scope->CalculateExecutionContext(exe_ctx);
// If we have any sections that are loaded, try and resolve using the
// section load list
if (exe_ctx.target && !exe_ctx.target->GetSectionLoadList().IsEmpty())

View File

@ -622,7 +622,7 @@ TestPromptFormats (StackFrame *frame)
SymbolContext sc (frame->GetSymbolContext(eSymbolContextEverything));
ExecutionContext exe_ctx;
frame->Calculate(exe_ctx);
frame->CalculateExecutionContext(exe_ctx);
const char *end = NULL;
if (Debugger::FormatPrompt (prompt_format, &sc, &exe_ctx, &sc.line_entry.range.GetBaseAddress(), s, &end))
{
@ -814,12 +814,9 @@ Debugger::FormatPrompt
}
else if (::strncmp (var_name_begin, "target.", strlen("target.")) == 0)
{
if (sc->target_sp || (exe_ctx && exe_ctx->process))
Target *target = Target::GetTargetFromContexts (exe_ctx, sc);
if (target)
{
Target *target = sc->target_sp.get();
if (target == NULL)
target = &exe_ctx->process->GetTarget();
assert (target);
var_name_begin += ::strlen ("target.");
if (::strncmp (var_name_begin, "arch}", strlen("arch}")) == 0)
{
@ -838,10 +835,9 @@ Debugger::FormatPrompt
case 'm':
if (::strncmp (var_name_begin, "module.", strlen("module.")) == 0)
{
Module *module = sc->module_sp.get();
if (module)
if (sc && sc->module_sp.get())
{
Module *module = sc->module_sp.get();
var_name_begin += ::strlen ("module.");
if (::strncmp (var_name_begin, "file.", strlen("file.")) == 0)
@ -1078,47 +1074,62 @@ Debugger::FormatPrompt
// If format addr is valid, then we need to print an address
if (format_addr.IsValid())
{
var_success = false;
if (calculate_format_addr_function_offset)
{
Address func_addr;
if (sc->function)
func_addr = sc->function->GetAddressRange().GetBaseAddress();
else if (sc->symbol && sc->symbol->GetAddressRangePtr())
func_addr = sc->symbol->GetAddressRangePtr()->GetBaseAddress();
else
var_success = false;
if (var_success)
if (sc)
{
if (sc->function)
func_addr = sc->function->GetAddressRange().GetBaseAddress();
else if (sc->symbol && sc->symbol->GetAddressRangePtr())
func_addr = sc->symbol->GetAddressRangePtr()->GetBaseAddress();
}
if (func_addr.IsValid())
{
if (func_addr.GetSection() == format_addr.GetSection())
{
addr_t func_file_addr = func_addr.GetFileAddress();
addr_t addr_file_addr = format_addr.GetFileAddress();
if (addr_file_addr > func_file_addr)
{
s.Printf(" + %llu", addr_file_addr - func_file_addr);
}
else if (addr_file_addr < func_file_addr)
{
s.Printf(" - %llu", func_file_addr - addr_file_addr);
}
var_success = true;
}
else
var_success = false;
{
Target *target = Target::GetTargetFromContexts (exe_ctx, sc);
if (target)
{
addr_t func_load_addr = func_addr.GetLoadAddress (target);
addr_t addr_load_addr = format_addr.GetLoadAddress (target);
if (addr_load_addr > func_load_addr)
s.Printf(" + %llu", addr_load_addr - func_load_addr);
else if (addr_load_addr < func_load_addr)
s.Printf(" - %llu", func_load_addr - addr_load_addr);
var_success = true;
}
}
}
}
else
{
Target *target = Target::GetTargetFromContexts (exe_ctx, sc);
addr_t vaddr = LLDB_INVALID_ADDRESS;
if (exe_ctx && exe_ctx->process && !exe_ctx->process->GetTarget().GetSectionLoadList().IsEmpty())
vaddr = format_addr.GetLoadAddress (&exe_ctx->process->GetTarget());
if (exe_ctx && !target->GetSectionLoadList().IsEmpty())
vaddr = format_addr.GetLoadAddress (target);
if (vaddr == LLDB_INVALID_ADDRESS)
vaddr = format_addr.GetFileAddress ();
if (vaddr != LLDB_INVALID_ADDRESS)
{
s.Printf("0x%16.16llx", vaddr);
else
var_success = false;
var_success = true;
}
}
}
}
@ -1154,47 +1165,57 @@ Debugger::FormatPrompt
case '0':
// 1 to 3 octal chars
{
unsigned long octal_value = 0;
++p;
int i=0;
for (; i<3; ++i)
// Make a string that can hold onto the initial zero char,
// up to 3 octal digits, and a terminating NULL.
char oct_str[5] = { 0, 0, 0, 0, 0 };
int i;
for (i=0; (p[i] >= '0' && p[i] <= '7') && i<4; ++i)
oct_str[i] = p[i];
// We don't want to consume the last octal character since
// the main for loop will do this for us, so we advance p by
// one less than i (even if i is zero)
p += i - 1;
unsigned long octal_value = ::strtoul (oct_str, NULL, 8);
if (octal_value <= UINT8_MAX)
{
if (*p >= '0' && *p <= '7')
octal_value = octal_value << 3 + (((uint8_t)*p) - '0');
else
break;
char octal_char = octal_value;
s.Write (&octal_char, 1);
}
if (i>0)
s.PutChar (octal_value);
else
s.PutCString ("\\0");
}
break;
case 'x':
// hex number in the format
if (isxdigit(p[1]))
{
++p;
++p; // Skip the 'x'
if (isxdigit(*p))
// Make a string that can hold onto two hex chars plus a
// NULL terminator
char hex_str[3] = { 0,0,0 };
hex_str[0] = *p;
if (isxdigit(p[1]))
{
char hex_str[3] = { 0,0,0 };
hex_str[0] = *p;
++p;
if (isxdigit(*p))
hex_str[1] = *p;
unsigned long hex_value = strtoul (hex_str, NULL, 16);
++p; // Skip the first of the two hex chars
hex_str[1] = *p;
}
unsigned long hex_value = strtoul (hex_str, NULL, 16);
if (hex_value <= UINT8_MAX)
s.PutChar (hex_value);
}
else
{
s.PutCString ("\\x");
}
}
else
{
s.PutChar('x');
}
break;
default:
s << '\\' << *p;
// Just desensitize any other character by just printing what
// came after the '\'
s << *p;
break;
}
@ -1247,6 +1268,8 @@ DebuggerInstanceSettings::DebuggerInstanceSettings
InstanceSettings (owner, (name == NULL ? InstanceSettings::InvalidName().AsCString() : name), live_instance),
m_term_width (80),
m_prompt (),
m_frame_format (),
m_thread_format (),
m_script_lang (),
m_use_external_editor (false)
{
@ -1265,13 +1288,14 @@ DebuggerInstanceSettings::DebuggerInstanceSettings
{
const lldb::InstanceSettingsSP &pending_settings = m_owner.FindPendingSettings (m_instance_name);
CopyInstanceSettings (pending_settings, false);
//m_owner.RemovePendingSettings (m_instance_name);
}
}
DebuggerInstanceSettings::DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs) :
InstanceSettings (*(Debugger::GetSettingsController().get()), CreateInstanceName ().AsCString()),
m_prompt (rhs.m_prompt),
m_frame_format (rhs.m_frame_format),
m_thread_format (rhs.m_thread_format),
m_script_lang (rhs.m_script_lang),
m_use_external_editor (rhs.m_use_external_editor)
{
@ -1291,6 +1315,8 @@ DebuggerInstanceSettings::operator= (const DebuggerInstanceSettings &rhs)
{
m_term_width = rhs.m_term_width;
m_prompt = rhs.m_prompt;
m_frame_format = rhs.m_frame_format;
m_thread_format = rhs.m_thread_format;
m_script_lang = rhs.m_script_lang;
m_use_external_editor = rhs.m_use_external_editor;
}
@ -1338,7 +1364,15 @@ DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var
Error &err,
bool pending)
{
if (var_name == PromptVarName())
if (var_name == TermWidthVarName())
{
if (ValidTermWidthValue (value, err))
{
m_term_width = ::strtoul (value, NULL, 0);
}
}
else if (var_name == PromptVarName())
{
UserSettingsController::UpdateStringVariable (op, m_prompt, value, err);
if (!pending)
@ -1355,19 +1389,20 @@ DebuggerInstanceSettings::UpdateInstanceSettingsVariable (const ConstString &var
BroadcastPromptChange (new_name, m_prompt.c_str());
}
}
else if (var_name == GetFrameFormatName())
{
UserSettingsController::UpdateStringVariable (op, m_frame_format, value, err);
}
else if (var_name == GetThreadFormatName())
{
UserSettingsController::UpdateStringVariable (op, m_thread_format, value, err);
}
else if (var_name == ScriptLangVarName())
{
bool success;
m_script_lang = Args::StringToScriptLanguage (value, eScriptLanguageDefault,
&success);
}
else if (var_name == TermWidthVarName())
{
if (ValidTermWidthValue (value, err))
{
m_term_width = ::strtoul (value, NULL, 0);
}
}
else if (var_name == UseExternalEditorVarName ())
{
UserSettingsController::UpdateBooleanVariable (op, m_use_external_editor, value, err);
@ -1382,7 +1417,7 @@ DebuggerInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
{
if (var_name == PromptVarName())
{
value.AppendString (m_prompt.c_str());
value.AppendString (m_prompt.c_str(), m_prompt.size());
}
else if (var_name == ScriptLangVarName())
@ -1395,6 +1430,14 @@ DebuggerInstanceSettings::GetInstanceSettingsValue (const SettingEntry &entry,
width_str.Printf ("%d", m_term_width);
value.AppendString (width_str.GetData());
}
else if (var_name == GetFrameFormatName ())
{
value.AppendString(m_frame_format.c_str(), m_frame_format.size());
}
else if (var_name == GetThreadFormatName ())
{
value.AppendString(m_thread_format.c_str(), m_thread_format.size());
}
else if (var_name == UseExternalEditorVarName())
{
if (m_use_external_editor)
@ -1434,7 +1477,8 @@ DebuggerInstanceSettings::CopyInstanceSettings (const lldb::InstanceSettingsSP &
BroadcastPromptChange (new_name, m_prompt.c_str());
}
m_frame_format = new_debugger_settings->m_frame_format;
m_thread_format = new_debugger_settings->m_thread_format;
m_term_width = new_debugger_settings->m_term_width;
m_script_lang = new_debugger_settings->m_script_lang;
m_use_external_editor = new_debugger_settings->m_use_external_editor;
@ -1499,6 +1543,22 @@ DebuggerInstanceSettings::PromptVarName ()
return prompt_var_name;
}
const ConstString &
DebuggerInstanceSettings::GetFrameFormatName ()
{
static ConstString prompt_var_name ("frame-format");
return prompt_var_name;
}
const ConstString &
DebuggerInstanceSettings::GetThreadFormatName ()
{
static ConstString prompt_var_name ("thread-format");
return prompt_var_name;
}
const ConstString &
DebuggerInstanceSettings::ScriptLangVarName ()
{
@ -1537,15 +1597,32 @@ Debugger::SettingsController::global_settings_table[] =
{ NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
};
#define MODULE_WITH_FUNC "{ ${module.file.basename}`${function.name}{${function.pc-offset}}}"
#define FILE_AND_LINE "{ at ${line.file.basename}:${line.number}}"
#define DEFAULT_THREAD_FORMAT "thread #${thread.index}: tid = ${thread.id}"\
"{, ${frame.pc}}"\
MODULE_WITH_FUNC\
"{, stop reason = ${thread.stop-reason}}"\
"{, name = ${thread.name}}"\
"{, queue = ${thread.queue}}"\
"\\n"
#define DEFAULT_FRAME_FORMAT "frame #${frame.index}: ${frame.pc}"\
MODULE_WITH_FUNC\
FILE_AND_LINE\
"\\n"
SettingEntry
Debugger::SettingsController::instance_settings_table[] =
{
//{ "var-name", var-type , "default", enum-table, init'd, hidden, "help-text"},
{ "term-width" , eSetVarTypeInt, "80" , NULL, false , false , "The maximum number of columns to use for displaying text." },
{ "script-lang" , eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." },
{ "prompt" , eSetVarTypeString, "(lldb)", NULL, false, false, "The debugger command line prompt displayed for the user." },
{ "use-external-editor", eSetVarTypeBool, "false", NULL, false, false, "Whether to use an external editor or not." },
{ NULL, eSetVarTypeNone, NULL, NULL, 0, 0, NULL }
// NAME Setting variable type Default Enum Init'd Hidden Help
// ======================= ======================= ====================== ==== ====== ====== ======================
{ "term-width", eSetVarTypeInt, "80" , NULL, false, false, "The maximum number of columns to use for displaying text." },
{ "script-lang", eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." },
{ "prompt", eSetVarTypeString, "(lldb)", NULL, false, false, "The debugger command line prompt displayed for the user." },
{ "frame-format", eSetVarTypeString, DEFAULT_FRAME_FORMAT, NULL, false, false, "The default frame format string to use when displaying thread information." },
{ "thread-format", eSetVarTypeString, DEFAULT_THREAD_FORMAT, NULL, false, false, "The default thread format string to use when displaying thread information." },
{ "use-external-editor", eSetVarTypeBool, "false", NULL, false, false, "Whether to use an external editor or not." },
{ NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL }
};

View File

@ -66,7 +66,7 @@ AppleObjCRuntimeV2::GetObjectDescription (Stream &str, Value &value, ExecutionCo
return false;
ExecutionContext exe_ctx;
exe_scope->Calculate(exe_ctx);
exe_scope->CalculateExecutionContext(exe_ctx);
if (!exe_ctx.process)
return false;

View File

@ -192,7 +192,7 @@ AppleObjCTrampolineHandler::GetStepThroughDispatchPlan (Thread &thread, bool sto
// making the object value a load address value and resolving it will get
// the pointer sized data pointed to by that value...
ExecutionContext exec_ctx;
thread.Calculate (exec_ctx);
thread.CalculateExecutionContext (exec_ctx);
isa_value.SetValueType(Value::eValueTypeLoadAddress);
isa_value.ResolveValue(&exec_ctx, clang_ast_context->getASTContext());

View File

@ -60,7 +60,7 @@ AppleThreadPlanStepThroughObjCTrampoline::DidPush ()
{
StreamString errors;
ExecutionContext exc_context;
m_thread.Calculate(exc_context);
m_thread.CalculateExecutionContext(exc_context);
m_func_sp.reset(m_impl_function->GetThreadPlanToCallFunction (exc_context, m_args_addr, errors, m_stop_others));
m_func_sp->SetPrivate(true);
m_thread.QueueThreadPlan (m_func_sp, false);
@ -109,7 +109,7 @@ AppleThreadPlanStepThroughObjCTrampoline::ShouldStop (Event *event_ptr)
{
Value target_addr_value;
ExecutionContext exc_context;
m_thread.Calculate(exc_context);
m_thread.CalculateExecutionContext(exc_context);
m_impl_function->FetchFunctionResults (exc_context, m_args_addr, target_addr_value);
m_impl_function->DeallocateFunctionResults(exc_context, m_args_addr);
lldb::addr_t target_addr = target_addr_value.GetScalar().ULongLong();

View File

@ -59,7 +59,7 @@ ExecutionContext::ExecutionContext(Process* p, Thread *t, StackFrame *f) :
ExecutionContext::ExecutionContext (ExecutionContextScope *exe_scope_ptr)
{
if (exe_scope_ptr)
exe_scope_ptr->Calculate (*this);
exe_scope_ptr->CalculateExecutionContext (*this);
else
{
target = NULL;
@ -71,7 +71,7 @@ ExecutionContext::ExecutionContext (ExecutionContextScope *exe_scope_ptr)
ExecutionContext::ExecutionContext (ExecutionContextScope &exe_scope_ref)
{
exe_scope_ref.Calculate (*this);
exe_scope_ref.CalculateExecutionContext (*this);
}
void

View File

@ -1818,7 +1818,7 @@ Process::CalculateStackFrame ()
}
void
Process::Calculate (ExecutionContext &exe_ctx)
Process::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
exe_ctx.target = &m_target;
exe_ctx.process = this;

View File

@ -226,12 +226,12 @@ RegisterContext::CalculateStackFrame ()
}
void
RegisterContext::Calculate (ExecutionContext &exe_ctx)
RegisterContext::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
if (m_frame)
m_frame->Calculate (exe_ctx);
m_frame->CalculateExecutionContext (exe_ctx);
else
m_thread.Calculate (exe_ctx);
m_thread.CalculateExecutionContext (exe_ctx);
}

View File

@ -14,6 +14,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Core/Module.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Disassembler.h"
#include "lldb/Core/Value.h"
#include "lldb/Core/ValueObjectVariable.h"
@ -248,7 +249,7 @@ StackFrame::Disassemble ()
if (m_disassembly.GetSize() == 0)
{
ExecutionContext exe_ctx;
Calculate(exe_ctx);
CalculateExecutionContext(exe_ctx);
Target &target = m_thread.GetProcess().GetTarget();
Disassembler::Disassemble (target.GetDebugger(),
target.GetArchitecture(),
@ -615,12 +616,35 @@ StackFrame::CalculateStackFrame ()
void
StackFrame::Calculate (ExecutionContext &exe_ctx)
StackFrame::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
m_thread.Calculate (exe_ctx);
m_thread.CalculateExecutionContext (exe_ctx);
exe_ctx.frame = this;
}
void
StackFrame::DumpUsingSettingsFormat (Stream *strm)
{
if (strm == NULL)
return;
GetSymbolContext(eSymbolContextEverything);
ExecutionContext exe_ctx;
CalculateExecutionContext(exe_ctx);
const char *end = NULL;
StreamString s;
const char *frame_format = m_thread.GetProcess().GetTarget().GetDebugger().GetFrameFormat();
if (frame_format && Debugger::FormatPrompt (frame_format, &m_sc, &exe_ctx, NULL, s, &end))
{
strm->Write(s.GetData(), s.GetSize());
}
else
{
Dump (strm, true, false);
strm->EOL();
}
}
void
StackFrame::Dump (Stream *strm, bool show_frame_index, bool show_fullpaths)
{

View File

@ -260,7 +260,7 @@ StackFrameList::Dump (Stream *s)
if (frame)
{
frame->GetStackID().Dump (s);
frame->Dump(s, true, false);
frame->DumpUsingSettingsFormat (s);
}
else
s->Printf("frame #%u", std::distance (begin, pos));

View File

@ -276,9 +276,9 @@ public:
StreamString strm;
const char *signal_name = m_thread.GetProcess().GetUnixSignals().GetSignalAsCString (m_value);
if (signal_name)
strm.Printf("signal = %s", signal_name);
strm.Printf("signal %s", signal_name);
else
strm.Printf("signal = %lli", m_value);
strm.Printf("signal %lli", m_value);
m_description.swap (strm.GetString());
}
return m_description.c_str();

View File

@ -708,7 +708,7 @@ Target::CalculateStackFrame ()
}
void
Target::Calculate (ExecutionContext &exe_ctx)
Target::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
exe_ctx.target = this;
exe_ctx.process = NULL; // Do NOT fill in process...
@ -794,6 +794,25 @@ Target::SetDefaultArchitecture (ArchSpec new_arch)
lldb::eVarSetOperationAssign, false, "[]");
}
Target *
Target::GetTargetFromContexts (const ExecutionContext *exe_ctx_ptr, const SymbolContext *sc_ptr)
{
// The target can either exist in the "process" of ExecutionContext, or in
// the "target_sp" member of SymbolContext. This accessor helper function
// will get the target from one of these locations.
Target *target = NULL;
if (sc_ptr != NULL)
target = sc_ptr->target_sp.get();
if (target == NULL)
{
if (exe_ctx_ptr != NULL && exe_ctx_ptr->process != NULL)
target = &exe_ctx_ptr->process->GetTarget();
}
return target;
}
void
Target::UpdateInstanceName ()
{

View File

@ -9,6 +9,7 @@
#include "lldb/lldb-private-log.h"
#include "lldb/Breakpoint/BreakpointLocation.h"
#include "lldb/Core/Debugger.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Stream.h"
#include "lldb/Core/StreamString.h"
@ -810,9 +811,9 @@ Thread::CalculateStackFrame ()
}
void
Thread::Calculate (ExecutionContext &exe_ctx)
Thread::CalculateExecutionContext (ExecutionContext &exe_ctx)
{
m_process.Calculate (exe_ctx);
m_process.CalculateExecutionContext (exe_ctx);
exe_ctx.thread = this;
exe_ctx.frame = NULL;
}
@ -872,52 +873,31 @@ Thread::SetSelectedFrameByIndex (uint32_t idx)
}
void
Thread::DumpInfo
(
Stream &strm,
bool show_stop_reason,
bool show_name,
bool show_queue,
uint32_t idx
)
Thread::DumpUsingSettingsFormat (Stream &strm, uint32_t frame_idx)
{
strm.Printf("thread #%u: tid = 0x%4.4x", GetIndexID(), GetID());
ExecutionContext exe_ctx;
SymbolContext frame_sc;
CalculateExecutionContext (exe_ctx);
if (idx != LLDB_INVALID_INDEX32)
if (frame_idx != LLDB_INVALID_INDEX32)
{
StackFrameSP frame_sp(GetStackFrameAtIndex (idx));
StackFrameSP frame_sp(GetStackFrameAtIndex (frame_idx));
if (frame_sp)
{
strm.PutCString(", ");
frame_sp->Dump (&strm, false, false);
exe_ctx.frame = frame_sp.get();
frame_sc = exe_ctx.frame->GetSymbolContext(eSymbolContextEverything);
}
}
if (show_stop_reason)
{
StopInfo *stop_info = GetStopInfo();
if (stop_info)
{
const char *stop_description = stop_info->GetDescription();
if (stop_description)
strm.Printf (", stop reason = %s", stop_description);
}
}
if (show_name)
{
const char *name = GetName();
if (name && name[0])
strm.Printf(", name = %s", name);
}
if (show_queue)
{
const char *queue = GetQueueName();
if (queue && queue[0])
strm.Printf(", queue = %s", queue);
}
const char *thread_format = GetProcess().GetTarget().GetDebugger().GetThreadFormat();
assert (thread_format);
const char *end = NULL;
Debugger::FormatPrompt (thread_format,
exe_ctx.frame ? &frame_sc : NULL,
&exe_ctx,
NULL,
strm,
&end);
}
lldb::ThreadSP