diff options
Diffstat (limited to 'lldb')
26 files changed, 297 insertions, 167 deletions
diff --git a/lldb/include/lldb/Core/Debugger.h b/lldb/include/lldb/Core/Debugger.h index d39f2428c70..bcfd47c61c8 100644 --- a/lldb/include/lldb/Core/Debugger.h +++ b/lldb/include/lldb/Core/Debugger.h @@ -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 { @@ -139,6 +173,12 @@ protected: PromptVarName (); static const ConstString & + GetFrameFormatName (); + + static const ConstString & + GetThreadFormatName (); + + static const ConstString & ScriptLangVarName (); static const ConstString & @@ -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; }; diff --git a/lldb/include/lldb/Target/ExecutionContextScope.h b/lldb/include/lldb/Target/ExecutionContextScope.h index f98e3276543..d8e754923e3 100644 --- a/lldb/include/lldb/Target/ExecutionContextScope.h +++ b/lldb/include/lldb/Target/ExecutionContextScope.h @@ -63,7 +63,7 @@ public: /// in. //------------------------------------------------------------------ virtual void - Calculate (ExecutionContext &exe_ctx) = 0; + CalculateExecutionContext (ExecutionContext &exe_ctx) = 0; }; } // namespace lldb_private diff --git a/lldb/include/lldb/Target/Process.h b/lldb/include/lldb/Target/Process.h index 4b096b82d90..71812d2098b 100644 --- a/lldb/include/lldb/Target/Process.h +++ b/lldb/include/lldb/Target/Process.h @@ -1589,7 +1589,7 @@ public: CalculateStackFrame (); virtual void - Calculate (ExecutionContext &exe_ctx); + CalculateExecutionContext (ExecutionContext &exe_ctx); lldb::ProcessSP GetSP (); diff --git a/lldb/include/lldb/Target/RegisterContext.h b/lldb/include/lldb/Target/RegisterContext.h index 1f97a79789d..5c313c5fa47 100644 --- a/lldb/include/lldb/Target/RegisterContext.h +++ b/lldb/include/lldb/Target/RegisterContext.h @@ -161,7 +161,7 @@ public: CalculateStackFrame (); virtual void - Calculate (ExecutionContext &exe_ctx); + CalculateExecutionContext (ExecutionContext &exe_ctx); protected: //------------------------------------------------------------------ diff --git a/lldb/include/lldb/Target/StackFrame.h b/lldb/include/lldb/Target/StackFrame.h index 797a117ce7a..f2c9e105ad1 100644 --- a/lldb/include/lldb/Target/StackFrame.h +++ b/lldb/include/lldb/Target/StackFrame.h @@ -103,6 +103,9 @@ public: Disassemble (); void + DumpUsingSettingsFormat (Stream *strm); + + void Dump (Stream *strm, bool show_frame_index, bool show_fullpaths); bool @@ -142,7 +145,7 @@ public: CalculateStackFrame (); virtual void - Calculate (ExecutionContext &exe_ctx); + CalculateExecutionContext (ExecutionContext &exe_ctx); lldb::StackFrameSP GetSP (); diff --git a/lldb/include/lldb/Target/Target.h b/lldb/include/lldb/Target/Target.h index 8e76ecb0187..d8bc8a43178 100644 --- a/lldb/include/lldb/Target/Target.h +++ b/lldb/include/lldb/Target/Target.h @@ -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 (); diff --git a/lldb/include/lldb/Target/Thread.h b/lldb/include/lldb/Target/Thread.h index 8be1851641a..9d04f1dacad 100644 --- a/lldb/include/lldb/Target/Thread.h +++ b/lldb/include/lldb/Target/Thread.h @@ -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); diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 9e0f35d0a1d..6f74a735db3 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -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"); diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index b87e56c1dcb..0ac463de3bf 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -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); diff --git a/lldb/source/API/SBThread.cpp b/lldb/source/API/SBThread.cpp index 8c74a34cdbe..216fa127816 100644 --- a/lldb/source/API/SBThread.cpp +++ b/lldb/source/API/SBThread.cpp @@ -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()); } diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 913577b087b..f21938f5fe2 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -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; diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp index 0ff7e673cf9..7f4f66efabe 100644 --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -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); } diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index 9d42b47ca13..f1b528d5856 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -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)); diff --git a/lldb/source/Core/Address.cpp b/lldb/source/Core/Address.cpp index df5a646fa91..c880d84b7c6 100644 --- a/lldb/source/Core/Address.cpp +++ b/lldb/source/Core/Address.cpp @@ -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()) diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp index 8be3da08ac3..8a010ae960c 100644 --- a/lldb/source/Core/Debugger.cpp +++ b/lldb/source/Core/Debugger.cpp @@ -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)) - { - 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); - s.PutChar (hex_value); - } - else + // 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])) { - s.PutCString ("\\x"); + ++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.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; @@ -1500,6 +1544,22 @@ DebuggerInstanceSettings::PromptVarName () } 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 () { static ConstString script_lang_var_name ("script-lang"); @@ -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 } }; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp index e4acd960323..a56eb364a45 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCRuntimeV2.cpp @@ -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; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp index f086d1b1da8..498937eb264 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleObjCTrampolineHandler.cpp @@ -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()); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp index 62b75d509b3..aec37ec00d1 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntimeV2/AppleThreadPlanStepThroughObjCTrampoline.cpp @@ -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(); diff --git a/lldb/source/Target/ExecutionContext.cpp b/lldb/source/Target/ExecutionContext.cpp index 74ad50a2676..d0bcdac8789 100644 --- a/lldb/source/Target/ExecutionContext.cpp +++ b/lldb/source/Target/ExecutionContext.cpp @@ -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 diff --git a/lldb/source/Target/Process.cpp b/lldb/source/Target/Process.cpp index 9086c15e805..3a65c5235e0 100644 --- a/lldb/source/Target/Process.cpp +++ b/lldb/source/Target/Process.cpp @@ -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; diff --git a/lldb/source/Target/RegisterContext.cpp b/lldb/source/Target/RegisterContext.cpp index 692fce042e8..b21890eee90 100644 --- a/lldb/source/Target/RegisterContext.cpp +++ b/lldb/source/Target/RegisterContext.cpp @@ -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); } diff --git a/lldb/source/Target/StackFrame.cpp b/lldb/source/Target/StackFrame.cpp index c7f2c040162..2be00d659a1 100644 --- a/lldb/source/Target/StackFrame.cpp +++ b/lldb/source/Target/StackFrame.cpp @@ -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,13 +616,36 @@ 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) { if (strm == NULL) diff --git a/lldb/source/Target/StackFrameList.cpp b/lldb/source/Target/StackFrameList.cpp index c6ac2de0f0d..2dd5fb8857b 100644 --- a/lldb/source/Target/StackFrameList.cpp +++ b/lldb/source/Target/StackFrameList.cpp @@ -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)); diff --git a/lldb/source/Target/StopInfo.cpp b/lldb/source/Target/StopInfo.cpp index d301cc156ff..49f07926715 100644 --- a/lldb/source/Target/StopInfo.cpp +++ b/lldb/source/Target/StopInfo.cpp @@ -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(); diff --git a/lldb/source/Target/Target.cpp b/lldb/source/Target/Target.cpp index bbc41be9f8c..f8e54aec57e 100644 --- a/lldb/source/Target/Target.cpp +++ b/lldb/source/Target/Target.cpp @@ -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 () { diff --git a/lldb/source/Target/Thread.cpp b/lldb/source/Target/Thread.cpp index fb4ad9a3bf2..d45f45ccfd8 100644 --- a/lldb/source/Target/Thread.cpp +++ b/lldb/source/Target/Thread.cpp @@ -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 |