summaryrefslogtreecommitdiff
path: root/Userland/Utilities/strace.cpp
AgeCommit message (Collapse)Author
2022-02-12strace: Add a chdir formatterAli Mohammad Pur
2022-01-24Everywhere: Convert ByteBuffer factory methods from Optional -> ErrorOrSam Atkins
Apologies for the enormous commit, but I don't see a way to split this up nicely. In the vast majority of cases it's a simple change. A few extra places can use TRY instead of manual error checking though. :^)
2022-01-08Kernel: Remove EWHYTHO error code :^)Andreas Kling
This error code was a hack for catching error handling mistakes in the kernel. It's no longer used anywhere.
2021-12-25strace: Port to LibMain :^)Andreas Kling
2021-12-23strace: Fix out-of-bounds read when formatting realpath()Daniel Bertalan
The actual length of the resulting string is encoded in the return value; treating the entire buffer as a string leads to reading uninitialized memory.
2021-12-23Kernel+UE: Add MAP_FIXED_NOREPLACE mmap() flagDaniel Bertalan
This feature was introduced in version 4.17 of the Linux kernel, and while it's not specified by POSIX, I think it will be a nice addition to our system. MAP_FIXED_NOREPLACE provides a less error-prone alternative to MAP_FIXED: while regular fixed mappings would cause any intersecting ranges to be unmapped, MAP_FIXED_NOREPLACE returns EEXIST instead. This ensures that we don't corrupt our process's address space if something is already at the requested address. Note that the more portable way to do this is to use regular MAP_ANONYMOUS, and check afterwards whether the returned address matches what we wanted. This, however, has a large performance impact on programs like Wine which try to reserve large portions of the address space at once, as the non-matching addresses have to be unmapped separately.
2021-12-12strace: Remove formatting support for SC_selectJean-Baptiste Boric
2021-12-12strace: Add formatting support for SC_pollJean-Baptiste Boric
2021-12-12strace: Sort syscalls formatters in alphabetic orderJean-Baptiste Boric
2021-12-05strace: Handle strings more gracefullyBen Wiederhake
In particular, strace can now stomach memory errors while copying invalid strings. Example with a valid string: dbgputstr("95.976 traceme(38:38) Well, Hello Friends!") = 55 Example with an invalid string: dbgputstr(Error(errno=14){0x00012345, 678b}) = -14 EFAULT (ANSI escapes removed for readability.)
2021-12-05strace: Use new PT_PEEKBUF functionBen Wiederhake
This necessarily introduces some usages (and benefits!) of the new ErrorOr<> pattern. To keep commits atomic, I do not yet rewrite the entire program to use ErrorOr<> correctly.
2021-12-05LibC: Add a couple of missing errno codesIdan Horowitz
These are required to compile a port.
2021-12-05Kernel: Add support for the MSG_WAITALL sys$recvmsg flagIdan Horowitz
2021-12-05Kernel: Add support for the MSG_DONTROUTE sys$sendmsg flagIdan Horowitz
2021-11-24strace: Implement get_process_name and gettidBen Wiederhake
2021-11-24strace: Implement dbgputstr syscallBen Wiederhake
2021-11-17AK: Convert AK::Format formatting helpers to returning ErrorOr<void>Andreas Kling
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-10strace: Interpret errno codes for pointer-like return codesBen Wiederhake
2021-11-10strace: Switch to new flag handler, support more flagsBen Wiederhake
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-10strace: Better support for bitflags, show unrecognized flagsBen Wiederhake
2021-10-31strace: Teach mmap() pretty-printer about more MAP_FOO flagsAndreas Kling
2021-10-27Kernel + WindowServer: Re-define the interface to framebuffer devicesLiav A
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-12strace: Add command line options to filter syscallsRodrigo Tobar
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-12strace: Show sun_path on AF_UNIX socket addressesRodrigo Tobar
2021-10-12strace: Add support for get{u,eu,g,eg,p,pp}id syscallsRodrigo Tobar
All these take no arguments so there's no formatting to be done.
2021-10-12strace: Add formatting for clock_gettimeRodrigo Tobar
2021-10-12strace: Add initial ioctl formattingRodrigo Tobar
This is useful in general, but adding it is what finally helped uncovering #10438.
2021-10-08Utilities: Fix -Wunreachable-code warnings from clangNico Weber
2021-10-07Strace: Add formatting for misc syscallsRodrigo Tobar
These are exit, realpath and getrandom. This required a bit of extra infrastructure to deal with exit's void return type.
2021-10-07Strace: Add formatting for main memory-related syscallsRodrigo Tobar
These include mmap, munmap, mprotect and mmap_set_name.
2021-10-07Strace: Add formatting for main socket syscallsRodrigo Tobar
The formatting of these functions is not complete, but gives already very good information to the user.
2021-10-07Strace: Add main infrastructure and formatting of main I/O operationsRodrigo Tobar
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-07Strace: Move output formatting to separate functionRodrigo Tobar
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-06-27Kernel: Rename Thread::tss to Thread::regs and add x86_64 supportGunnar Beutner
We're using software context switches so calling this struct tss is somewhat misleading.
2021-06-27Kernel+Userland: Add x86_64 registers to RegisterState/PtraceRegistersGunnar Beutner
2021-06-08Utilities: Make `strace` stop parsing options on first non-optionJelle Raaijmakers
2021-06-03Everywhere: Remove accidental '\n' from various outln() invocationsAndreas Kling
Also convert outln(stderr, ...) to warnln(...)
2021-05-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
2021-05-11strace: Write output to stderr instead of stdout (#7016)SViN24
Fixes #7014.
2021-05-07strace: Stop using Core::IODevice::printf()Andreas Kling
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-04Userland: Pledge wpath & cpath in straceSergey Bugaev
...while we open the output file.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
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-03-12Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)Andreas Kling
Good-bye LogStream. Long live AK::Format!
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...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-05Userland: Add LibSystem and funnel all syscalls through itAndreas Kling
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-01-12Userland: Move command-line utilities to Userland/Utilities/Andreas Kling