Commit Graph

32 Commits

Author SHA1 Message Date
Ben Wiederhake
3e7e503dee strace: Implement get_process_name and gettid 2021-11-24 22:56:39 +01:00
Ben Wiederhake
2dd5c7d2cc strace: Implement dbgputstr syscall 2021-11-24 22:56:39 +01:00
Andreas Kling
216e21a1fa AK: Convert AK::Format formatting helpers to returning ErrorOr<void>
This isn't a complete conversion to ErrorOr<void>, but a good chunk.
The end goal here is to propagate buffer allocation failures to the
caller, and allow the use of TRY() with formatting functions.
2021-11-17 00:21:13 +01:00
Ben Wiederhake
4512e89159 strace: Interpret errno codes for pointer-like return codes 2021-11-10 14:47:31 +01:00
Ben Wiederhake
81b6be4bf4 strace: Switch to new flag handler, support more flags
In particular, strace now supports all O_*, MSG_*, MAP_*, and PROT_*
flags, as well as a more context-dependent default value (e.g.
"PROT_NONE").
2021-11-10 14:47:31 +01:00
Ben Wiederhake
491ed375fc strace: Better support for bitflags, show unrecognized flags 2021-11-10 14:47:31 +01:00
Andreas Kling
248ff8e971 strace: Teach mmap() pretty-printer about more MAP_FOO flags 2021-10-31 21:07:29 +01:00
Liav A
8554952690 Kernel + WindowServer: Re-define the interface to framebuffer devices
We create a base class called GenericFramebufferDevice, which defines
all the virtual functions that must be implemented by a
FramebufferDevice. Then, we make the VirtIO FramebufferDevice and other
FramebufferDevice implementations inherit from it.
The most important consequence of rearranging the classes is that we now
have one IOCTL method, so all drivers should be committed to not
override the IOCTL method or make their own IOCTLs of FramebufferDevice.
All graphical IOCTLs are known to all FramebufferDevices, and it's up to
the specific implementation whether to support them or discard them (so
we require extensive usage of KResult and KResultOr, together with
virtual characteristic functions).
As a result, the interface is much cleaner and understandable to read.
2021-10-27 07:57:44 +03:00
Rodrigo Tobar
e3dffdacb8 strace: Add command line options to filter syscalls
By default strace outputs all system calls the monitored process
invokes, but it's sometimes useful to either exclude some calls, or to
include only some others.

This commit adds two new command line options to specify two
exclusion/inclusion command-delimited lists of system calls. These are
then used to decide if an intercepted system call should be displayed in
the output or not.
2021-10-12 10:56:50 -07:00
Rodrigo Tobar
6ff56a96bd strace: Show sun_path on AF_UNIX socket addresses 2021-10-12 10:56:50 -07:00
Rodrigo Tobar
441a1ae35d strace: Add support for get{u,eu,g,eg,p,pp}id syscalls
All these take no arguments so there's no formatting to be done.
2021-10-12 10:56:50 -07:00
Rodrigo Tobar
1409cc8395 strace: Add formatting for clock_gettime 2021-10-12 10:56:50 -07:00
Rodrigo Tobar
78de54f0f1 strace: Add initial ioctl formatting
This is useful in general, but adding it is what finally helped
uncovering #10438.
2021-10-12 10:56:50 -07:00
Nico Weber
f46a40a471 Utilities: Fix -Wunreachable-code warnings from clang 2021-10-08 23:33:46 +02:00
Rodrigo Tobar
96a67d24e9 Strace: Add formatting for misc syscalls
These are exit, realpath and getrandom. This required a bit of extra
infrastructure to deal with exit's void return type.
2021-10-07 08:47:49 +03:30
Rodrigo Tobar
8125edfe79 Strace: Add formatting for main memory-related syscalls
These include mmap, munmap, mprotect and mmap_set_name.
2021-10-07 08:47:49 +03:30
Rodrigo Tobar
9394cfcaf3 Strace: Add formatting for main socket syscalls
The formatting of these functions is not complete, but gives already
very good information to the user.
2021-10-07 08:47:49 +03:30
Rodrigo Tobar
a09b1879ca Strace: Add main infrastructure and formatting of main I/O operations
This commit introduces the main infrastructure used for turning register
values into user-facing values that can be printed by strace. This
includes the ability to copy data from a particular memory address in
the traced process. On top of this, (partial) formatting has been added
for the most common I/O operations (open, read, write, lseek, close,
stat, fstat).
2021-10-07 08:47:49 +03:30
Rodrigo Tobar
f7a0196764 Strace: Move output formatting to separate function
Moving the formatting of strace's output into a separate function will
allow us to introduce more complexity into the formatting logic without
touching the main body of the program.

The new function uses a switch statement to select how to format the
arguments and result depending on the syscall. At this point we only
include the default formatting, where the registers are simply dumped,
but later on we can add specializations for each system call we want to
support.
2021-10-07 08:47:49 +03:30
Gunnar Beutner
f285241cb8 Kernel: Rename Thread::tss to Thread::regs and add x86_64 support
We're using software context switches so calling this struct tss is
somewhat misleading.
2021-06-27 15:46:42 +02:00
Gunnar Beutner
233ef26e4d Kernel+Userland: Add x86_64 registers to RegisterState/PtraceRegisters 2021-06-27 15:46:42 +02:00
Jelle Raaijmakers
fb6d141601 Utilities: Make strace stop parsing options on first non-option 2021-06-08 11:30:58 +02:00
Andreas Kling
bf8fd4c193 Everywhere: Remove accidental '\n' from various outln() invocations
Also convert outln(stderr, ...) to warnln(...)
2021-06-03 22:50:21 +02:00
Ali Mohammad Pur
a91a49337c LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
2021-05-12 11:00:45 +01:00
SViN24
e60c0d675e
strace: Write output to stderr instead of stdout (#7016)
Fixes #7014.
2021-05-11 09:56:28 +02:00
Andreas Kling
c7e5ef3057 strace: Stop using Core::IODevice::printf()
There are no other clients of this weird API, so let's get rid of it.
Now that we call IODevice::write() instead, we can also handle errors.
2021-05-07 22:06:58 +02:00
Sergey Bugaev
7f98aaa65a Userland: Pledge wpath & cpath in strace
...while we open the output file.
2021-05-04 22:36:58 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
Andreas Kling
e87eac9273 Userland: Add LibSystem and funnel all syscalls through it
This achieves two things:

- Programs can now intentionally perform arbitrary syscalls by calling
  syscall(). This allows us to work on things like syscall fuzzing.

- It restricts the ability of userspace to make syscalls to a single
  4KB page of code. In order to call the kernel directly, an attacker
  must now locate this page and call through it.
2021-02-05 12:23:39 +01:00
Andreas Kling
ececac65c2 Userland: Move command-line utilities to Userland/Utilities/ 2021-01-12 12:04:09 +01:00