summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibDebug
AgeCommit message (Collapse)Author
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-09-10LibDebug: Use the first memory segment of a library as the ELF's baseItamar
When parsing the libraries of the debugee process, we previously assumed that the region that's called `<library name>: .text` was also the base of the ELF file. However, since we started linking with `-z separate-code`, this is no longer the case - our executables have a read-only segment before the .text segment, and that segment is actually at the base of the ELF. This broke inserting breakpoints with the debugger since they were inserted at a wrong offset. To fix that, we now use the address of the first segment in the memory map for the ELF's base address (The memory map is sorted by address).
2021-09-04LibDebug: Use HashMap::ensure() in DebugInfo::prepare_lines()Andreas Kling
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-08-06LibDebug+Everywhere: Make DebugInfo not own the ELF imageAli Mohammad Pur
This is required to avoid copying the image where otherwise a reference would be enough.
2021-08-02LibDebug: Make single-stepping work for x86_64Gunnar Beutner
2021-07-22LibELF+Utilities: Avoid truncating 64-bit valuesGunnar Beutner
This fixes displaying 64-bit addresses in readelf and also fixes showing backtraces from core dumps on x86_64.
2021-07-18LibRegex+Everywhere: Make LibRegex more unicode-awareAli Mohammad Pur
This commit makes LibRegex (mostly) capable of operating on any of the three main string views: - StringView for raw strings - Utf8View for utf-8 encoded strings - Utf32View for raw unicode strings As a result, regexps with unicode strings should be able to properly handle utf-8 and not stop in the middle of a code point. A future commit will update LibJS to use the correct type of string depending on the flags.
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-30AK+Everywhere: Add and use static APIs for LexicalPathMax Wipfli
The LexicalPath instance methods dirname(), basename(), title() and extension() will be changed to return StringView const& in a further commit. Due to this, users creating temporary LexicalPath objects just to call one of those getters will recieve a StringView const& pointing to a possible freed buffer. To avoid this, static methods for those APIs have been added, which will return a String by value to avoid those problems. All cases where temporary LexicalPath objects have been used as described above haven been changed to use the static APIs.
2021-06-27Kernel+Userland: Add x86_64 registers to RegisterState/PtraceRegistersGunnar Beutner
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 DebugInfo::get_source_position_with_inlinesItamar
This function returns the source position of a given address in the program. If that address exists in an inline chain, then it also returns the source positions that are in the chain.
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-06-19LibDebug: Remove unused DebugInfo::for_each_source_positionItamar
2021-06-19LibDebug: Fix typo in DebugInfo::get_source_positionItamar
2021-06-12AK: Rename Vector::append(Vector) => Vector::extend(Vector)Andreas Kling
Let's make it a bit more clear when we're appending the elements from one vector to the end of another vector.
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-23LibDebug: Pre-allocate capacity for the LineProgram::LineInfo vectorAndreas Kling
This shaves another ~15% off of "bt 12" on my machine :^)
2021-05-23LibDebug: Memoize resolved paths in DebugInfo::prepare_lines()Andreas Kling
When loading debug info, we encounter the same filename over and over (since files usually have many lines!) and we were wasting a ton of time re-checking if the filename was part of the Toolchain or libgcc, along with some other checks. This patch makes prepare_lines() significantly faster by memoizing the result of these checks per filename. This makes "bt 12" ~25% faster (from 850ms to 650ms on my machine.) :^)
2021-05-19Everywhere: Add missing includes for <AK/OwnPtr.h>Gunnar Beutner
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to change though. This patch fixes a few build problems that will occur when that change happens.
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-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
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-05-03Userland: Fix 64-bit portability issuesGunnar Beutner
2021-05-01Everywhere: Turn #if *_DEBUG into dbgln_if/if constexprGunnar Beutner
2021-04-29Everywhere: "file name" => "filename"Andreas Kling
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