170 Commits
Author SHA1 Message Date
Sönke Holz db7686eaf1 LibDebug: Don't continue the debuggee before detaching
Since 0b7dc6869e, all ptrace operations except PT_TRACE_ME and
PT_ATTACH are forbidden unless the tracee is stopped. This includes
PT_DETACH.
2026-06-22 01:35:57 +02:00
Andrew Kaster ab64b7d352 LibDebug: Clean up Debug session includes and ifdefs
The changes to PtraceRegisters to add generic setters and getters for
instruction pointer and frame pointer were not propogated to this
class.
2026-06-14 13:33:54 -04:00
Andrew Kaster dfa6047882 LibDebug: Convert watchpoint cleanup to use AK stack walking method
This removes non-portable frame pointer walking from the debug session,
and stores the stashed frame pointer in WachPoints as a FlatPtr rather
than a u32, which hasn't ever been correct on 64-bit platforms.

More work is needed to actually make hardware watchpoints work on 64-bit
platforms, as the existing code only works on 32-bit x86 and references
that architecture's debug control register.
2026-06-14 13:33:54 -04:00
NoobZang 2a417fc55f Kernel/aarch64+LibDebug: Implement full software step support
Add a PT_SINGLESTEP request to the ptrace API and implement its
handing logic in the kernel.

Update the debugger to call ptrace(PT_SINGLESTEP) instead of directly
poking registers.

Ensure MDSCR_EL1.SS is properly cleared and then reloaded when a
software step occurs.
2025-07-13 13:16:44 -04:00
NoobZang 9b2a0210e4 LibDebug: Add software breakpoint instruction insertion for aarch64 2025-07-13 13:16:44 -04:00
Sönke Holz 8afc0f72d8 LibDebug: Resolve some TODO_RISCV64s 2025-02-13 20:15:45 +01:00
kleines Filmröllchen a3077203fe AK: Don't implicitly convert Optional<T&> to Optional<T>
C++ will jovially select the implicit conversion operator, even if it's
complete bogus, such as for unknown-size types or non-destructible
types. Therefore, all such conversions (which incur a copy) must
(unfortunately) be explicit so that non-copyable types continue to work.
2024-09-14 13:30:27 +02:00
Sönke Holz 3059ac71f3 HackStudio: Use AK::unwind_stack_from_frame_pointer 2024-05-14 14:02:06 -06:00
Sönke Holz 116f82d21a LibDebug: Don't assume compilation unit index == line program index
Instead, use the `DW_AT_stmt_list` attribute of the compilation unit
entry to determine the corresponding line program.
2024-05-07 16:57:09 -06:00
Sönke Holz 14ae04075e LibDebug: Make LineProgram::create take DwarfInfo as a const reference
The m_dwarf_info is never mutated, so it can be const.
2024-05-07 16:57:09 -06:00
Sönke Holz bc7d067821 LibDebug: Remove m_stream member from LineProgram
The stream passed to LineProgram::create is a temporary, so rather than
keeping an (unused) dangling reference, pass this stream explicitly to
all functions used by LineProgram::create.
2024-05-07 16:57:09 -06:00
Dan Klishch 7b88363490 Meta+Userland: Make LibELF a proper library on Serenity
Dynamically loaded LibC doesn't need LibELF definitions, so let's not
put them there.
2024-04-26 19:08:13 -06:00
Nico Weber 24a469f521 Everywhere: Prefer {:#x} over 0x{:x} in format strings
The former automatically adapts the prefix to binary and octal
output, and is what we already use in the majority of cases.

Patch generated by:

    rg -l '0x\{' | xargs sed -i '' -e 's/0x{:/{:#/'

I ran it 4 times (until it stopped changing things) since each
invocation only converted one instance per line.

No behavior change.
2024-02-21 17:54:38 +01:00
Ali Mohammad Pur 5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
Sönke Holz 6824d2a788 Userland+Tests: Add initial riscv64 support 2023-11-10 10:30:08 -07:00
0GreenClover0 eeddbb6fa6 HackStudio: Don't crash on null progress bar update function 2023-11-06 10:02:16 +01:00
Ali Mohammad Pur aeee98b3a1 AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all
its users with one of the following:
- A normal, empty DeprecatedString
- Optional<DeprecatedString>

Note that null states of DeprecatedFlyString/StringView/etc are *not*
affected by this commit. However, DeprecatedString::empty() is now
considered equal to a null StringView.
2023-10-13 18:33:21 +03:30
kleines Filmröllchen 062e0db46c LibCore: Make MappedFile OwnPtr-based
Since it will become a stream in a little bit, it should behave like all
non-trivial stream classes, who are not primarily intended to have
shared ownership to make closing behavior more predictable. Across all
uses of MappedFile, there is only one use case of shared mapped files in
LibVideo, which now uses the thin SharedMappedFile wrapper.
2023-09-27 03:22:56 +02:00
Andrew Kaster aa0ed4ab4e LibDebug: Keep track of the SetEpilogueBegin LineProgram OpCode
This prevents a crash with clang 16.
2023-06-27 12:40:38 +02:00
Ben Wiederhake 9474e0cd94 LibDebug: Prefer File::read_until_eof over DeprecatedFile 2023-05-19 23:31:20 +02:00
MacDue cf79df0edb LibDebug: Stub out LocListX and remove stub expression evaluator
The expression evaluator is dead code that does nothing but crash on
all paths, as no opcodes are implemented.

Stubbing out the LocListX form fixes a crash while reading DWARF 5
debug data that contains location lists. These are just a new way
to store location expressions, and since we never implemented
expressions, we can just ignore these too.

As far as I can tell this is enough for DWARF 5 to work for us (since
we mainly just use the line tables).
2023-05-14 09:21:08 +02:00
Ben Wiederhake c5d3de3f7d LibDebug: Propagate errors around LineProgram
Found while playing Fixme-Roulette.
2023-05-13 07:54:34 +02:00
Daniel Bertalan ed13b7beb6 LibDebug: Support DW_FORM_ref_udata
This is used alongside/instead of the fixed-length DW_FORM_ref4 form
when compiling for AArch64.
2023-04-23 14:30:59 +02:00
Ben Wiederhake 560133a0c6 Everywhere: Remove unused DeprecatedString includes 2023-04-09 22:00:54 +02:00
Cameron Youell 1d24f394c6 Everywhere: Use LibFileSystem where trivial 2023-03-21 19:03:21 +00:00
Tim Schumacher a3f73e7d85 AK: Rename Stream::read_entire_buffer to Stream::read_until_filled
No functional changes.
2023-03-13 15:16:20 +00:00
Andreas Kling 21db2b7b90 Everywhere: Remove NonnullOwnPtr.h includes 2023-03-06 23:46:35 +01:00
Andreas Kling 359d6e7b0b Everywhere: Stop using NonnullOwnPtrVector
Same as NonnullRefPtrVector: weird semantics, questionable benefits.
2023-03-06 23:46:35 +01:00
Itamar 47f5a3ea9a HackStudio: Add 'pause debuggee' button
This button sends a SIGSTOP to the debugged process, which pauses it.
The debuggee can be resumed with the 'continue' button.
2023-02-24 19:09:27 +01:00
Itamar 6e5b1f5819 HackStudio: Add progress bar to Debugger initialization
During Debugger initialization, most of the time is spent creating
DebugInfo objects for the libraries that the program has loaded.
2023-02-24 19:09:27 +01:00
Itamar eb16513165 LibDebug: Remove file path fixup for library sources
It's no longer needed as the file paths we get for libraries in the
current build process is canonical.
2023-02-24 19:09:27 +01:00
Tim Schumacher 43f98ac6e1 Everywhere: Remove the AK:: qualifier from Stream usages 2023-02-13 00:50:07 +00:00
Tim Schumacher 874c7bba28 LibCore: Remove Stream.h 2023-02-13 00:50:07 +00:00
Tim Schumacher d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Itamar 26250fe14a LibDebug: Add static attach() function
This function is similar to exec_and_attach(), but instead of spawning
a new process and debugging it, it attaches to an existing process.
2023-02-08 19:23:07 +01:00
Tim Schumacher 220fbcaa7e AK: Remove the fallible constructor from FixedMemoryStream 2023-02-08 17:44:32 +00:00
Tim Schumacher 47531a42a9 AK: Make LEB128 decoding work with read_value 2023-02-04 18:41:27 -07:00
Tim Schumacher 787f4d639a AK: Port LEB128 to the new AK::Stream 2023-02-04 18:41:27 -07:00
Tim Schumacher 093cf428a3 AK: Move memory streams from LibCore 2023-01-29 19:16:44 -07:00
Tim Schumacher 8464da1439 AK: Move Stream and SeekableStream from LibCore
`Stream` will be qualified as `AK::Stream` until we remove the
`Core::Stream` namespace. `IODevice` now reuses the `SeekMode` that is
defined by `SeekableStream`, since defining its own would require us to
qualify it with `AK::SeekMode` everywhere.
2023-01-29 19:16:44 -07:00
Tim Schumacher 89a4a9c7a7 LibDebug: Correct a (un-)signed mixup in the DWARF abbreviations map
I accidentally replaced this with `read_unsigned` in
908b88db34, now it's correct again.
2023-01-29 18:21:11 +00:00
Sam Atkins 04b3908172 LibDebug: Replace uses of JsonObject::get_deprecated()/get_ptr() 2023-01-26 09:57:14 -05:00
Tim Schumacher 448b187782 LibDebug: Pass read_from_stream calls through read_value instead 2023-01-24 12:47:39 +00:00
Tim Schumacher a9eea2e0c4 LibDebug: Use Core::Stream to read opcodes for expression evaluation 2023-01-22 19:12:26 +01:00
Tim Schumacher 91505d8cf3 LibDebug: Port the rest of DWARF parsing to Core::Stream 2023-01-22 19:12:26 +01:00
Tim Schumacher e62269650a LibDebug: Propagate errors throughout DWARF parsing
Splitting this into a separate commit was an afterthought, so this does
not yet feature any fallible operations.
2023-01-22 19:12:26 +01:00
Tim Schumacher e235c42e4d LibDebug: Parse DWARF address ranges using Core::Stream 2023-01-22 19:12:26 +01:00
Tim Schumacher 908b88db34 LibDebug: Use Core::Stream to read the DWARF abbreviations map 2023-01-22 19:12:26 +01:00
Tim Schumacher e65767c2e7 LibDebug: Identify embedded resources with a preceding dot 2023-01-19 11:29:29 +01:00
Tim Schumacher edd4913573 LibDebug: Factor out the "looks like embedded resource" condition 2023-01-19 11:29:29 +01:00