Commit graph

663 commits

Author SHA1 Message Date
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
Itamar cb432ffe8c HackStudio: Add icons for "step in" and "step out" 2020-08-22 09:48:59 +02:00
Itamar f5aa0988f5 HackStudio: Move debugger actions to a toolbar in the debug widget 2020-08-22 09:48:59 +02:00
Nico Weber 8d293601b6 IPCCompiler: Fix formatting mishap after GenericLexer change 2020-08-21 16:40:35 +02:00
Nico Weber 0d52e7f6e3 IPCCompiler: Use GenericLexer
No behavior change.
2020-08-21 16:01:07 +02:00
Andreas Kling 56c3748dcc LibWeb: Rename PageView => InProcessWebView 2020-08-17 18:05:35 +02:00
Andreas Kling c0462c65cf HackStudio: Move everything into the HackStudio namespace 2020-08-17 18:05:35 +02:00
Brian Gianforcaro 4ca493a86a UserspaceEmulator: Extra format arguments in MallocTracker, found by Coverity 2020-08-17 09:17:57 +02:00
Brian Gianforcaro 5a3cc2da8b UserspaceEmulator: Identical code on both branches, unify return in virt$ioctl 2020-08-17 09:17:57 +02:00
Brian Gianforcaro 7688539402 UserspaceEmulator: Fix conditionally uninitialized locals in virt$select 2020-08-17 09:17:57 +02:00
Nico Weber fd73de684e X86+Profiler+UserspaceEmulator: Deduplicate ELFSymbolProvider to LibX86
From a layering perspective, it's maybe a bit surprising that the
X86::SymbolProvider implementation also lives in LibX86, but since
everything depends on LibELF via LibC, and since all current
LibX86-based disassemblers want to use ELFSymbolProvider, it makes
some amount of sense to put it there.
2020-08-16 19:37:58 +02:00
Andreas Kling 9102b624ac LibGUI+DevTools+Applications: Use ModelIndex::data() in many places
This way you don't have to keep track of which model it came from.
2020-08-16 16:44:09 +02:00
Andreas Kling a1e381a0f8 LibGUI: Move GUI::Model::Role to GUI::ModelRole
This is preparation for using ModelRole in the ModelIndex API.
2020-08-16 16:44:09 +02:00
Nico Weber 430b265cd4 AK: Rename KB, MB, GB to KiB, MiB, GiB
The SI prefixes "k", "M", "G" mean "10^3", "10^6", "10^9".
The IEC prefixes "Ki", "Mi", "Gi" mean "2^10", "2^20", "2^30".

Let's use the correct name, at least in code.

Only changes the name of the constants, no other behavior change.
2020-08-16 16:33:28 +02:00
Matus Ferech 0dac7af6c5 HackStudio: Silence make output when checking if make is present 2020-08-15 20:11:46 +02:00
Matus Ferech e451ce816c HackStudio: Use Core::ArgsParser for path to workspace 2020-08-15 20:11:46 +02:00
Linus Groh 2e5c434e22 Misc: Use automatic window positioning in more applications
This is a follow up to #2936 / d3e3b4ae56aa79d9bde12ca1f143dcf116f89a4c.

Affected programs:
- Applications: Browser (Download, View source, Inspect DOM tree, JS
  console), Terminal (Settings)
- Demos: Cube, Eyes, Fire, HelloWorld, LibGfxDemo, WebView,
  WidgetGallery
- DevTools: HackStudio, Inspector, Profiler
- Games: 2048, Minesweeper, Snake, Solitaire
- Userland: test-web

A few have been left out where manual positioning is done on purpose,
e.g. ClipboardManager (to be close to the menu bar) or VisualBuilder (to
preserve alignment of the multiple application windows).
2020-08-15 17:38:19 +02:00
Linus Groh 0cab3bca2f LibGUI: Add and use Window::center_on_screen()
Various applications were using the same slightly verbose code to center
themselves on the screen/desktop:

Gfx::IntRect window_rect { 0, 0, width, height };
window_rect.center_within(GUI::Desktop::the().rect());
window->set_rect(window_rect);

Which now becomes:

window->resize(width, height);
window->center_on_screen();
2020-08-15 17:38:19 +02:00
Itamar 627f258c97 HackStudio: Use CodeDocument instead of TextDocument
This commit adds a new GUI widget type, called CodeDocument, which
is a TextDocument that can additionaly store data related to the
debugger.

This fixes various bugs and crashes that occured when we switched
between files in debug mode, because we previously held stale breakpoint
data for the previous file in the Editor object.
We now keep this data at the "document" level rather than the Editor
level, which fixes things.
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 311a355505 HackStudio: Change singlestepping logic in the debugger
Previously, we did source-level singlestepping by inserting a
breakpoint at every source line and continued execution until we hit
a breakpoint. We did this because we used to not generate source
locations debug info for library code, and it allowed us to not single
step through lots of library code to get to the next source line
(which is super slow).

Since we now do generate source locations debug info for libraries
(-g1), we can improve the way we implement source level stepping by
stepping at the assembly level until we reach a different source code
location.
2020-08-15 15:06:35 +02:00
Andreas Kling 65f2270232 Kernel+LibC+UserspaceEmulator: Bring back sys$dup2()
This is racy in userspace and non-racy in kernelspace so let's keep
it in kernelspace.

The behavior change where CLOEXEC is preserved when dup2() is called
with (old_fd == new_fd) was good though, let's keep that.
2020-08-15 11:11:34 +02:00
Andreas Kling bf247fb45f Kernel+LibC+UserspaceEmulator: Remove sys$dup() and sys$dup2()
We can just implement these in userspace, so yay two less syscalls!
2020-08-15 01:30:22 +02:00
Andreas Kling 75b8f4e4e6 LibGUI: Make focus events more aware of why focus is changing
This patch adds GUI::FocusEvent which has a GUI::FocusSource.
The focus source is one of three things:

- Programmatic
- Mouse
- Keyboard

This allows receivers of focus events to implement different behaviors
depending on how they receive/lose focus.
2020-08-15 00:05:45 +02:00
Nico Weber 8126104a03 Inspector: Require horizontal scrollbars less often
Make the window a bit larger, and give the left pane a Fixed
size policy, so that it takes up less than half the window.
2020-08-14 10:29:01 +02:00
Ben Wiederhake 5574d45eda DevTools: Mark compilation-unit-only functions as static
This enables a nice warning in case a function becomes dead code. Also, in case
of signal_trampoline_dummy, marking it external (non-static) prevents it from
being 'optimized away', which would lead to surprising and weird linker errors.
2020-08-12 20:40:59 +02:00
Ben Wiederhake 7893871d5a HackStudio: Mark compilation-unit-only functions as static
This also resolves some typing issues that only 'accidentally' worked, like declaring
a function to return type A, and the definition actually returning type B (which works
if type B is a subtype of type A). I like to call these "ninja imports".

To prevent problems like this in the future, I put all globals in a HackStudio.h.
I'm not sure about the name, but main.h and common.h felt wrong.
2020-08-12 20:40:59 +02:00
Andreas Kling 845aaaf5fd HackStudio: Use adopt_own(*new T) instead of OwnPtr(new T) 2020-08-12 12:17:20 +02:00
Nico Weber f8084cc083 UserspaceEmulator: Remove some silly semicolons 2020-08-11 21:04:38 +02:00
Andreas Kling c6ee6c0b42 UserspaceEmulator: Log unimplemented instructions with proper backtrace 2020-08-11 20:29:14 +02:00
Brian Gianforcaro 0f42463eab Kernel: Use Userspace<T> for the execve syscall 2020-08-10 12:52:15 +02:00
AnotherTest 1222be7e3a HackStudio: Set the pgrp of the pseudoterminal to the child pid
This fixes #3046.
2020-08-09 11:33:15 +02:00
Andreas Kling fae9c9f81f UserspaceEmulator: Add the dup2 syscall 2020-08-07 18:46:56 +02:00
Andreas Kling 5dce5fa7c2 UserspaceEmulator: Add the chdir syscall 2020-08-07 18:44:51 +02:00
Andreas Kling ee5e8081da UserspaceEmulator: Pass full path to new UE instance in virt$execve()
Don't just pass argv[0] to the new UE, pass the full program path.
2020-08-07 17:28:00 +02:00
Andreas Kling 5a5b687014 UserspaceEmulator: Add the getpgid() and waitid() syscalls
With this, you can now kinda sorta run the shell in UserspaceEmulator!
2020-08-07 16:51:08 +02:00
Andreas Kling 93b1e54237 UserspaceEmulator: Add the setpgid syscall 2020-08-07 16:34:50 +02:00
Andreas Kling 2b3b83801b UserspaceEmulator: Make the "unimplemented syscall" output look nicer 2020-08-07 16:34:50 +02:00
Andreas Kling 5ba2022b8e UserspaceEmulator: Result is initialized after OR with all-1 immediate
When compiling with "-Os", GCC produces the following pattern for
atomic decrement (which is used by our RefCounted template):

    or eax, -1
    lock xadd [destination], eax

Since or-ing with -1 will always produce the same output (-1), we can
mark the result of these operations as initialized. This stops us from
complaining about false positives when running the shell in UE. :^)
2020-08-07 15:41:53 +02:00
Andreas Kling 2f1d596dd3 UserspaceEmulator: Fix bad rc check in ttyname and getcwd syscalls
Errors here are (rc < 0), not (rc < 1).
2020-08-06 11:45:52 +02:00
Andreas Kling d608d714b9 UserspaceEmulator: Support ioctl(TCGETS) and ioctl(TCSETS) 2020-08-05 22:34:50 +02:00
Andreas Kling e0e3e5b9b1 UserspaceEmulator: Add the access syscall 2020-08-05 22:34:50 +02:00
Andreas Kling c497603177 UserspaceEmulator: Add the getcwd syscall 2020-08-05 22:34:50 +02:00
Andreas Kling b187a42e53 UserspaceEmulator: Add the ttyname syscall 2020-08-05 22:34:50 +02:00
Andreas Kling 9d93e208ac UserspaceEmulator: Support ioctl(TIOCSPGRP) 2020-08-05 22:34:50 +02:00
Andreas Kling 3717a00290 UserspaceEmulator: Add the getpgrp syscall 2020-08-05 22:34:50 +02:00
Andreas Kling 8dea25d974 UserspaceEmulator: Add support for UNIX signals :^)
The emulator will now register signal handlers for all possible signals
and act as a translation layer between the kernel and the emulated
process.

To get an accurate simulation of signal handling, we duplicate the same
trampoline mechanism used by the kernel's signal delivery system, and
also use the "sigreturn" syscall to return from a signal handler.

Signal masking is not fully implemented yet, but this is pretty cool!
2020-08-05 22:34:50 +02:00
Andreas Kling db450dbc44 Base: Move "js" and "little" HackStudio projects into ~/Source/ 2020-08-05 17:40:47 +02:00
Linus Groh a8d7cd5a15 HackStudio: Open project or file from argv[1] if given
When HackStudio is invoked with one or more arguments it will attempt to
treat the first argument as a project or source file and open it
accordingly.
2020-08-05 16:54:23 +02:00