Commit Graph

32 Commits

Author SHA1 Message Date
asynts
9efc69a6e2 Debugger: Use format instead of printf.
There was one bogus printf in a signal handler, I just left it there.
2020-10-05 14:19:24 +02:00
Linus Groh
bcfc6f0c57 Everywhere: Fix more typos 2020-10-03 12:36:49 +02:00
Luke
694b86a4bf LibDebug: Move everything into the "Debug" namespace 2020-08-25 09:46:06 +02:00
Ben Wiederhake
ef9a3b8e46 Applications: Mark compilation-unit-only functions as static
This enables a nice warning in case a function becomes dead code.
2020-08-12 20:40:59 +02:00
Andreas Kling
7f394435da Debugger: Add some pledges required by LibLine
These are a bit unfortunate. We should reorganize LibLine so it sets
up the RPC server earlier, then we can drop these pledges later on.
2020-07-12 01:36:45 +02:00
Andreas Kling
fdfda6dec2 AK: Make string-to-number conversion helpers return Optional
Get rid of the weird old signature:

- int StringType::to_int(bool& ok) const

And replace it with sensible new signature:

- Optional<int> StringType::to_int() const
2020-06-12 21:28:55 +02:00
AnotherTest
70a213a6ec LibLine: Use Core::EventLoop for outer read loop
This commit changes LibLine's internal structure to work in an event
loop, and as a result, also switches it to being a Core::Object.
2020-05-27 11:13:02 +02:00
Sergey Bugaev
4139838a93 Userland et al: Pledge sigaction when needed
* In some cases, we can first call sigaction()/signal(), then *not* pledge
  sigaction.
* In other cases, we pledge sigaction at first, call sigaction()/signal()
  second, then pledge again, this time without sigaction.
* In yet other cases, we keep the sigaction pledge. I suppose these could all be
  migrated to drop it or not pledge it at all, if somebody is interested in
  doing that.
2020-05-26 14:35:10 +02:00
AnotherTest
bc9013f706 LibLine: Change get_line to return a Result<String, Error>
This fixes a bunch of FIXME's in LibLine.
Also handles the case where read() would read zero bytes in vt_dsr() and
effectively block forever by erroring out.

Fixes #2370
2020-05-25 21:36:51 +02:00
Itamar
bedce69b23 Debugger: Use Core::ArgsParser 2020-05-24 10:42:21 +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
Ben Wiederhake
da837fe46e Meta: Fix Makefile permissions (not executable) 2020-05-03 14:24:08 +02:00
Andreas Kling
a40aa80df1 Debugger: Add missing newline in "help" output 2020-04-30 22:15:16 +02:00
AnotherTest
9473733d7a LibLine: Handle initialize() internally
This patch makes initialize() transparent to the users, but exposes it
publicly, as the users might need a copy of the default termios (i.e.
Shell)
2020-04-28 23:29:07 +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
1642fdf82d Debugger: Use LibLine 2020-04-16 12:22:59 +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
Itamar
109c24ae97 Debugger: Repeat previous command when an empty command is entered 2020-04-13 23:20:59 +02:00
Itamar
312559b131 Debugger: Add single step command
Also, this commit does some refactoring to the debugging loop logic.
2020-04-13 23:20:59 +02:00
Itamar
c3faaeb9b9 Debugger: Breakpoints now persist after being tripped
Previously, a breakpoint was removed after it was tripped.

After a breakpoint trips, we have to undo the 'int3' patch
from the instruction in order to continue the exceution.

To make a breakpoint persist, we switch to "single step" mode,
which stops the execution after a single instruction, and then we
insert the breakpoint at the previous instruction.

There is also some code that deals with an edge case where there are
breakpoints in two consecutive instructions.
2020-04-13 23:20:59 +02:00
Itamar
1191ab9500 Debugger: Print where we're stopped at
For some reaason, some magic is required to convince gcc to give us
the implementation for "__cxa_demangle"
Thanks @predmond for finding this simpler form of magic :)
2020-04-13 23:20:59 +02:00
Itamar
e207de8449 LibELF: Add find_demangled_function
Also, added AK::String::index_of and fixed a bug in ELF::Loader::symbol_ptr
2020-04-13 23:20:59 +02:00
Itamar
479348c9e7 Debugger: Add pledges 2020-04-13 00:53:22 +02:00
Itamar
3e9a7175d1 Debugger: Add DebugSession
The DebugSession class wraps the usage of Ptrace.
It is intended to be used by cli & gui debugger programs.

Also, call objdump for disassemly
2020-04-13 00:53:22 +02:00
Itamar
9e51e295cf ptrace: Add PT_SETREGS
PT_SETTREGS sets the regsiters of the traced thread. It can only be
used when the tracee is stopped.

Also, refactor ptrace.
The implementation was getting long and cluttered the alraedy large
Process.cpp file.

This commit moves the bulk of the implementation to Kernel/Ptrace.cpp,
and factors out peek & poke to separate methods of the Process class.
2020-04-13 00:53:22 +02:00
Itamar
0431712660 ptrace: Stop a traced thread when it exists from execve
This was a missing feature in the PT_TRACEME command.

This feature allows the tracer to interact with the tracee before the
tracee has started executing its program.

It will be useful for automatically inserting a breakpoint at a
debugged program's entry point.
2020-04-13 00:53:22 +02:00
Itamar
b306ac9b2b ptrace: Add PT_POKE
PT_POKE writes a single word to the tracee's address space.

Some caveats:
- If the user requests to write to an address in a read-only region, we
temporarily change the page's protections to allow it.

- If the user requests to write to a region that's backed by a
SharedInodeVMObject, we replace the vmobject with a PrivateIndoeVMObject.
2020-04-13 00:53:22 +02:00
Itamar
924fda19b0 Debugger: Get entry point of debugged process
Also, start debugging only after execve is done
2020-04-13 00:53:22 +02:00
Itamar
984ff93406 ptrace: Add PT_PEEK
PT_PEEK reads a single word from the tracee's address space and returns
it to the tracer.
2020-04-13 00:53:22 +02:00
Itamar
77f671b462 CPU: Handle breakpoint trap
Also, start working on the debugger app.
2020-04-13 00:53:22 +02:00