aadsm created this revision. aadsm added reviewers: clayborg, jasonmolenda. Herald added subscribers: lldb-commits, jdoerfert, eraman, mgorny. Herald added a project: LLDB.
This diff changes the function `LineEntry::GetSameLineContiguousAddressRange` so that it also includes function calls that were inlined at the same line of code. My motivation is to decrease the step over time of lines that heavly rely on inlined functions. I have multiple examples in the code base I work that makes a step over stop 20 or mote times internally. This can easly had up to step overs that take >500ms which I was able to lower to 25ms with this new strategy. The reason the current code is not extending the address range beyond an inlined function is because when we resolve the symbol at the next address of the line entry we will get the entry line corresponding to where the original code for the inline function lives, making us barely extend the range. This then will end up on a step over having to stop multiple times everytime there's an inlined function. To check if the range is an inlined function at that line I also get the block associated with the next address and check if there is a parent block with a call site at the line we're trying to extend. To check this I created a new function in Block called `GetContainingInlinedBlockWithCallSite` that does exactly that. I also added a new function to Declaration for convinence of checking file/line named `CompareFileAndLine`. To avoid potential issues when extending an address range I added an `Extend` function that extends the range by the AddressRange given as an argument. This function returns true to indicate sucess when the rage was agumented, false otherwise (e.g.: the ranges are not connected). The reason I do is to make sure that we're not just blindly extending complete_line_range by whatever `GetByteSize()` we got. If for some reason the ranges are not connected or overlap, or even 0, this could be an issue. I also added a unit tests for this change and include the instructions on the test itself on how to generate the yaml file I use for testing. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D61292 Files: lldb/include/lldb/Core/AddressRange.h lldb/include/lldb/Symbol/Block.h lldb/include/lldb/Symbol/Declaration.h lldb/include/lldb/Symbol/LineEntry.h lldb/source/Core/AddressRange.cpp lldb/source/Symbol/Block.cpp lldb/source/Symbol/Declaration.cpp lldb/source/Symbol/LineEntry.cpp lldb/source/Target/Thread.cpp lldb/source/Target/ThreadPlanStepRange.cpp lldb/unittests/Symbol/CMakeLists.txt lldb/unittests/Symbol/Inputs/inlined-functions.yaml lldb/unittests/Symbol/TestLineEntry.cpp
Index: lldb/unittests/Symbol/TestLineEntry.cpp =================================================================== --- /dev/null +++ lldb/unittests/Symbol/TestLineEntry.cpp @@ -0,0 +1,278 @@ +//===-- TestLineEntry.cpp ------------------------------*- C++ -*-===// +// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "gtest/gtest.h" +#include <iostream> + +#include "Plugins/ObjectFile/Mach-O/ObjectFileMachO.h" +#include "Plugins/SymbolFile/DWARF/DWARFASTParserClang.h" +#include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" +#include "Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.h" +#include "TestingSupport/TestUtilities.h" +#include "lldb/Symbol/ClangASTContext.h" + +#include "lldb/Core/Module.h" +#include "lldb/Host/FileSystem.h" +#include "lldb/Host/HostInfo.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Symbol/SymbolContext.h" +#include "lldb/Utility/StreamString.h" + +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/Program.h" + +using namespace lldb_private; +using namespace lldb; + +class LineEntryTest : public testing::Test { +public: + void SetUp() override { + FileSystem::Initialize(); + HostInfo::Initialize(); + ObjectFileMachO::Initialize(); + SymbolVendorMacOSX::Initialize(); + SymbolFileDWARF::Initialize(); + ClangASTContext::Initialize(); + } + + void TearDown() override { + ClangASTContext::Terminate(); + SymbolFileDWARF::Terminate(); + SymbolVendorMacOSX::Terminate(); + ObjectFileMachO::Terminate(); + HostInfo::Terminate(); + FileSystem::Terminate(); + } + +protected: + llvm::Expected<ModuleSP> GetModule(); + llvm::Expected<LineEntry> GetLineEntryForLine(uint32_t line); + ModuleSP m_module_sp; +}; + +#define EXPECTED_NO_ERROR(x) \ + if (std::error_code ASSERT_NO_ERROR_ec = x) { \ + llvm::SmallString<128> MessageStorage; \ + llvm::raw_svector_ostream Message(MessageStorage); \ + Message << #x ": did not return errc::success.\n" \ + << "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \ + << "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \ + return llvm::make_error<llvm::StringError>( \ + MessageStorage.c_str(), llvm::inconvertibleErrorCode()); \ + } + +#define EXPECTED_SUCCESS(x, message) \ + if (x != 0) { \ + return llvm::make_error<llvm::StringError>( \ + message, llvm::inconvertibleErrorCode()); \ + } + +#define EXPECTED_GT(value, number, message) \ + if (value <= number) { \ + return llvm::make_error<llvm::StringError>( \ + message, llvm::inconvertibleErrorCode()); \ + } + +#define EXPECTED_VALUE(value, message) \ + if (!value) { \ + return llvm::make_error<llvm::StringError>( \ + message, llvm::inconvertibleErrorCode()); \ + } + +#define DUMP_RANGE(range) \ + { \ + StreamString s; \ + range.DumpDebug(&s); \ + std::cout << s.GetData() << std::endl; \ + } + +llvm::Expected<ModuleSP> LineEntryTest::GetModule() { + if (m_module_sp) + return m_module_sp; + + std::string yaml = GetInputFilePath("inlined-functions.yaml"); + llvm::SmallString<128> obj; + + EXPECTED_NO_ERROR( + llvm::sys::fs::createTemporaryFile("source-%%%%%%", "obj", obj)); + llvm::FileRemover obj_remover(obj); + + llvm::StringRef args[] = {YAML2OBJ, yaml}; + llvm::StringRef obj_ref = obj; + const llvm::Optional<llvm::StringRef> redirects[] = {llvm::None, obj_ref, + llvm::None}; + EXPECTED_SUCCESS( + llvm::sys::ExecuteAndWait(YAML2OBJ, args, llvm::None, redirects), + "Error running yaml2obj."); + uint64_t size; + EXPECTED_NO_ERROR(llvm::sys::fs::file_size(obj, size)); + EXPECTED_GT(size, 0, "Empty object file created from yaml2obj."); + + m_module_sp = std::make_shared<Module>(ModuleSpec(FileSpec(obj))); + // Preload because the temporary file will be gone once we exit this function. + m_module_sp->PreloadSymbols(); + return m_module_sp; +} + +llvm::Expected<LineEntry> LineEntryTest::GetLineEntryForLine(uint32_t line) { + auto expected_module_so = GetModule(); + + EXPECTED_VALUE(expected_module_so, "Not able to get module for test object."); + + auto module = expected_module_so->get(); + bool check_inlines = true; + bool exact = true; + SymbolContextList sc_comp_units; + SymbolContextList sc_line_entries; + FileSpec file_spec("inlined-functions.cpp"); + module->ResolveSymbolContextsForFileSpec(file_spec, line, check_inlines, + lldb::eSymbolContextCompUnit, + sc_comp_units); + EXPECTED_GT(sc_comp_units.GetSize(), 0, + "No comp unit found on the test object."); + sc_comp_units[0].comp_unit->ResolveSymbolContext( + file_spec, line, check_inlines, exact, eSymbolContextLineEntry, + sc_line_entries); + EXPECTED_GT(sc_line_entries.GetSize(), 0, + "No line entry found on the test object."); + + return sc_line_entries[0].line_entry; +} + +TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeNoInlines) { + auto line_entry = GetLineEntryForLine(17); + if (!line_entry) + ASSERT_TRUE(false) << line_entry.takeError(); + bool include_inlined_functions = false; + auto range = + line_entry->GetSameLineContiguousAddressRange(include_inlined_functions); + ASSERT_EQ(range.GetByteSize(), (uint64_t)0x24); +} + +TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeOneInline) { + auto line_entry = GetLineEntryForLine(17); + if (!line_entry) + ASSERT_TRUE(false) << line_entry.takeError(); + bool include_inlined_functions = true; + auto range = + line_entry->GetSameLineContiguousAddressRange(include_inlined_functions); + ASSERT_EQ(range.GetByteSize(), (uint64_t)0x49); +} + +TEST_F(LineEntryTest, GetSameLineContiguousAddressRangeNestedInline) { + auto line_entry = GetLineEntryForLine(12); + if (!line_entry) + ASSERT_TRUE(false) << line_entry.takeError(); + bool include_inlined_functions = true; + auto range = + line_entry->GetSameLineContiguousAddressRange(include_inlined_functions); + ASSERT_EQ(range.GetByteSize(), (uint64_t)0x33); +} + +/* +# inlined-functions.cpp +inline __attribute__((always_inline)) int sum2(int a, int b) { + int result = a + b; + return result; +} + +int sum3(int a, int b, int c) { + int result = a + b + c; + return result; +} + +inline __attribute__((always_inline)) int sum4(int a, int b, int c, int d) { + int result = sum2(a, b) + sum2(c, d); + return result; +} + +int main(int argc, char** argv) { + sum3(3, 4, 5) + sum2(1, 2); + int sum = sum4(1, 2, 3, 4); + sum2(5, 6); + return 0; +} + +// g++ -c inlined-functions.cpp -o inlined-functions.o -g -Wno-unused-value +// obj2yaml inlined-functions.o > inlined-functions.yaml + +# Dump of source line per address: +# inlined-functions.cpp is src.cpp for space considerations. +0x20: outl %eax, %dx src.cpp:16 +0x21: movl $0xbeefdead, %esi src.cpp:16 +0x26: lodsl (%rsi), %eax src.cpp:16 +0x27: fsubrp %st(7) src.cpp:16 +0x29: movl $0xbeefdead, %esi src.cpp:16 +0x2e: lodsl (%rsi), %eax src.cpp:16 +0x2f: fsubrp %st(7) src.cpp:16 +0x31: movl $0xbeefdead, %esi src.cpp:16 +0x36: lodsl (%rsi), %eax src.cpp:17 +0x37: fsubrp %st(7) src.cpp:17 +0x39: movl $0xbeefdead, %esi src.cpp:17 +0x3e: lodsl (%rsi), %eax src.cpp:17 +0x3f: fsubrp %st(7) src.cpp:17 +0x41: movl $0xbeefdead, %esi src.cpp:17 +0x46: lodsl (%rsi), %eax src.cpp:17 +0x47: fsubrp %st(7) src.cpp:17 +0x49: movl $0xbeefdead, %esi src.cpp:17 +0x4e: lodsl (%rsi), %eax src.cpp:17 +0x4f: fsubrp %st(7) src.cpp:17 +0x51: movl $0xbeefdead, %esi src.cpp:17 +0x56: lodsl (%rsi), %eax src.cpp:17 +0x57: fsubrp %st(7) src.cpp:17 +0x59: movl $0xbeefdead, %esi src.cpp:17 +0x5e: lodsl (%rsi), %eax src.cpp:17 -> s...@src.cpp:2 +0x5f: fsubrp %st(7) src.cpp:17 -> s...@src.cpp:2 +0x61: movl $0xbeefdead, %esi src.cpp:17 -> s...@src.cpp:2 +0x66: lodsl (%rsi), %eax src.cpp:17 -> s...@src.cpp:2 +0x67: fsubrp %st(7) src.cpp:17 -> s...@src.cpp:2 +0x69: movl $0xbeefdead, %esi src.cpp:17 -> s...@src.cpp:2 +0x6e: lodsl (%rsi), %eax src.cpp:17 -> s...@src.cpp:2 +0x6f: fsubrp %st(7) src.cpp:17 -> s...@src.cpp:2 +0x71: movl $0xbeefdead, %esi src.cpp:17 -> s...@src.cpp:2 +0x76: lodsl (%rsi), %eax src.cpp:17 -> s...@src.cpp:2 +0x77: fsubrp %st(7) src.cpp:17 -> s...@src.cpp:2 +0x79: movl $0xbeefdead, %esi src.cpp:17 -> s...@src.cpp:2 +0x7e: lodsl (%rsi), %eax src.cpp:17 -> s...@src.cpp:2 +0x7f: fsubrp %st(7) src.cpp:18 -> s...@src.cpp:12 +0x81: movl $0xbeefdead, %esi src.cpp:18 -> s...@src.cpp:12 +0x86: lodsl (%rsi), %eax src.cpp:18 -> s...@src.cpp:12 +0x87: fsubrp %st(7) src.cpp:18 -> s...@src.cpp:12 +0x89: movl $0xbeefdead, %esi src.cpp:18 -> s...@src.cpp:12 +0x8e: lodsl (%rsi), %eax src.cpp:18 -> s...@src.cpp:12 -> s...@src.cpp:2 +0x8f: fsubrp %st(7) src.cpp:18 -> s...@src.cpp:12 -> s...@src.cpp:2 +0x91: movl $0xbeefdead, %esi src.cpp:18 -> s...@src.cpp:12 -> s...@src.cpp:2 +0x96: lodsl (%rsi), %eax src.cpp:18 -> s...@src.cpp:12 -> s...@src.cpp:3 +0x97: fsubrp %st(7) src.cpp:18 -> s...@src.cpp:12 +0x99: movl $0xbeefdead, %esi src.cpp:18 -> s...@src.cpp:12 +0x9e: lodsl (%rsi), %eax src.cpp:18 -> s...@src.cpp:12 +0x9f: fsubrp %st(7) src.cpp:18 -> s...@src.cpp:12 +0xa1: movl $0xbeefdead, %esi src.cpp:18 -> s...@src.cpp:12 +0xa6: lodsl (%rsi), %eax src.cpp:18 -> s...@src.cpp:12 -> s...@src.cpp:2 +0xa7: fsubrp %st(7) src.cpp:18 -> s...@src.cpp:12 -> s...@src.cpp:2 +0xa9: movl $0xbeefdead, %esi src.cpp:18 -> s...@src.cpp:12 -> s...@src.cpp:2 +0xae: lodsl (%rsi), %eax src.cpp:18 -> s...@src.cpp:12 +0xaf: fsubrp %st(7) src.cpp:18 -> s...@src.cpp:12 +0xb1: movl $0xbeefdead, %esi src.cpp:18 -> s...@src.cpp:12 +0xb6: lodsl (%rsi), %eax src.cpp:18 +0xb7: fsubrp %st(7) src.cpp:18 +0xb9: movl $0xbeefdead, %esi src.cpp:18 +0xbe: lodsl (%rsi), %eax src.cpp:18 +0xbf: fsubrp %st(7) src.cpp:18 +0xc1: movl $0xbeefdead, %esi src.cpp:18 +0xc6: lodsl (%rsi), %eax src.cpp:19 -> s...@src.cpp:2 +0xc7: fsubrp %st(7) src.cpp:19 -> s...@src.cpp:2 +0xc9: movl $0xbeefdead, %esi src.cpp:19 -> s...@src.cpp:2 +0xce: lodsl (%rsi), %eax src.cpp:19 -> s...@src.cpp:2 +0xcf: fsubrp %st(7) src.cpp:20 +0xd1: movl $0xbeefdead, %esi src.cpp:20 +0xd6: lodsl (%rsi), %eax src.cpp:20 +0xd7: fsubrp %st(7) src.cpp:20 +*/ \ No newline at end of file Index: lldb/unittests/Symbol/Inputs/inlined-functions.yaml =================================================================== --- /dev/null +++ lldb/unittests/Symbol/Inputs/inlined-functions.yaml @@ -0,0 +1,938 @@ +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x01000007 + cpusubtype: 0x00000003 + filetype: 0x00000001 + ncmds: 4 + sizeofcmds: 1160 + flags: 0x00002000 + reserved: 0x00000000 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 1032 + segname: '' + vmaddr: 0 + vmsize: 1995 + fileoff: 1192 + filesize: 1995 + maxprot: 7 + initprot: 7 + nsects: 6 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0000000000000000 + size: 218 + offset: 0x000004A8 + align: 4 + reloff: 0x00000C74 + nreloc: 1 + flags: 0x80000400 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_str + segname: __DWARF + addr: 0x00000000000000DA + size: 200 + offset: 0x00000582 + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_abbrev + segname: __DWARF + addr: 0x00000000000001A2 + size: 190 + offset: 0x0000064A + align: 0 + reloff: 0x00000000 + nreloc: 0 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_info + segname: __DWARF + addr: 0x0000000000000260 + size: 583 + offset: 0x00000708 + align: 0 + reloff: 0x00000C7C + nreloc: 8 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __compact_unwind + segname: __LD + addr: 0x0000000000000658 + size: 64 + offset: 0x00000B00 + align: 3 + reloff: 0x00000CBC + nreloc: 2 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - sectname: __debug_line + segname: __DWARF + addr: 0x0000000000000700 + size: 203 + offset: 0x00000BA8 + align: 0 + reloff: 0x00000CCC + nreloc: 1 + flags: 0x02000000 + reserved1: 0x00000000 + reserved2: 0x00000000 + reserved3: 0x00000000 + - cmd: LC_BUILD_VERSION + cmdsize: 24 + platform: 1 + minos: 658944 + sdk: 658944 + ntools: 0 + - cmd: LC_SYMTAB + cmdsize: 24 + symoff: 3284 + nsyms: 2 + stroff: 3316 + strsize: 20 + - cmd: LC_DYSYMTAB + cmdsize: 80 + ilocalsym: 0 + nlocalsym: 0 + iextdefsym: 0 + nextdefsym: 2 + iundefsym: 2 + nundefsym: 0 + tocoff: 0 + ntoc: 0 + modtaboff: 0 + nmodtab: 0 + extrefsymoff: 0 + nextrefsyms: 0 + indirectsymoff: 0 + nindirectsyms: 0 + extreloff: 0 + nextrel: 0 + locreloff: 0 + nlocrel: 0 +LinkEditData: + NameList: + - n_strx: 7 + n_type: 0x0F + n_sect: 1 + n_desc: 0 + n_value: 0 + - n_strx: 1 + n_type: 0x0F + n_sect: 1 + n_desc: 0 + n_value: 32 + StringTable: + - '' + - _main + - __Z4sum3iii + - '' +DWARF: + debug_str: + - 'Apple LLVM version 10.0.1 (clang-1001.0.46.3)' + - inlined-functions.cpp + - '/Users/aadsm/toolchain_dev/external/lldb' + - sum3 + - _Z4sum3iii + - _Z4sum2ii + - sum2 + - int + - a + - b + - result + - _Z4sum4iiii + - sum4 + - c + - d + - main + - argc + - argv + - char + - sum + debug_abbrev: + - Code: 0x00000001 + Tag: DW_TAG_compile_unit + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_producer + Form: DW_FORM_strp + - Attribute: DW_AT_language + Form: DW_FORM_data2 + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_stmt_list + Form: DW_FORM_sec_offset + - Attribute: DW_AT_comp_dir + Form: DW_FORM_strp + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Code: 0x00000002 + Tag: DW_TAG_subprogram + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Attribute: DW_AT_frame_base + Form: DW_FORM_exprloc + - Attribute: DW_AT_linkage_name + Form: DW_FORM_strp + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Attribute: DW_AT_external + Form: DW_FORM_flag_present + - Code: 0x00000003 + Tag: DW_TAG_formal_parameter + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_location + Form: DW_FORM_exprloc + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Code: 0x00000004 + Tag: DW_TAG_variable + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_location + Form: DW_FORM_exprloc + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Code: 0x00000005 + Tag: DW_TAG_subprogram + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_linkage_name + Form: DW_FORM_strp + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Attribute: DW_AT_external + Form: DW_FORM_flag_present + - Attribute: DW_AT_inline + Form: DW_FORM_data1 + - Code: 0x00000006 + Tag: DW_TAG_formal_parameter + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Code: 0x00000007 + Tag: DW_TAG_variable + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Code: 0x00000008 + Tag: DW_TAG_base_type + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_encoding + Form: DW_FORM_data1 + - Attribute: DW_AT_byte_size + Form: DW_FORM_data1 + - Code: 0x00000009 + Tag: DW_TAG_subprogram + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Attribute: DW_AT_frame_base + Form: DW_FORM_exprloc + - Attribute: DW_AT_name + Form: DW_FORM_strp + - Attribute: DW_AT_decl_file + Form: DW_FORM_data1 + - Attribute: DW_AT_decl_line + Form: DW_FORM_data1 + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + - Attribute: DW_AT_external + Form: DW_FORM_flag_present + - Code: 0x0000000A + Tag: DW_TAG_inlined_subroutine + Children: DW_CHILDREN_yes + Attributes: + - Attribute: DW_AT_abstract_origin + Form: DW_FORM_ref4 + - Attribute: DW_AT_low_pc + Form: DW_FORM_addr + - Attribute: DW_AT_high_pc + Form: DW_FORM_data4 + - Attribute: DW_AT_call_file + Form: DW_FORM_data1 + - Attribute: DW_AT_call_line + Form: DW_FORM_data1 + - Code: 0x0000000B + Tag: DW_TAG_formal_parameter + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_location + Form: DW_FORM_exprloc + - Attribute: DW_AT_abstract_origin + Form: DW_FORM_ref4 + - Code: 0x0000000C + Tag: DW_TAG_variable + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_location + Form: DW_FORM_exprloc + - Attribute: DW_AT_abstract_origin + Form: DW_FORM_ref4 + - Code: 0x0000000D + Tag: DW_TAG_pointer_type + Children: DW_CHILDREN_no + Attributes: + - Attribute: DW_AT_type + Form: DW_FORM_ref4 + debug_info: + - Length: + TotalLength: 579 + Version: 4 + AbbrOffset: 0 + AddrSize: 8 + Entries: + - AbbrCode: 0x00000001 + Values: + - Value: 0x0000000000000000 + - Value: 0x0000000000000004 + - Value: 0x000000000000002E + - Value: 0x0000000000000000 + - Value: 0x0000000000000044 + - Value: 0x0000000000000000 + - Value: 0x00000000000000DA + - AbbrCode: 0x00000002 + Values: + - Value: 0x0000000000000000 + - Value: 0x000000000000001E + - Value: 0x0000000000000001 + BlockData: + - 0x56 + - Value: 0x0000000000000072 + - Value: 0x000000000000006D + - Value: 0x0000000000000001 + - Value: 0x0000000000000006 + - Value: 0x00000000000000B2 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x7C + - Value: 0x0000000000000090 + - Value: 0x0000000000000001 + - Value: 0x0000000000000006 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x78 + - Value: 0x0000000000000092 + - Value: 0x0000000000000001 + - Value: 0x0000000000000006 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x74 + - Value: 0x00000000000000AC + - Value: 0x0000000000000001 + - Value: 0x0000000000000006 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000004 + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x70 + - Value: 0x0000000000000094 + - Value: 0x0000000000000001 + - Value: 0x0000000000000007 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000005 + Values: + - Value: 0x000000000000007D + - Value: 0x0000000000000087 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - Value: 0x00000000000000B2 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000006 + Values: + - Value: 0x0000000000000090 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000006 + Values: + - Value: 0x0000000000000092 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000007 + Values: + - Value: 0x0000000000000094 + - Value: 0x0000000000000001 + - Value: 0x0000000000000002 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000008 + Values: + - Value: 0x000000000000008C + - Value: 0x0000000000000005 + - Value: 0x0000000000000004 + - AbbrCode: 0x00000005 + Values: + - Value: 0x000000000000009B + - Value: 0x00000000000000A7 + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - Value: 0x0000000000000001 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000006 + Values: + - Value: 0x0000000000000090 + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000006 + Values: + - Value: 0x0000000000000092 + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000006 + Values: + - Value: 0x00000000000000AC + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000006 + Values: + - Value: 0x00000000000000AE + - Value: 0x0000000000000001 + - Value: 0x000000000000000B + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000007 + Values: + - Value: 0x0000000000000094 + - Value: 0x0000000000000001 + - Value: 0x000000000000000C + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000009 + Values: + - Value: 0x0000000000000020 + - Value: 0x00000000000000BA + - Value: 0x0000000000000001 + BlockData: + - 0x56 + - Value: 0x00000000000000B0 + - Value: 0x0000000000000001 + - Value: 0x0000000000000010 + - Value: 0x00000000000000B2 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000003 + BlockData: + - 0x91 + - 0xB4 + - 0x7F + - Value: 0x00000000000000B5 + - Value: 0x0000000000000001 + - Value: 0x0000000000000010 + - Value: 0x00000000000000B2 + - AbbrCode: 0x00000003 + Values: + - Value: 0x0000000000000003 + BlockData: + - 0x91 + - 0xA8 + - 0x7F + - Value: 0x00000000000000BA + - Value: 0x0000000000000001 + - Value: 0x0000000000000010 + - Value: 0x0000000000000235 + - AbbrCode: 0x00000004 + Values: + - Value: 0x0000000000000003 + BlockData: + - 0x91 + - 0xA4 + - 0x7F + - Value: 0x00000000000000C4 + - Value: 0x0000000000000001 + - Value: 0x0000000000000012 + - Value: 0x00000000000000B2 + - AbbrCode: 0x0000000A + Values: + - Value: 0x0000000000000080 + - Value: 0x000000000000005A + - Value: 0x0000000000000025 + - Value: 0x0000000000000001 + - Value: 0x0000000000000011 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x44 + - Value: 0x0000000000000090 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x40 + - Value: 0x000000000000009B + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000003 + BlockData: + - 0x91 + - 0xBC + - 0x7F + - Value: 0x00000000000000A6 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x0000000A + Values: + - Value: 0x00000000000000B9 + - Value: 0x000000000000007F + - Value: 0x0000000000000036 + - Value: 0x0000000000000001 + - Value: 0x0000000000000012 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x64 + - Value: 0x00000000000000C9 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x60 + - Value: 0x00000000000000D4 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x5C + - Value: 0x00000000000000DF + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x58 + - Value: 0x00000000000000EA + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x54 + - Value: 0x00000000000000F5 + - AbbrCode: 0x0000000A + Values: + - Value: 0x0000000000000080 + - Value: 0x000000000000008B + - Value: 0x000000000000000C + - Value: 0x0000000000000001 + - Value: 0x000000000000000C + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x70 + - Value: 0x0000000000000090 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x6C + - Value: 0x000000000000009B + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x68 + - Value: 0x00000000000000A6 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x0000000A + Values: + - Value: 0x0000000000000080 + - Value: 0x00000000000000A3 + - Value: 0x0000000000000009 + - Value: 0x0000000000000001 + - Value: 0x000000000000000C + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x7C + - Value: 0x0000000000000090 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x78 + - Value: 0x000000000000009B + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x74 + - Value: 0x00000000000000A6 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x0000000A + Values: + - Value: 0x0000000000000080 + - Value: 0x00000000000000C6 + - Value: 0x0000000000000009 + - Value: 0x0000000000000001 + - Value: 0x0000000000000013 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x50 + - Value: 0x0000000000000090 + - AbbrCode: 0x0000000B + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x4C + - Value: 0x000000000000009B + - AbbrCode: 0x0000000C + Values: + - Value: 0x0000000000000002 + BlockData: + - 0x91 + - 0x48 + - Value: 0x00000000000000A6 + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x00000000 + Values: [] + - AbbrCode: 0x0000000D + Values: + - Value: 0x000000000000023A + - AbbrCode: 0x0000000D + Values: + - Value: 0x000000000000023F + - AbbrCode: 0x00000008 + Values: + - Value: 0x00000000000000BF + - Value: 0x0000000000000006 + - Value: 0x0000000000000001 + - AbbrCode: 0x00000000 + Values: [] + debug_line: + - Length: + TotalLength: 199 + Version: 4 + PrologueLength: 45 + MinInstLength: 1 + MaxOpsPerInst: 1 + DefaultIsStmt: 1 + LineBase: 251 + LineRange: 14 + OpcodeBase: 13 + StandardOpcodeLengths: [ 0, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1 ] + IncludeDirs: [] + Files: + - Name: inlined-functions.cpp + DirIdx: 0 + ModTime: 0 + Length: 0 + Opcodes: + - Opcode: DW_LNS_extended_op + ExtLen: 9 + SubOpcode: DW_LNE_set_address + Data: 0 + - Opcode: 0x17 + Data: 0 + - Opcode: DW_LNS_set_column + Data: 15 + - Opcode: DW_LNS_set_prologue_end + Data: 15 + - Opcode: 0xC9 + Data: 15 + - Opcode: DW_LNS_set_column + Data: 17 + - Opcode: DW_LNS_negate_stmt + Data: 17 + - Opcode: 0x3C + Data: 17 + - Opcode: DW_LNS_set_column + Data: 21 + - Opcode: 0x3C + Data: 21 + - Opcode: DW_LNS_set_column + Data: 6 + - Opcode: 0x3C + Data: 6 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: DW_LNS_negate_stmt + Data: 9 + - Opcode: 0x3D + Data: 9 + - Opcode: DW_LNS_set_column + Data: 2 + - Opcode: DW_LNS_negate_stmt + Data: 2 + - Opcode: 0x3C + Data: 2 + - Opcode: DW_LNS_set_column + Data: 0 + - Opcode: DW_LNS_negate_stmt + Data: 0 + - Opcode: 0x52 + Data: 0 + - Opcode: DW_LNS_set_column + Data: 2 + - Opcode: DW_LNS_set_prologue_end + Data: 2 + - Opcode: DW_LNS_const_add_pc + Data: 2 + - Opcode: 0x59 + Data: 2 + - Opcode: DW_LNS_set_column + Data: 15 + - Opcode: DW_LNS_advance_line + SData: -15 + Data: 15 + - Opcode: DW_LNS_advance_pc + Data: 36 + - Opcode: DW_LNS_copy + Data: 36 + - Opcode: DW_LNS_set_column + Data: 17 + - Opcode: DW_LNS_negate_stmt + Data: 17 + - Opcode: 0x3C + Data: 17 + - Opcode: DW_LNS_set_column + Data: 6 + - Opcode: 0x3C + Data: 6 + - Opcode: DW_LNS_set_column + Data: 20 + - Opcode: DW_LNS_negate_stmt + Data: 20 + - Opcode: DW_LNS_advance_line + SData: 10 + Data: 20 + - Opcode: DW_LNS_const_add_pc + Data: 20 + - Opcode: 0xD6 + Data: 20 + - Opcode: DW_LNS_set_column + Data: 23 + - Opcode: DW_LNS_negate_stmt + Data: 23 + - Opcode: 0x3C + Data: 23 + - Opcode: DW_LNS_set_column + Data: 15 + - Opcode: DW_LNS_negate_stmt + Data: 15 + - Opcode: DW_LNS_advance_line + SData: -10 + Data: 15 + - Opcode: 0x90 + Data: 15 + - Opcode: DW_LNS_set_column + Data: 17 + - Opcode: DW_LNS_negate_stmt + Data: 17 + - Opcode: 0x3C + Data: 17 + - Opcode: DW_LNS_set_column + Data: 6 + - Opcode: 0x3C + Data: 6 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: DW_LNS_negate_stmt + Data: 9 + - Opcode: 0x3D + Data: 9 + - Opcode: DW_LNS_set_column + Data: 33 + - Opcode: DW_LNS_advance_line + SData: 9 + Data: 33 + - Opcode: 0x3C + Data: 33 + - Opcode: DW_LNS_set_column + Data: 36 + - Opcode: DW_LNS_negate_stmt + Data: 36 + - Opcode: 0x3C + Data: 36 + - Opcode: DW_LNS_set_column + Data: 15 + - Opcode: DW_LNS_negate_stmt + Data: 15 + - Opcode: DW_LNS_advance_line + SData: -10 + Data: 15 + - Opcode: 0x90 + Data: 15 + - Opcode: DW_LNS_set_column + Data: 17 + - Opcode: DW_LNS_negate_stmt + Data: 17 + - Opcode: 0x3C + Data: 17 + - Opcode: DW_LNS_set_column + Data: 6 + - Opcode: 0x3C + Data: 6 + - Opcode: DW_LNS_set_column + Data: 26 + - Opcode: DW_LNS_negate_stmt + Data: 26 + - Opcode: DW_LNS_advance_line + SData: 10 + Data: 26 + - Opcode: 0x3C + Data: 26 + - Opcode: DW_LNS_set_column + Data: 6 + - Opcode: DW_LNS_negate_stmt + Data: 6 + - Opcode: 0x3C + Data: 6 + - Opcode: DW_LNS_set_column + Data: 9 + - Opcode: DW_LNS_negate_stmt + Data: 9 + - Opcode: 0x3D + Data: 9 + - Opcode: DW_LNS_set_column + Data: 6 + - Opcode: 0x41 + Data: 6 + - Opcode: DW_LNS_set_column + Data: 15 + - Opcode: DW_LNS_advance_line + SData: -16 + Data: 15 + - Opcode: DW_LNS_const_add_pc + Data: 15 + - Opcode: 0x12 + Data: 15 + - Opcode: DW_LNS_set_column + Data: 17 + - Opcode: DW_LNS_negate_stmt + Data: 17 + - Opcode: 0x3C + Data: 17 + - Opcode: DW_LNS_set_column + Data: 6 + - Opcode: 0x3C + Data: 6 + - Opcode: DW_LNS_set_column + Data: 2 + - Opcode: DW_LNS_negate_stmt + Data: 2 + - Opcode: DW_LNS_advance_line + SData: 18 + Data: 2 + - Opcode: 0x3C + Data: 2 + - Opcode: DW_LNS_advance_pc + Data: 11 + - Opcode: DW_LNS_extended_op + ExtLen: 1 + SubOpcode: DW_LNE_end_sequence + Data: 11 +... Index: lldb/unittests/Symbol/CMakeLists.txt =================================================================== --- lldb/unittests/Symbol/CMakeLists.txt +++ lldb/unittests/Symbol/CMakeLists.txt @@ -4,17 +4,22 @@ TestClangASTContext.cpp TestDWARFCallFrameInfo.cpp TestType.cpp + TestLineEntry.cpp LINK_LIBS lldbHost lldbSymbol lldbUtilityHelpers lldbPluginObjectFileELF + lldbPluginObjectFileMachO + lldbPluginSymbolVendorMacOSX + lldbPluginSymbolFileDWARF ) add_dependencies(SymbolTests yaml2obj) add_definitions(-DYAML2OBJ="$<TARGET_FILE:yaml2obj>") set(test_inputs basic-call-frame-info.yaml + inlined-functions.yaml ) add_unittest_inputs(SymbolTests "${test_inputs}") Index: lldb/source/Target/ThreadPlanStepRange.cpp =================================================================== --- lldb/source/Target/ThreadPlanStepRange.cpp +++ lldb/source/Target/ThreadPlanStepRange.cpp @@ -126,8 +126,10 @@ new_context.line_entry.original_file) { if (m_addr_context.line_entry.line == new_context.line_entry.line) { m_addr_context = new_context; - AddRange( - m_addr_context.line_entry.GetSameLineContiguousAddressRange()); + const bool include_inlined_functions = + GetKind() == eKindStepOverRange; + AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange( + include_inlined_functions)); ret_value = true; if (log) { StreamString s; @@ -142,8 +144,10 @@ } else if (new_context.line_entry.line == 0) { new_context.line_entry.line = m_addr_context.line_entry.line; m_addr_context = new_context; - AddRange( - m_addr_context.line_entry.GetSameLineContiguousAddressRange()); + const bool include_inlined_functions = + GetKind() == eKindStepOverRange; + AddRange(m_addr_context.line_entry.GetSameLineContiguousAddressRange( + include_inlined_functions)); ret_value = true; if (log) { StreamString s; Index: lldb/source/Target/Thread.cpp =================================================================== --- lldb/source/Target/Thread.cpp +++ lldb/source/Target/Thread.cpp @@ -1395,10 +1395,12 @@ bool abort_other_plans, const LineEntry &line_entry, const SymbolContext &addr_context, lldb::RunMode stop_other_threads, Status &status, LazyBool step_out_avoids_code_withoug_debug_info) { + const bool include_inlined_functions = true; + auto address_range = + line_entry.GetSameLineContiguousAddressRange(include_inlined_functions); return QueueThreadPlanForStepOverRange( - abort_other_plans, line_entry.GetSameLineContiguousAddressRange(), - addr_context, stop_other_threads, status, - step_out_avoids_code_withoug_debug_info); + abort_other_plans, address_range, addr_context, stop_other_threads, + status, step_out_avoids_code_withoug_debug_info); } ThreadPlanSP Thread::QueueThreadPlanForStepInRange( Index: lldb/source/Symbol/LineEntry.cpp =================================================================== --- lldb/source/Symbol/LineEntry.cpp +++ lldb/source/Symbol/LineEntry.cpp @@ -190,40 +190,62 @@ return FileSpec::Compare(a.file, b.file, true); } -AddressRange LineEntry::GetSameLineContiguousAddressRange() const { +AddressRange LineEntry::GetSameLineContiguousAddressRange( + bool include_inlined_functions) const { // Add each LineEntry's range to complete_line_range until we find a // different file / line number. AddressRange complete_line_range = range; + auto symbol_context_scope = lldb::eSymbolContextLineEntry; + Declaration find_call_site(original_file, line); + if (include_inlined_functions) + symbol_context_scope |= lldb::eSymbolContextBlock; while (true) { SymbolContext next_line_sc; Address range_end(complete_line_range.GetBaseAddress()); range_end.Slide(complete_line_range.GetByteSize()); - range_end.CalculateSymbolContext(&next_line_sc, - lldb::eSymbolContextLineEntry); + range_end.CalculateSymbolContext(&next_line_sc, symbol_context_scope); - if (next_line_sc.line_entry.IsValid() && - next_line_sc.line_entry.range.GetByteSize() > 0 && - original_file == next_line_sc.line_entry.original_file) { + if (!next_line_sc.line_entry.IsValid() || + next_line_sc.line_entry.range.GetByteSize() == 0) + break; + + if (original_file == next_line_sc.line_entry.original_file && + (next_line_sc.line_entry.line == 0 || + line == next_line_sc.line_entry.line)) { // Include any line 0 entries - they indicate that this is compiler- // generated code that does not correspond to user source code. - if (next_line_sc.line_entry.line == 0) { - complete_line_range.SetByteSize( - complete_line_range.GetByteSize() + - next_line_sc.line_entry.range.GetByteSize()); - continue; - } - - if (line == next_line_sc.line_entry.line) { - // next_line_sc is the same file & line as this LineEntry, so extend - // our AddressRange by its size and continue to see if there are more - // LineEntries that we can combine. - complete_line_range.SetByteSize( - complete_line_range.GetByteSize() + - next_line_sc.line_entry.range.GetByteSize()); - continue; - } + // next_line_sc is the same file & line as this LineEntry, so extend + // our AddressRange by its size and continue to see if there are more + // LineEntries that we can combine. However, if there was nothing to + // extend we're done. + if (!complete_line_range.Extend(next_line_sc.line_entry.range)) + break; + continue; + } + + if (include_inlined_functions && next_line_sc.block && + next_line_sc.block->GetContainingInlinedBlock() != nullptr) { + // The next_line_sc might be in a different file if it's an inlined + // function. If this is the case then we still want to expand our line + // range to include them if the inlined function is at the same call site + // as this line entry. The current block could represent a nested inline + // function call so we need to need to check up the block tree to see if + // we find one. + auto inlined_parent_block = + next_line_sc.block->GetContainingInlinedBlockWithCallSite( + find_call_site); + if (!inlined_parent_block) + // We didn't find any parent inlined block with a call site at this line + // entry so this inlined function is probably at another line. + break; + // Extend our AddressRange by the size of the inlined block, but if there + // was nothing to add then we're done. + if (!complete_line_range.Extend(next_line_sc.line_entry.range)) + break; + continue; } + break; } return complete_line_range; Index: lldb/source/Symbol/Declaration.cpp =================================================================== --- lldb/source/Symbol/Declaration.cpp +++ lldb/source/Symbol/Declaration.cpp @@ -83,6 +83,17 @@ return 0; } +int Declaration::CompareFileAndLine(const Declaration &declaration) const { + int result = FileSpec::Compare(this->m_file, declaration.m_file, true); + if (result) + return result; + if (this->m_line < declaration.m_line) + return -1; + else if (this->m_line > declaration.m_line) + return 1; + return 0; +} + bool lldb_private::operator==(const Declaration &lhs, const Declaration &rhs) { #ifdef LLDB_ENABLE_DECLARATION_COLUMNS if (lhs.GetColumn() == rhs.GetColumn()) Index: lldb/source/Symbol/Block.cpp =================================================================== --- lldb/source/Symbol/Block.cpp +++ lldb/source/Symbol/Block.cpp @@ -212,6 +212,21 @@ return nullptr; } +Block *Block::GetContainingInlinedBlockWithCallSite( + const Declaration &find_call_site) { + auto inlined_block = GetContainingInlinedBlock(); + + while (inlined_block) { + auto function_info = inlined_block->GetInlinedFunctionInfo(); + + if (function_info && + function_info->GetCallSite().CompareFileAndLine(find_call_site) == 0) + return inlined_block; + inlined_block = inlined_block->GetInlinedParent(); + } + return nullptr; +} + bool Block::GetRangeContainingOffset(const addr_t offset, Range &range) { const Range *range_ptr = m_ranges.FindEntryThatContains(offset); if (range_ptr) { Index: lldb/source/Core/AddressRange.cpp =================================================================== --- lldb/source/Core/AddressRange.cpp +++ lldb/source/Core/AddressRange.cpp @@ -122,6 +122,24 @@ return false; } +bool AddressRange::Extend(const AddressRange &rhs_range) { + addr_t lhs_end_addr = GetBaseAddress().GetFileAddress() + GetByteSize(); + addr_t rhs_base_addr = rhs_range.GetBaseAddress().GetFileAddress(); + + if (!ContainsFileAddress(rhs_range.GetBaseAddress()) && + lhs_end_addr != rhs_base_addr) + // The ranges don't intercept at all on the right side of this range. + return false; + + addr_t rhs_end_addr = rhs_base_addr + rhs_range.GetByteSize(); + if (lhs_end_addr >= rhs_end_addr) + // The rhs range totally overlaps this one, nothing to add. + return false; + + m_byte_size += rhs_end_addr - lhs_end_addr; + return true; +} + void AddressRange::Clear() { m_base_addr.Clear(); m_byte_size = 0; Index: lldb/include/lldb/Symbol/LineEntry.h =================================================================== --- lldb/include/lldb/Symbol/LineEntry.h +++ lldb/include/lldb/Symbol/LineEntry.h @@ -123,13 +123,21 @@ /// LineEntry (and it will include the range of the following LineEntries /// that match either 32 or 0.) /// + /// When \b include_inlined_functions is \b true inlined functions with + /// a call site at this LineEntry will also be included in the complete + /// range. + /// /// If the initial LineEntry this method is called on is a line #0, only the /// range of contiuous LineEntries with line #0 will be included in the /// complete range. /// + /// @param[in] include_inlined_functions + /// Whether to include inlined functions at the same line are not. + /// /// \return /// The contiguous AddressRange for this source line. - AddressRange GetSameLineContiguousAddressRange() const; + AddressRange GetSameLineContiguousAddressRange( + bool include_inlined_functions = false) const; /// Apply file mappings from target.source-map to the LineEntry's file. /// Index: lldb/include/lldb/Symbol/Declaration.h =================================================================== --- lldb/include/lldb/Symbol/Declaration.h +++ lldb/include/lldb/Symbol/Declaration.h @@ -107,6 +107,20 @@ /// \li 1 if lhs > rhs static int Compare(const Declaration &lhs, const Declaration &rhs); + /// Compare another declaration object by file and line. + /// + /// Compares the specification from \a rhs. If the file specifications are + /// equal, then continue to compare the line. + /// + /// \param[in] declaration + /// The const Declaration object to compare with. + /// + /// \return + /// \li -1 if this < declaration + /// \li 0 if this == declaration + /// \li 1 if this > declaration + int CompareFileAndLine(const Declaration &declaration) const; + /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream Index: lldb/include/lldb/Symbol/Block.h =================================================================== --- lldb/include/lldb/Symbol/Block.h +++ lldb/include/lldb/Symbol/Block.h @@ -185,6 +185,25 @@ /// parent. Block *GetInlinedParent(); + //------------------------------------------------------------------ + /// Get the inlined block at the given call site that contains this block. + /// + /// @param[in] file + /// the file to match at the call site. + /// + /// @param[in] line + /// the line to match at the call site. + /// + /// @return + /// If this block contains inlined function info and is at the call + /// site given by \b file and \b line it will return this block, else + /// the parent blocks will be searched to see if any is at the call + /// site. nullptr will be returned if no block is found at the call + /// site. + //------------------------------------------------------------------ + Block * + GetContainingInlinedBlockWithCallSite(const Declaration &find_call_site); + /// Get the sibling block for this block. /// /// \return Index: lldb/include/lldb/Core/AddressRange.h =================================================================== --- lldb/include/lldb/Core/AddressRange.h +++ lldb/include/lldb/Core/AddressRange.h @@ -163,6 +163,20 @@ /// range, \b false otherwise. bool ContainsLoadAddress(lldb::addr_t load_addr, Target *target) const; + //------------------------------------------------------------------ + /// Extends this range with \b rhs_range if it overlaps this range on the + /// right side. The range overlaps on the right side if the base address + /// of \b rhs_range lies within this range or if it's contiguous on its + /// right side. + /// + /// @param[in] rhs_range + /// The range to extend at the right side. + /// + /// @return + /// Returns \b true if this range was extended, \b false otherwise. + //------------------------------------------------------------------ + bool Extend(const AddressRange &rhs_range); + /// Dump a description of this object to a Stream. /// /// Dump a description of the contents of this object to the supplied stream
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits