Commit graph

116 commits

Author SHA1 Message Date
networkException 4230dbbb21 AK+Everywhere: Replace "protocol" with "scheme" url helpers
URL had properly named replacements for protocol(), set_protocol() and
create_with_file_protocol() already. This patch removes these function
and updates all call sites to use the functions named according to the
specification.

See https://url.spec.whatwg.org/#concept-url-scheme
2022-09-29 09:39:04 +01:00
Andreas Kling 8690f36eb3 CrashReporter: Turn off line wrapping in the various text editors
It's much nicer to look at a backtrace when it has one line per stack
frame instead of a random number of lines.
2022-08-01 10:29:53 +02:00
Andreas Kling f80e19086e CrashReporter: Focus the "Close" button on startup
The most common action people will want to do with these windows is
to close them, so let's make that the first choice.
2022-08-01 10:29:53 +02:00
Andreas Kling b480f02117 CrashReporter: Add ellipsis (...) to "Save Backtrace" button
Since you must provide a file name before saving occurs, this button
should have an ellipsis.
2022-08-01 10:29:53 +02:00
Undefine 97cc33ca47 Everywhere: Make the codebase more architecture aware 2022-07-27 21:46:42 +00:00
FrHun 761325cd66 CrashReporter: Tweak layout
These changes bring the margins, spacing, and sizes more in line with
what is used in the rest of the system.
2022-07-15 12:34:25 +02:00
sin-ack c8585b77d2 Everywhere: Replace single-char StringView op. arguments with chars
This prevents us from needing a sv suffix, and potentially reduces the
need to run generic code for a single character (as contains,
starts_with, ends_with etc. for a char will be just a length and
equality check).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack 3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
sin-ack 60f6bc902b Userland: Convert command line arguments to String/StringView
StringView was used where possible. Some utilities still use libc
functions which expect null-terminated strings, so String objects were
used there instead.
2022-07-12 23:11:35 +02:00
FrHun 8081a8a5de LibGUI: Add layout spacer support to GML
This is a bit of a hack, but it is an easy way to finally get spacers
into GML.
This will translate well if spacers are later to become child objects of
the continer widget.
2022-06-10 21:26:06 +01:00
MacDue 5fd5a03d1f Applications: Use spawn_or_show_error() for common spawn pattern 2022-06-03 12:29:56 +01:00
Jelle Raaijmakers f25123df66 LibCore: Remove main event loop
The main event loop functionality was used in just two places where the
alternative is a bit simpler. Remove it in favor of referencing the
event loop directly, or just invoking `EventLoop::current()`.

Note that we don't need locking in the constructor since we're now only
modifying a thread-local `Vector`. We also don't need locking in the
old call sites to `::with_main_locked()` since we already lock the
event loop in the subsequent `::post_event()` invocation.
2022-04-27 11:54:37 +02:00
Lucas CHOLLET c741db967c CrashReporter: Don't display an error when cancelling backtrace saving
Pressing the cancel button on the prompt displayed by try_save_file()
used to show an error.
2022-04-20 12:01:49 +02:00
Lucas CHOLLET ad8c6d858e CrashReporter: Fix "Save Backtrace" button width
Previously, the size of the button changed with the window's size. Now
this parameter is fixed and consistent with the "Debug in Hack Studio"
button.
2022-04-20 12:01:49 +02:00
Ali Chraghi 8f5d80a41d CrashReporter: Implement Save Backtrace button 2022-04-12 21:43:07 +01:00
Idan Horowitz 086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Idan Horowitz c8ab45e79f Userland: Run gml-format
This brings the existing GML files up to spec with the new requirements
2022-02-13 02:36:35 +02:00
kleines Filmröllchen 6ee597369d Meta+Userland: Run the GML formatter on CI and pre-commit
Now that the GML formatter is both perserving comments and also mostly
agrees to the existing GML style, it can be used to auto-format all the
GML files in the system. This commit does not only contain the scripts
for running the formatting on CI and the pre-commit hook, but also
initially formats all the existing GML files so that the hook is
successfull.
2022-02-07 18:39:50 +01:00
Sviatoslav Peleshko 3caac65cc8 CrashReporter: Capture backtrace progress callback's arguments by value
Previously we captured them by reference, but when the deferred code
finally runs from an event loop, the references may be stale.
In that case, value and max of the progressbar are set with random
numbers.
If we were especially unlucky, the `frame_count` turned into a negative
int, and would crash at `VERIFY(min <= max)`.
2022-02-06 18:25:05 +03:30
Brian Gianforcaro e8857f9b2d CrashReporter: Stop attempting to lockdown the process veil
The idea of locking the process veil in CrashReproter is well
intentioned, but ultimately frought with issues.

The fundamental premise is a bit flawed, as we are using the crashing
program as input to dynamically add new paths to the process veil.
This means that an attacker can potentially produce a custom or
malformed binary to trick CrashReporter into allowing an arbitrary
path to be read.
2022-02-03 14:57:01 +01:00
Ali Mohammad Pur e72521f286 LibCoredump: Copy out the FooInfo structs to an aligned address
We were handing out unaligned pointers to these, which made UBSAN super
mad, copy them out to avoid that.
2022-01-28 22:51:27 +00:00
Andreas Kling 58b5aede65 CrashReporter: Dispatch backtrace progress callbacks on the main thread
We can't fiddle with GUI widgets off the main thread, so let's use
Core::EventLoop::deferred_invoke() to dispatch the work.

The progress bar doesn't visibly update yet, but at least we're not
crashing anymore.
2022-01-25 09:13:40 +01:00
Sam Atkins 94f2508519 CrashReporter: Don't crash when investigating a HackStudio crash
Previously when opening a crash report for HackStudio, the
`unveil("/bin/HackStudio", "rx")` call was failing because of the
earlier `unveil(executable_path.characters(), "r")` call requesting only
"r" permissions for it. This patch handles this specific case, so you
can crash HackStudio to your heart's content. :^)

Also, we were unveiling the executable path twice, once manually and
once implicitly as part of the coredump's libraries, so we now check for
the latter and avoid it.

Thanks to Daniel for noticing what was right in front of me and I didn't
see!

Co-authored-by: Daniel Bertalan <dani@danielbertalan.dev>
2022-01-20 10:38:10 +01:00
Samuel Bowman 4711d789c9 CrashReporter: Move progressbar into main window
Previously we would create a temporary progress window to show a
progressbar while the coredump is processed. Since we're only waiting
on backtraces and CPU register states, we can move the progressbar
into the main window and show everything else immediately while the
slow parts are generated in a BackgroundAction.
2022-01-03 16:19:47 +01:00
bugreport0 1a2ff38609 CrashReporter: Remove redundant pledge() 2021-12-11 23:06:56 +01:00
Sam Atkins 3ca2aee054 Applications: Cast unused smart-pointer TRY return values to void 2021-12-05 15:31:03 +01:00
Andreas Kling 01228bf4ef CrashReporter: Port to LibMain and use TRY() while building the UI :^) 2021-12-04 14:24:04 +01:00
Andreas Kling fc0a040e5d CrashReporter: Remove unnecessary button height overrides from GML 2021-11-30 23:34:40 +01:00
Andreas Kling 85eb0eaad0 CrashReporter+HackStudio: Let's call it "Debug in Hack Studio"
"Inspect in Hack Studio" was a bit vague.
2021-11-30 23:34:40 +01:00
Maciej 700c76ba23 CrashReporter: Don't visualize whitespace in memory regions text editor
This was visible for memory regions with empty name.
2021-11-24 19:44:02 +01:00
Tim Schumacher 8d5fb99703 CrashReporter: Show the available memory region information 2021-11-21 17:29:08 +00:00
Itamar dd76ba2fe1 CrashReporter: Add "Inspect in Hack Studio" button
This allows the user to open the crash coredump in Hack Studio and
inspect it in the Debug tab.
2021-11-20 21:22:24 +00:00
Itamar d6d48ce936 CrashReporter: Unlink coredump file on exit
Previously, when the --unlink flag was passed to CrashReporter, it
unlinked the coredump file immediately after reading it.

This change makes it so the coredump file is deleted when CrashReporter
exits.
2021-11-20 21:22:24 +00:00
sw1tchbl4d3 fc2ed732df CrashReporter: Don't crash when "Generating..." Window gets closed 2021-10-03 16:16:57 +02:00
Andreas Kling 9d7fe39640 CrashReporter: Show coredump loading progress in the Taskbar :^) 2021-09-21 20:52:29 +02:00
Andreas Kling f6f9599899 CrashReporter+LibCoredump: Show progress window while loading coredump
Some coredumps take a long time to symbolicate, so let's show a simple
window with a progress bar while they are loading.

I'm not super happy with the factoring of this feature, but it's an
absolutely kickass feature that makes crashing feel 100% more responsive
than before, since you now get GUI feedback almost immediately after a
crash occurs. :^)
2021-09-21 20:52:29 +02:00
Andreas Kling 4f224b15ed CrashDaemon+CrashReporter: Streamline crash reporting a little bit
Before this patch, this is what would happen after something crashed:

1. CrashDaemon finds a new coredump in /tmp
2. CrashDaemon compresses the new coredump (gzip)
3. CrashDaemon parses the uncompressed coredump and prints a backtrace
4. CrashDaemon launches CrashReporter
5. CrashReporter parses the uncompressed coredump (again)
6. CrashReporter unlinks the uncompressed coredump
7. CrashReporter displays a GUI

This was taking quite a long time when dealing with large programs
crashing (like Browser's WebContent processes.)

The new flow:

1. CrashDaemon finds a new coredump in /tmp
2. CrashDaemon mmap()'s the (uncompressed) coredump
3. CrashDaemon launches CrashReporter
4. CrashDaemon goes to sleep for 3 seconds (hack alert!)
5. CrashReporter parses the (uncompressed) coredump
6. CrashReporter unlinks the (uncompressed) coredump
7. CrashReporter displays a GUI
8. CrashDaemon wakes up (after step 4)
9. CrashDaemon compresses the coredump (gzip)

TL;DR: we no longer parse the coredumps twice, and we also prioritize
launching the CrashReporter GUI immediately when a new coredump shows
up, instead of compressing and parsing it in CrashDaemon first.

The net effect of this is that you get a backtrace on screen much
sooner. That's pretty nice. :^)
2021-09-21 20:52:29 +02:00
Andreas Kling 58f6bf8a4d CrashReporter: Add some margin around the backtrace & register views 2021-09-19 17:25:52 +02:00
Andreas Kling bcd2025311 Everywhere: Core dump => Coredump
We all know what a coredump is, and it feels more natural to refer to
it as a coredump (most code already does), so let's be consistent.
2021-08-23 00:02:09 +02:00
sin-ack e11d177618 Userland+LibGUI: Add shorthand versions of the Margins constructor
This allows for typing [8] instead of [8, 8, 8, 8] to specify the same
margin on all edges, for example. The constructors follow CSS' style of
specifying margins. The added constructors are:

- Margins(int all): Sets the same margin on all edges.
- Margins(int vertical, int horizontal): Sets the first argument to top
  and bottom margins, and the second argument to left and right margins.
- Margins(int top, int vertical, int bottom): Sets the first argument to
  the top margin, the second argument to the left and right margins,
  and the third argument to the bottom margin.
2021-08-18 10:30:50 +02:00
Gunnar Beutner 31f30e732a Everywhere: Prefix hexadecimal numbers with 0x
Depending on the values it might be difficult to figure out whether a
value is decimal or hexadecimal. So let's make this more obvious. Also
this allows copying and pasting those numbers into GNOME calculator and
probably also other apps which auto-detect the base.
2021-07-22 08:57:01 +02:00
Daniel Bertalan ca06fd658d Everywhere: Remove unused local variables and lambda captures 2021-07-08 10:11:00 +02:00
Andreas Kling 3f5c9d3edb CrashReporter: Fix bogus register alignment on x86_64 2021-07-01 11:35:52 +02:00
Max Wipfli fc6d051dfd AK+Everywhere: Add and use static APIs for LexicalPath
The LexicalPath instance methods dirname(), basename(), title() and
extension() will be changed to return StringView const& in a further
commit. Due to this, users creating temporary LexicalPath objects just
to call one of those getters will recieve a StringView const& pointing
to a possible freed buffer.

To avoid this, static methods for those APIs have been added, which will
return a String by value to avoid those problems. All cases where
temporary LexicalPath objects have been used as described above haven
been changed to use the static APIs.
2021-06-30 11:13:54 +02:00
Gunnar Beutner 233ef26e4d Kernel+Userland: Add x86_64 registers to RegisterState/PtraceRegisters 2021-06-27 15:46:42 +02:00
Gunnar Beutner 631d36fd98 Everywhere: Add component declarations
This adds component declarations so that users can select to not build
certain parts of the OS.
2021-06-17 11:03:51 +02:00
Andreas Kling 31d4bcf5bf Userland: Tighten a *lot* of pledges! :^)
Since applications using Core::EventLoop no longer need to create a
socket in /tmp/rpc/, and also don't need to listen for incoming
connections on this socket, we can remove a whole bunch of pledges!
2021-05-13 23:28:40 +02:00
Linus Groh ebdeed087c Everywhere: Use linusg@serenityos.org for my copyright headers 2021-04-22 22:51:19 +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 0b8226811f Kernel+CrashReporter: Add metadata about page faults to crash reports
Crash reports for page faults now tell you what kind of memory access
failed and where. :^)
2021-04-04 20:13:55 +02:00
Andreas Kling e238435c4f CrashReporter: Only create coredump metadata hash map once
We were rebuilding the metadata map a bunch of times on startup.
2021-04-04 20:13:55 +02:00
Edgar Araújo 243d7d9ecf Everywhere: Remove empty {} from GML objects 2021-03-29 09:10:23 +02:00
Idan Horowitz 9f656b6fa9 LibCoreDump+CrashDaemon: Compress coredumps
Most coredumps contain large amounts of consecutive null bytes and as
such are a prime candidate for compression.

This commit makes CrashDaemon compress files once the kernel finishes
emitting them, as well as adds the functionality needed in LibCoreDump
to then parse them.
2021-03-28 20:42:33 +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
speles 6e16a5cdfa Applications: Open folder with pre-selected file where appropriate :^) 2021-03-07 11:00:36 +01:00
AnotherTest 7c2754c3a6 AK+Kernel+Userland: Enable some more compiletime format string checks
This enables format string checks for three more functions:
- String::formatted()
- Builder::appendff()
- KBufferBuilder::appendff()
2021-02-23 13:59:33 +01:00
Linus Groh 8d0b744ebb CrashReporter: Fix showing assertion info in backtrace
This was needlessly expecting the first backtrace entry function name to
start with '__assertion_failed', which is no longer the case - it's now
something from libsystem.so. Let's just check whether we have an
'assertion' key in the coredump's metadata, just like we do for pledge
violations.
2021-02-19 18:53:00 +01:00
Linus Groh 17f90e72b4 CrashReporter: Show pledge violation in backtrace 2021-01-20 21:01:15 +01:00
Andreas Kling d312011708 Everywhere: Drop "shared_buffer" in most GUI programs, pledge "recvfd"
Now that WindowServer broadcasts the system theme using an anonymous
file, we need clients to pledge "recvfd" so they can receive it.

Some programs keep the "shared_buffer" pledge since it's still used for
a handful of things.
2021-01-16 19:30:32 +01:00
Linus Groh 6f666c20f5 CrashReporter: Show CPU register state for all threads
Closes #4777 .
2021-01-15 23:26:47 +01:00
Linus Groh 33c31e2198 CrashReporter: Show arguments and environment
Arguments as a simple label, environment in a new tab. :^)

Closes #4779.
2021-01-15 23:26:47 +01:00
Linus Groh 7668e968af LibCoreDump+Crash{Daemon,Reporter}: Make backtraces thread-specific
We want to show an individual backtrace for each thread, not one
containing backtrace entries from all threads.

Fixes #4778.
2021-01-15 23:26:47 +01:00
Linus Groh 3718a16f59 CrashReporter: Put backtrace TextEditor in a TabWidget
Since CrashReporter will be showing more info from coredumps soon, we
need tabs to put those things somewhere! :^)
2021-01-15 23:26:47 +01:00
Linus Groh 568cde5e23 Kernel+LibELF+LibCoreDump+CrashReporter: Use JSON for ProcessInfo
This is in preparation of adding (much) more process information to
coredumps. As we can only have one null-terminated char[] of arbitrary
length in each struct it's now a single JSON blob, which is a great fit:
easily extensible in the future and allows for key/value pairs and even
nested objects, which will be used e.g. for the process environment, for
example.
2021-01-15 23:26:47 +01:00
Andreas Kling 20915795a8 Everywhere: Pledge "sendfd" in WindowServer client programs
This is needed for the new way we transfer window backing stores.
2021-01-15 14:10:32 +01:00
Andreas Kling dc28c07fa5 Applications: Move to Userland/Applications/ 2021-01-12 12:05:23 +01:00