Commit graph

48 commits

Author SHA1 Message Date
Andreas Kling
395313039d LibDebug: Use FlyString for file paths
The same file path occurs over and over in debug info, so let's store
them as FlyString to ensure we only have one of each in memory.
2020-11-16 09:10:49 +01:00
Andreas Kling
4eb3cf68b7 LibDebug: Avoid creating the String("serenity/") a bazillion times
We were creating and destroying this string twice for every LineInfo.
That's a lot of malloc() and free() during UE startup.
2020-11-16 09:10:49 +01:00
Andreas Kling
42bc518d70 LibDebug: Oops, file:line info should have '/' between directory & file 2020-11-15 15:12:13 +01:00
Andreas Kling
485d28298a LibDebug: Use StringBuilder in append_to_line_info()
This avoids a lot of temporary allocations and speeds up launching
UE on a large executable by quite a bit.
2020-11-15 13:12:07 +01:00
Andreas Kling
744af11991 LibDebug: Use move semantics when populating abbreviations map 2020-11-08 23:05:34 +01:00
Andreas Kling
c66434e085 LibDebug: Avoid copying AttributeSpecifications when iterating them 2020-11-08 22:52:22 +01:00
Andreas Kling
fc948ea3df LibDebug: Shrink some of the high-volume data structures
We quickly allocate a *ton* of these when loading large executables.
2020-11-08 22:39:39 +01:00
Andreas Kling
957e7d10d4 LibDebug: Handle the "set ISA" standard opcode
I don't know what to do with this information, but let's at least skip
over the opcode instead of asserting.
2020-11-08 01:15:02 +01:00
Andreas Kling
0f84e246b2 LibDebug: Handle AttributeDataForm::SData (DW_FORM_sdata)
This is a LEB128-encoded signed constant.
2020-11-08 01:15:02 +01:00
Linus Groh
bcfc6f0c57 Everywhere: Fix more typos 2020-10-03 12:36:49 +02:00
Nico Weber
ef1b21004f Everywhere: Fix typos
Mostly in comments, but sprintf() now prints "August" instead of
"Auguest" so that's something.
2020-10-02 16:03:17 +02:00
Itamar
8ce641cefc LibDebug: Add ability to detach from debuggee 2020-09-26 17:18:21 +02:00
Ben Wiederhake
0d79e57c4d Kernel: Fix various forward declarations
I decided to modify MappedROM.h because all other entried in Forward.h
are also classes, and this is visually more pleasing.

Other than that, it just doesn't make any difference which way we resolve
the conflicts.
2020-09-12 13:46:15 +02:00
asynts
b68a873067 AK: Move memory streams into their own header. 2020-09-01 17:25:26 +02:00
asynts
9ce4475907 Streams: Distinguish recoverable and fatal errors. 2020-09-01 17:25:26 +02:00
Luke
694b86a4bf LibDebug: Move everything into the "Debug" namespace 2020-08-25 09:46:06 +02:00
Itamar
5c494eefd6 HackStudio: Implement "Step Over" debugging action
The "Step Over" action continues execution without stepping into
instructions in subsequent function calls.
2020-08-22 09:48:59 +02:00
Itamar
99788e6b32 HackStudio: Implement "Step Out" debugging action
The "Step Out" action continues execution until the current function
returns.

Also, LibDebug/StackFrameUtils was introduced to eliminate the
duplication of stack frame inspection logic between the "Step Out"
action and the BacktraceModel.
2020-08-22 09:48:59 +02:00
Andreas Kling
ba856c7ebe LibDebug: Don't include <Libraries/...> 2020-08-17 18:05:35 +02:00
asynts
fff581cd72 AK: Rename span() to bytes() when appropriate.
I originally defined the bytes() method for the String class, because it
made it obvious that it's a span of bytes instead of span of characters.

This commit makes this more consistent by defining a bytes() method when
the type of the span is known to be u8.

Additionaly, the cast operator to Bytes is overloaded for ByteBuffer and
such.
2020-08-15 21:21:18 +02:00
Itamar
dca6a77669 LibDebug: Fix DebugSession teardown
Previously, we were trying to remove the breakpoints we set on the
debugee even if it has already exited, which caused PT_POKE to fail.
2020-08-15 15:06:35 +02:00
Itamar
7eac9fe10e HackStudio: Support debugging library code
We can now step into library code in the debugger.

Since we now need the whole source code of our libraries
(and not just the headers), we clone the whole serenity git repo into
/usr/share/serenity.
2020-08-15 15:06:35 +02:00
Itamar
b5f6a1a9e8 LibDebug: Assert that we can read the executable of the debugee 2020-08-15 15:06:35 +02:00
Andreas Kling
4c44c96bc6 LibDebug: Unbreak LineProgram::parse_source_directories()
This regressed with ac9f6fd1f8 where
we switched to using InputMemoryStream.
2020-08-06 11:35:40 +02:00
Andreas Kling
078969b92f LibDebug: Fix bitrotted DWARF_DEBUG code 2020-08-06 11:32:17 +02:00
asynts
ac9f6fd1f8 LibDebug: Use InputMemoryStream instead of BufferStream.
This removes another call to ByteBuffer::wrap(const void*, size_t).
2020-08-06 10:33:16 +02:00
Brian Gianforcaro
1f7c61b15f LibDebug: Disable and cleanup DebugSession breakpoints on destruction
Breakpoints need to be disabled before we detach from the debugee.

I noticed this while looking into the fact that if you continue
executing a program in sdb (/bin/ls) where you had previously
set a breakpoint, it would crash on sdb exit once the debugee died
with an assert on HashMap destruction where we were iterating
while clearing is set. This change also happens to fix this assert.
2020-08-02 19:26:58 +02:00
Itamar
240eb3242a LibDebug: Add support for the various DW_FORM_block types
This fixes #2885.
2020-07-27 00:06:47 +02:00
Andreas Kling
4a572df465 LibDebug: Put DWARF debug logging spam behind DEBUG_SPAM
With this logging enabled, it takes way too long to load debug info.
2020-07-21 19:08:01 +02:00
FalseHonesty
870bcaeef6 LibDebug: Add all Dwarf v5 attributes, tags, and form enum values 2020-06-03 08:12:50 +02:00
FalseHonesty
a4f23429aa LibDebug: Add support for enum value types
Additionally, we will parse and expose the types of variables
if they are complex, like Enums or Structs. Variables of an enum
type are special in that they do not store all the members of said
enum in their own VariableInfo like Structs do, rather, all of the
values are stored in the VariableInfo for the Enum.
2020-06-03 08:12:50 +02:00
Emanuele Torre
937d0be762 Meta: Add a script check the presence of "#pragma once" in header files
.. and make travis run it.

I renamed check-license-headers.sh to check-style.sh and expanded it so
that it now also checks for the presence of "#pragma once" in .h files.

It also checks the presence of a (single) blank line above and below the
"#pragma once" line.

I also added "#pragma once" to all the files that need it: even the ones
we are not check.
I also added/removed blank lines in order to make the script not fail.

I also ran clang-format on the files I modified.
2020-05-29 07:59:45 +02:00
Itamar
f9d62fd5e5 LibDebug: Make sure to not single step the program twice
After hitting a breakpoint, we single step the program to execute the
instruction we breaked on and re-enable the breakpoint.
We also single step the program when the user of LibDebug returned a
DebugDecision::SingleStep.

Previously, if we hit a breakpoint and then were asked to to a
DebugDecision::SingleStep, we would single step twice.

This bug can actually crash programs, because it might cause us to
skip over a patched INT3 instruction in the second single-step.

Interestingely enough, this bug manifested as functrace crashing
certain programs: after hitting a breakpoint on a CALL instruction,
functrace single steps the program to see where the CALL jumps to
(yes, this can be optimized :D). functrace crashed when a CALL
instruction jumps to another CALL, because it inserts breakpoints on CALL
instructions, and so the INT3 in the 2nd CALL was skipped over, and we
executed garbage :).

This commit fixes this by making sure not to single-step twice.
2020-05-24 10:42:21 +02:00
Itamar
2686957836 LibDebug: Tolerate missing debug information
We previously crashed when programs were missing certain debug information.
2020-05-24 10:42:21 +02:00
Andreas Kling
dd924b730a Kernel+LibC: Fix various build issues introduced by ssize_t
Now that ssize_t is derived from size_t, we have to
2020-05-23 15:27:33 +02:00
Andreas Kling
250c3b363d Revert "Build: Include headers from LibC, LibM, and LibPthread with -isystem"
This reverts commit c1eb744ff0.
2020-05-20 16:24:26 +02:00
Andrew Kaster
c1eb744ff0 Build: Include headers from LibC, LibM, and LibPthread with -isystem
Make sure that userspace is always referencing "system" headers in a way
that would build on target :). This means removing the explicit
include_directories of Libraries/LibC in favor of having it export its
headers as SYSTEM. Also remove a redundant include_directories of
Libraries in the 'serenity build' part of the build script. It's already
set at the top.

This causes issues for the Kernel, and for crt0.o. These special cases
are handled individually.
2020-05-20 08:37:50 +02:00
Sergey Bugaev
450a2a0f9c Build: Switch to CMake :^)
Closes https://github.com/SerenityOS/serenity/issues/2080
2020-05-14 20:15:18 +02:00
Itamar
b28ca9fad1 LibDebug: Add support for creating VariableInfo for paramters 2020-05-09 23:41:08 +02:00
Itamar
1fb62df02a HackStudio: Show a backtrace in the debug information tab 2020-05-09 23:41:08 +02:00
Itamar
14ee090f25 HackStudio: Support variable inspection in nested scopes 2020-05-08 12:16:10 +02:00
Itamar
5fd64045b1 LibDebug: Miscellaneous fixes from #2097 2020-05-07 23:32:11 +02:00
Itamar
c5eb20d0cc LibDebug: Parse DWARF information entries
We can now iterate the tree structure of the DIEs, access attribute
values and parse some very basic DWARF expressions.
2020-05-05 11:01:36 +02:00
Itamar
009b4ea3f4 LibDebug: Add remove_breakpoint
Also, change the interface of all breakpoint management functions to
only take the address of the breakpoint as an argument.
2020-04-25 13:16:46 +02:00
Itamar
e35219b5ce Debugger: Add source-level operations
- Print current source location, if available
- Add a breakpoint at a source location
- "sl" command - step to the next line in source
2020-04-20 17:25:50 +02:00
Itamar
8a886e0e96 LibDebug: Parse line number information from DWARF format
DWARF line number information, if generated, is stored  in the
.debug_line section of an object file.

The information is encoded as instructions for a VM that is defined in
the DWARF specification.
By executing these instructions, we can extract the encoded line number
information.
2020-04-20 17:25:50 +02:00
Itamar
af338a34c0 LibDebug: Add ContinueBreakAtSyscall decision
When the user of the DebugSession uses this decision, the debugged
program will be continued until it is either stopped by a singal (e.g
as a reuslt of a breakpoint), or enters a syscall.
2020-04-16 11:17:33 +02:00
Itamar
f4418361c4 Userland: Add "functrace" utility
functrace traces the function calls a program makes.
It's like strace, but for userspace.

It works by using Debugging functionality to insert breakpoints
at call&ret instructions.
2020-04-16 11:17:33 +02:00