From gclayton at apple.com Mon Nov 21 15:44:34 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 21 Nov 2011 21:44:34 -0000 Subject: [Lldb-commits] [lldb] r145050 - in /lldb/trunk: include/lldb/Core/Debugger.h source/Core/Debugger.cpp source/Target/StackFrame.cpp Message-ID: <20111121214434.A4FF21BE001@llvm.org> Author: gclayton Date: Mon Nov 21 15:44:34 2011 New Revision: 145050 URL: http://llvm.org/viewvc/llvm-project?rev=145050&view=rev Log: Many GDB users always want to display disassembly when they stop by using something like "display/4i $pc" (or something like this). With LLDB we already were showing 3 lines of source before and 3 lines of source after the current source line when showing a stop context. We now improve this by allowing the user to control the number of lines with the new "stop-line-count-before" and "stop-line-count-after" settings. Also, there is a new setting for how many disassembly lines to show: "stop-disassembly-count". This will control how many source lines are shown when there is no source or when we have no source line info. settings set stop-line-count-before 3 settings set stop-line-count-after 3 settings set stop-disassembly-count 4 settings set stop-disassembly-display no-source The default values are set as shown above and allow 3 lines of source before and after (what we used to do) the current stop location, and will display 4 lines of disassembly if the source is not available or if we have no debug info. If both "stop-source-context-before" and "stop-source-context-after" are set to zero, this will disable showing any source when stopped. The "stop-disassembly-display" setting is an enumeration that allows you to control when to display disassembly. It has 3 possible values: "never" - never show disassembly no matter what "no-source" - only show disassembly when there is no source line info or the source files are missing "always" - always show disassembly. Modified: lldb/trunk/include/lldb/Core/Debugger.h lldb/trunk/source/Core/Debugger.cpp lldb/trunk/source/Target/StackFrame.cpp Modified: lldb/trunk/include/lldb/Core/Debugger.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Debugger.h?rev=145050&r1=145049&r2=145050&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Debugger.h (original) +++ lldb/trunk/include/lldb/Core/Debugger.h Mon Nov 21 15:44:34 2011 @@ -44,6 +44,14 @@ { public: + enum StopDisassemblyType + { + eStopDisassemblyTypeNever = 0, + eStopDisassemblyTypeNoSource, + eStopDisassemblyTypeAlways + }; + + DebuggerInstanceSettings (UserSettingsController &owner, bool live_instance = true, const char *name = NULL); DebuggerInstanceSettings (const DebuggerInstanceSettings &rhs); @@ -81,6 +89,44 @@ { m_term_width = term_width; } + + uint32_t + GetStopSourceLineCount (bool before) const + { + if (before) + return m_stop_source_before_count; + else + return m_stop_source_after_count; + } + + + void + SetStopSourceLineCount (bool before, uint32_t n) + { + if (before) + m_stop_source_before_count = n; + else + m_stop_source_after_count = n; + } + + StopDisassemblyType + GetStopDisassemblyDisplay () const + { + return m_stop_disassembly_display; + } + + + uint32_t + GetDisassemblyLineCount () const + { + return m_stop_disassembly_count; + } + + void + SetDisassemblyLineCount (uint32_t n) + { + m_stop_disassembly_count = n; + } const char * GetPrompt() const @@ -169,7 +215,7 @@ { m_auto_confirm_on = auto_confirm_on; } - + protected: void @@ -185,30 +231,15 @@ const ConstString CreateInstanceName (); - static const ConstString & - PromptVarName (); - - static const ConstString & - GetFrameFormatName (); - - static const ConstString & - GetThreadFormatName (); - - static const ConstString & - ScriptLangVarName (); - - static const ConstString & - TermWidthVarName (); - - static const ConstString & - UseExternalEditorVarName (); - - static const ConstString & - AutoConfirmName (); + static OptionEnumValueElement g_show_disassembly_enum_values[]; private: uint32_t m_term_width; + uint32_t m_stop_source_before_count; + uint32_t m_stop_source_after_count; + uint32_t m_stop_disassembly_count; + StopDisassemblyType m_stop_disassembly_display; std::string m_prompt; std::string m_frame_format; std::string m_thread_format; Modified: lldb/trunk/source/Core/Debugger.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Debugger.cpp?rev=145050&r1=145049&r2=145050&view=diff ============================================================================== --- lldb/trunk/source/Core/Debugger.cpp (original) +++ lldb/trunk/source/Core/Debugger.cpp Mon Nov 21 15:44:34 2011 @@ -61,6 +61,94 @@ } +static const ConstString & +PromptVarName () +{ + static ConstString g_const_string ("prompt"); + return g_const_string; +} + +static const ConstString & +GetFrameFormatName () +{ + static ConstString g_const_string ("frame-format"); + return g_const_string; +} + +static const ConstString & +GetThreadFormatName () +{ + static ConstString g_const_string ("thread-format"); + return g_const_string; +} + +static const ConstString & +ScriptLangVarName () +{ + static ConstString g_const_string ("script-lang"); + return g_const_string; +} + +static const ConstString & +TermWidthVarName () +{ + static ConstString g_const_string ("term-width"); + return g_const_string; +} + +static const ConstString & +UseExternalEditorVarName () +{ + static ConstString g_const_string ("use-external-editor"); + return g_const_string; +} + +static const ConstString & +AutoConfirmName () +{ + static ConstString g_const_string ("auto-confirm"); + return g_const_string; +} + +static const ConstString & +StopSourceContextBeforeName () +{ + static ConstString g_const_string ("stop-line-count-before"); + return g_const_string; +} + +static const ConstString & +StopSourceContextAfterName () +{ + static ConstString g_const_string ("stop-line-count-after"); + return g_const_string; +} + +static const ConstString & +StopDisassemblyCountName () +{ + static ConstString g_const_string ("stop-disassembly-count"); + return g_const_string; +} + +static const ConstString & +StopDisassemblyDisplayName () +{ + static ConstString g_const_string ("stop-disassembly-display"); + return g_const_string; +} + +OptionEnumValueElement +DebuggerInstanceSettings::g_show_disassembly_enum_values[] = +{ + { eStopDisassemblyTypeNever, "never", "Never show disassembly when displaying a stop context."}, + { eStopDisassemblyTypeNoSource, "no-source", "Show disassembly when there is no source information, or the source file is missing when displaying a stop context."}, + { eStopDisassemblyTypeAlways, "always", "Always show disassembly when displaying a stop context."}, + { 0, NULL, NULL } +}; + + + #pragma mark Debugger UserSettingsControllerSP & @@ -2108,6 +2196,10 @@ ) : InstanceSettings (owner, name ? name : InstanceSettings::InvalidName().AsCString(), live_instance), m_term_width (80), + m_stop_source_before_count (3), + m_stop_source_after_count (3), + m_stop_disassembly_count (4), + m_stop_disassembly_display (eStopDisassemblyTypeNoSource), m_prompt (), m_frame_format (), m_thread_format (), @@ -2255,6 +2347,37 @@ { UserSettingsController::UpdateBooleanVariable (op, m_auto_confirm_on, value, false, err); } + else if (var_name == StopSourceContextBeforeName ()) + { + uint32_t new_value = Args::StringToUInt32(value, UINT32_MAX, 10, NULL); + if (new_value != UINT32_MAX) + m_stop_source_before_count = new_value; + else + err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopSourceContextAfterName ().GetCString()); + } + else if (var_name == StopSourceContextAfterName ()) + { + uint32_t new_value = Args::StringToUInt32(value, UINT32_MAX, 10, NULL); + if (new_value != UINT32_MAX) + m_stop_source_after_count = new_value; + else + err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopSourceContextBeforeName ().GetCString()); + } + else if (var_name == StopDisassemblyCountName ()) + { + uint32_t new_value = Args::StringToUInt32(value, UINT32_MAX, 10, NULL); + if (new_value != UINT32_MAX) + m_stop_disassembly_count = new_value; + else + err.SetErrorStringWithFormat("invalid unsigned string value '%s' for the '%s' setting", value, StopDisassemblyCountName ().GetCString()); + } + else if (var_name == StopDisassemblyDisplayName ()) + { + int new_value; + UserSettingsController::UpdateEnumVariable (g_show_disassembly_enum_values, &new_value, value, err); + if (err.Success()) + m_stop_disassembly_display = (StopDisassemblyType)new_value; + } } bool @@ -2275,7 +2398,7 @@ else if (var_name == TermWidthVarName()) { StreamString width_str; - width_str.Printf ("%d", m_term_width); + width_str.Printf ("%u", m_term_width); value.AppendString (width_str.GetData()); } else if (var_name == GetFrameFormatName ()) @@ -2300,6 +2423,31 @@ else value.AppendString ("false"); } + else if (var_name == StopSourceContextAfterName ()) + { + StreamString strm; + strm.Printf ("%u", m_stop_source_before_count); + value.AppendString (strm.GetData()); + } + else if (var_name == StopSourceContextBeforeName ()) + { + StreamString strm; + strm.Printf ("%u", m_stop_source_after_count); + value.AppendString (strm.GetData()); + } + else if (var_name == StopDisassemblyCountName ()) + { + StreamString strm; + strm.Printf ("%u", m_stop_disassembly_count); + value.AppendString (strm.GetData()); + } + else if (var_name == StopDisassemblyDisplayName ()) + { + if (m_stop_disassembly_display >= eStopDisassemblyTypeNever && m_stop_disassembly_display <= eStopDisassemblyTypeAlways) + value.AppendString (g_show_disassembly_enum_values[m_stop_disassembly_display].string_value); + else + value.AppendString (""); + } else { if (err) @@ -2391,61 +2539,6 @@ return ret_val; } -const ConstString & -DebuggerInstanceSettings::PromptVarName () -{ - static ConstString prompt_var_name ("prompt"); - - 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 () -{ - static ConstString script_lang_var_name ("script-lang"); - - return script_lang_var_name; -} - -const ConstString & -DebuggerInstanceSettings::TermWidthVarName () -{ - static ConstString term_width_var_name ("term-width"); - - return term_width_var_name; -} - -const ConstString & -DebuggerInstanceSettings::UseExternalEditorVarName () -{ - static ConstString use_external_editor_var_name ("use-external-editor"); - - return use_external_editor_var_name; -} - -const ConstString & -DebuggerInstanceSettings::AutoConfirmName () -{ - static ConstString use_external_editor_var_name ("auto-confirm"); - - return use_external_editor_var_name; -} //-------------------------------------------------- // SettingsController Variable Tables @@ -2495,7 +2588,11 @@ { "script-lang", eSetVarTypeString, "python", NULL, false, false, "The script language to be used for evaluating user-written scripts." }, { "term-width", eSetVarTypeInt, "80" , NULL, false, false, "The maximum number of columns to use for displaying text." }, { "thread-format", eSetVarTypeString, DEFAULT_THREAD_FORMAT, NULL, false, false, "The default thread format string to use when displaying thread information." }, -{ "use-external-editor", eSetVarTypeBoolean, "false", NULL, false, false, "Whether to use an external editor or not." }, -{ "auto-confirm", eSetVarTypeBoolean, "false", NULL, false, false, "If true all confirmation prompts will receive their default reply." }, +{ "use-external-editor", eSetVarTypeBoolean, "false", NULL, false, false, "Whether to use an external editor or not." }, +{ "auto-confirm", eSetVarTypeBoolean, "false", NULL, false, false, "If true all confirmation prompts will receive their default reply." }, +{ "stop-line-count-before",eSetVarTypeInt, "3", NULL, false, false, "The number of sources lines to display that come before the current source line when displaying a stopped context." }, +{ "stop-line-count-after", eSetVarTypeInt, "3", NULL, false, false, "The number of sources lines to display that come after the current source line when displaying a stopped context." }, +{ "stop-disassembly-count", eSetVarTypeInt, "0", NULL, false, false, "The number of disassembly lines to show when displaying a stopped context." }, +{ "stop-disassembly-display", eSetVarTypeEnum, "no-source", g_show_disassembly_enum_values, false, false, "Control when to display disassembly when displaying a stopped context." }, { NULL, eSetVarTypeNone, NULL, NULL, false, false, NULL } }; Modified: lldb/trunk/source/Target/StackFrame.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/StackFrame.cpp?rev=145050&r1=145049&r2=145050&view=diff ============================================================================== --- lldb/trunk/source/Target/StackFrame.cpp (original) +++ lldb/trunk/source/Target/StackFrame.cpp Mon Nov 21 15:44:34 2011 @@ -1270,19 +1270,62 @@ if (show_source) { - GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry); - - if (m_sc.comp_unit && m_sc.line_entry.IsValid()) + Target &target = GetThread().GetProcess().GetTarget(); + Debugger &debugger = target.GetDebugger(); + const uint32_t source_before = debugger.GetStopSourceLineCount(true); + const uint32_t source_after = debugger.GetStopSourceLineCount(false); + bool have_source = false; + if (source_before || source_after) { - Target &target = GetThread().GetProcess().GetTarget(); - target.GetSourceManager().DisplaySourceLinesWithLineNumbers ( - m_sc.line_entry.file, - m_sc.line_entry.line, - 3, - 3, - "->", - &strm); + GetSymbolContext(eSymbolContextCompUnit | eSymbolContextLineEntry); + + if (m_sc.comp_unit && m_sc.line_entry.IsValid()) + { + if (target.GetSourceManager().DisplaySourceLinesWithLineNumbers (m_sc.line_entry.file, + m_sc.line_entry.line, + source_before, + source_after, + "->", + &strm)) + { + have_source = true; + } + } + } + DebuggerInstanceSettings::StopDisassemblyType disasm_display = debugger.GetStopDisassemblyDisplay (); + switch (disasm_display) + { + case DebuggerInstanceSettings::eStopDisassemblyTypeNever: + break; + + case DebuggerInstanceSettings::eStopDisassemblyTypeNoSource: + if (have_source) + break; + // Fall through to next case + case DebuggerInstanceSettings::eStopDisassemblyTypeAlways: + { + const uint32_t disasm_lines = debugger.GetDisassemblyLineCount(); + if (disasm_lines > 0) + { + const ArchSpec &target_arch = target.GetArchitecture(); + AddressRange pc_range; + pc_range.GetBaseAddress() = GetFrameCodeAddress(); + pc_range.SetByteSize(disasm_lines * target_arch.GetMaximumOpcodeByteSize()); + ExecutionContext exe_ctx; + CalculateExecutionContext(exe_ctx); + Disassembler::Disassemble (debugger, + target_arch, + NULL, + exe_ctx, + pc_range, + disasm_lines, + 0, + Disassembler::eOptionMarkPCAddress, + strm); + } + } + break; } } return true; From gclayton at apple.com Mon Nov 21 15:51:18 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 21 Nov 2011 21:51:18 -0000 Subject: [Lldb-commits] [lldb] r145051 - /lldb/trunk/source/Commands/CommandObjectProcess.cpp Message-ID: <20111121215118.3C6BB1BE001@llvm.org> Author: gclayton Date: Mon Nov 21 15:51:18 2011 New Revision: 145051 URL: http://llvm.org/viewvc/llvm-project?rev=145051&view=rev Log: Save the arguments for a process launch in the target.run-args so they can easily be used in the next run. Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=145051&r1=145050&r2=145051&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Mon Nov 21 15:51:18 2011 @@ -220,6 +220,9 @@ } else { + // Save the arguments for subsequent runs in the current target. + target->SetRunArguments (launch_args); + m_options.launch_info.GetArguments().AppendArguments (launch_args); } From gclayton at apple.com Tue Nov 22 12:07:35 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 22 Nov 2011 18:07:35 -0000 Subject: [Lldb-commits] [lldb] r145067 - /lldb/trunk/source/Commands/CommandObjectMemory.cpp Message-ID: <20111122180735.D686A2A6C134@llvm.org> Author: gclayton Date: Tue Nov 22 12:07:35 2011 New Revision: 145067 URL: http://llvm.org/viewvc/llvm-project?rev=145067&view=rev Log: Fixed an issue with the options for memory read where --count couldn't be used with the --binary option when writing data to a file. Also removed the GDB format option from the --binary version of memory read. Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp Modified: lldb/trunk/source/Commands/CommandObjectMemory.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectMemory.cpp?rev=145067&r1=145066&r2=145067&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectMemory.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectMemory.cpp Tue Nov 22 12:07:35 2011 @@ -323,10 +323,10 @@ // Add the "--format" and "--count" options to group 1 and 3 m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_FORMAT | OptionGroupFormat::OPTION_GROUP_COUNT, - LLDB_OPT_SET_1 | LLDB_OPT_SET_3); + LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3); m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_GDB_FMT, - LLDB_OPT_SET_1 | LLDB_OPT_SET_2 | LLDB_OPT_SET_3); + LLDB_OPT_SET_1 | LLDB_OPT_SET_3); // Add the "--size" option to group 1 and 2 m_option_group.Append (&m_format_options, OptionGroupFormat::OPTION_GROUP_SIZE, From gclayton at apple.com Tue Nov 22 12:47:25 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 22 Nov 2011 18:47:25 -0000 Subject: [Lldb-commits] [lldb] r145069 - in /lldb/trunk: include/lldb/Symbol/Symtab.h source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Message-ID: <20111122184725.10A772A6C134@llvm.org> Author: gclayton Date: Tue Nov 22 12:47:24 2011 New Revision: 145069 URL: http://llvm.org/viewvc/llvm-project?rev=145069&view=rev Log: 12% allocated memory savings when debugging clang with DWARF in .o files by making sure we perfectly size our vector of symbols on the symbol table. Modified: lldb/trunk/include/lldb/Symbol/Symtab.h lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Modified: lldb/trunk/include/lldb/Symbol/Symtab.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symtab.h?rev=145069&r1=145068&r2=145069&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symtab.h (original) +++ lldb/trunk/include/lldb/Symbol/Symtab.h Tue Nov 22 12:47:24 2011 @@ -78,6 +78,16 @@ static void DumpSymbolHeader (Stream *s); + + void Finalize () + { + // Shrink to fit the symbols so we don't waste memory + if (m_symbols.capacity() > m_symbols.size()) + { + collection new_symbols (m_symbols.begin(), m_symbols.end()); + m_symbols.swap (new_symbols); + } + } protected: typedef std::vector collection; typedef collection::iterator iterator; Modified: lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp?rev=145069&r1=145068&r2=145069&view=diff ============================================================================== --- lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp (original) +++ lldb/trunk/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp Tue Nov 22 12:47:24 2011 @@ -320,6 +320,7 @@ m_symtab_ap.reset(new Symtab(this)); Mutex::Locker symtab_locker (m_symtab_ap->GetMutex()); ParseSymtab (true); + m_symtab_ap->Finalize (); } return m_symtab_ap.get(); } @@ -1488,6 +1489,8 @@ } } } + + return symtab->GetNumSymbols(); } From gclayton at apple.com Tue Nov 22 15:20:33 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 22 Nov 2011 21:20:33 -0000 Subject: [Lldb-commits] [lldb] r145084 - in /lldb/trunk: include/lldb/Symbol/Symbol.h source/Symbol/Symbol.cpp Message-ID: <20111122212033.6B0022A6C134@llvm.org> Author: gclayton Date: Tue Nov 22 15:20:33 2011 New Revision: 145084 URL: http://llvm.org/viewvc/llvm-project?rev=145084&view=rev Log: Got the sizeof(lldb_private::Symbol) down to 64 bytes (from 72 bytes) by not having the enumeration take up 32 bits for the type and by putting it into the bitfields that were already being used. Modified: lldb/trunk/include/lldb/Symbol/Symbol.h lldb/trunk/source/Symbol/Symbol.cpp Modified: lldb/trunk/include/lldb/Symbol/Symbol.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/Symbol.h?rev=145084&r1=145083&r2=145084&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/Symbol.h (original) +++ lldb/trunk/include/lldb/Symbol/Symbol.h Tue Nov 22 15:20:33 2011 @@ -111,10 +111,10 @@ GetByteSize () const { return m_addr_range.GetByteSize(); } lldb::SymbolType - GetType () const { return m_type; } + GetType () const { return (lldb::SymbolType)m_type; } void - SetType (lldb::SymbolType type) { m_type = type; } + SetType (lldb::SymbolType type) { m_type = (lldb::SymbolType)type; } const char * GetTypeAsString () const; @@ -204,7 +204,6 @@ uint32_t m_uid; // User ID (usually the original symbol table index) Mangled m_mangled; // uniqued symbol name/mangled name pair - lldb::SymbolType m_type; // symbol type uint16_t m_type_data; // data specific to m_type uint16_t m_type_data_resolved:1, // True if the data in m_type_data has already been calculated m_is_synthetic:1, // non-zero if this symbol is not actually in the symbol table, but synthesized from other info in the object file. @@ -212,9 +211,10 @@ m_is_external:1, // non-zero if this symbol is globally visible m_size_is_sibling:1, // m_size contains the index of this symbol's sibling m_size_is_synthesized:1,// non-zero if this symbol's size was calculated using a delta between this symbol and the next - m_searched_for_function:1;// non-zero if we have looked for the function associated with this symbol already. - AddressRange m_addr_range; // Contains the value, or the section offset address when the value is an address in a section, and the size (if any) + m_searched_for_function:1,// non-zero if we have looked for the function associated with this symbol already. + m_type:8; uint32_t m_flags; // A copy of the flags from the original symbol table, the ObjectFile plug-in can interpret these + AddressRange m_addr_range; // Contains the value, or the section offset address when the value is an address in a section, and the size (if any) }; } // namespace lldb_private Modified: lldb/trunk/source/Symbol/Symbol.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Symbol.cpp?rev=145084&r1=145083&r2=145084&view=diff ============================================================================== --- lldb/trunk/source/Symbol/Symbol.cpp (original) +++ lldb/trunk/source/Symbol/Symbol.cpp Tue Nov 22 15:20:33 2011 @@ -23,7 +23,6 @@ SymbolContextScope (), m_uid (UINT32_MAX), m_mangled (), - m_type (eSymbolTypeInvalid), m_type_data (0), m_type_data_resolved (false), m_is_synthetic (false), @@ -32,8 +31,9 @@ m_size_is_sibling (false), m_size_is_synthesized (false), m_searched_for_function (false), - m_addr_range (), - m_flags () + m_type (eSymbolTypeInvalid), + m_flags (), + m_addr_range () { } @@ -55,7 +55,6 @@ SymbolContextScope (), m_uid (symID), m_mangled (name, name_is_mangled), - m_type (type), m_type_data (0), m_type_data_resolved (false), m_is_synthetic (is_artificial), @@ -64,8 +63,9 @@ m_size_is_sibling (false), m_size_is_synthesized (false), m_searched_for_function (false), - m_addr_range (section, offset, size), - m_flags (flags) + m_type (type), + m_flags (flags), + m_addr_range (section, offset, size) { } @@ -85,7 +85,6 @@ SymbolContextScope (), m_uid (symID), m_mangled (name, name_is_mangled), - m_type (type), m_type_data (0), m_type_data_resolved (false), m_is_synthetic (is_artificial), @@ -94,8 +93,9 @@ m_size_is_sibling (false), m_size_is_synthesized (false), m_searched_for_function (false), - m_addr_range (range), - m_flags (flags) + m_type (type), + m_flags (flags), + m_addr_range (range) { } @@ -103,7 +103,6 @@ SymbolContextScope (rhs), m_uid (rhs.m_uid), m_mangled (rhs.m_mangled), - m_type (rhs.m_type), m_type_data (rhs.m_type_data), m_type_data_resolved (rhs.m_type_data_resolved), m_is_synthetic (rhs.m_is_synthetic), @@ -112,8 +111,9 @@ m_size_is_sibling (rhs.m_size_is_sibling), m_size_is_synthesized (false), m_searched_for_function (false), - m_addr_range (rhs.m_addr_range), - m_flags (rhs.m_flags) + m_type (rhs.m_type), + m_flags (rhs.m_flags), + m_addr_range (rhs.m_addr_range) { } @@ -125,7 +125,6 @@ SymbolContextScope::operator= (rhs); m_uid = rhs.m_uid; m_mangled = rhs.m_mangled; - m_type = rhs.m_type; m_type_data = rhs.m_type_data; m_type_data_resolved = rhs.m_type_data_resolved; m_is_synthetic = rhs.m_is_synthetic; @@ -134,8 +133,9 @@ m_size_is_sibling = rhs.m_size_is_sibling; m_size_is_synthesized = rhs.m_size_is_sibling; m_searched_for_function = rhs.m_searched_for_function; - m_addr_range = rhs.m_addr_range; + m_type = rhs.m_type; m_flags = rhs.m_flags; + m_addr_range = rhs.m_addr_range; } return *this; } @@ -145,7 +145,6 @@ { m_uid = UINT32_MAX; m_mangled.Clear(); - m_type = eSymbolTypeInvalid; m_type_data = 0; m_type_data_resolved = false; m_is_synthetic = false; @@ -154,8 +153,9 @@ m_size_is_sibling = false; m_size_is_synthesized = false; m_searched_for_function = false; - m_addr_range.Clear(); + m_type = eSymbolTypeInvalid; m_flags = 0; + m_addr_range.Clear(); } AddressRange * From gclayton at apple.com Tue Nov 22 15:35:28 2011 From: gclayton at apple.com (Greg Clayton) Date: Tue, 22 Nov 2011 21:35:28 -0000 Subject: [Lldb-commits] [lldb] r145086 - in /lldb/trunk/source/Plugins/SymbolFile/DWARF: DWARFCompileUnit.cpp DWARFCompileUnit.h DWARFDebugInfoEntry.cpp Message-ID: <20111122213528.1C6022A6C134@llvm.org> Author: gclayton Date: Tue Nov 22 15:35:27 2011 New Revision: 145086 URL: http://llvm.org/viewvc/llvm-project?rev=145086&view=rev Log: Shrink-to-fit our std::vector collections and save 20% to 30% of memory. The size doubling was killing us and we ended up with up to just under 50% of empty capacity. Cleaning this up saves us a ton of memory. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=145086&r1=145085&r2=145086&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Tue Nov 22 15:35:27 2011 @@ -271,7 +271,17 @@ } fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); } + + // Since std::vector objects will double their size, we really need to + // make a new array with the perfect size so we don't end up wasting + // space. So here we copy and swap to make sure we don't have any extra + // memory taken up. + if (m_die_array.size () < m_die_array.capacity()) + { + DWARFDebugInfoEntry::collection exact_size_die_array (m_die_array.begin(), m_die_array.end()); + exact_size_die_array.swap (m_die_array); + } LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO)); if (log) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h?rev=145086&r1=145085&r2=145086&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h Tue Nov 22 15:35:27 2011 @@ -74,13 +74,11 @@ } void - AddDIE(DWARFDebugInfoEntry& die) + AddDIE (DWARFDebugInfoEntry& die) { // The average bytes per DIE entry has been seen to be - // around 14-20 so lets pre-reserve the needed memory for - // our DIE entries accordingly. Search forward for "Compute - // average bytes per DIE" to see #if'ed out code that does - // that determination. + // around 14-20 so lets pre-reserve half of that since + // we are now stripping the NULL tags. // Only reserve the memory if we are adding children of // the main compile unit DIE. The compile unit DIE is always @@ -88,7 +86,7 @@ // the first compile unit child DIE and should reserve // the memory. if (m_die_array.empty()) - m_die_array.reserve(GetDebugInfoSize() / 14); + m_die_array.reserve(GetDebugInfoSize() / 24); m_die_array.push_back(die); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=145086&r1=145085&r2=145086&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Tue Nov 22 15:35:27 2011 @@ -1926,8 +1926,8 @@ { DWARFDebugInfoEntry::const_iterator pos; DWARFDebugInfoEntry::const_iterator end = die_collection.end(); - puts("offset parent sibling child"); - puts("-------- -------- -------- --------"); + strm.PutCString("\noffset parent sibling child\n"); + strm.PutCString("-------- -------- -------- --------\n"); for (pos = die_collection.begin(); pos != end; ++pos) { const DWARFDebugInfoEntry& die_ref = *pos; From dawn at burble.org Thu Nov 24 01:31:22 2011 From: dawn at burble.org (dawn at burble.org) Date: Wed, 23 Nov 2011 23:31:22 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux Message-ID: <20111124073122.GA13244@bloodbath.burble.org> This patch was created using clang/llvm rev 144569, lldb rev 144919 but has been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. Debugging on Linux broke when the assumption was made that a process could be launched by spawning it in a suspended state and then attaching to it. That support does not exist on Linux. To work around this, I added a new method "CanLaunchViaAttach" which tests whether the platform supports being launched in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find an easy way to set it from within the Linux plugins. Commit message: Fix debugging on Linux. Implement remote vs. host platform code as was done with PlatformDarwin. Platform::CanLaunchViaAttach(): new: return true if the process can be launched via spawn and attach. Default is true. Override in PlatformLinux to false. Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) then launch the process via CreateProcess and Launch. Please review and commit if acceptable. Thanks! -Dawn -------------- next part -------------- Index: include/lldb/Target/Platform.h =================================================================== --- include/lldb/Target/Platform.h (revision 145118) +++ include/lldb/Target/Platform.h (working copy) @@ -146,6 +146,10 @@ virtual const char * GetDescription () = 0; + /// By default, launch the process by spawning and attaching. + virtual bool + CanLaunchViaAttach () { return true; } + //------------------------------------------------------------------ /// Report the current status for this platform. /// Index: include/lldb/Core/MappedHash.h =================================================================== --- include/lldb/Core/MappedHash.h (revision 145118) +++ include/lldb/Core/MappedHash.h (working copy) @@ -98,7 +98,7 @@ virtual size_t GetByteSize (const HeaderData &header_data) = 0; - size_t + void SetHeaderDataByteSize (uint32_t header_data_byte_size) { header_data_len = header_data_byte_size; Index: source/Plugins/Platform/Linux/PlatformLinux.cpp =================================================================== --- source/Plugins/Platform/Linux/PlatformLinux.cpp (revision 145118) +++ source/Plugins/Platform/Linux/PlatformLinux.cpp (working copy) @@ -17,6 +17,7 @@ // Other libraries and framework includes // Project includes #include "lldb/Core/Error.h" +#include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/PluginManager.h" @@ -29,10 +30,12 @@ using namespace lldb; using namespace lldb_private; +static uint32_t g_initialize_count = 0; + Platform * PlatformLinux::CreateInstance () { - return new PlatformLinux(); + return new PlatformLinux(true); } const char * @@ -42,33 +45,51 @@ } const char * -PlatformLinux::GetPluginDescriptionStatic() +PlatformLinux::GetShortPluginNameStatic (bool is_host) { - return "Default platform plugin for Linux"; + if (is_host) + return Platform::GetHostPlatformName (); + else + return "remote-linux"; } +const char * +PlatformLinux::GetPluginDescriptionStatic (bool is_host) +{ + if (is_host) + return "Local Linux user platform plug-in."; + else + return "Remote Linux user platform plug-in."; +} + void PlatformLinux::Initialize () { - static bool g_initialized = false; - - if (!g_initialized) + if (g_initialize_count++ == 0) { - PlatformSP default_platform_sp (CreateInstance()); +#if defined(__linux__) + PlatformSP default_platform_sp (new PlatformLinux(true)); + default_platform_sp->SetSystemArchitecture (Host::GetArchitecture()); Platform::SetDefaultPlatform (default_platform_sp); - PluginManager::RegisterPlugin(GetPluginNameStatic(), - GetPluginDescriptionStatic(), - CreateInstance); - g_initialized = true; +#endif + PluginManager::RegisterPlugin(PlatformLinux::GetShortPluginNameStatic(false), + PlatformLinux::GetPluginDescriptionStatic(false), + PlatformLinux::CreateInstance); } } void PlatformLinux::Terminate () { + if (g_initialize_count > 0) + { + if (--g_initialize_count == 0) + { + PluginManager::UnregisterPlugin (PlatformLinux::CreateInstance); + } + } } - Error PlatformLinux::ResolveExecutable (const FileSpec &exe_file, const ArchSpec &exe_arch, @@ -77,18 +98,51 @@ Error error; // Nothing special to do here, just use the actual file and architecture + char exe_path[PATH_MAX]; FileSpec resolved_exe_file (exe_file); - // If we have "ls" as the exe_file, resolve the executable loation based on - // the current path variables - if (!resolved_exe_file.Exists()) - resolved_exe_file.ResolveExecutableLocation (); + if (IsHost()) + { + // If we have "ls" as the exe_file, resolve the executable location based on + // the current path variables + if (!resolved_exe_file.Exists()) + { + exe_file.GetPath(exe_path, sizeof(exe_path)); + resolved_exe_file.SetFile(exe_path, true); + } - // Resolve any executable within a bundle on MacOSX - Host::ResolveExecutableInBundle (resolved_exe_file); + if (!resolved_exe_file.Exists()) + resolved_exe_file.ResolveExecutableLocation (); - if (resolved_exe_file.Exists()) + if (resolved_exe_file.Exists()) + error.Clear(); + else + { + exe_file.GetPath(exe_path, sizeof(exe_path)); + error.SetErrorStringWithFormat("unable to find executable for '%s'", exe_path); + } + } + else { + if (m_remote_platform_sp) + { + error = m_remote_platform_sp->ResolveExecutable (exe_file, + exe_arch, + exe_module_sp); + } + else + { + // We may connect to a process and use the provided executable (Don't use local $PATH). + + if (resolved_exe_file.Exists()) + error.Clear(); + else + error.SetErrorStringWithFormat("the platform is not currently connected, and '%s' doesn't exist in the system root.", exe_path); + } + } + + if (error.Success()) + { if (exe_arch.IsValid()) { error = ModuleList::GetSharedModule (resolved_exe_file, @@ -152,21 +206,20 @@ } } } - else - { - error.SetErrorStringWithFormat ("'%s%s%s' does not exist", - exe_file.GetDirectory().AsCString(""), - exe_file.GetDirectory() ? "/" : "", - exe_file.GetFilename().AsCString("")); - } return error; } Error PlatformLinux::GetFile (const FileSpec &platform_file, - const UUID *uuid, FileSpec &local_file) + const UUID *uuid_ptr, FileSpec &local_file) { + if (IsRemote()) + { + if (m_remote_platform_sp) + return m_remote_platform_sp->GetFile (platform_file, uuid_ptr, local_file); + } + // Default to the local case local_file = platform_file; return Error(); @@ -176,8 +229,9 @@ //------------------------------------------------------------------ /// Default Constructor //------------------------------------------------------------------ -PlatformLinux::PlatformLinux () : - Platform(true) +PlatformLinux::PlatformLinux (bool is_host) : + Platform(is_host), // This is the local host platform + m_remote_platform_sp () { } @@ -194,7 +248,17 @@ bool PlatformLinux::GetProcessInfo (lldb::pid_t pid, ProcessInstanceInfo &process_info) { - return Host::GetProcessInfo (pid, process_info); + bool success = false; + if (IsHost()) + { + success = Platform::GetProcessInfo (pid, process_info); + } + else + { + if (m_remote_platform_sp) + success = m_remote_platform_sp->GetProcessInfo (pid, process_info); + } + return success; } bool @@ -225,11 +289,9 @@ PlatformLinux::GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site) { - static const uint8_t g_i386_opcode[] = { 0xCC }; - ArchSpec arch = target.GetArchitecture(); - const uint8_t *opcode = NULL; - size_t opcode_size = 0; + const uint8_t *trap_opcode = NULL; + size_t trap_opcode_size = 0; switch (arch.GetCore()) { @@ -239,15 +301,41 @@ case ArchSpec::eCore_x86_32_i386: case ArchSpec::eCore_x86_64_x86_64: - opcode = g_i386_opcode; - opcode_size = sizeof(g_i386_opcode); + { + static const uint8_t g_i386_breakpoint_opcode[] = { 0xCC }; + trap_opcode = g_i386_breakpoint_opcode; + trap_opcode_size = sizeof(g_i386_breakpoint_opcode); + } break; } - bp_site->SetTrapOpcode(opcode, opcode_size); - return opcode_size; + if (bp_site->SetTrapOpcode(trap_opcode, trap_opcode_size)) + return trap_opcode_size; + return 0; } +Error +PlatformLinux::LaunchProcess (ProcessLaunchInfo &launch_info) +{ + Error error; + + if (IsHost()) + { + if (launch_info.GetFlags().Test (eLaunchFlagLaunchInShell)) + { + const bool is_localhost = true; + if (!launch_info.ConvertArgumentsForLaunchingInShell (error, is_localhost)) + return error; + } + error = Platform::LaunchProcess (launch_info); + } + else + { + error.SetErrorString ("the platform is not currently connected"); + } + return error; +} + lldb::ProcessSP PlatformLinux::Attach(ProcessAttachInfo &attach_info, Debugger &debugger, @@ -255,7 +343,42 @@ Listener &listener, Error &error) { - ProcessSP processSP; - assert(!"Not implemented yet!"); - return processSP; + lldb::ProcessSP process_sp; + if (IsHost()) + { + if (target == NULL) + { + TargetSP new_target_sp; + FileSpec emptyFileSpec; + ArchSpec emptyArchSpec; + + error = debugger.GetTargetList().CreateTarget (debugger, + emptyFileSpec, + emptyArchSpec, + false, + m_remote_platform_sp, + new_target_sp); + target = new_target_sp.get(); + } + else + error.Clear(); + + if (target && error.Success()) + { + debugger.GetTargetList().SetSelectedTarget(target); + + process_sp = target->CreateProcess (listener, attach_info.GetProcessPluginName()); + + if (process_sp) + error = process_sp->Attach (attach_info); + } + } + else + { + if (m_remote_platform_sp) + process_sp = m_remote_platform_sp->Attach (attach_info, debugger, target, listener, error); + else + error.SetErrorString ("the platform is not currently connected"); + } + return process_sp; } Index: source/Plugins/Platform/Linux/PlatformLinux.h =================================================================== --- source/Plugins/Platform/Linux/PlatformLinux.h (revision 145118) +++ source/Plugins/Platform/Linux/PlatformLinux.h (working copy) @@ -28,7 +28,7 @@ static void Terminate (); - PlatformLinux (); + PlatformLinux (bool is_host); virtual ~PlatformLinux(); @@ -43,8 +43,11 @@ GetPluginNameStatic(); static const char * - GetPluginDescriptionStatic(); + GetShortPluginNameStatic(bool is_host); + static const char * + GetPluginDescriptionStatic(bool is_host); + virtual const char * GetPluginName() { @@ -71,10 +74,14 @@ const ArchSpec &arch, lldb::ModuleSP &module_sp); + /// Linux processes can not be launched by spawning and attaching. + virtual bool + CanLaunchViaAttach () { return false; } + virtual const char * GetDescription () { - return GetPluginDescriptionStatic(); + return GetPluginDescriptionStatic(IsHost()); } virtual void @@ -94,13 +101,16 @@ GetSoftwareBreakpointTrapOpcode (Target &target, BreakpointSite *bp_site); + virtual lldb_private::Error + LaunchProcess (lldb_private::ProcessLaunchInfo &launch_info); + virtual lldb::ProcessSP Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Listener &listener, Error &error); protected: + lldb::PlatformSP m_remote_platform_sp; // Allow multiple ways to connect to a remote darwin OS - private: DISALLOW_COPY_AND_ASSIGN (PlatformLinux); }; Index: source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp (revision 145118) +++ source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp (working copy) @@ -34,7 +34,7 @@ s.PutCString("\n "); s.Indent(); - s.AddressRange(start_addr + base_addr, end_addr + base_addr, NULL, ": "); + s.AddressRange(start_addr + base_addr, end_addr + base_addr, 0, ": "); uint32_t loc_length = debug_loc_data.GetU16(&offset); DataExtractor locationData(debug_loc_data, offset, loc_length); Index: source/Plugins/Process/Linux/ProcessLinux.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessLinux.cpp (revision 145118) +++ source/Plugins/Process/Linux/ProcessLinux.cpp (working copy) @@ -87,7 +87,6 @@ m_in_limbo(false), m_exit_now(false) { - #if 0 // FIXME: Putting this code in the ctor and saving the byte order in a // member variable is a hack to avoid const qual issues in GetByteOrder. @@ -152,7 +151,6 @@ SetPrivateState(eStateLaunching); - uint32_t launch_flags = launch_info.GetFlags().Get(); const char *stdin_path = NULL; const char *stdout_path = NULL; const char *stderr_path = NULL; @@ -270,7 +268,13 @@ Error ProcessLinux::DoDetach() { - return Error(1, eErrorTypeGeneric); + Error error; + + error = m_monitor->Detach(); + if (error.Success()) + SetPrivateState(eStateDetached); + + return error; } Error @@ -388,7 +392,7 @@ ProcessLinux::IsAlive() { StateType state = GetPrivateState(); - return state != eStateExited && state != eStateInvalid; + return state != eStateDetached && state != eStateExited && state != eStateInvalid; } size_t Index: source/Plugins/Process/Linux/ProcessMonitor.cpp =================================================================== --- source/Plugins/Process/Linux/ProcessMonitor.cpp (revision 145118) +++ source/Plugins/Process/Linux/ProcessMonitor.cpp (working copy) @@ -722,6 +722,30 @@ m_result = true; } +//------------------------------------------------------------------------------ +/// @class KillOperation +/// @brief Implements ProcessMonitor::BringProcessIntoLimbo. +class DetachOperation : public Operation +{ +public: + DetachOperation(Error &result) : m_error(result) { } + + void Execute(ProcessMonitor *monitor); + +private: + Error &m_error; +}; + +void +DetachOperation::Execute(ProcessMonitor *monitor) +{ + lldb::pid_t pid = monitor->GetPID(); + + if (ptrace(PT_DETACH, pid, NULL, 0) < 0) + m_error.SetErrorToErrno(); + +} + ProcessMonitor::OperationArgs::OperationArgs(ProcessMonitor *monitor) : m_monitor(monitor) { @@ -1220,7 +1244,7 @@ ProcessMessage ProcessMonitor::MonitorSIGTRAP(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid) + const siginfo_t *info, lldb::pid_t pid) { ProcessMessage message; @@ -1261,7 +1285,7 @@ ProcessMessage ProcessMonitor::MonitorSignal(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid) + const siginfo_t *info, lldb::pid_t pid) { ProcessMessage message; int signo = info->si_signo; @@ -1312,7 +1336,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGSEGV(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGSEGV(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGSEGV); @@ -1336,7 +1360,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGILL(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGILL(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGILL); @@ -1378,7 +1402,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGFPE(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGFPE(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGFPE); @@ -1420,7 +1444,7 @@ } ProcessMessage::CrashReason -ProcessMonitor::GetCrashReasonForSIGBUS(const struct siginfo *info) +ProcessMonitor::GetCrashReasonForSIGBUS(const siginfo_t *info) { ProcessMessage::CrashReason reason; assert(info->si_signo == SIGBUS); @@ -1646,7 +1670,9 @@ ProcessMonitor::Detach() { bool result; - KillOperation op(result); + lldb_private::Error error; + DetachOperation op(error); + result = error.Success(); DoOperation(&op); StopMonitor(); return result; Index: source/Plugins/Process/Linux/ProcessMonitor.h =================================================================== --- source/Plugins/Process/Linux/ProcessMonitor.h (revision 145118) +++ source/Plugins/Process/Linux/ProcessMonitor.h (working copy) @@ -257,23 +257,23 @@ static ProcessMessage MonitorSIGTRAP(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid); + const siginfo_t *info, lldb::pid_t pid); static ProcessMessage MonitorSignal(ProcessMonitor *monitor, - const struct siginfo *info, lldb::pid_t pid); + const siginfo_t *info, lldb::pid_t pid); static ProcessMessage::CrashReason - GetCrashReasonForSIGSEGV(const struct siginfo *info); + GetCrashReasonForSIGSEGV(const siginfo_t *info); static ProcessMessage::CrashReason - GetCrashReasonForSIGILL(const struct siginfo *info); + GetCrashReasonForSIGILL(const siginfo_t *info); static ProcessMessage::CrashReason - GetCrashReasonForSIGFPE(const struct siginfo *info); + GetCrashReasonForSIGFPE(const siginfo_t *info); static ProcessMessage::CrashReason - GetCrashReasonForSIGBUS(const struct siginfo *info); + GetCrashReasonForSIGBUS(const siginfo_t *info); void DoOperation(Operation *op); Index: source/Target/Platform.cpp =================================================================== --- source/Target/Platform.cpp (revision 145118) +++ source/Target/Platform.cpp (working copy) @@ -574,20 +574,31 @@ ProcessSP process_sp; // Make sure we stop at the entry point launch_info.GetFlags ().Set (eLaunchFlagDebug); - error = LaunchProcess (launch_info); - if (error.Success()) + + if (!target->GetPlatform()->CanLaunchViaAttach()) { - if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) + const char *plugin_name = launch_info.GetProcessPluginName(); + process_sp = target->CreateProcess (listener, plugin_name).get(); + error = process_sp->Launch (launch_info); + } + else + { + // We can launch the process using spawn and attach. + error = LaunchProcess (launch_info); + if (error.Success()) { - ProcessAttachInfo attach_info (launch_info); - process_sp = Attach (attach_info, debugger, target, listener, error); - if (process_sp) + if (launch_info.GetProcessID() != LLDB_INVALID_PROCESS_ID) { - // Since we attached to the process, it will think it needs to detach - // if the process object just goes away without an explicit call to - // Process::Kill() or Process::Detach(), so let it know to kill the - // process if this happens. - process_sp->SetShouldDetach (false); + ProcessAttachInfo attach_info (launch_info); + process_sp = Attach (attach_info, debugger, target, listener, error); + if (process_sp) + { + // Since we attached to the process, it will think it needs to detach + // if the process object just goes away without an explicit call to + // Process::Kill() or Process::Detach(), so let it know to kill the + // process if this happens. + process_sp->SetShouldDetach (false); + } // If we didn't have any file actions, the pseudo terminal might // have been used where the slave side was given as the file to From baldrick at free.fr Thu Nov 24 03:02:04 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 24 Nov 2011 10:02:04 +0100 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <20111124073122.GA13244@bloodbath.burble.org> References: <20111124073122.GA13244@bloodbath.burble.org> Message-ID: <4ECE080C.5090709@free.fr> As a side-note, there is a buildbot trying to build and test lldb on linux. If you look here http://lab.llvm.org:8011/console you will see this builder http://lab.llvm.org:8011/builders/lldb-x86_64-linux which is compiling lldb, but tests are failing: The evaluating printf(...) after break stop and then up a stack frame. ... python: Host.cpp:42: static lldb_private::Error lldb_private::Host::LaunchProcess(lldb_private::ProcessLaunchInfo&): Assertion `!"Not implemented yet!!!"' failed. Should this buildbot be managed from the general LLVM build master like this, or does lldb have its own build master? Ciao, Duncan. On 24/11/11 08:31, dawn at burble.org wrote: > This patch was created using clang/llvm rev 144569, lldb rev 144919 but has > been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on > Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. > > Debugging on Linux broke when the assumption was made that a process could be > launched by spawning it in a suspended state and then attaching to it. That > support does not exist on Linux. To work around this, I added a new method > "CanLaunchViaAttach" which tests whether the platform supports being launched > in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find > an easy way to set it from within the Linux plugins. > > Commit message: > > Fix debugging on Linux. > Implement remote vs. host platform code as was done with PlatformDarwin. > Platform::CanLaunchViaAttach(): new: return true if the process can be launched > via spawn and attach. Default is true. Override in PlatformLinux to false. > Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) > then launch the process via CreateProcess and Launch. > > Please review and commit if acceptable. > Thanks! > -Dawn > > > > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Sun Nov 27 18:42:24 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 00:42:24 -0000 Subject: [Lldb-commits] [lldb] r145212 - /lldb/trunk/include/lldb/Core/MappedHash.h Message-ID: <20111128004224.DAC8F2A6C12D@llvm.org> Author: gclayton Date: Sun Nov 27 18:42:24 2011 New Revision: 145212 URL: http://llvm.org/viewvc/llvm-project?rev=145212&view=rev Log: Remove incorrect return type from SetHeaderDataByteSize accessor (partial patch from Dawn). Modified: lldb/trunk/include/lldb/Core/MappedHash.h Modified: lldb/trunk/include/lldb/Core/MappedHash.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/MappedHash.h?rev=145212&r1=145211&r2=145212&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/MappedHash.h (original) +++ lldb/trunk/include/lldb/Core/MappedHash.h Sun Nov 27 18:42:24 2011 @@ -98,7 +98,7 @@ virtual size_t GetByteSize (const HeaderData &header_data) = 0; - size_t + void SetHeaderDataByteSize (uint32_t header_data_byte_size) { header_data_len = header_data_byte_size; From gclayton at apple.com Sun Nov 27 18:51:27 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 00:51:27 -0000 Subject: [Lldb-commits] [lldb] r145216 - in /lldb/trunk/source: Core/Stream.cpp Plugins/SymbolFile/DWARF/DWARFLocationList.cpp Message-ID: <20111128005127.5AC912A6C12D@llvm.org> Author: gclayton Date: Sun Nov 27 18:51:27 2011 New Revision: 145216 URL: http://llvm.org/viewvc/llvm-project?rev=145216&view=rev Log: Fixed an issue in the DWARFLocationList::Dump() function where default arguments were quietly masked as the code changed (modified version of a path from Dawn). Modified: lldb/trunk/source/Core/Stream.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp Modified: lldb/trunk/source/Core/Stream.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Stream.cpp?rev=145216&r1=145215&r2=145216&view=diff ============================================================================== --- lldb/trunk/source/Core/Stream.cpp (original) +++ lldb/trunk/source/Core/Stream.cpp Sun Nov 27 18:51:27 2011 @@ -168,10 +168,12 @@ void Stream::AddressRange(uint64_t lo_addr, uint64_t hi_addr, int addr_size, const char *prefix, const char *suffix) { - if (prefix != NULL) + if (prefix && prefix[0]) PutCString (prefix); Address (lo_addr, addr_size, "["); Address (hi_addr, addr_size, "-", ")"); + if (suffix && suffix[0]) + PutCString (suffix); } Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp?rev=145216&r1=145215&r2=145216&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFLocationList.cpp Sun Nov 27 18:51:27 2011 @@ -34,7 +34,11 @@ s.PutCString("\n "); s.Indent(); - s.AddressRange(start_addr + base_addr, end_addr + base_addr, NULL, ": "); + s.AddressRange (start_addr + base_addr, + end_addr + base_addr, + cu->GetAddressByteSize(), + NULL, + ": "); uint32_t loc_length = debug_loc_data.GetU16(&offset); DataExtractor locationData(debug_loc_data, offset, loc_length); From gclayton at apple.com Sun Nov 27 19:45:01 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 01:45:01 -0000 Subject: [Lldb-commits] [lldb] r145219 - in /lldb/trunk: include/lldb/Core/Module.h include/lldb/Symbol/SymbolFile.h include/lldb/Target/Platform.h source/Commands/CommandObjectProcess.cpp source/Core/Module.cpp source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h source/Symbol/SymbolFile.cpp Message-ID: <20111128014501.449402A6C12D@llvm.org> Author: gclayton Date: Sun Nov 27 19:45:00 2011 New Revision: 145219 URL: http://llvm.org/viewvc/llvm-project?rev=145219&view=rev Log: CommandObjectProcess was recently changed to automatically use the platform to launch a process for debugging. Since this isn't supported on all platforms, we need to do what we used to do if this isn't supported. I added: bool Platform::CanDebugProcess (); This will get checked before trying to launch a process for debugging and then fall back to launching the process through the current host debugger. This should solve the issue for linux and keep the platform code clean. Centralized logging code for logging errors, warnings and logs when reporting things for modules or symbol files. Both lldb_private::Module and lldb_private::SymbolFile now have the following member functions: void LogMessage (Log *log, const char *format, ...); void ReportWarning (const char *format, ...); void ReportError (const char *format, ...); These will all output the module name and object (if any) such as: "error: lldb.so ...." "warning: my_archive.a(foo.o) ...." This will keep the output consistent and stop a lot of logging calls from having to try and output all of the information that uniquely identifies a module or symbol file. Many places in the code were grabbing the path to the object file manually and if the module represented a .o file in an archive, we would see log messages like: error: foo.a - some error happened Modified: lldb/trunk/include/lldb/Core/Module.h lldb/trunk/include/lldb/Symbol/SymbolFile.h lldb/trunk/include/lldb/Target/Platform.h lldb/trunk/source/Commands/CommandObjectProcess.cpp lldb/trunk/source/Core/Module.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h lldb/trunk/source/Symbol/SymbolFile.cpp Modified: lldb/trunk/include/lldb/Core/Module.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Module.h?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/include/lldb/Core/Module.h (original) +++ lldb/trunk/include/lldb/Core/Module.h Sun Nov 27 19:45:00 2011 @@ -114,7 +114,8 @@ CalculateSymbolContextModule (); void - GetDescription (Stream *s); + GetDescription (Stream *s, + lldb::DescriptionLevel level = lldb::eDescriptionLevelFull); //------------------------------------------------------------------ /// Dump a description of this object to a Stream. @@ -664,6 +665,19 @@ ClangASTContext & GetClangASTContext (); + // Special error functions that can do printf style formatting that will prepend the message with + // something appropriate for this module (like the architecture, path and object name (if any)). + // This centralizes code so that everyone doesn't need to format their error and log messages on + // their own and keeps the output a bit more consistent. + void + LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4))); + + void + ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3))); + + void + ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3))); + protected: //------------------------------------------------------------------ // Member Variables Modified: lldb/trunk/include/lldb/Symbol/SymbolFile.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/SymbolFile.h?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/include/lldb/Symbol/SymbolFile.h (original) +++ lldb/trunk/include/lldb/Symbol/SymbolFile.h Sun Nov 27 19:45:00 2011 @@ -133,6 +133,14 @@ ObjectFile* GetObjectFile() { return m_obj_file; } const ObjectFile* GetObjectFile() const { return m_obj_file; } + + // Special error functions that can do printf style formatting that will prepend the message with + // something appropriate for this symbol file (like the architecture, path and object name). This + // centralizes code so that everyone doesn't need to format their error and log messages on their + // own and keeps the output a bit more consistent. + void LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4))); + void ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3))); + void ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3))); protected: ObjectFile* m_obj_file; // The object file that symbols can be extracted from. Modified: lldb/trunk/include/lldb/Target/Platform.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Platform.h?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/include/lldb/Target/Platform.h (original) +++ lldb/trunk/include/lldb/Target/Platform.h Sun Nov 27 19:45:00 2011 @@ -276,6 +276,19 @@ LaunchProcess (ProcessLaunchInfo &launch_info); //------------------------------------------------------------------ + /// Not all platforms will support debugging a process by spawning + /// somehow halted for a debugger (specified using the + /// "eLaunchFlagDebug" launch flag) and then attaching. If your + /// platform doesn't support this, override this function and return + /// false. + //------------------------------------------------------------------ + virtual bool + CanDebugProcess () + { + return true; + } + + //------------------------------------------------------------------ /// Subclasses should NOT need to implement this function as it uses /// the Platform::LaunchProcess() followed by Platform::Attach () //------------------------------------------------------------------ Modified: lldb/trunk/source/Commands/CommandObjectProcess.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectProcess.cpp?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/source/Commands/CommandObjectProcess.cpp (original) +++ lldb/trunk/source/Commands/CommandObjectProcess.cpp Sun Nov 27 19:45:00 2011 @@ -257,11 +257,23 @@ if (!m_options.launch_info.GetArchitecture().IsValid()) m_options.launch_info.GetArchitecture() = target->GetArchitecture(); - process = target->GetPlatform()->DebugProcess (m_options.launch_info, - debugger, - target, - debugger.GetListener(), - error).get(); + PlatformSP platform_sp (target->GetPlatform()); + + if (platform_sp && platform_sp->CanDebugProcess ()) + { + process = target->GetPlatform()->DebugProcess (m_options.launch_info, + debugger, + target, + debugger.GetListener(), + error).get(); + } + else + { + const char *plugin_name = m_options.launch_info.GetProcessPluginName(); + process = target->CreateProcess (debugger.GetListener(), plugin_name).get(); + if (process) + error = process->Launch (m_options.launch_info); + } if (process == NULL) { Modified: lldb/trunk/source/Core/Module.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/source/Core/Module.cpp (original) +++ lldb/trunk/source/Core/Module.cpp Sun Nov 27 19:45:00 2011 @@ -11,6 +11,7 @@ #include "lldb/Core/Log.h" #include "lldb/Core/ModuleList.h" #include "lldb/Core/RegularExpression.h" +#include "lldb/Core/StreamString.h" #include "lldb/Core/Timer.h" #include "lldb/lldb-private-log.h" #include "lldb/Symbol/ObjectFile.h" @@ -578,16 +579,28 @@ } void -Module::GetDescription (Stream *s) +Module::GetDescription (Stream *s, lldb::DescriptionLevel level) { Mutex::Locker locker (m_mutex); - if (m_arch.IsValid()) - s->Printf("(%s) ", m_arch.GetArchitectureName()); + if (level >= eDescriptionLevelFull) + { + if (m_arch.IsValid()) + s->Printf("(%s) ", m_arch.GetArchitectureName()); + } - char path[PATH_MAX]; - if (m_file.GetPath(path, sizeof(path))) - s->PutCString(path); + if (level == eDescriptionLevelBrief) + { + const char *filename = m_file.GetFilename().GetCString(); + if (filename) + s->PutCString (filename); + } + else + { + char path[PATH_MAX]; + if (m_file.GetPath(path, sizeof(path))) + s->PutCString(path); + } const char *object_name = m_object_name.GetCString(); if (object_name) @@ -595,6 +608,48 @@ } void +Module::ReportError (const char *format, ...) +{ + StreamString module_description; + GetDescription(&module_description, lldb::eDescriptionLevelBrief); + ::fprintf (stderr, "error: %s ", module_description.GetString().c_str()); + + va_list args; + va_start (args, format); + vfprintf (stderr, format, args); + va_end (args); +} + +void +Module::ReportWarning (const char *format, ...) +{ + StreamString module_description; + GetDescription(&module_description, lldb::eDescriptionLevelBrief); + ::fprintf (stderr, "warning: %s ", module_description.GetString().c_str()); + + va_list args; + va_start (args, format); + vfprintf (stderr, format, args); + va_end (args); +} + +void +Module::LogMessage (Log *log, const char *format, ...) +{ + if (log) + { + StreamString log_message; + GetDescription(&log_message, lldb::eDescriptionLevelBrief); + log_message.PutCString (": "); + va_list args; + va_start (args, format); + log_message.PrintfVarArg (format, args); + va_end (args); + log->PutCString(log_message.GetString().c_str()); + } +} + +void Module::Dump(Stream *s) { Mutex::Locker locker (m_mutex); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Sun Nov 27 19:45:00 2011 @@ -10,6 +10,7 @@ #include "DWARFCompileUnit.h" #include "lldb/Core/Mangled.h" +#include "lldb/Core/Module.h" #include "lldb/Core/Stream.h" #include "lldb/Core/Timer.h" #include "lldb/Symbol/ObjectFile.h" @@ -164,14 +165,16 @@ DWARFDebugInfoEntry die; // Keep a flat array of the DIE for binary lookup by DIE offset -// Log *log = LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO); -// if (log) -// log->Printf("0x%8.8x: Compile Unit: length = 0x%8.8x, version = 0x%4.4x, abbr_offset = 0x%8.8x, addr_size = 0x%2.2x", -// cu->GetOffset(), -// cu->GetLength(), -// cu->GetVersion(), -// cu->GetAbbrevOffset(), -// cu->GetAddressByteSize()); + if (!cu_die_only) + { + LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); + if (log) + { + m_dwarf2Data->LogMessage (log.get(), + "DWARFCompileUnit::ExtractDIEsIfNeeded () for compile unit at .debug_info[0x%8.8x]", + GetOffset()); + } + } uint32_t depth = 0; // We are in our compile unit, parse starting at the offset @@ -263,13 +266,9 @@ // unit header). if (offset > next_cu_offset) { - char path[PATH_MAX]; - ObjectFile *objfile = m_dwarf2Data->GetObjectFile(); - if (objfile) - { - objfile->GetFileSpec().GetPath(path, sizeof(path)); - } - fprintf (stderr, "warning: DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x in '%s'\n", GetOffset(), offset, path); + m_dwarf2Data->ReportWarning ("DWARF compile unit extends beyond its bounds cu 0x%8.8x at 0x%8.8x\n", + GetOffset(), + offset); } // Since std::vector objects will double their size, we really need to @@ -282,7 +281,7 @@ DWARFDebugInfoEntry::collection exact_size_die_array (m_die_array.begin(), m_die_array.end()); exact_size_die_array.swap (m_die_array); } - LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO)); + LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_DEBUG_INFO | DWARF_LOG_VERBOSE)); if (log) { StreamString strm; @@ -404,10 +403,11 @@ LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_ARANGES)); if (log) - log->Printf ("DWARFCompileUnit::GetFunctionAranges() for \"%s/%s\" compile unit at 0x%8.8x", - m_dwarf2Data->GetObjectFile()->GetFileSpec().GetDirectory().GetCString(), - m_dwarf2Data->GetObjectFile()->GetFileSpec().GetFilename().GetCString(), - m_offset); + { + m_dwarf2Data->LogMessage (log.get(), + "DWARFCompileUnit::GetFunctionAranges() for compile unit at .debug_info[0x%8.8x]", + GetOffset()); + } DIE()->BuildFunctionAddressRangeTable (m_dwarf2Data, this, m_func_aranges_ap.get()); const bool minimize = false; m_func_aranges_ap->Sort(minimize); @@ -573,6 +573,15 @@ const uint8_t *fixed_form_sizes = DWARFFormValue::GetFixedFormSizesForAddressSize (GetAddressByteSize()); + LogSP log (LogChannelDWARF::GetLogIfAll (DWARF_LOG_LOOKUPS)); + + if (log) + { + m_dwarf2Data->LogMessage (log.get(), + "DWARFCompileUnit::Index() for compile unit at .debug_info[0x%8.8x]", + GetOffset()); + } + DWARFDebugInfoEntry::const_iterator pos; DWARFDebugInfoEntry::const_iterator begin = m_die_array.begin(); DWARFDebugInfoEntry::const_iterator end = m_die_array.end(); Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Sun Nov 27 19:45:00 2011 @@ -92,6 +92,15 @@ } uint64_t +DWARFDebugInfoEntry::Attributes::FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const +{ + const uint32_t attr_idx = FindAttributeIndex (attr); + if (attr_idx != UINT32_MAX) + return FormValueAsUnsignedAtIndex (dwarf2Data, attr_idx, fail_value); + return fail_value; +} + +uint64_t DWARFDebugInfoEntry::Attributes::FormValueAsUnsignedAtIndex(SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const { DWARFFormValue form_value; @@ -1713,6 +1722,152 @@ } +const DWARFDebugInfoEntry * +DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu) const +{ + DWARFDebugInfoEntry::Attributes attributes; + GetAttributes(dwarf2Data, cu, NULL, attributes); + return GetParentDeclContextDIE (dwarf2Data, cu, attributes); +} + +const DWARFDebugInfoEntry * +DWARFDebugInfoEntry::GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu, + const DWARFDebugInfoEntry::Attributes& attributes) const +{ + const DWARFDebugInfoEntry * die = this; + + while (die != NULL) + { + // If this is the original DIE that we are searching for a declaration + // for, then don't look in the cache as we don't want our own decl + // context to be our decl context... + if (die != this) + { + switch (die->Tag()) + { + case DW_TAG_compile_unit: + case DW_TAG_namespace: + case DW_TAG_structure_type: + case DW_TAG_union_type: + case DW_TAG_class_type: + return die; + + default: + break; + } + } + + dw_offset_t die_offset; + + die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_specification, DW_INVALID_OFFSET); + if (die_offset != DW_INVALID_OFFSET) + { + const DWARFDebugInfoEntry *spec_die = cu->GetDIEPtr (die_offset); + if (spec_die) + { + const DWARFDebugInfoEntry *spec_die_decl_ctx_die = spec_die->GetParentDeclContextDIE (dwarf2Data, cu); + if (spec_die_decl_ctx_die) + return spec_die_decl_ctx_die; + } + } + + die_offset = attributes.FormValueAsUnsigned(dwarf2Data, DW_AT_abstract_origin, DW_INVALID_OFFSET); + if (die_offset != DW_INVALID_OFFSET) + { + const DWARFDebugInfoEntry *abs_die = cu->GetDIEPtr (die_offset); + if (abs_die) + { + const DWARFDebugInfoEntry *abs_die_decl_ctx_die = abs_die->GetParentDeclContextDIE (dwarf2Data, cu); + if (abs_die_decl_ctx_die) + return abs_die_decl_ctx_die; + } + } + + die = die->GetParent(); + } + return NULL; +} + + +const char * +DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu, + std::string &storage) const +{ + DWARFDebugInfoEntry::Attributes attributes; + GetAttributes(dwarf2Data, cu, NULL, attributes); + return GetQualifiedName (dwarf2Data, cu, attributes, storage); +} + +const char* +DWARFDebugInfoEntry::GetQualifiedName (SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu, + const DWARFDebugInfoEntry::Attributes& attributes, + std::string &storage) const +{ + + const char *name = GetName (dwarf2Data, cu); + + if (name) + { + const DWARFDebugInfoEntry *parent_decl_ctx_die = GetParentDeclContextDIE (dwarf2Data, cu); + storage.clear(); + // TODO: change this to get the correct decl context parent.... + while (parent_decl_ctx_die) + { + const dw_tag_t parent_tag = parent_decl_ctx_die->Tag(); + switch (parent_tag) + { + case DW_TAG_namespace: + { + const char *namespace_name = parent_decl_ctx_die->GetName (dwarf2Data, cu); + if (namespace_name) + { + storage.insert (0, "::"); + storage.insert (0, namespace_name); + } + else + { + storage.insert (0, "(anonymous namespace)::"); + } + parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu); + } + break; + + case DW_TAG_class_type: + case DW_TAG_structure_type: + case DW_TAG_union_type: + { + const char *class_union_struct_name = parent_decl_ctx_die->GetName (dwarf2Data, cu); + + if (class_union_struct_name) + { + storage.insert (0, "::"); + storage.insert (0, class_union_struct_name); + } + parent_decl_ctx_die = parent_decl_ctx_die->GetParentDeclContextDIE(dwarf2Data, cu); + } + break; + + default: + parent_decl_ctx_die = NULL; + break; + } + } + + if (storage.empty()) + storage.append ("::"); + + storage.append (name); + } + if (storage.empty()) + return NULL; + return storage.c_str(); +} + + //---------------------------------------------------------------------- // LookupAddress //---------------------------------------------------------------------- Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Sun Nov 27 19:45:00 2011 @@ -68,6 +68,7 @@ dw_attr_t FormAtIndex(uint32_t i) const { return m_infos[i].form; } bool ExtractFormValueAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, DWARFFormValue &form_value) const; uint64_t FormValueAsUnsignedAtIndex (SymbolFileDWARF* dwarf2Data, uint32_t i, uint64_t fail_value) const; + uint64_t FormValueAsUnsigned (SymbolFileDWARF* dwarf2Data, dw_attr_t attr, uint64_t fail_value) const; uint32_t FindAttributeIndex(dw_attr_t attr) const; bool ContainsAttribute(dw_attr_t attr) const; bool RemoveAttribute(dw_attr_t attr); @@ -226,6 +227,17 @@ const dw_offset_t die_offset, lldb_private::Stream &s); + const char * GetQualifiedName ( + SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu, + std::string &storage) const; + + const char * GetQualifiedName ( + SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu, + const DWARFDebugInfoEntry::Attributes& attributes, + std::string &storage) const; + // static int Compare( // SymbolFileDWARF* dwarf2Data, // dw_offset_t a_die_offset, @@ -340,6 +352,13 @@ DWARFDebugInfoEntry* GetFirstChild() { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; } const DWARFDebugInfoEntry* GetFirstChild() const { return (HasChildren() && !m_empty_children) ? this + 1 : NULL; } + + const DWARFDebugInfoEntry* GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu) const; + const DWARFDebugInfoEntry* GetParentDeclContextDIE (SymbolFileDWARF* dwarf2Data, + DWARFCompileUnit* cu, + const DWARFDebugInfoEntry::Attributes& attributes) const; + void SetParent (DWARFDebugInfoEntry* parent) { Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun Nov 27 19:45:00 2011 @@ -2273,10 +2273,12 @@ if (log) { - log->Printf ("SymbolFileDWARF::FindGlobalVariables (file=\"%s/%s\", name=\"%s\", append=%u, max_matches=%u, variables)", - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString(), - name.GetCString(), append, max_matches); + LogMessage (log.get(), + "SymbolFileDWARF::FindGlobalVariables (name=\"%s\", namespace_decl=%p, append=%u, max_matches=%u, variables)", + name.GetCString(), + namespace_decl, + append, + max_matches); } if (!NamespaceDeclMatchesThisSymbolFile(namespace_decl)) @@ -2369,10 +2371,11 @@ if (log) { - log->Printf ("SymbolFileDWARF::FindGlobalVariables (file=\"%s/%s\", regex=\"%s\", append=%u, max_matches=%u, variables)", - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString(), - regex.GetText(), append, max_matches); + LogMessage (log.get(), + "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", append=%u, max_matches=%u, variables)", + regex.GetText(), + append, + max_matches); } DWARFDebugInfo* info = DebugInfo(); @@ -2649,10 +2652,11 @@ if (log) { - log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", name=\"%s\", name_type_mask=0x%x, append=%u, sc_list)", - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString(), - name.GetCString(), name_type_mask, append); + LogMessage (log.get(), + "SymbolFileDWARF::FindFunctions (name=\"%s\", name_type_mask=0x%x, append=%u, sc_list)", + name.GetCString(), + name_type_mask, + append); } // If we aren't appending the results to this list, then clear the list @@ -2922,10 +2926,10 @@ if (log) { - log->Printf ("SymbolFileDWARF::FindFunctions (file=\"%s/%s\", regex=\"%s\"append=%u, sc_list)", - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString(), - regex.GetText(), append); + LogMessage (log.get(), + "SymbolFileDWARF::FindFunctions (regex=\"%s\", append=%u, sc_list)", + regex.GetText(), + append); } @@ -2957,40 +2961,6 @@ return sc_list.GetSize() - original_size; } -void -SymbolFileDWARF::ReportError (const char *format, ...) -{ - ::fprintf (stderr, - "error: %s/%s ", - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString()); - - if (m_obj_file->GetModule()->GetObjectName()) - ::fprintf (stderr, "(%s) ", m_obj_file->GetModule()->GetObjectName().GetCString()); - - va_list args; - va_start (args, format); - vfprintf (stderr, format, args); - va_end (args); -} - -void -SymbolFileDWARF::ReportWarning (const char *format, ...) -{ - ::fprintf (stderr, - "warning: %s/%s ", - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString()); - - if (m_obj_file->GetModule()->GetObjectName()) - ::fprintf (stderr, "(%s) ", m_obj_file->GetModule()->GetObjectName().GetCString()); - - va_list args; - va_start (args, format); - vfprintf (stderr, format, args); - va_end (args); -} - uint32_t SymbolFileDWARF::FindTypes(const SymbolContext& sc, const ConstString &name, const lldb_private::ClangNamespaceDecl *namespace_decl, bool append, uint32_t max_matches, TypeList& types) { @@ -3002,10 +2972,11 @@ if (log) { - log->Printf ("SymbolFileDWARF::FindTypes (file=\"%s/%s\", sc, name=\"%s\", append=%u, max_matches=%u, type_list)", - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString(), - name.GetCString(), append, max_matches); + LogMessage (log.get(), + "SymbolFileDWARF::FindTypes (sc, name=\"%s\", append=%u, max_matches=%u, type_list)", + name.GetCString(), + append, + max_matches); } // If we aren't appending the results to this list, then clear the list @@ -3086,9 +3057,8 @@ if (log) { - log->Printf ("SymbolFileDWARF::FindNamespace (file=\"%s/%s\", sc, name=\"%s\")", - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString(), + LogMessage (log.get(), + "SymbolFileDWARF::FindNamespace (sc, name=\"%s\")", name.GetCString()); } @@ -3635,33 +3605,24 @@ LogSP log (LogChannelDWARF::GetLogIfAll(DWARF_LOG_DEBUG_INFO)); if (log) { - const char *object_name = m_obj_file->GetModule()->GetObjectName().GetCString(); if (namespace_name) { - log->Printf ("ASTContext => %p: 0x%8.8llx: DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl * %p in %s/%s%s%s%s (original = %p)", + LogMessage (log.get(), + "ASTContext => %p: 0x%8.8llx: DW_TAG_namespace with DW_AT_name(\"%s\") => clang::NamespaceDecl *%p (original = %p)", GetClangASTContext().getASTContext(), MakeUserID(die->GetOffset()), namespace_name, namespace_decl, - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString(), - object_name ? "(" : "", - object_name ? object_name : "", - object_name ? "(" : "", namespace_decl->getOriginalNamespace()); } else { - log->Printf ("ASTContext => %p: 0x%8.8llx: DW_TAG_namespace (anonymous) => clang::NamespaceDecl * %p in %s/%s%s%s%s (original = %p)", - GetClangASTContext().getASTContext(), - MakeUserID(die->GetOffset()), - namespace_decl, - m_obj_file->GetFileSpec().GetDirectory().GetCString(), - m_obj_file->GetFileSpec().GetFilename().GetCString(), - object_name ? "(" : "", - object_name ? object_name : "", - object_name ? "(" : "", - namespace_decl->getOriginalNamespace()); + LogMessage (log.get(), + "ASTContext => %p: 0x%8.8llx: DW_TAG_namespace (anonymous) => clang::NamespaceDecl *%p (original = %p)", + GetClangASTContext().getASTContext(), + MakeUserID(die->GetOffset()), + namespace_decl, + namespace_decl->getOriginalNamespace()); } } @@ -4196,6 +4157,15 @@ // current type index just in case we have a forward // declaration followed by an actual declarations in the // DWARF. If this fails, we need to look elsewhere... + if (log) + { + LogMessage (log.get(), + "SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is forward declaration, trying to find real type", + this, + die->GetOffset(), + DW_TAG_value_to_name(tag), + type_name_cstr); + } type_sp = FindDefinitionTypeForDIE (dwarf_cu, die, type_name_const_str); @@ -4209,6 +4179,16 @@ if (type_sp) { + if (log) + { + log->Printf ("SymbolFileDWARF(%p) - 0x%8.8x: %s type \"%s\" is forward declaration, real type is 0x%8.8llx", + this, + die->GetOffset(), + DW_TAG_value_to_name(tag), + type_name_cstr, + type_sp->GetID()); + } + // We found a real definition for this type elsewhere // so lets use it and cache the fact that we found // a complete type for this die Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Sun Nov 27 19:45:00 2011 @@ -456,11 +456,6 @@ const lldb_private::ClangASTContext::TemplateParameterInfos &template_param_infos); - void - ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3))); - void - ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3))); - SymbolFileDWARFDebugMap * m_debug_map_symfile; clang::TranslationUnitDecl * m_clang_tu_decl; lldb_private::Flags m_flags; Modified: lldb/trunk/source/Symbol/SymbolFile.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/SymbolFile.cpp?rev=145219&r1=145218&r2=145219&view=diff ============================================================================== --- lldb/trunk/source/Symbol/SymbolFile.cpp (original) +++ lldb/trunk/source/Symbol/SymbolFile.cpp Sun Nov 27 19:45:00 2011 @@ -7,10 +7,13 @@ // //===----------------------------------------------------------------------===// -#include "lldb/lldb-private.h" #include "lldb/Symbol/SymbolFile.h" + +#include "lldb/lldb-private.h" +#include "lldb/Core/Log.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Core/StreamString.h" #include "lldb/Symbol/ObjectFile.h" using namespace lldb_private; @@ -68,3 +71,45 @@ return m_obj_file->GetModule()->GetClangASTContext(); } + +void +SymbolFile::ReportError (const char *format, ...) +{ + StreamString module_description; + m_obj_file->GetModule()->GetDescription (&module_description, lldb::eDescriptionLevelBrief); + ::fprintf (stderr, "error: %s ", module_description.GetString().c_str()); + + va_list args; + va_start (args, format); + vfprintf (stderr, format, args); + va_end (args); +} + +void +SymbolFile::ReportWarning (const char *format, ...) +{ + StreamString module_description; + m_obj_file->GetModule()->GetDescription (&module_description, lldb::eDescriptionLevelBrief); + ::fprintf (stderr, "warning: %s ", module_description.GetString().c_str()); + + va_list args; + va_start (args, format); + vfprintf (stderr, format, args); + va_end (args); +} + +void +SymbolFile::LogMessage (Log *log, const char *format, ...) +{ + if (log) + { + StreamString log_message; + m_obj_file->GetModule()->GetDescription (&log_message, lldb::eDescriptionLevelBrief); + log_message.PutChar(' '); + va_list args; + va_start (args, format); + log_message.PrintfVarArg (format, args); + va_end (args); + log->PutCString (log_message.GetString().c_str()); + } +} From gclayton at apple.com Sun Nov 27 19:47:46 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 01:47:46 -0000 Subject: [Lldb-commits] [lldb] r145221 - /lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Message-ID: <20111128014746.9D7F92A6C12D@llvm.org> Author: gclayton Date: Sun Nov 27 19:47:46 2011 New Revision: 145221 URL: http://llvm.org/viewvc/llvm-project?rev=145221&view=rev Log: Now the linux platform lets it be known that it can't launch processes for debugging. Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Modified: lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h?rev=145221&r1=145220&r2=145221&view=diff ============================================================================== --- lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h (original) +++ lldb/trunk/source/Plugins/Platform/Linux/PlatformLinux.h Sun Nov 27 19:47:46 2011 @@ -98,6 +98,12 @@ Attach(ProcessAttachInfo &attach_info, Debugger &debugger, Target *target, Listener &listener, Error &error); + virtual bool + CanDebugProcess () + { + return false; + } + protected: From gclayton at apple.com Sun Nov 27 20:03:03 2011 From: gclayton at apple.com (Greg Clayton) Date: Sun, 27 Nov 2011 18:03:03 -0800 Subject: [Lldb-commits] [PATCH] fix debugging on linux In-Reply-To: <20111124073122.GA13244@bloodbath.burble.org> References: <20111124073122.GA13244@bloodbath.burble.org> Message-ID: <51F34F73-EDED-4B6C-85A2-829DDAA55369@apple.com> On Nov 23, 2011, at 11:31 PM, dawn at burble.org wrote: > This patch was created using clang/llvm rev 144569, lldb rev 144919 but has > been updated to clang/llvm rev 144982, lldb rev 145118. It gets debugging on > Linux back to the state it was in in llvm/clang rev 143631, lldb rev 143774. > > Debugging on Linux broke when the assumption was made that a process could be > launched by spawning it in a suspended state and then attaching to it. That > support does not exist on Linux. To work around this, I added a new method > "CanLaunchViaAttach" which tests whether the platform supports being launched > in this way. I wanted to add a flag to ProcessLaunchInfo, but could not find > an easy way to set it from within the Linux plugins. > > Commit message: > > Fix debugging on Linux. > Implement remote vs. host platform code as was done with PlatformDarwin. > Platform::CanLaunchViaAttach(): new: return true if the process can be launched > via spawn and attach. Default is true. Override in PlatformLinux to false. > Platform::DebugProcess(): if (!target->GetPlatform()->CanLaunchViaAttach()) > then launch the process via CreateProcess and Launch. > > Please review and commit if acceptable. I checked in an alternate fix: % svn commit Sending include/lldb/Core/Module.h Sending include/lldb/Symbol/SymbolFile.h Sending include/lldb/Target/Platform.h Sending source/Commands/CommandObjectProcess.cpp Sending source/Core/Module.cpp Sending source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp Sending source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sending source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Sending source/Symbol/SymbolFile.cpp Transmitting file data ........... Committed revision 145219. % svn commit Sending Platform/Linux/PlatformLinux.h Transmitting file data . Committed revision 145221. The first one contains the necessary changes to CommandObjectProcess.cpp and to include/lldb/Target/Platform.h that allow a platform to say: virtual bool CanDebugProcess () { return true; } This keeps the code out of the platform since when a platform launches a process, it shouldn't be tied to a process plug-in as in the patch you submitted. Here is the vision of platforms: - They should be able to list all of the processes on the platform. This way you can connect to your local machine and list the processes, or connect to a remote platform, and if the remote platform supports it, it can list the processes that are there. - Platforms should support launching processes. Not always for debugging, but sometimes just to spawn a child process. On the localhost, this means just using the Host::LaunchProcess() functionality. This way, we just need to implement a single copy of the process launching code. When you create a remote platform, you should be able to link against the native linux or darwin launching code and then we don't end up with multiple copies of the launching code like we have now. You make a good point in that not all platforms will be able to support launching with a program stopped for debugging, so we now ask the platform up in the CommandObjectProcessLaunch class before we launch the process. This keeps the platform clean, yet also lets us fall back to just launching the process through the built in process plug-in. - Platforms should support attaching to a remote process. Combined with being able to launch for debug, this allows debugging as we have it on MacOSX. If we do this while remotely connected to a remote darwin machine, we now have the ability to talk to a remote computer and launch, attach, list and do a lot more - Platforms should know if there are files locally on the current machine in an SDK or PDK or some over developer kit/cross compiling sysroot, etc to allow locating files in terms of the path you would us on the remote machine. For example when debugging on a remote device, if the are asked to find the file for "/bin/ls", this might locally be located in developer kit directory such as "/path/to/old/linux/sysroot/bin/ls". This allows you to debug remote machines, or event mount the root file system on a mountpoint so you have access to the files so you can debug. - Platforms should be able to upload/download files so you could install a new binary and run it, or upload a shared library so we can locally cache it for faster debugging. We are in the process of slowly makine these Platforms a reality, so keep the questions coming if anyone has any. So in short: I made the fix you requested, but in a different way. If you can rework your patch around what is in top of tree, then we can get the rest of it submitted. Greg Clayton > Thanks! > -Dawn > _______________________________________________ > lldb-commits mailing list > lldb-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits From gclayton at apple.com Sun Nov 27 21:17:13 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 03:17:13 -0000 Subject: [Lldb-commits] [lldb] r145225 - /lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Message-ID: <20111128031713.A31972A6C12D@llvm.org> Author: gclayton Date: Sun Nov 27 21:17:13 2011 New Revision: 145225 URL: http://llvm.org/viewvc/llvm-project?rev=145225&view=rev Log: Fixed an issue where we might cause our test suite to exit if we end up concatenating a string with "None" in python. Using a python format string gets us around this by handling it gracefully. Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Modified: lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py?rev=145225&r1=145224&r2=145225&view=diff ============================================================================== --- lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py (original) +++ lldb/trunk/test/functionalities/data-formatter/data-formatter-synth/TestDataFormatterSynth.py Sun Nov 27 21:17:13 2011 @@ -90,7 +90,7 @@ 'z = 8']) # Same output, but using Python - self.runCmd("type summary add BagOfInts --python-script \"return 'y='+valobj.GetChildMemberWithName('y').GetValue()\" -e") + self.runCmd("type summary add BagOfInts --python-script \"return 'y=%s' % valobj.GetChildMemberWithName('y').GetValue()\" -e") self.expect('frame variable int_bag', substrs = ['y=7', 'x = 6', From gclayton at apple.com Sun Nov 27 21:29:03 2011 From: gclayton at apple.com (Greg Clayton) Date: Mon, 28 Nov 2011 03:29:03 -0000 Subject: [Lldb-commits] [lldb] r145226 - /lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Message-ID: <20111128032903.83B702A6C12D@llvm.org> Author: gclayton Date: Sun Nov 27 21:29:03 2011 New Revision: 145226 URL: http://llvm.org/viewvc/llvm-project?rev=145226&view=rev Log: Fixed a potential crasher where we weren't checking we got a valid DIE in a compile unit. Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=145226&r1=145225&r2=145226&view=diff ============================================================================== --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original) +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Sun Nov 27 21:29:03 2011 @@ -1007,27 +1007,30 @@ if (dwarf_cu) { const DWARFDebugInfoEntry *dwarf_cu_die = dwarf_cu->GetCompileUnitDIEOnly(); - const dw_offset_t cu_line_offset = dwarf_cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET); - if (cu_line_offset != DW_INVALID_OFFSET) + if (dwarf_cu_die) { - std::auto_ptr line_table_ap(new LineTable(sc.comp_unit)); - if (line_table_ap.get()) + const dw_offset_t cu_line_offset = dwarf_cu_die->GetAttributeValueAsUnsigned(this, dwarf_cu, DW_AT_stmt_list, DW_INVALID_OFFSET); + if (cu_line_offset != DW_INVALID_OFFSET) { - ParseDWARFLineTableCallbackInfo info = { - line_table_ap.get(), - m_obj_file->GetSectionList(), - 0, - 0, - m_debug_map_symfile != NULL, - false, - DWARFDebugLine::Row(), - SectionSP(), - SectionSP() - }; - uint32_t offset = cu_line_offset; - DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset, ParseDWARFLineTableCallback, &info); - sc.comp_unit->SetLineTable(line_table_ap.release()); - return true; + std::auto_ptr line_table_ap(new LineTable(sc.comp_unit)); + if (line_table_ap.get()) + { + ParseDWARFLineTableCallbackInfo info = { + line_table_ap.get(), + m_obj_file->GetSectionList(), + 0, + 0, + m_debug_map_symfile != NULL, + false, + DWARFDebugLine::Row(), + SectionSP(), + SectionSP() + }; + uint32_t offset = cu_line_offset; + DWARFDebugLine::ParseStatementTable(get_debug_line_data(), &offset, ParseDWARFLineTableCallback, &info); + sc.comp_unit->SetLineTable(line_table_ap.release()); + return true; + } } } }