summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibDebug/Dwarf
AgeCommit message (Collapse)Author
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-01-28LibDebug+LibCoredump: Replace remaining reinterpret_casts and C castsAli Mohammad Pur
You misused your toys and I'm now taking them away, reflect on what you did wrong for a bit.
2022-01-28LibDebug+LibCoredump: Use ByteReader to do unaligned readsAli Mohammad Pur
The previous solution of "lol whats a UB" was not nice and tripped over itself when it was run under UBSAN, fix this by doing explicit byte-by-byte reads where needed.
2022-01-28LibDebug+Everywhere: Avoid void* -> FlatPtr -> void* danceAli Mohammad Pur
And limit the `void*` to the functions that interface the system (i.e. ptrace wrappers). This generally makes the code less riddled with casts.
2022-01-07Everywhere: Fix spelling mistakesmjz19910
2022-01-07Everywhere: Fix many spelling errorsmjz19910
2021-12-15LibDebug: Handle DWARF 4 address rangesDaniel Bertalan
The format of the address range section is different between DWARF version 4 and version 5. This meant that we parsed programs compiled with `-gdwarf-4` incorrectly.
2021-12-15LibDebug: Fix truncation in ExtendedOpcodes::SetDiscriminatorDaniel Bertalan
The parameter of this operator is an unsigned LEB128 integer, so it can be more than 1 byte in length. If we only read 1 byte, we might mess up the offsets for the instructions following it.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-10-17LibDebug: Don't create compilation units for embedded resourcesDaniel Bertalan
Our implementation (naively) assumes that there is a one-to-one correspondence between compilation units and line programs, and that their orders are identical. This is not the case for embedded resources, as Clang only creates line programs for it, but not compilation units. This mismatch caused an assertion failure, which made generating backtraces for GUI applications impossible. This commit introduces a hack that skips creating CompilationUnit objects for LinePrograms that come from embedded resources.
2021-10-17LibDebug: Make use of the newly supported data formsDaniel Bertalan
With this change, our DWARF 5 support is nearly feature-complete.
2021-10-17LibDebug: Support `DW_FORM_data16`Daniel Bertalan
Clang emits this form at all debug levels.
2021-10-17LibDebug: Support `addrx*`, `strx*` and `rnglistx` formsDaniel Bertalan
These forms were introduced in DWARF5, and have a fair deal of advantages over the more traditional encodings: they reduce the size of the binary and the number of relocations. GCC does not emit these with `-g1` by default, but Clang does at all debug levels.
2021-10-17LibDebug: Don't expose AttributeValue internals, use getters insteadDaniel Bertalan
This will be needed when we add `DW_FORM_strx*` and `DW_FORM_addrx*` support, which requires us to fetch `DW_AT_str_offsets_base` and `DW_AT_addr_base` attributes from the parent compilation unit. This can't be done as we read the values, because it would create infinite recursion (as we might try to parse the compilation unit's `DW_FORM_strx*` encoded name before we get to the attribute). Having getters ensures that we will perform lookups if they are needed.
2021-09-28LibDebug: Add missing `break` in AddressRanges::for_each_range()Andreas Kling
2021-09-28LibDebug: Use DW_AT_ranges to get address ranges of DIEsItamar
Previously, we only supported DIEs with a contiguous address ranges and ignored ones with a non-contiguous set of ranges. We now check if a DIE has the DW_AT_ranges attribute, and if it does we parse its range list. This improves the quality of our backtraces - we previously missed many inlined function calls because their DIEs had non-contigues address ranges.
2021-09-28LibDebug: Support parsing non-contiguous DWARF address rangesItamar
This adds support for parsing DWARF "range lists", which are identified by the DW_AT_ranges form. They contain code addresses for DIEs whose location is not contiguous.
2021-09-28LibDebug: Add Dwarf::CompilationUnit::base_address()Itamar
The base address of the compilation unit is used in some range lists entry types.
2021-09-18LibDebug: Dont copy an AbbreviationEntry every time we retrieve a valueBrian Gianforcaro
These API's are used in a variety of ways when building the die cache. Each AbbreviationEntry has vector and other members, so avoid copying it at all costs.
2021-09-18LibDebug: Avoid short lived allocations in DIE::for_each_childBrian Gianforcaro
This algorithm is both iterative and recursive, so allocating on every recursion, or when iterating each child is extremely costly. Instead allow the on stack DIE to be re-initialized so it can be reused.
2021-08-08LibDebug: Store 64-bit numbers in AttributeValueDaniel Bertalan
This helps us avoid weird truncation issues and fixes a bug on Clang builds where truncation while reading caused the DIE offsets following large LEB128 numbers to be incorrect. This removes the need for the separate `LongUnsignedNumber` type.
2021-08-08LibDebug: Keep track of 'prologue end'Daniel Bertalan
This LineProgram instruction is emitted by Clang. Although we currently have no use for it (it's mostly a debugger feature), we need to handle this opcode, as otherwise CrashReporter wouldn't work.
2021-07-13LibDebug: Implement symbolication for x86_64Gunnar Beutner
2021-07-13LibDebug: Fix spelling mistakeGunnar Beutner
2021-07-08Everywhere: Add braces to aggregate initializersDaniel Bertalan
This fixes a couple of warnings emitted by Clang.
2021-07-08Everywhere: Remove unused local variables and lambda capturesDaniel Bertalan
2021-06-24Userland: Add more TODO()s for arch-specific codeGunnar Beutner
This enables building more of the userspace applications for x86_64.
2021-06-19LibDebug: Convert LibDebug to east-const styleItamar
2021-06-19LibDebug: Add DwarfInfo::get_cached_die_at_offsetItamar
This function returns a DIE object from the cache with the given offset in the debug_info section.
2021-06-19LibDebug:: Add DwarfInfo::get_die_at_addressItamar
This function returns the die object whose address range intersects with the given address. This function will also construct the DIE cache, if it hasn't been constructed yet.
2021-06-19LibDebug: Add caches of DIE objects to DwarfInfoItamar
There is one cache that indexes DIE objects by the start address of their range, and another cache that indexes by their offset in the debug_info section. Both caches are implemented with RedBlackTree, and are optional - they will only be populated if 'build_cached_dies' is invoked.
2021-06-19LibDebug: Store optional parent_offset in Dwarf::DIE objectsItamar
In the current implementation, only DIE objects that are created via DIE::for_each_child() will have parent offsets. DIE objects that are created with CompilationUnit::get_die_at_offset() do not currently store a parent offset. We may improve this in the future, but this is enough for what we currently need.
2021-06-19LibDebug: Add AttributeForm field to Dwarf::AttributeValueItamar
In some contexts, it's helpful to also know the "Attribute Form", in addition to the "Attribute Type". An example for such context is the interpretation of the "DW_AT_high_pc" attribute, which has different meaning if the form is an address or a constant.
2021-06-19LibDebug: Add LineProgram::get_directory_and_file(size_t)Itamar
This function returns the directory path & filename for a given file index.
2021-06-19LibDebug: Move Dwarf::LineProgram into Dwarf::CompilationUnitItamar
Previously, the LineProgram objects were short-lived, and only created inside DebugInfo::prepare_lines() to create a vector of sorted LineInfo data. However, Dwarf::LineProgram also contains other useful data, such as index-to-string mapping of source directories and filenames. This commit makes each Dwarf::CompilationUnit own its Dwarf::LineProgram. DebugInfo::prepare_lines() then iterates over the compilation units to prepare its sorted vector of lines.
2021-06-19LibDebug: Store LibDebug objects on the heap & make them non-copyableItamar
This fixes an issue were some LibDebug objects (for example, Dwarf::CompilationUnit) held a reference to their parent Dwarf::DwarfInfo object, which was constructed on the stack and later moved to the heap.
2021-06-19LibDebug: Move Dwarf::AttributeValue to a separate fileItamar
2021-06-19LibDebug: Move get_die_at_offset to Dwarf::CompilationUnitItamar
2021-05-31LibELF + LibDebug: Reduce allocations during symbolificationBrian Gianforcaro
Avoid promotion of static strings to AK::String, instead use AK::StringView and operator ""sv, to force string view's instead which avoids allocation of String. This code path isn't hot enough that it makes a huge difference, but every bit counts.
2021-05-16Userland: Add missing #includesGunnar Beutner
These two header files relied on transitive header includes.
2021-05-15LibDebug: Avoid unnecessary String allocation in append_to_line_info()Andreas Kling
This code path is very hot, and since we're seeing a lot of the same strings repeatedly (and they're heading into a FlyString for storage) let's construct those using FlyString(StringView) to avoid temporary String objects.
2021-05-15Everywhere: Add a blank line after copyright header where missingLinus Groh
2021-05-15LibELF: Remove sketchy use of "undefined" ELF::Image::SectionAndreas Kling
We were using ELF::Image::section(0) to indicate the "undefined" section, when what we really wanted was just Optional<Section>. So let's use Optional instead. :^)
2021-05-03LibDebug: add DW_LNS_set_basic_block supportspigwitmer
This adds support for the basic_block register to the Dwarf line number state machine.
2021-04-29LibDebug: Implement support for AttributeDataForm::ImplicitConstGunnar Beutner
While symbolicating a crash dump for UserspaceEmulator I came across another data form we didn't support. ImplicitConst encodes a LEB128 value in the abbreviation record rather than - like all other values - in the .debug_info section.
2021-04-28LibDebug: Implement support for AttributeDataForm::{UData,LineStrP}Gunnar Beutner
2021-04-28LibDebug: Implement support for DWARF 5 line programsGunnar Beutner
2021-04-28LibDebug: Implement support for DWARF 5 compilation unit headersGunnar Beutner
2021-04-28LibDebug: Move UnitHeader32 out of the LineProgram classGunnar Beutner
2021-04-28LibDebug: Move get_attribute_value to the DwarfInfo classGunnar Beutner