summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibDebug
AgeCommit message (Collapse)Author
2022-11-06Everywhere: Remove redundant inequality comparison operatorsDaniel Bertalan
C++20 can automatically synthesize `operator!=` from `operator==`, so there is no point in writing such functions by hand if all they do is call through to `operator==`. This fixes a compile error with compilers that implement P2468 (Clang 16 currently). This paper restores the C++17 behavior that if both `T::operator==(U)` and `T::operator!=(U)` exist, `U == T` won't be rewritten in reverse to call `T::operator==(U)`. Removing `!=` operators makes the rewriting possible again. See https://reviews.llvm.org/D134529#3853062
2022-11-01Everywhere: Mark dependencies of most targets as PRIVATETim Schumacher
Otherwise, we end up propagating those dependencies into targets that link against that library, which creates unnecessary link-time dependencies. Also included are changes to readd now missing dependencies to tools that actually need them.
2022-11-01Everywhere: Explicitly link all binaries against the LibC targetTim Schumacher
Even though the toolchain implicitly links against -lc, it does not know where it should get LibC from except for the sysroot. In the case of Clang this causes it to pick up the LibC stub instead, which might be slightly outdated and feature missing symbols. This is currently not an issue that manifests because we pass through the dependency on LibC and other libraries by accident, which causes CMake to link against the LibC target (instead of just the library), and thus points the linker at the build output directory. Since we are looking to fix that in the upcoming commits, let's make sure that everything will still be able to find the proper LibC first.
2022-10-14AK+Userland: Stub out code that isn't currently implemented on AARCH64Gunnar Beutner
Even though this almost certainly wouldn't run properly even if we had a working kernel for AARCH64 this at least lets us build all the userland binaries.
2022-10-04AK+Everywhere: Add AK_COMPILER_{GCC,CLANG} and use them most placesNico Weber
Doesn't use them in libc headers so that those don't have to pull in AK/Platform.h. AK_COMPILER_GCC is set _only_ for gcc, not for clang too. (__GNUC__ is defined in clang builds as well.) Using AK_COMPILER_GCC simplifies things some. AK_COMPILER_CLANG isn't as much of a win, other than that it's consistent with AK_COMPILER_GCC.
2022-09-17LibDebug: Break inclusion cycle through many forward-declarationsBen Wiederhake
2022-09-17Everywhere: Fix badly-formatted includesBen Wiederhake
2022-07-27Everywhere: Make the codebase more architecture awareUndefine
2022-07-12Everywhere: Replace single-char StringView op. arguments with charssin-ack
This prevents us from needing a sv suffix, and potentially reduces the need to run generic code for a single character (as contains, starts_with, ends_with etc. for a char will be just a length and equality check). No functional changes.
2022-07-12Everywhere: Add sv suffix to strings relying on StringView(char const*)sin-ack
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
2022-07-03LibDebug: Make sure current_breakpoint has value before usageMarcus Nilsson
Previously this caused a crash when no breakpoint was active since we tried to get value().address before the has_value() check.
2022-04-01Everywhere: Run clang-formatIdan Horowitz
2022-03-10Libraries: Use default constructors/destructors in LibDebugLenny Maiorani
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#cother-other-default-operation-rules "The compiler is more likely to get the default semantics right and you cannot implement these functions better than the compiler."
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-22LibDebug: Add optional setup_child() callback to debuggerItamar
If set, this callback gets called right after fork() in the child process. It can be used by the caller if it wants to perform some logic in the child process before it starts executing the debuggee program.
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-23LibCore+AK: Move MappedFile from AK to LibCoreAndreas Kling
MappedFile is strictly a userspace thing, so it doesn't belong in AK (which is supposed to be user/kernel agnostic.)
2021-11-20HackStudio: Use ProcessInspector instead of DebugSession where possibleItamar
2021-11-20LibDebug: Add ProcessInspector base classItamar
ProcessInspector is an abstract base class for an object that can inspect the address space of a process. Concrete sub classes need to implement methods for peeking & poking memory and walking the loaded libraries. It is currently only implemented by DebugSession.
2021-11-17AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)Andreas Kling
Also add slightly richer parse errors now that we can include a string literal with returned errors. This will allow us to use TRY() when working with JSON data.
2021-11-11Everywhere: Pass AK::StringView by valueAndreas Kling
2021-11-10Everywhere: Move shared library checks into a common functionTim Schumacher
While we're at it, unify the various different conditions that are scattered accross the codebase.
2021-10-17LibDebug: Enable parsing `libgcc_s.so`Daniel Bertalan
Now that our DWARF 5 support is nearly feature-complete, there is no reason anymore to special-case this library, as we can process it just fine.
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-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.