[Lldb-commits] [lldb] a18b17b - [lldb] Make the test for D153043 linux-only
Author: Jaroslav Sevcik Date: 2023-06-20T07:57:47+02:00 New Revision: a18b17b1befd833165ec34da581cb83ebab43ace URL: https://github.com/llvm/llvm-project/commit/a18b17b1befd833165ec34da581cb83ebab43ace DIFF: https://github.com/llvm/llvm-project/commit/a18b17b1befd833165ec34da581cb83ebab43ace.diff LOG: [lldb] Make the test for D153043 linux-only Added: Modified: lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test Removed: diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test index ccf973d9313c2..477a656a711f9 100644 --- a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test +++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test @@ -1,7 +1,6 @@ # Test restoring of register values. -# UNSUPPORTED: system-windows -# REQUIRES: target-x86_64, native +# REQUIRES: target-x86_64, system-linux, native # RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind-abort.s -o %t # RUN: %lldb %t -s %s -o exit | FileCheck %s ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 7ac0ff5 - [lldb] Make test for D153043 independent of external symbols
Author: Jaroslav Sevcik Date: 2023-06-20T07:28:30+02:00 New Revision: 7ac0ff562ab8b0c2134b17333f4efa6fbbeab48c URL: https://github.com/llvm/llvm-project/commit/7ac0ff562ab8b0c2134b17333f4efa6fbbeab48c DIFF: https://github.com/llvm/llvm-project/commit/7ac0ff562ab8b0c2134b17333f4efa6fbbeab48c.diff LOG: [lldb] Make test for D153043 independent of external symbols This removes dependence on the libc abort function. Added: Modified: lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s Removed: diff --git a/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s b/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s index 660bb14395e8d..95099ce42d3f5 100644 --- a/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s +++ b/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s @@ -10,7 +10,7 @@ asm_main: .cfi_offset 6, -16 movq%rsp, %rbp .cfi_def_cfa_register 6 -callq abort +callq abort_function .L: .cfi_def_cfa 7, 8 .cfi_restore 6 @@ -18,6 +18,12 @@ asm_main: ud2 .cfi_endproc +.globl abort_function +abort_function: +.cfi_startproc +ud2 +.cfi_endproc + .data .globl g_hard_abort g_hard_abort: ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] af35be5 - [lldb] Remove unused directive from test for D153043
Author: Jaroslav Sevcik Date: 2023-06-16T12:46:21+02:00 New Revision: af35be55c032a5af93e235ca8347fffeb68b788e URL: https://github.com/llvm/llvm-project/commit/af35be55c032a5af93e235ca8347fffeb68b788e DIFF: https://github.com/llvm/llvm-project/commit/af35be55c032a5af93e235ca8347fffeb68b788e.diff LOG: [lldb] Remove unused directive from test for D153043 Added: Modified: lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s Removed: diff --git a/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s b/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s index e03a69f67f8f9..660bb14395e8d 100644 --- a/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s +++ b/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s @@ -22,4 +22,3 @@ asm_main: .globl g_hard_abort g_hard_abort: .byte 1 - .size g_hard_abort, 1 \ No newline at end of file ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 07b9e6e - [lldb] Fix handling of cfi_restore in the unwinder
Author: Jaroslav Sevcik Date: 2023-06-16T08:01:29+02:00 New Revision: 07b9e6ed0db206912b99c153a6bcfcb41f792cc5 URL: https://github.com/llvm/llvm-project/commit/07b9e6ed0db206912b99c153a6bcfcb41f792cc5 DIFF: https://github.com/llvm/llvm-project/commit/07b9e6ed0db206912b99c153a6bcfcb41f792cc5.diff LOG: [lldb] Fix handling of cfi_restore in the unwinder Currently, lldb's unwinder ignores cfi_restore opcodes for registers that are not set in the first row of the unwinding info. This prevents unwinding of failed assertion in Chrome/v8 (https://github.com/v8/v8). The attached test is an x64 copy of v8's function that failed to unwind correctly (V8_Fatal). This patch changes handling of cfi_restore to reset the location if the first unwind table row does not map the restored register. Differential Revision: https://reviews.llvm.org/D153043 Added: lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test Modified: lldb/source/Symbol/DWARFCallFrameInfo.cpp Removed: diff --git a/lldb/source/Symbol/DWARFCallFrameInfo.cpp b/lldb/source/Symbol/DWARFCallFrameInfo.cpp index be9f64356b4e0..dc54d13ae23cb 100644 --- a/lldb/source/Symbol/DWARFCallFrameInfo.cpp +++ b/lldb/source/Symbol/DWARFCallFrameInfo.cpp @@ -674,6 +674,11 @@ bool DWARFCallFrameInfo::FDEToUnwindPlan(dw_offset_t dwarf_offset, unwind_plan.GetRowAtIndex(0)->GetRegisterInfo(reg_num, reg_location)) row->SetRegisterInfo(reg_num, reg_location); + else { +// If the register was not set in the first row, remove the +// register info to keep the unmodified value from the caller. +row->RemoveRegisterInfo(reg_num); + } break; } } diff --git a/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s b/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s new file mode 100644 index 0..e03a69f67f8f9 --- /dev/null +++ b/lldb/test/Shell/Unwind/Inputs/eh-frame-dwarf-unwind-abort.s @@ -0,0 +1,25 @@ +.text +.globl asm_main +asm_main: +.cfi_startproc +cmpb $0x0, g_hard_abort(%rip) +jne .L + +pushq %rbp +.cfi_def_cfa_offset 16 +.cfi_offset 6, -16 +movq%rsp, %rbp +.cfi_def_cfa_register 6 +callq abort +.L: +.cfi_def_cfa 7, 8 +.cfi_restore 6 +int3 +ud2 +.cfi_endproc + + .data + .globl g_hard_abort +g_hard_abort: + .byte 1 + .size g_hard_abort, 1 \ No newline at end of file diff --git a/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test new file mode 100644 index 0..ccf973d9313c2 --- /dev/null +++ b/lldb/test/Shell/Unwind/eh-frame-dwarf-unwind-abort.test @@ -0,0 +1,21 @@ +# Test restoring of register values. + +# UNSUPPORTED: system-windows +# REQUIRES: target-x86_64, native + +# RUN: %clang_host %p/Inputs/call-asm.c %p/Inputs/eh-frame-dwarf-unwind-abort.s -o %t +# RUN: %lldb %t -s %s -o exit | FileCheck %s + +process launch +# CHECK: stop reason = signal SIGTRAP + +thread backtrace +# CHECK: frame #0: {{.*}}`asm_main + 23 +# CHECK: frame #1: {{.*}}`main + {{.*}} + +target modules show-unwind -n asm_main +# CHECK: eh_frame UnwindPlan: +# CHECK: row[0]:0: CFA=rsp +8 => rip=[CFA-8] +# CHECK: row[1]: 14: CFA=rsp+16 => rbp=[CFA-16] rip=[CFA-8] +# CHECK: row[2]: 17: CFA=rbp+16 => rbp=[CFA-16] rip=[CFA-8] +# CHECK: row[3]: 22: CFA=rsp +8 => rip=[CFA-8] ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] f72ae5c - [lldb] Fix windows path guessing for root paths
Author: Jaroslav Sevcik Date: 2021-12-07T11:16:04+01:00 New Revision: f72ae5cba1d625301aa8a668a3d54ec3ac5b7806 URL: https://github.com/llvm/llvm-project/commit/f72ae5cba1d625301aa8a668a3d54ec3ac5b7806 DIFF: https://github.com/llvm/llvm-project/commit/f72ae5cba1d625301aa8a668a3d54ec3ac5b7806.diff LOG: [lldb] Fix windows path guessing for root paths Fix recognizing ":\" as a windows path. Differential Revision: https://reviews.llvm.org/D115104 Added: Modified: lldb/source/Utility/FileSpec.cpp lldb/unittests/Utility/FileSpecTest.cpp Removed: diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp index 601edb86c1b0c..24f8c2b1c23fc 100644 --- a/lldb/source/Utility/FileSpec.cpp +++ b/lldb/source/Utility/FileSpec.cpp @@ -310,7 +310,7 @@ llvm::Optional FileSpec::GuessPathStyle(llvm::StringRef absolut return Style::posix; if (absolute_path.startswith(R"(\\)")) return Style::windows; - if (absolute_path.size() > 3 && llvm::isAlpha(absolute_path[0]) && + if (absolute_path.size() >= 3 && llvm::isAlpha(absolute_path[0]) && absolute_path.substr(1, 2) == R"(:\)") return Style::windows; return llvm::None; diff --git a/lldb/unittests/Utility/FileSpecTest.cpp b/lldb/unittests/Utility/FileSpecTest.cpp index 3dd355284ce0f..64b72bec483e5 100644 --- a/lldb/unittests/Utility/FileSpecTest.cpp +++ b/lldb/unittests/Utility/FileSpecTest.cpp @@ -198,8 +198,10 @@ TEST(FileSpecTest, GuessPathStyle) { FileSpec::GuessPathStyle(R"(C:\foo.txt)")); EXPECT_EQ(FileSpec::Style::windows, FileSpec::GuessPathStyle(R"(\\net\foo.txt)")); + EXPECT_EQ(FileSpec::Style::windows, FileSpec::GuessPathStyle(R"(Z:\)")); EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("foo.txt")); EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("foo/bar.txt")); + EXPECT_EQ(llvm::None, FileSpec::GuessPathStyle("Z:")); } TEST(FileSpecTest, GetPath) { ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 5a3556a - [lldb] Add omitted abstract formal parameters in DWARF symbol files
Author: Jaroslav Sevcik Date: 2021-10-21T12:33:42+02:00 New Revision: 5a3556aa5563fb89693935303463881df44094de URL: https://github.com/llvm/llvm-project/commit/5a3556aa5563fb89693935303463881df44094de DIFF: https://github.com/llvm/llvm-project/commit/5a3556aa5563fb89693935303463881df44094de.diff LOG: [lldb] Add omitted abstract formal parameters in DWARF symbol files This patch fixes a problem introduced by clang change https://reviews.llvm.org/D95617 and described by https://bugs.llvm.org/show_bug.cgi?id=50076#c6, where inlined functions omit unused parameters both in the stack trace and in `frame var` command. With this patch, the parameters are listed correctly in the stack trace and in `frame var` command. Specifically, we parse formal parameters from the abstract version of inlined functions and use those formal parameters if they are missing from the concrete version. Differential Revision: https://reviews.llvm.org/D110571 Added: lldb/test/API/functionalities/unused-inlined-parameters/Makefile lldb/test/API/functionalities/unused-inlined-parameters/TestUnusedInlinedParameters.py lldb/test/API/functionalities/unused-inlined-parameters/main.c lldb/test/Shell/SymbolFile/DWARF/x86/Inputs/unused-inlined-params.s lldb/test/Shell/SymbolFile/DWARF/x86/unused-inlined-params.test Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 9078fa3cdc268..90b07ad061b05 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -3092,7 +3092,7 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext ) { sc.comp_unit->SetVariableList(variables); m_index->GetGlobalVariables(*dwarf_cu, [&](DWARFDIE die) { - VariableSP var_sp(ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS)); + VariableSP var_sp(ParseVariableDIECached(sc, die)); if (var_sp) { variables->AddVariableIfUnique(var_sp); ++vars_added; @@ -3106,6 +3106,26 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext ) { return 0; } +VariableSP SymbolFileDWARF::ParseVariableDIECached(const SymbolContext , + const DWARFDIE ) { + if (!die) +return nullptr; + + DIEToVariableSP _to_variable = die.GetDWARF()->GetDIEToVariable(); + + VariableSP var_sp = die_to_variable[die.GetDIE()]; + if (var_sp) +return var_sp; + + var_sp = ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS); + if (var_sp) { +die_to_variable[die.GetDIE()] = var_sp; +if (DWARFDIE spec_die = die.GetReferencedDIE(DW_AT_specification)) + die_to_variable[spec_die.GetDIE()] = var_sp; + } + return var_sp; +} + VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext , const DWARFDIE , const lldb::addr_t func_low_pc) { @@ -3115,9 +3135,6 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext , if (!die) return nullptr; - if (VariableSP var_sp = GetDIEToVariable()[die.GetDIE()]) -return var_sp; // Already been parsed! - const dw_tag_t tag = die.Tag(); ModuleSP module = GetObjectFile()->GetModule(); @@ -3127,8 +3144,6 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext , DWARFAttributes attributes; const size_t num_attributes = die.GetAttributes(attributes); - DWARFDIE spec_die; - VariableSP var_sp; const char *name = nullptr; const char *mangled = nullptr; Declaration decl; @@ -3175,9 +3190,6 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext , case DW_AT_location: location_form = form_value; break; -case DW_AT_specification: - spec_die = form_value.Reference(); - break; case DW_AT_start_scope: // TODO: Implement this. break; @@ -3188,6 +3200,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext , case DW_AT_description: case DW_AT_endianity: case DW_AT_segment: +case DW_AT_specification: case DW_AT_visibility: default: case DW_AT_abstract_origin: @@ -3380,7 +3393,7 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext , location.Update_DW_OP_addr(exe_file_addr); } else { // Variable didn't make it into the final executable -return var_sp; +return nullptr; } } } @@ -3426,35 +3439,25 @@ VariableSP SymbolFileDWARF::ParseVariableDIE(const SymbolContext , } } - if (symbol_context_scope) { -auto type_sp =
[Lldb-commits] [lldb] fd185cf - Reland "[lldb] Refactor variable parsing"
Author: Jaroslav Sevcik Date: 2021-10-06T14:25:47+02:00 New Revision: fd185cfc513c4e5e280acc6d4e7248b773285798 URL: https://github.com/llvm/llvm-project/commit/fd185cfc513c4e5e280acc6d4e7248b773285798 DIFF: https://github.com/llvm/llvm-project/commit/fd185cfc513c4e5e280acc6d4e7248b773285798.diff LOG: Reland "[lldb] Refactor variable parsing" Separates the methods for recursive variable parsing in function context and non-recursive parsing of global variables. Original patch: https://reviews.llvm.org/rG601168e42037ac4433e74b920bb22f76d59ba420 Revert patch: https://reviews.llvm.org/rGca5be065c4c612554acdcae3ead01a1474eff296 Diff from the original patch: avoid using nullptr deref/ref. Differential Revision: https://reviews.llvm.org/D110570 Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index f89fb1655d3bf..b1025650ced24 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2135,7 +2135,7 @@ void SymbolFileDWARF::FindGlobalVariables( } } -ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, ); +ParseAndAppendGlobalVariable(sc, die, variables); while (pruned_idx < variables.GetSize()) { VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx); if (name_is_mangled || @@ -2188,7 +2188,7 @@ void SymbolFileDWARF::FindGlobalVariables(const RegularExpression , return true; sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu); -ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, ); +ParseAndAppendGlobalVariable(sc, die, variables); return variables.GetSize() - original_size < max_matches; }); @@ -3049,8 +3049,8 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext ) { /*check_hi_lo_pc=*/true)) func_lo_pc = ranges.GetMinRangeBase(0); if (func_lo_pc != LLDB_INVALID_ADDRESS) { -const size_t num_variables = ParseVariables( -sc, function_die.GetFirstChild(), func_lo_pc, true, true); +const size_t num_variables = +ParseVariablesInFunctionContext(sc, function_die, func_lo_pc); // Let all blocks know they have parse all their variables sc.function->GetBlock(false).SetDidParseVariables(true, true); @@ -3479,117 +3479,136 @@ SymbolFileDWARF::FindBlockContainingSpecification( return DWARFDIE(); } -size_t SymbolFileDWARF::ParseVariables(const SymbolContext , - const DWARFDIE _die, - const lldb::addr_t func_low_pc, - bool parse_siblings, bool parse_children, - VariableList *cc_variable_list) { - if (!orig_die) -return 0; +void SymbolFileDWARF::ParseAndAppendGlobalVariable( +const SymbolContext , const DWARFDIE , +VariableList _variable_list) { + if (!die) +return; + dw_tag_t tag = die.Tag(); + if (tag != DW_TAG_variable && tag != DW_TAG_constant) +return; + + // Check to see if we have already parsed this variable or constant? + VariableSP var_sp = GetDIEToVariable()[die.GetDIE()]; + if (var_sp) { +cc_variable_list.AddVariableIfUnique(var_sp); +return; + } + + // We haven't already parsed it, lets do that now. VariableListSP variable_list_sp; + DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die); + dw_tag_t parent_tag = sc_parent_die.Tag(); + switch (parent_tag) { + case DW_TAG_compile_unit: + case DW_TAG_partial_unit: +if (sc.comp_unit != nullptr) { + variable_list_sp = sc.comp_unit->GetVariableList(false); +} else { + GetObjectFile()->GetModule()->ReportError( + "parent 0x%8.8" PRIx64 " %s with no valid compile unit in " + "symbol context for 0x%8.8" PRIx64 " %s.\n", + sc_parent_die.GetID(), sc_parent_die.GetTagAsCString(), die.GetID(), + die.GetTagAsCString()); + return; +} +break; + + default: +GetObjectFile()->GetModule()->ReportError( +"didn't find appropriate parent DIE for variable list for " +"0x%8.8" PRIx64 " %s.\n", +die.GetID(), die.GetTagAsCString()); +return; + } + + var_sp = ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS); + if (!var_sp) +return; + + cc_variable_list.AddVariableIfUnique(var_sp); + if (variable_list_sp) +variable_list_sp->AddVariableIfUnique(var_sp); +} + +size_t SymbolFileDWARF::ParseVariablesInFunctionContext( +const SymbolContext , const DWARFDIE , +const lldb::addr_t func_low_pc) { + if (!die || !sc.function) +return 0; + VariableList
[Lldb-commits] [lldb] 601168e - [lldb] Refactor variable parsing
Author: Jaroslav Sevcik Date: 2021-10-04T07:58:20+02:00 New Revision: 601168e42037ac4433e74b920bb22f76d59ba420 URL: https://github.com/llvm/llvm-project/commit/601168e42037ac4433e74b920bb22f76d59ba420 DIFF: https://github.com/llvm/llvm-project/commit/601168e42037ac4433e74b920bb22f76d59ba420.diff LOG: [lldb] Refactor variable parsing Separates the methods for recursive variable parsing in function context and non-recursive parsing of global variables. Differential Revision: https://reviews.llvm.org/D110570 Added: Modified: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h Removed: diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index f89fb1655d3b..c111ff656736 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -2135,7 +2135,7 @@ void SymbolFileDWARF::FindGlobalVariables( } } -ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, ); +ParseAndAppendGlobalVariable(sc, die, variables); while (pruned_idx < variables.GetSize()) { VariableSP var_sp = variables.GetVariableAtIndex(pruned_idx); if (name_is_mangled || @@ -2188,7 +2188,7 @@ void SymbolFileDWARF::FindGlobalVariables(const RegularExpression , return true; sc.comp_unit = GetCompUnitForDWARFCompUnit(*dwarf_cu); -ParseVariables(sc, die, LLDB_INVALID_ADDRESS, false, false, ); +ParseAndAppendGlobalVariable(sc, die, variables); return variables.GetSize() - original_size < max_matches; }); @@ -3049,8 +3049,8 @@ size_t SymbolFileDWARF::ParseVariablesForContext(const SymbolContext ) { /*check_hi_lo_pc=*/true)) func_lo_pc = ranges.GetMinRangeBase(0); if (func_lo_pc != LLDB_INVALID_ADDRESS) { -const size_t num_variables = ParseVariables( -sc, function_die.GetFirstChild(), func_lo_pc, true, true); +const size_t num_variables = +ParseVariablesInFunctionContext(sc, function_die, func_lo_pc); // Let all blocks know they have parse all their variables sc.function->GetBlock(false).SetDidParseVariables(true, true); @@ -3479,117 +3479,137 @@ SymbolFileDWARF::FindBlockContainingSpecification( return DWARFDIE(); } -size_t SymbolFileDWARF::ParseVariables(const SymbolContext , - const DWARFDIE _die, - const lldb::addr_t func_low_pc, - bool parse_siblings, bool parse_children, - VariableList *cc_variable_list) { - if (!orig_die) -return 0; +void SymbolFileDWARF::ParseAndAppendGlobalVariable( +const SymbolContext , const DWARFDIE , +VariableList _variable_list) { + if (!die) +return; + dw_tag_t tag = die.Tag(); + if (tag != DW_TAG_variable && tag != DW_TAG_constant) +return; + + // Check to see if we have already parsed this variable or constant? + VariableSP var_sp = GetDIEToVariable()[die.GetDIE()]; + if (var_sp) { +cc_variable_list.AddVariableIfUnique(var_sp); +return; + } + + // We haven't already parsed it, lets do that now. VariableListSP variable_list_sp; + DWARFDIE sc_parent_die = GetParentSymbolContextDIE(die); + dw_tag_t parent_tag = sc_parent_die.Tag(); + switch (parent_tag) { + case DW_TAG_compile_unit: + case DW_TAG_partial_unit: +if (sc.comp_unit != nullptr) { + variable_list_sp = sc.comp_unit->GetVariableList(false); +} else { + GetObjectFile()->GetModule()->ReportError( + "parent 0x%8.8" PRIx64 " %s with no valid compile unit in " + "symbol context for 0x%8.8" PRIx64 " %s.\n", + sc_parent_die.GetID(), sc_parent_die.GetTagAsCString(), die.GetID(), + die.GetTagAsCString()); + return; +} +break; + + default: +GetObjectFile()->GetModule()->ReportError( +"didn't find appropriate parent DIE for variable list for " +"0x%8.8" PRIx64 " %s.\n", +die.GetID(), die.GetTagAsCString()); +return; + } + + var_sp = ParseVariableDIE(sc, die, LLDB_INVALID_ADDRESS); + if (!var_sp) +return; + + cc_variable_list.AddVariableIfUnique(var_sp); + if (variable_list_sp) +variable_list_sp->AddVariableIfUnique(var_sp); +} + +size_t SymbolFileDWARF::ParseVariablesInFunctionContext( +const SymbolContext , const DWARFDIE , +const lldb::addr_t func_low_pc) { + if (!die || !sc.function) +return 0; + Block *block = + sc.function->GetBlock(/*can_create=*/true).FindBlockByID(die.GetID()); + const bool can_create = false; + VariableListSP variable_list_sp = block->GetBlockVariableList(can_create); + return ParseVariablesInFunctionContextRecursive(sc, die,
[Lldb-commits] [lldb] 93ec6cd - [lldb] Desugar template specializations
Author: Jaroslav Sevcik Date: 2020-07-16T09:01:01+02:00 New Revision: 93ec6cd684265161623b4ea67836f022cd18c224 URL: https://github.com/llvm/llvm-project/commit/93ec6cd684265161623b4ea67836f022cd18c224 DIFF: https://github.com/llvm/llvm-project/commit/93ec6cd684265161623b4ea67836f022cd18c224.diff LOG: [lldb] Desugar template specializations Template specializations are not handled in many of the TypeSystemClang methods. For example, GetNumChildren does not handle the TemplateSpecialization type class, so template specializations always look like empty objects. This patch just desugars template specializations in the existing RemoveWrappingTypes desugaring helper. Differential Revision: https://reviews.llvm.org/D83858 Added: lldb/test/API/lang/cpp/template-specialization-type/Makefile lldb/test/API/lang/cpp/template-specialization-type/TestTemplateSpecializationType.py lldb/test/API/lang/cpp/template-specialization-type/main.cpp Modified: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp Removed: diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index bc06ea8164d4..8825b473cd33 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -2499,6 +2499,7 @@ RemoveWrappingTypes(QualType type, ArrayRef mask = {}) { case clang::Type::Decltype: case clang::Type::Elaborated: case clang::Type::Paren: +case clang::Type::TemplateSpecialization: case clang::Type::Typedef: case clang::Type::TypeOf: case clang::Type::TypeOfExpr: diff --git a/lldb/test/API/lang/cpp/template-specialization-type/Makefile b/lldb/test/API/lang/cpp/template-specialization-type/Makefile new file mode 100644 index ..8b20bcb0 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-specialization-type/Makefile @@ -0,0 +1,3 @@ +CXX_SOURCES := main.cpp + +include Makefile.rules diff --git a/lldb/test/API/lang/cpp/template-specialization-type/TestTemplateSpecializationType.py b/lldb/test/API/lang/cpp/template-specialization-type/TestTemplateSpecializationType.py new file mode 100644 index ..31f0081dc697 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-specialization-type/TestTemplateSpecializationType.py @@ -0,0 +1,30 @@ +""" +Test value with a template specialization type. +""" +import lldb +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TemplateSpecializationTypeTestCase(TestBase): + +mydir = TestBase.compute_mydir(__file__) + +def test_template_specialization_cast_children(self): +self.build() +lldbutil.run_to_source_breakpoint(self, '// break here', +lldb.SBFileSpec("main.cpp", False)) + +v = self.frame().EvaluateExpression("t") +self.assertEquals(2, v.GetNumChildren()) +self.assertEquals("42", v.GetChildAtIndex(0).GetValue()) +self.assertEquals("21", v.GetChildAtIndex(1).GetValue()) + +# Test a value of the TemplateSpecialization type. We turn +# RecordType into TemplateSpecializationType by casting and +# dereferencing a pointer to a record. +v = self.frame().EvaluateExpression("*((TestObj*))") +self.assertEquals(2, v.GetNumChildren()) +self.assertEquals("42", v.GetChildAtIndex(0).GetValue()) +self.assertEquals("21", v.GetChildAtIndex(1).GetValue()) diff --git a/lldb/test/API/lang/cpp/template-specialization-type/main.cpp b/lldb/test/API/lang/cpp/template-specialization-type/main.cpp new file mode 100644 index ..5ef9c4962c85 --- /dev/null +++ b/lldb/test/API/lang/cpp/template-specialization-type/main.cpp @@ -0,0 +1,9 @@ +template struct TestObj { + int f; + T g; +}; + +int main() { + TestObj t{42, 21}; + return t.f + t.g; // break here +} ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] fac5d05 - [lldb] Fix and enable Windows minidump tests
Author: Jaroslav Sevcik Date: 2020-06-09T20:03:44Z New Revision: fac5d05eb75fab163dc316859fa5e7d255b98f7c URL: https://github.com/llvm/llvm-project/commit/fac5d05eb75fab163dc316859fa5e7d255b98f7c DIFF: https://github.com/llvm/llvm-project/commit/fac5d05eb75fab163dc316859fa5e7d255b98f7c.diff LOG: [lldb] Fix and enable Windows minidump tests SBFileSpec.fullpath always uses the forward slash to join the directory with the base name. This causes mismatches when comparing Windows paths with backslashes in two of the minidump tests. To get around that we just compare the directory names separately from the filenames. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D81465 Added: Modified: lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py Removed: diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py index 601546b1dc8e..8cb7de9714e3 100644 --- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py +++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py @@ -19,9 +19,14 @@ class MiniDumpUUIDTestCase(TestBase): NO_DEBUG_INFO_TESTCASE = True def verify_module(self, module, verify_path, verify_uuid): -uuid = module.GetUUIDString() -self.assertEqual(verify_path, module.GetFileSpec().fullpath) -self.assertEqual(verify_uuid, uuid) +# Compare the filename and the directory separately. We are avoiding +# SBFileSpec.fullpath because it causes a slash/backslash confusion +# on Windows. +self.assertEqual( +os.path.basename(verify_path), module.GetFileSpec().basename) +self.assertEqual( +os.path.dirname(verify_path), module.GetFileSpec().dirname or "") +self.assertEqual(verify_uuid, module.GetUUIDString()) def get_minidump_modules(self, yaml_file): minidump_path = self.getBuildArtifact(os.path.basename(yaml_file) + ".dmp") @@ -130,7 +135,6 @@ def test_uuid_modules_elf_build_id_same(self): self.verify_module(modules[1], "/file/does/not/exist/b", '11223344-1122-3344-1122-334411223344-11223344') -@expectedFailureAll(oslist=["windows"]) def test_partial_uuid_match(self): """ Breakpad has been known to create minidump files using CvRecord in each @@ -248,7 +252,6 @@ def test_add_module_build_id_4(self): "a", "", "01020304-0506-0708-090A-0B0C0D0E0F10").IsValid()) self.assertFalse(self.target.AddModule("a", "", "01020305").IsValid()) -@expectedFailureAll(oslist=["windows"]) def test_remove_placeholder_add_real_module(self): """ Test that removing a placeholder module and adding back the real ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 6143874 - [lldb] Disable remove-add module test on Windows
Author: Jaroslav Sevcik Date: 2020-06-08T08:21:07Z New Revision: 6143874f734bf3b27eeeb82d7756e008cba3b043 URL: https://github.com/llvm/llvm-project/commit/6143874f734bf3b27eeeb82d7756e008cba3b043 DIFF: https://github.com/llvm/llvm-project/commit/6143874f734bf3b27eeeb82d7756e008cba3b043.diff LOG: [lldb] Disable remove-add module test on Windows This disables the test introduced by https://github.com/llvm/llvm-project/commit/1beffc18886ae4cd72dfe1f9b6b79204cac51e5e on Windows. Reviewed By: labath Differential Revision: https://reviews.llvm.org/D81363 Added: Modified: lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py Removed: diff --git a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py index 2229ba05149d..601546b1dc8e 100644 --- a/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py +++ b/lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py @@ -248,6 +248,7 @@ def test_add_module_build_id_4(self): "a", "", "01020304-0506-0708-090A-0B0C0D0E0F10").IsValid()) self.assertFalse(self.target.AddModule("a", "", "01020305").IsValid()) +@expectedFailureAll(oslist=["windows"]) def test_remove_placeholder_add_real_module(self): """ Test that removing a placeholder module and adding back the real ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] 1beffc1 - Support build-ids of other sizes than 16 in UUID::SetFromStringRef
Author: Jaroslav Sevcik Date: 2020-06-07T10:03:41Z New Revision: 1beffc18886ae4cd72dfe1f9b6b79204cac51e5e URL: https://github.com/llvm/llvm-project/commit/1beffc18886ae4cd72dfe1f9b6b79204cac51e5e DIFF: https://github.com/llvm/llvm-project/commit/1beffc18886ae4cd72dfe1f9b6b79204cac51e5e.diff LOG: Support build-ids of other sizes than 16 in UUID::SetFromStringRef SBTarget::AddModule currently handles the UUID parameter in a very weird way: UUIDs with more than 16 bytes are trimmed to 16 bytes. On the other hand, shorter-than-16-bytes UUIDs are completely ignored. In this patch, we change the parsing code to handle UUIDs of arbitrary size. To support arbitrary size UUIDs in SBTarget::AddModule, this patch changes UUID::SetFromStringRef to parse UUIDs of arbitrary length. We subtly change the semantics of SetFromStringRef - SetFromStringRef now only succeeds if the entire input is consumed to prevent some prefix-parsing confusion. This is up for discussion, but I believe this is more consistent - we always return false for invalid UUIDs rather than sometimes truncating to a valid prefix. Also, all the call-sites except the API and interpreter seem to expect to consume the entire input. This also adds tests for adding existing modules 4-, 16-, and 20-byte build-ids. Finally, we took the liberty of testing the minidump scenario we care about - removing placeholder module from minidump and replacing it with the real module. Reviewed By: labath, friss Differential Revision: https://reviews.llvm.org/D80755 Added: lldb/test/API/functionalities/postmortem/minidump-new/linux-arm-uuids-elf-build-id-4.yaml lldb/test/API/functionalities/postmortem/minidump-new/linux-arm-uuids-match.yaml Modified: lldb/include/lldb/Utility/UUID.h lldb/source/Interpreter/OptionValueUUID.cpp lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp lldb/source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Utility/UUID.cpp lldb/test/API/functionalities/postmortem/minidump-new/TestMiniDumpUUID.py lldb/unittests/ObjectFile/ELF/TestObjectFileELF.cpp lldb/unittests/Target/ModuleCacheTest.cpp lldb/unittests/Utility/UUIDTest.cpp Removed: diff --git a/lldb/include/lldb/Utility/UUID.h b/lldb/include/lldb/Utility/UUID.h index 0284357be44a..5327719094c0 100644 --- a/lldb/include/lldb/Utility/UUID.h +++ b/lldb/include/lldb/Utility/UUID.h @@ -63,18 +63,13 @@ class UUID { std::string GetAsString(llvm::StringRef separator = "-") const; - size_t SetFromStringRef(llvm::StringRef str, uint32_t num_uuid_bytes = 16); + bool SetFromStringRef(llvm::StringRef str); // Same as SetFromStringRef, but if the resultant UUID is all 0 bytes, set the // UUID to invalid. - size_t SetFromOptionalStringRef(llvm::StringRef str, - uint32_t num_uuid_bytes = 16); - - // Decode as many UUID bytes (up to 16) as possible from the C string "cstr" - // This is used for auto completion where a partial UUID might have been - // typed in. It - /// Decode as many UUID bytes (up to 16) as possible from the C - /// string \a cstr. + bool SetFromOptionalStringRef(llvm::StringRef str); + + /// Decode as many UUID bytes as possible from the C string \a cstr. /// /// \param[in] str /// An llvm::StringRef that points at a UUID string value (no leading @@ -88,8 +83,7 @@ class UUID { /// The original string, with all decoded bytes removed. static llvm::StringRef DecodeUUIDBytesFromString(llvm::StringRef str, -llvm::SmallVectorImpl _bytes, -uint32_t num_uuid_bytes = 16); +llvm::SmallVectorImpl _bytes); private: UUID(llvm::ArrayRef bytes) : m_bytes(bytes.begin(), bytes.end()) {} diff --git a/lldb/source/Interpreter/OptionValueUUID.cpp b/lldb/source/Interpreter/OptionValueUUID.cpp index 4da839233472..2bd749773556 100644 --- a/lldb/source/Interpreter/OptionValueUUID.cpp +++ b/lldb/source/Interpreter/OptionValueUUID.cpp @@ -38,7 +38,7 @@ Status OptionValueUUID::SetValueFromString(llvm::StringRef value, case eVarSetOperationReplace: case eVarSetOperationAssign: { -if (m_uuid.SetFromStringRef(value) == 0) +if (!m_uuid.SetFromStringRef(value)) error.SetErrorStringWithFormat("invalid uuid string value '%s'", value.str().c_str()); else { diff --git a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp index 2b14ece5cfa3..bd8eeedce57d 100644 --- a/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp +++ b/lldb/source/Plugins/ObjectFile/Breakpad/BreakpadRecords.cpp @@ -205,7 +205,7 @@ llvm::Optional InfoRecord::parse(llvm::StringRef Line) {