Commit graph

810 commits

Author SHA1 Message Date
Tim Schumacher fc6f265155 Profiler: Use existing path split when mmapping libraries
We already extracted the `path` part of the segment name, so use that
for checking if the filename looks like a shared library.
2021-11-10 14:42:49 +01:00
Brendan Coles 1e48cd35a1 UserspaceEmulator: Add support for SC_uname and SC_sysconf syscalls 2021-11-08 16:30:32 -08:00
Andreas Kling fbe8f185b5 Profiler: Replace Result<T, E> use with ErrorOr<T> 2021-11-08 00:35:27 +01:00
Andreas Kling 4a2b718ba2 LibCore: Use ErrorOr<T> for Core::File::copy_file() 2021-11-08 00:35:27 +01:00
Andreas Kling c7e62d448c LibCore: Use ErrorOr<T> for Core::File::remove()
This function returns a subclass of Error, which is now possible.
2021-11-08 00:35:27 +01:00
Andreas Kling 0de33b3d6c LibGfx: Use ErrorOr<T> for Bitmap::try_create()
Another one that was used in a fajillion places.
2021-11-08 00:35:27 +01:00
Andreas Kling 235f39e449 LibGfx: Use ErrorOr<T> for Bitmap::try_load_from_file()
This was used in a lot of places, so this patch makes liberal use of
ErrorOr<T>::release_value_but_fixme_should_propagate_errors().
2021-11-08 00:35:27 +01:00
Hendiadyoin1 2867d93115 UserspaceEmulator: Improve the MMX formatting on environment dump 2021-11-07 22:42:23 +00:00
Hendiadyoin1 83f50a1507 UserspaceEmulator: Raise an error on FPU stack underflow
Accessing an unset part of the FPU stack should not be a simple warning,
but should trigger the FPU exception mechanism.
2021-11-07 22:42:23 +00:00
Hendiadyoin1 0d6d780183 UserspaceEmulator: Remove some unnecessary casting 2021-11-07 22:42:23 +00:00
Hendiadyoin1 d759175767 UserspaceEmulator: Stop overriding flags in FCOMI
We no longer override the flags we just set. We now also unset of, af,
and sf after the comparison.
This fixes the asin function for LibM!
2021-11-07 22:42:23 +00:00
Hendiadyoin1 f2eff767a0 UserspaceEmulator: Fix typos in SoftFPU.[cpp|h] 2021-11-07 22:42:23 +00:00
Hendiadyoin1 74aba07b70 UserspaceEmulator: Align FPU-exception names with the manual 2021-11-07 22:42:23 +00:00
Hendiadyoin1 5d2a4bd18d UserspaceEmulator: Check the right flags in FCMOV
Also make FCMOVNB do an actual CMOV and not a copy of FILD_m32
2021-11-07 22:42:23 +00:00
Hendiadyoin1 8108aaca39 UserspaceEmulator: Correct FSCALES rounding
We were rounding the wrong way, FSCALE is supposed to trunc internally,
while we were flooring.
Now LibM exponentials and related tests work :^)
2021-11-07 22:42:23 +00:00
Hendiadyoin1 fa02b46295 UserspaceEmulator: Always set C1 when rounding 2021-11-07 22:42:23 +00:00
Hendiadyoin1 7214b08f81 UserspaceEmulator: Simplify the definition of the FPU register stack
Long doubles are always at least 80 bits wide in memory and it suffices
if we can address these 80 bits, to mark the long double as NAN at the
end of an MMX instruction, so the additional magic using conditional
types is unnecessary.
2021-11-07 22:42:23 +00:00
Hendiadyoin1 d06675e3e4 UserspaceEmulator: Use unsigned types for logical MMX shifting 2021-11-07 22:42:23 +00:00
Ben Wiederhake 3796d417e0 Demos+DevTools+Games: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
thislooksfun 8462234208 HackStudio: Don't close autocomplete after applying #include directories 2021-11-02 17:53:22 +01:00
thislooksfun d5baf1c1fa LibGUI: Allow autocomplete to stay open after applying
Previously the autocomplete box would always close after applying a
suggestion. This is the desired behavior in almost all cases, but there
are some situations (like autocompleting paths) where it would be nicer
to keep the autocomplete box open after applying the suggestion.
2021-11-02 17:53:22 +01:00
thislooksfun 81f00c0aa8 HackStudio: Remove unused #include
Found this while looking at who uses GUI::AutocompleteProvider.
2021-11-02 17:53:22 +01:00
thislooksfun 0be3f5b4ae HackStudio: Append a / when completing a directory 2021-11-02 17:53:22 +01:00
thislooksfun 8b3a2cdad9 HackStudio: Correctly handle nested paths
Previously the paths were concatinated incorrectly, so triggering
the autocomplete on `#include "foo/bar"` would never work. Now it
does. :^)
2021-11-02 17:53:22 +01:00
thislooksfun a6a71869d7 HackStudio: Handle autocomplete inside #include's <> and "" 2021-11-02 17:53:22 +01:00
thislooksfun f7f9d09e72 LibGUI: Remove GUI::AutocompleteProvider::Entry::kind
The only code using it was removed in the previous commit.
2021-11-02 17:53:22 +01:00
thislooksfun f699dbdc3f HackStudio+LibGUI: Handle #include quotes and brackets in the engine
Previously we had a special case in order to auto-append quotes or
angle brackets to #include statements. After the previous commit this
is no longer necessary.
2021-11-02 17:53:22 +01:00
thislooksfun a5b3c3f85f LibGUI: Allow completion suggestions to fill and display different text
There are times when it is nice to display one suggestion but fill
something different. This lays the groundwork for allowing
GMLAutocompleteProvider to automatically add ': ' to the end of
suggested properties, while keeping the ': ' suffix from cluttering up
the suggestion UI.
2021-11-02 17:53:22 +01:00
Ben Wiederhake 70c7861c33 UserspaceEmulator: Avoid special character in pseudo-identifier
In the generated HTML code, '#' gets interpreted as the beginning of a
shell comment, which throws the syntax highlighting off. Regardless,
spelling out the meaning of the '#' might make it more readable.
2021-11-01 21:12:58 +01:00
Ben Wiederhake b8f11b1bae Everywhere: Remove unused ArgsParser header
Found while trying to enumerate all programs that use ArgsParser.
2021-11-01 21:12:58 +01:00
Andreas Kling aff2b42f82 UserspaceEmulator: Fix inconsistent log formatting
Remove some extra { and } around the PID in log output that weren't used
consistently in all logging.
2021-10-31 21:07:29 +01:00
Daniel Bertalan b883652a83 Profiler: Cache parsed DWARF debug information in disassembly view
This changes browsing through disassembled functions in Profiler from a
painfully sluggish experience into quite a swift one. It's especially
true for profiling the kernel, as it has more than 10 megabytes of DWARF
data to churn through.
2021-10-31 16:54:02 +01:00
Daniel Bertalan 8e1f882ac9 Profiler: Load the actual kernel binary for disassembly
/boot/Kernel.debug only contains the symbol table and DWARF debug
information, and has its `.text` and other PT_LOAD segments stripped
out. When we try to parse its data as instructions, we get a crash from
within LibX86.

We now load the actual /boot/Kernel binary when we want to disassemble
kernel functions.
2021-10-31 16:54:02 +01:00
Daniel Bertalan 80b660132c Profiler: Share the mapped kernel between Profile and DisassemblyModel
There is no point in keeping around a separate MappedFile object for
/boot/Kernel.debug for each DisassemblyModel we create and re-parsing
the kernel image multiple times. This will significantly speed up
browsing through profile entries from the kernel in disassembly view.
2021-10-31 16:54:02 +01:00
Marco Cutecchia 3428e2a76c HackStudio: Add 'Show Dotfiles' option 2021-10-29 22:40:11 +02:00
Filiph Sandström d6a0726302 Everywhere: Rename left/right-click to primary/secondary
This resolves #10641.
2021-10-27 22:05:58 +03: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
Daniel Bertalan ac1cac286b Profiler: Fix disassembling objects with a non-zero .text vaddr
Previously, we assumed that the `.text` segment was loaded at vaddr 0 in
shared object, which is not the case with `-z separate-code` enabled.
Because we didn't do the right calculations to translate an address from
a performance event into its value within the ELF file, Profiler would
try to disassemble out-of-bounds memory locations, leading to a crash.

This commit also changes `LibraryMetadata` to apply to a loaded library
as a whole, not just to one of its segments (like .text or .data). This
lets us simplify the interface, as we no longer have to worry about
`text_base`.

Fixes #10628
2021-10-25 12:14:26 +02:00
Daniel Bertalan 15a14d3d21 LibX86: Take load base address into consideration during disassembly
Since our executables are position-independent, the address values
extraced from processes don't correspond to their values within the ELF
file. We have to offset the absolute addresses by the load base address
to get the relative symbol that we need for disassembly.
2021-10-25 12:14:26 +02:00
Daniel Bertalan 7c27ba1240 Profiler: Subtract the kernel's base address when searching for symbols
Now that the kernel is compiled as a PIE, all addresses are relative to
the loaded base address, so Symbolication::kernel_base has to be
subtracted off from the absolute addresses if we want to symbolicate
them.
2021-10-25 12:14:26 +02:00
Idan Horowitz 87bd98fe8e Profiler: Handle profiles with more kernel samples than user samples
Previously we assumed there were less kernel samples than user samples,
by implicitly using the kernel histogram size for indicies to the user
histogram. Such a profile can be reproduced by profiling a very short
lived program like true: `profile -c true`
2021-10-24 23:04:47 +02:00
Idan Horowitz db68a52e23 Profiler: Use profile length in ms as histogram column count directly
Beforehand we were dividing the frame width by the profile length in ms
and then dividing the frame width by the result once more, which is
equivalent to (but slower) just using the length in ms directly, aside
from the case in which the profile is less than 1 ms long, in which
case this would trigger undefined behaviour due to the division by zero
2021-10-24 23:04:47 +02:00
Daniel Bertalan 0a748de1a0 UE: Properly align stack for signal handlers
This issue was also present in the kernel, the description of which is
provided in an identically titled commit.

Note that this couldn't have affected any programs running in
UserspaceEmulator as we don't support SSE instructions, and don't seem
to raise faults under any conditions.
2021-10-24 21:54:51 +02:00
Andreas Kling 398c181c79 LibJS: Rename PropertyName to PropertyKey
Let's use the same name as the spec. :^)
2021-10-24 17:18:07 +02:00
Sam Atkins 79522db5d0 HackStudio: Add syntax-highlighting for CSS files 2021-10-23 19:07:44 +02:00
Hediadyoin1 3ad6d87a45 LibX86: Add SSE support
This only adds the decodeing support for SSE, not SSE2, etc.
may contain traces of SSE2.
2021-10-17 13:06:23 -07:00
Hediadyoin1 bce3bf9f1e UserspaceEmulator: Handle PerfEvent syscalls
We only froward String setting and FlagPost creation for now, due to the
other performance events being nonsensical to forward.
We also record these signposts in the optionally generated profile.
2021-10-06 17:35:29 +00:00
Hendiadyoin1 045461b7cb UserspaceEmulator: Use only the base name for the profile name 2021-10-06 17:35:29 +00:00
Marco Cutecchia 3c5e07fa1c HackStudio: Save editor's font in configs 2021-10-06 17:14:40 +02:00
Marco Cutecchia 423c2e44c9 HackStudio: Add option to change the editor's font 2021-10-06 17:14:40 +02:00
Andreas Kling 0264ae23bc LibWeb: Make CSS layout lazier
Instead of doing layout synchronously whenever something changes,
we now use a basic event loop timer to defer and coalesce relayouts.

If you did something that requires a relayout of the page, make sure
to call Document::set_needs_layout() and it will get coalesced with all
the other layout updates.

There's lots of room for improvement here, but this already makes many
web pages significantly snappier. :^)

Also, note that this exposes a number of layout bugs where we have been
relying on multiple relayouts to calculate the correct dimensions for
things. Now that we only do a single layout in many cases, these kind of
problems are much more noticeable. That should also make them easier to
figure out and fix. :^)
2021-10-06 17:14:22 +02:00
Tim Schumacher 7af7fc8c16 Everywhere: Fix more Copyright header inconsistencies 2021-10-04 11:10:09 +01:00
Nico Weber 6c9bc18a79 Userland: Fix typos 2021-10-01 01:18:52 +01:00
Linus Groh e5409c6ead LibJS: Convert internal_set() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Linus Groh 6c2b974db2 LibJS: Convert internal_get() to ThrowCompletionOr 2021-09-29 23:49:53 +01:00
Marco Cutecchia 194dc8b25d HackStudio: Support renaming files from the tree view 2021-09-27 01:20:48 +02:00
thankyouverycool 92fffc3abc LibGUI: Rename CallOnChange => AllowCallback and implement elsewhere
This is a helpful option to prevent unwanted side effects, distinguish
between user and programmatic input, etc. Sliders and SpinBoxes were
implementing it idiosyncratically, so let's generalize the API and
give Buttons and TextEditors the same ability.
2021-09-22 21:35:42 +02:00
Itamar a27716846f HackStudio: Make sure Window is destroyed before Application object
We previously stored the Window object in a global RefPtr (for no
apparent reason).

This led to a use-after-free bug in the Window's destructor when
HackStudio was exited via the Quit action (Exiting by closing the
window did not trigger this bug).
2021-09-18 16:45:50 +02:00
Ali Mohammad Pur 44cc6e1662 Profiler: Make the ProfileModel searchable
Note that this only searches the items at the same level as the selected
index.
2021-09-14 21:33:15 +04:30
Karol Kosek 6c5fb2ca63 HackStudio: Remove an old file from the vectors in 'Save as...' action
If you saved a file under a different name and then went back to
the first file, then you had the same TextDocument buffer, and therefore
the same changes to the file as in the new one.
2021-09-12 22:10:48 +02:00
Karol Kosek d811ad921c HackStudio: Rename Project::get_file() to Project::create_file()
The function no longer looks for the already opened files, so let's
emphasize that by renaming it to `create_file`. :^)
2021-09-12 22:10:48 +02:00
Karol Kosek 4a1974b174 HackStudio: Remove storing a vector of opened files in Project class
It looks to me like this has the same purpose as m_open_files
in the HackStudioWidget, so removing it shouldn't change anything.
2021-09-12 22:10:48 +02:00
Karol Kosek c0709c4447 Playground: Ask to save file contents on quit action
Prior this change, activating the action instantly closed the program.
2021-09-12 16:30:25 +02:00
Idan Horowitz 6704961c82 AK: Replace the mutable String::replace API with an immutable version
This removes the awkward String::replace API which was the only String
API which mutated the String and replaces it with a new immutable
version that returns a new String with the replacements applied. This
also fixes a couple of UAFs that were caused by the use of this API.

As an optimization an equivalent StringView::replace API was also added
to remove an unnecessary String allocations in the format of:
`String { view }.replace(...);`
2021-09-11 20:36:43 +03:00
Andreas Kling 2116fb5be9 UserspaceEmulator: Ignore perf_event and perf_register_string syscalls
We can just fail these with ENOSYS pending a full implementation.
2021-09-11 02:13:52 +02:00
Karol Kosek cf71805aa8 HackStudio: Reuse TextDocument::is_modified()
Previously, the modification tag in the editor file label was unset only
after a file was saved.

This commit will also unset the tag if you undo the stack (for example
by hitting Ctrl+Z) to the last saved state.
2021-09-10 00:00:53 +02:00
Karol Kosek eb5320023a HackStudio: Preserve the untitled filename text on file modification
Previously, the title of an unnamed file would just disappear from
the editor label if you started typing.
2021-09-09 02:33:18 +02:00
Hendiadyoin1 93ce8fc985 UserspaceEmulator: Handle SO_ERROR in getsockopt
This makes GUI applications work again
2021-09-07 21:26:21 +00:00
Andreas Kling 226383f45b LibELF: Use StringView to carry temporary strings in auxiliary vector
Let's not force clients to provide a String.
2021-09-07 13:53:14 +02:00
Ali Mohammad Pur 97e97bccab Everywhere: Make ByteBuffer::{create_*,copy}() OOM-safe 2021-09-06 01:53:26 +02:00
Brian Gianforcaro 3e45c3ed90 Userland: Switch static_assert of type sizes to AK::AssertSize 2021-09-05 20:08:57 +02:00
Karol Kosek dcc9db48c5 HackStudio: Drop files to the selected editor
Previously, the files were opened in the current editor, instead of one
that received a drop event.
2021-09-04 21:48:27 +02:00
Andreas Kling eaf88cc78a AK: Rename create<T> => make_ref_counted<T>
And also try_create<T> => try_make_ref_counted<T>.

A global "create" was a bit much. The new name matches make<T> better,
which we've used for making single-owner objects since forever.
2021-09-03 02:36:09 +02:00
sin-ack e9121f8b1f LibCore+Userland: Implement Core::deferred_invoke
Core::deferred_invoke is a way of executing an action after previously
queued events have been processed. It removes the requirement of
having/being a Core::Object subclass in order to defer invocation
through Core::Object::deferred_invoke.

Core::Object::deferred_invoke now delegates to Core::deferred_invoke.
The version with the Object& argument is still present but will be
removed in the following commits.

This commit additionally fixes a new places where the
DeferredInvocationEvent was dispatched to the event loop directly, and
replaces them with the Core::deferred_invoke equivalent.
2021-09-02 03:47:47 +04:30
Brian Gianforcaro 4de0f68486 Profiler: Minor static code analysis issues in FlameGraphView 2021-09-01 18:06:14 +02:00
Brian Gianforcaro 16f0248ca2 Profiler: Use = default for empty destructor 2021-09-01 18:06:14 +02:00
Brian Gianforcaro 511822c9fe HackStudio: Fix typo in C++ file extension mapping code
This looks like a copy past bug where we were checking "cc" twice
instead of checking for the equivalent header extension.

Found by Sonar Cloud.
2021-09-01 18:06:14 +02:00
Nicholas Hollett 0d98bba167 Profiler: Add a flamegraph view for the stack
The flamegraph makes it easier to quickly spot expensive functions,
based on the width of their bar.
2021-08-31 12:40:51 +02:00
Brian Gianforcaro f0b3aa0331 Everywhere: Pass AK::Format TypeErasedFormatParams by reference
This silences a overeager warning in sonar cloud, warning that
slicing could occur with `VariadicFormatParams` which derives from
`TypeErasedFormatParams`.

Reference:
https://sonarcloud.io/project/issues?id=SerenityOS_serenity&issues=AXuVPBO_k92xXUF3qWsm&open=AXuVPBO_k92xXUF3qWsm
2021-08-30 15:50:00 +04:30
Itamar 11832544e5 HackStudio: Add "Go Back" and "Go Forward" navigation actions
These actions allow the user to move backwards & forwards between
previous project locations they were at.
2021-08-30 12:44:26 +02:00
Itamar 8fc9ec942e HackStudio: Optionally pass line & column to open_file
This makes it easier to open a file at a specific location.
2021-08-30 12:44:26 +02:00
Brian Gianforcaro ad1051089c UserspaceEmulator: Profiles are now expected to have a strings array
The kernel profiles were recently changed to have a `strings` array
as part of the profile objects. The `ProfileViewer` now checks for
that during startup and declares the profile invalid if the array
is not present.

The UserspaceEmulator doesn't use the API which the kernel exposed
the string array for, so just fake it by always adding an empty array
to the generated profiles.
2021-08-28 20:03:08 +02:00
Brian Gianforcaro e00c871f65 UserspaceEmulator: Make generated profiles debugable with cli tools
The fact that profiles are json on one giant line makes them very
difficult to debug when things go wrong. Instead make sure to wrap
each event or sample on a newline so you can easily grep/heap/tail
the profile files.
2021-08-28 20:03:08 +02:00
Andrew Kaster 63956b36d0 Everywhere: Move all host tools into the Lagom/Tools subdirectory
This allows us to remove all the add_subdirectory calls from the top
level CMakeLists.txt that referred to targets linking LagomCore.

Segregating the host tools and Serenity targets helps us get to a place
where the main Serenity build can simply use a CMake toolchain file
rather than swapping all the compiler/sysroot variables after building
host libraries and tools.
2021-08-28 08:44:17 +01:00
Andrew Kaster fb15cdcc10 StateMachineGenerator: Don't move() return value from actions()
With the proper warnings enabled, this gives a Wpessimizing-move warning
2021-08-28 08:44:17 +01:00
Andreas Kling 82d8cd2b87 Terminal+LibVT: Use LibConfig instead of Core::ConfigFile 2021-08-26 00:54:27 +02:00
Karol Kosek a230524c46 HackStudio: Update the tree view cursor on editor change and 'Save as'
The more important thing here is to update the tree view
on 'Save As..', as we want to drop every connection from an old file.

Updating the tree view on current editor change is just a cool small
bonus. :^)
2021-08-25 17:42:54 +02:00
Marco Cutecchia d1f936e3d0 HackStudio: Add "New File" actions for different file extensions
Currently this supports the following file types: cpp, header, gml,
js, css, html and plain files
2021-08-25 12:12:15 +02:00
Karol Kosek 8d3304f853 HackStudio: Update every editor with matching filename on 'Save as...'
Prior this change, if user had more than two copies of one file opened
in a split view, then only the active editor was renamed,
when the others had the same file contents changed.

This change will set a new file name for every file.

The is_null() check is for uncreated files, as they shouldn't be
treated as the same single file.
2021-08-22 23:41:53 +02:00
Karol Kosek 90396f5b08 HackStudio: Convert selected path to a relative path on 'Save as...'
This makes the editor title a bit more consistent with the other files
and removes duplicating the file name in the file history
when reopening that file.
2021-08-22 23:41:53 +02:00
Lennon Donaghy 283d8d3928 HackStudio: Warn about unsaved changes on opening different project 2021-08-22 10:30:06 +02:00
Lennon Donaghy 82b88c6e16 HackStudio: Fix editor not marking file with unsaved changes as dirty
The editor's on_change callback was being overwritten in
HackStudioWidget.cpp in order to call update_gml_preview on every
change. This stopped the original callback from being called and marking
files as dirty when changed.

Now we call update_gml_preview in a new callback within the editor
wrapper, which is then called within the original on_change callback
in the editor.
2021-08-22 10:30:06 +02:00
Lennon Donaghy d454c63bde HackStudio: Fix GitWidget issues with switching between projects
GitWidget no longer crashes upon trying to create a repository for a new
project, and it correctly updates after opening a different project. A
new method, change_repo, has been added to make this work, which changes
m_repo_root and resets most of the widget's state in order to make this
work.
2021-08-22 10:30:06 +02:00
Lennon Donaghy d9c295de46 HackStudio: Moved code closing project from open_project to own method
Take the code which closes the current project out of open_project
method and move it into its own method.
2021-08-22 10:30:06 +02:00
Lennon Donaghy 3ce96134b5 HackStudio: Call update_gml_preview() to reset when opening new project 2021-08-22 10:30:06 +02:00
Lennon Donaghy 5ca888132d HackStudio: Make FindInFilesWidget reset when opening new project
Add method to FindInFilesWidget which resets the model in order to
clear the output when needed, and use this when a new project is opened.
2021-08-22 10:30:06 +02:00
Lennon Donaghy ff2a1ee8b0 HackStudio: Stop debugger when opening new project
Moved code to stop the debugger in the HackStudioWidget destructor to
a new method so that this can be called in both the destructor and when
opening a new project.
2021-08-22 10:30:06 +02:00
Lennon Donaghy 971a5a70d1 HackStudio: Clear embedded terminal upon opening a different project 2021-08-22 10:30:06 +02:00
Lennon Donaghy 6076deae1d HackStudio: Clear ToDo entries upon opening new project
The ToDoEntries and ToDoEntriesWidget classes now have methods for
clearing the entries, before entries would stay permanently, even after
switching to a new project.
2021-08-22 10:30:06 +02:00
Lennon Donaghy d48bd49002 HackStudio: Move handle_external_file_deletion logic into own method
Added a close_file_in_all_editors method to HackStudioWidget and moved
the code from handle_external_file_deletion into it so that it can be
reused elsewhere to close files.
2021-08-22 10:30:06 +02:00
networkException acde7d12b0 Everywhere: Rename get in ConfigFile::get_for_{lib,app,system} to open
This patch brings the ConfigFile helpers for opening lib, app and system
configs more inline with the regular ConfigFile::open functions.
2021-08-22 01:32:25 +02:00
Luke Wilde 4ab8939670 HackStudio: Fix ds => fs typo in fs changed check in RegistersModel
The changed check for `fs` was accidentally comparing the current `ds`
to the previous `fs`.
2021-08-21 08:41:27 +02:00
Karol Kosek 947b61c1de HackStudio: Update the window title after changing a file name
This is a very similar fix as the previous commit, but here it's
due to my oversight when I was adding an 'Save as..' feature.
2021-08-20 11:47:00 +02:00
Karol Kosek 6e64988396 HackStudio: Update the window title after changing an active editor
Prior this change, the window title was updated only when a new file
has been opened, which means that it wasn't updated when user selected
an already opened file in the split view.

This change updates the title whenever the active editor changes.
In addition, this title update logic has now its own function
as it'll also be used in the next commit. :)
2021-08-20 11:47:00 +02:00
Itamar 43392c567e HackStudio: Fix "navigate to include"
This fixes an off-by-one error in the "navigate to include" feature
of HackStudio.
2021-08-19 17:20:37 +02:00
Itamar 9ae98bc81b LibCpp: Handle circular imports gracefully
This patch prevents CppComprehensionEngine from endlessly looping when
there's a circular #include in the code.

We now keep track of the set of currently processed files, and will not
re-process a file if it already exists in this set.
When we're done with processing a file it is removed from this set.

The pragma once directive is not yet implemented, but regardless a
mechanism that prevents #include loops even in the absence of
pragma once is desired.
2021-08-19 17:20:37 +02:00
Andreas Kling 4eb198baf3 Profiler: Limit the initial size of the timeline container
If there are a lot of process timeline tracks, we don't want to make the
window gigantic. So let's just put a limit on it.
2021-08-18 13:06:27 +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
sin-ack 9c9a5c55cb Userland+LibGUI: Make Margins arguments match CSS ordering
Previously the argument order for Margins was (left, top, right,
bottom). To make it more familiar and closer to how CSS does it, the
argument order is now (top, right, bottom, left).
2021-08-18 10:30:50 +02:00
Daniel Bertalan 87ef2718bc UserspaceEmulator+LibC: Use sys$emuctl() to disable auditing in malloc
It was fragile to use the address of the body of the memory management
functions to disable memory auditing within them. Functions called from
these did not get exempted from the audits, so in some cases
UserspaceEmulator reported bogus heap buffer overflows.

Memory auditing did not work at all on Clang because when querying the
addresses, their offset was taken relative to the base of `.text` which
is not the first segment in the `R/RX/RW(RELRO)/RW(non-RELRO)` layout
produced by LLD.

Similarly to when setting metadata about the allocations, we now use the
`emuctl` system call to selectively suppress auditing when we reach
these functions. This ensures that functions called from `malloc` are
affected too, and no issues occur because of the inconsistency between
Clang and GCC memory layouts.
2021-08-14 18:42:14 +02:00
Daniel Bertalan 09cef25e92 UserspaceEmulator: Make call rm32 work with address on the stack
Previously, we pushed the old `eip` on the stack before reading the new
address, which made us jump to the wrong place if the destination was
relative to the `esp`.
2021-08-14 18:42:14 +02:00
Daniel Bertalan bfe5509a28 UserspaceEmulator: Prefix MmapRegions' name with '(UE)'
When printing a backtrace, each library's base address is found by
walking through all memory regions in the coredump, and selecting the
address of the first region whose name begins with the library's soname.
This is done to support the Clang toolchain, where .text is not at
offset 0.

However, because the libraries loaded by the emulated process used the
same names, we could not distinguish those with the ones used by
UserspaceEmulator, so the backtrace ended up being garbage.

Using the libraries mapped by UE would not be a sufficient, as the
running application could ask for other libraries too, and doing away
with setting names would make debugging issues within UE code more
difficult.
2021-08-14 18:42:14 +02:00
Itamar 8505fcb8ae LibCpp: Understand preprocessor macro definition and invocation
The preprocessor now understands when a function-like macro is defined,
and can also parse calls to such macros.

The actual evaluation of function-like macros will be done in a
separate commit.
2021-08-14 12:40:55 +02:00
Andreas Kling 0d21a1307e Profiler: Set the initial size of the timeline container to a snug fit 2021-08-14 01:28:26 +02:00
Andreas Kling 8f590cbeb8 Profiler: Add a "Signposts" tab next to the "Samples" tab
This tab provides a filtered listing of all the signpost events in the
currently selected time range.
2021-08-14 01:28:26 +02:00
Andreas Kling 9a334ebb3a Profiler: Don't lose sight of timeline tracks when zooming out
Update the track sizes before repositioning them. This ensures that they
always remain visible in the timeline container.
2021-08-14 01:28:26 +02:00
Andreas Kling 3cc5308ddc Profiler: Don't include signposts in the samples list 2021-08-14 01:28:26 +02:00
Andreas Kling 2da817615e Profiler: Store signposts in the main event stream
Instead of keeping a separate Vector<Event> for signposts, let them live
in the main event stream. For fast iteration, we instead keep a cache of
the signpost event indices.
2021-08-14 01:28:26 +02:00
Andreas Kling f5db92448d Profiler: Use AK::Variant for type-specific data in Profile::Event
Each event has a different set of data depending on the event type.
2021-08-14 01:28:26 +02:00
Andreas Kling 7abf58ecaf Profiler: Store event type as enum
Also check for the most common event type (sample) first instead of
leaving it as the fallback. This avoids a lot of string comparisons
while parsing profiles.
2021-08-13 03:06:07 +02:00
Andreas Kling 5a2ccbffc5 Profiler: Remove "Signpost " prefix from timeline tooltips 2021-08-13 03:03:53 +02:00
Andreas Kling 00603d9fd0 Revert "HackStudio: Remove noop code when opening the project"
This reverts commit 012fc3f923.
2021-08-12 20:56:54 +02:00
Jean-Baptiste Boric 2084289162 Userland: Fix PATH environment variable ordering 2021-08-12 18:56:30 +02:00
Karol Kosek 012fc3f923 HackStudio: Remove noop code when opening the project
28b1e66b51 made that
the m_all_editor_wrappers vector is cleared everytime a project path
is changed (the m_project if check is just for the app launch --
the vector is empty there anyway), making the code never execute.
2021-08-12 18:55:58 +02:00
Karol Kosek a2cb5c862d HackStudio: Show the 'Save as...' dialog when saving uncreated file
Previously when user wanted to save an uncreated file, the program
would just quietly ignore the save request, without giving any message.
This can be seen when creating a new editor in split view mode.
2021-08-12 18:54:57 +02:00
Karol Kosek 8516b9532e HackStudio: Add 'Save as...' action
Not adding it to the toolbar, because it has the same icon as
a typical 'Save' action.
2021-08-12 18:54:57 +02:00
Karol Kosek 8a4bb581a2 HackStudio: Show text editor after starting the application
The user can now start typing text instead of creating a file first.

This also enables drag-and-dropping a file as soon as the application
starts.
2021-08-12 18:54:25 +02:00
Andreas Kling 1e90a3a542 Kernel: Make sys$perf_register_string() generate the string ID's
Making userspace provide a global string ID was silly, and made the API
extremely difficult to use correctly in a global profiling context.

Instead, simply make the kernel do the string ID allocation for us.
This also allows us to convert the string storage to a Vector in the
kernel (and an array in the JSON profile data.)
2021-08-12 00:03:39 +02:00
Andreas Kling 3ed6c137df Profiler: Parse and render signpost strings
The first perf_event argument to a PERF_EVENT_SIGNPOST is now
interpreted as a string ID (in the profile strings set.)

This allows us to generate signposts with custom strings. :^)
2021-08-12 00:03:39 +02:00
Andreas Kling 00b11d7577 Profiler: Parse and paint profile signpost events :^)
Signposts generated by perf_event(PERF_EVENT_SIGNPOST) now show up in
profile timelines, and if you hover them you get a tooltip with the two
arguments passed with the event.
2021-08-12 00:03:38 +02:00
Karol Kosek b1bc5532e7 HackStudio: Make "Open project" action open in the current project path
Prior this change, the action opened a File Picker
in user home directory.

Changing the startup path to a project path might make correcting
the path or switching between different projects a bit faster,
as you don't have to go through the subdirectories all over again.
It's also the path that's showed in the project tree view.
2021-08-11 01:50:33 +02:00
Ali Mohammad Pur 3ad2f1bfd1 Profiler: Disassemble the entire function if the symbol is a function
Previously the view would've cut off at the last instruction that was
hit in the profile, which is not the right behaviour for functions.
2021-08-10 23:19:33 +02:00
sin-ack b6ef12bd26 Profiler: Use SelectionBehavior::SelectRows
Profiler uses the TreeView in a tabular fashion, and so should set the
selection behavior appropriately.
2021-08-10 21:56:47 +02:00
Andreas Kling 02f9ffeb7f UserspaceEmulator: Fail sys$map_time_page() with ENOSYS for now
This allows LibC to fall back to sys$clock_gettime() until we can
add support for the kernel time page to UserspaceEmulator.
2021-08-10 19:21:16 +02:00
Andreas Kling fa64ab26a4 Kernel+UserspaceEmulator: Remove unused sys$gettimeofday()
Now that LibC uses clock_gettime() to implement gettimeofday(), we can
get rid of this entire syscall. :^)
2021-08-10 13:01:39 +02:00
Ali Mohammad Pur 369e3da6a2 UserspaceEmulator: Move all the profiling details into the Emulator
Them being in the global namespace doesn't have a lot of fans, it seems.
2021-08-10 05:13:44 +04:30
Ali Mohammad Pur 2128ae4ab0 Profiler: Disassemble the containing function for non-function symbols
This can happen if the symbol is part of a switch-case, and not
a function, which would previously have made the disassembly view
appear empty.
Now we disassemble the containing function, starting at the given label
and continuing up until the last captured instruction.
2021-08-10 05:13:44 +04:30
Ali Mohammad Pur 4bef63fa6a Profiler: Show the symbol address in object file 2021-08-10 05:13:44 +04:30
Ali Mohammad Pur 64ccf2196c UserspaceEmulator+LibC: Add support for Region-of-Interest profiling 2021-08-10 05:13:44 +04:30
Tobias Christiansen 2a77abf85e Everywhere: Use tobyase@serenityos.org for my copyright headers 2021-08-09 21:43:05 +02:00
Daniel Bertalan e9dd9d1f2c UserspaceEmulator: Use for_each_region_of_type in find_text_region
Since we now have this helper template, we can make our code cleaner.
2021-08-08 10:55:36 +02:00
Daniel Bertalan c1d6637dc7 UserspaceEmulator: Make symbolication work when .text isn't the first
... segment

This happens with binaries build with Clang or with a custom linker
script. If this is the case, offsets should be calculated not from the
base address of `.text`, but from the first section loaded for the
library.

This commit moves all UserspaceEmulator symbolication into a common
helper function and fixes a FIXME.
2021-08-08 10:55:36 +02:00
Daniel Bertalan 980f314a03 UserspaceEmulator: Fix typo in a method name
Changes `load_library_from_adress` to `load_library_from_address`.
2021-08-08 10:55:36 +02:00
Itamar 9da9398bf0 LibCpp: Do macro substitution in the preprocessor instead of the parser
After this change, the parser is completely separated from preprocessor
concepts.
2021-08-07 21:24:11 +02:00
Itamar 0c4dc00f01 LibCpp: Import definitions from headers while processing
When the preprocessor encounters an #include statement it now adds
the preprocessor definitions that exist in the included header to its
own set of definitions.

We previously only aggregated the definitions from headers after
processing the source, which was less correct. (For example, there
could be an #ifdef that depends on a definition from another header).
2021-08-07 21:24:11 +02:00
Itamar 4673a517f6 LibCpp: Do lexing in the Preprocessor
We now call Preprocessor::process_and_lex() and pass the result to the
parser.

Doing the lexing in the preprocessor will allow us to maintain the
original position information of tokens after substituting definitions.
2021-08-07 21:24:11 +02:00
sin-ack 16ac3bbfd7 LibGUI+Applications: Rename Model::is_valid to is_within_range
The previous name did not describe what the function checked, and was
easy to confuse with ModelIndex::is_valid.
2021-08-06 21:03:53 +02:00
sin-ack ca2c81251a Everywhere: Replace Model::update() with Model::invalidate()
Most of the models were just calling did_update anyway, which is
pointless since it can be unified to the base Model class. Instead, code
calling update() will now call invalidate(), which functions identically
and is more obvious in what it does.

Additionally, a default implementation is provided, which removes the
need to add empty implementations of update() for each model subclass.

Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2021-08-06 19:14:31 +02:00
Ali Mohammad Pur 5d3b452897 Profiler: Display source location information in the disassembly view
With this, we can now have some amount of source-level profiling
information :^)
2021-08-06 01:14:03 +02:00
Ali Mohammad Pur c4437e19bd LibDebug+Everywhere: Make DebugInfo not own the ELF image
This is required to avoid copying the image where otherwise a reference
would be enough.
2021-08-06 01:14:03 +02:00
Ali Mohammad Pur 521217735b UserspaceEmulator: Optionally generate a Profiler-compatible profile
`ue --profile --profile-file ~/some-file.profile id` can now generate a
full profile (instruction-by-instruction, if needed), at the cost of not
being able to see past the syscall boundary (a.la. callgrind).
This makes it significantly easier to profile seemingly fast userspace
things, like Loader.so :^)
2021-08-06 01:14:03 +02:00
Gunnar Beutner b81926d933 HackStudio: Enable building HackStudio on x86_64
This implements bits and pieces to get the debugging functionality to
build. No testing has been done to check whether it actually works
because GCC doesn't currently work.
2021-08-02 00:57:06 +02:00
Lennon Donaghy 28b1e66b51 HackStudio: Properly close previous project when opening a new one
Previously files in the open files view would stay open from the
previous project, and files in the new project with the same name as
files in the old one would be inaccessible, with the old ones showing
up instead. Now all files and open editors are closed before a new
project is opened.

Fixes #9103
2021-08-01 09:17:02 +02:00
Brian Gianforcaro a4c37d49a0 DevTools: Remove unused header includes 2021-08-01 08:10:16 +02:00
Karol Kosek ceadbafa97 HackStudio+TextEditor: Sync extensions from the FileIconProvider file
This adds more possible extensions for highlighting C/C++ files
and JavaScript module files.
2021-07-31 08:18:01 +02:00
Karol Kosek d1f5cd3c7e HackStudio: Don't use 'else' after 'return' 2021-07-31 08:18:01 +02:00
Karol Kosek bf322e072f HackStudio: Add syntax highlighting for HTML, Shell, and SQL files
.html files were recognised before -- the name was shown on
the statusbar, but it didn't actually enable the syntax highlighting.

This also sneaks a highlighting for JSON using JS highlighting.
It isn't technically correct, but so does TextEditor. :^)
2021-07-31 08:18:01 +02:00
Andreas Kling f6ccff944a Profiler: Don't perform disassembly when disassembly view is hidden 2021-07-29 11:44:39 +02:00
Conor Byrne 6aa2b7d4cc HackStudio: Add GML Preview action tab
This allows us to show a GML Preview in realtime via
HackStudio::GMLPreviewWidget! :^)
2021-07-29 11:33:16 +02:00
Conor Byrne 0295cf96a8 HackStudio: Add autocompletion for GML files 2021-07-29 11:33:16 +02:00
Conor Byrne 2b5566d7cc LibGUI+Playground: Move GMLAutocompleteProvider to LibGUI 2021-07-29 11:33:16 +02:00
Andreas Kling 4dff72fbf7 HackStudio: Tweak splitter spacings in the main UI
The splitters all felt a little bit too small and hard-to-grab.
This patch puts a little more fat on them.
2021-07-28 20:24:56 +02:00
Gunnar Beutner 57417a3d6e Kernel: Support loading the kernel at almost arbitrary virtual addresses
This enables further work on implementing KASLR by adding relocation
support to the pre-kernel and updating the kernel to be less dependent
on specific virtual memory layouts.
2021-07-27 13:15:16 +02:00
Nicholas Hollett 4857943a71 HackStudio: Resize editors when removing panes
Splitter does weird things when you resize and then remove children.
This works around the limitation by forcing at least one of the editors
to fill the space. It's janky, but at least doesn't result in the last
editor not filling the window.
2021-07-26 23:46:39 +02:00
Phoenix 1621311d73 GML Playground: Add Vim emulation 2021-07-24 01:13:42 +02:00
Hendiadyoin1 7da12f0faf UserspaceEmulator: Move to using the new SoftFPU 2021-07-22 23:33:21 +02:00
Hendiadyoin1 45d0f84a27 UserspaceEmulator: Implement SoftFPU instructions
This implements almost all instructions related to the FPU, including
all MMX instructions as well.
A lot of these were copied and adjusted from the SoftCPU implementation.

The next big milestone would be QNan detection and ShadowValue handling.
2021-07-22 23:33:21 +02:00
Hendiadyoin1 09a1a0b319 UserspaceEmulator: Sketch out a SoftFPU interface 2021-07-22 23:33:21 +02:00
Hendiadyoin1 eb6af29421 LibX86: Add missing MovD and MovQ instructions
These are placeholders for now
2021-07-22 23:33:21 +02:00
Hendiadyoin1 efa42c4d45 LibX86: Use names closer to the spec for the Modrm
This gets rid of a lot of magic number shifts and ands.
2021-07-22 23:33:21 +02:00
Gunnar Beutner 60d6137e73 Userland: Use /proc/kernel_base to determine the kernel base address
This removes all the hard-coded kernel base addresses from userspace
tools.

One downside for this is that e.g. Profiler no longer uses a different
color for kernel symbols when run as a non-root user.
2021-07-22 21:38:23 +02:00
Gunnar Beutner 36e36507d5 Everywhere: Prefer using {:#x} over 0x{:x}
We have a dedicated format specifier which adds the "0x" prefix, so
let's use that instead of adding it manually.
2021-07-22 08:57:01 +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
Andreas Kling 687a12d7fb Userland: Add GUI::Window::add_menu() and use it everywhere
Applications previously had to create a GUI::Menubar object, add menus
to it, and then call GUI::Window::set_menubar().

This patch introduces GUI::Window::add_menu() which creates the menubar
automatically and adds items to it. Application code becomes slightly
simpler as a result. :^)
2021-07-21 21:24:26 +02:00
Andreas Kling c7d891765c LibGfx: Use "try_" prefix for static factory functions
Also mark them as [[nodiscard]].
2021-07-21 18:02:15 +02:00
Andreas Kling e7136399a1 LibX86: Add INT1 instruction (needed for disassembly) 2021-07-20 18:05:05 +02:00
Gunnar Beutner fbc56461da Profiler: Make profiler not truncate 64-bit addresses 2021-07-20 15:12:19 +02:00
Gunnar Beutner 60b52cfb02 Userland: Hardcode the x86_64 kernel base address for now 2021-07-20 15:12:19 +02:00
Brian Gianforcaro 06468d9794 Revert "Profiler: Configure the TimelineContainer to be shrink to fit"
This reverts commit cfef3040fb.

It looks like although this does improve things, it also degrades the
experience and messes with the usability, especially for large amounts
of processes.

Need to come back to this with a more holistic fix.
2021-07-19 23:09:28 +04:30
Tom 7e77a2ec40 Everywhere: Improve CPU usage calculation
As threads come and go, we can't simply account for how many time
slices the threads at any given point may have been using. We need to
also account for threads that have since disappeared. This means we
also need to track how many time slices we have expired globally.

However, because this doesn't account for context switches outside of
the system timer tick values may still be under-reported. To solve this
we will need to track more accurate time information on each context
switch.

This also fixes top's cpu usage calculation which was still based on
the number of context switches.

Fixes #6473
2021-07-18 22:08:26 +02:00
Ali Mohammad Pur f364fcec5d LibRegex+Everywhere: Make LibRegex more unicode-aware
This commit makes LibRegex (mostly) capable of operating on any of
the three main string views:
- StringView for raw strings
- Utf8View for utf-8 encoded strings
- Utf32View for raw unicode strings

As a result, regexps with unicode strings should be able to properly
handle utf-8 and not stop in the middle of a code point.
A future commit will update LibJS to use the correct type of string
depending on the flags.
2021-07-18 21:10:55 +04:30
Gunnar Beutner 98f8ecd9d2 Kernel: Split debug symbols into a separate file
This speeds up the boot process considerably when specifying the kernel
image via -initrd.
2021-07-18 17:31:13 +02:00
Maurice Hieronymus a205633643 HackStudio: Prevent crash when stepping through a program
The backtrace view expects that there is always a valid selection. This
is not true when we execute a step in the debugger. Therefore we need
to check if we have a valid selection in the on_selection_change
handler.
2021-07-18 13:13:31 +02:00
Brian Gianforcaro cfef3040fb Profiler: Configure the TimelineContainer to be shrink to fit
Today the profile viewer timeline view has a static size, which is
computed as half the height of the window given it has two root widgets.

Instead the timeline view should shrink to only consume the size that
each process timeline consumes.
2021-07-17 18:24:54 +04:30
Karol Kosek c66f484bce HackStudio: Continue removing files after failure 2021-07-17 01:11:00 +02:00
Karol Kosek 6e51fe146c HackStudio: Disable Delete action on insufficient permissions
Hack Studio will now disable the action when any parent
of selected files do not have write permission.
2021-07-17 01:11:00 +02:00
ry-sev 2634cab7a8 HackStudio: Add statusbar with file and selected text information 2021-07-16 12:58:20 +02:00
Hendiadyoin1 54c005754a UserpaceEmulator: Handle possibly unaligned IO
We also should add some UB warnings for that in the future
2021-07-14 11:26:34 +04:30
Karol Kosek b2daaca5ee HackStudio: Activate window only on file drop 2021-07-12 20:02:15 +02:00
Gunnar Beutner cbdc7f9e41 UserspaceEmulator: Fix stack for new processes
Fixes #8646.
2021-07-12 12:27:13 +02:00
Andrew Kaster f26d4e1d90 IPCCompiler: Use GENERATE_DEBUG from AK/Debug instead of custom defines
The IPCCompiler was using GENERATE_DEBUG_CODE, which was missing from
AK/Debug.h.in, and plain old DEBUG. Let's just use the one that
was already in the debug header, but unused.
2021-07-12 12:26:52 +02:00
Maurice Hieronymus dfc33cd412 HackStudio: Disable debug specific context entries
Context menu entries like evaluate expression and
move execution to line action should only be enabled
when a debug session is running. Otherwise they should
be disabled.
2021-07-12 00:47:04 +02:00
Maurice Hieronymus 488d0722bd HackStudio: Disable run button while debugging
This commit disables the run button while we
are in debug mode. Otherwise the stop button
gets disabled when we run the program while
we are in debug mode. This would prevent us
from exiting the debug mode.
2021-07-12 00:47:04 +02:00
Itamar b5a02b180c LibCpp: Use fast_is<T> and verify_cast<T> to replace C-style casts
Thanks to @alimpfard for suggesting this :)
2021-07-10 21:58:28 +02:00
Itamar 34fc6c7e1c LibCpp: Make the fields of AST node types private
Previously almost all fields were public and were directly accessed by
the Parser and CppComprehensionEngine.

This commit makes all fields of AST node types private. They are now
accessed via getters & setters.
2021-07-10 21:58:28 +02:00
Andreas Kling b8a204c5b9 LibThreading: Rename Lock => Mutex 2021-07-09 11:15:50 +02:00
Daniel Bertalan 3bdefb4623 UserspaceEmulator: Use long double in FABS
`fpu_get` returns a long double and `fpu_set` expects a long double as
its parameter, and the X87 FPU uses long doubles as its internal
storage, meaning the `FABS` operates on them. This means the correct
intrinsic function for implementing it is `__builtin_fabsl`.
2021-07-08 10:11:00 +02:00
Daniel Bertalan 98a9a1d7f9 Everywhere: Add break after the last case label before default
We already do this in most places, so the style should be consistent.
Also, Clang does not like it, as this could cause an unexpected compile
error if some statements are added to the default label or a new label
is added above it.
2021-07-08 10:11:00 +02:00
Daniel Bertalan b0208ce433 Everywhere: Forward declare structs as structs
While structs being forward declared as classes is not strictly an
issue, Clang complains as this is not portable code, since some ABIs
treat classes declared as `class` and `struct` differently.

It's easier to fix these than to reason about explicitly disabling
another warning.
2021-07-08 10:11:00 +02:00
Daniel Bertalan b76ad3db90 IPCCompiler+WindowServer: Fix deleted function warning
It might be the case that we are passing non-movable/non-copyable things
through IPC. In this case, Clang will emit a warning as it can't
generate the requested default move/copy ctor for the IPC message.

To fix this, we use a `#pragma` to make the compiler silently ignore our
request.

The same was the case with the three-way comparison in `Screen`. Since
we don't use the three-way comparison operator anywhere else in our
codebase, we simply use the `==` operator instead.
2021-07-08 10:11:00 +02:00
Daniel Bertalan 01a0aa6e0b HackStudio: Do not check NonnullRefPtr for null value 2021-07-08 10:11:00 +02:00
Daniel Bertalan ca06fd658d Everywhere: Remove unused local variables and lambda captures 2021-07-08 10:11:00 +02:00
Idan Horowitz e3ef241108 LibJS: Remove the non-standard put helper and replace it's usages
This removes all usages of the non-standard put helper method and
replaces all of it's usages with the specification required alternative
or with define_direct_property where appropriate.
2021-07-06 14:20:30 +01:00
Linus Groh 09bd5f8772 LibJS: Rewrite most of Object for spec compliance :^)
This is a huge patch, I know. In hindsight this perhaps could've been
done slightly more incremental, but I started and then fixed everything
until it worked, and here we are. I tried splitting of some completely
unrelated changes into separate commits, however. Anyway.

This is a rewrite of most of Object, and by extension large parts of
Array, Proxy, Reflect, String, TypedArray, and some other things.

What we already had worked fine for about 90% of things, but getting the
last 10% right proved to be increasingly difficult with the current code
that sort of grew organically and is only very loosely based on the
spec - this became especially obvious when we started fixing a large
number of test262 failures.

Key changes include:

- 1:1 matching function names and parameters of all object-related
  functions, to avoid ambiguity. Previously we had things like put(),
  which the spec doesn't have - as a result it wasn't always clear which
  need to be used.
- Better separation between object abstract operations and internal
  methods - the former are always the same, the latter can be overridden
  (and are therefore virtual). The internal methods (i.e. [[Foo]] in the
  spec) are now prefixed with 'internal_' for clarity - again, it was
  previously not always clear which AO a certain method represents,
  get() could've been both Get and [[Get]] (I don't know which one it
  was closer to right now).
  Note that some of the old names have been kept until all code relying
  on them is updated, but they are now simple wrappers around the
  closest matching standard abstract operation.
- Simplifications of the storage layer: functions that write values to
  storage are now prefixed with 'storage_' to make their purpose clear,
  and as they are not part of the spec they should not contain any steps
  specified by it. Much functionality is now covered by the layers above
  it and was removed (e.g. handling of accessors, attribute checks).
- PropertyAttributes has been greatly simplified, and is being replaced
  by PropertyDescriptor - a concept similar to the current
  implementation, but more aligned with the actual spec. See the commit
  message of the previous commit where it was introduced for details.
- As a bonus, and since I had to look at the spec a whole lot anyway, I
  introduced more inline comments with the exact steps from the spec -
  this makes it super easy to verify correctness.
- East-const all the things.

As a result of all of this, things are much more correct but a bit
slower now. Retaining speed wasn't a consideration at all, I have done
no profiling of the new code - there might be low hanging fruits, which
we can then harvest separately.

Special thanks to Idan for helping me with this by tracking down bugs,
updating everything outside of LibJS to work with these changes (LibWeb,
Spreadsheet, HackStudio), as well as providing countless patches to fix
regressions I introduced - there still are very few (we got it down to
5), but we also get many new passing test262 tests in return. :^)

Co-authored-by: Idan Horowitz <idan.horowitz@gmail.com>
2021-07-04 22:07:36 +01:00
Itamar 2af5bb9083 CppLanguageServer: Add test for "get_parameters_hint" 2021-07-04 17:50:33 +02:00
Itamar f26f764c7d HackStudio: Show tooltip with parameters hint when pressing Ctrl+P
When you press Ctrl+P while the cursor is inside the parameters list of
a function call site, HackStudio will request the C++ language server
to retrieve the parameters of the called function.

The result is displayed in a tooltip window, with the current argument
in bold font.
2021-07-04 17:50:33 +02:00
Itamar 32be65a8b4 CppLanguageServer: Add "get_parameters_hint" capability
Given a call site, the C++ language server can now return the declared
parameters of the called function, as well as the index of the
parameter that the cursor is currently at.
2021-07-04 17:50:33 +02:00
Gunnar Beutner 3bbe86d8ea Everywhere: Prefer using "..."sv over StringView { "..." } 2021-07-04 14:24:03 +02:00
Erik Biederstadt ba4d367dea HackStudio: Remove old form editing logic
In the past Hack Studio had the ability to design GUI widgets via `.frm`
files. We now use the GML playground for this purpose, and the old code
can be removed. `.frm` files are now treated as plain text files.

This commit also fixes a crash when opening `.frm` files.
`m_form_inner_container` was never instantiated, and caused a null
pointer dereference.
2021-07-04 01:14:54 +02:00
Timothy 944e5cfb35 Everywhere: Use IPC include syntax
Remove superfluous includes from IPCCompiler's generated output and
add include directives in IPC definitions where appropriate.
2021-07-03 12:16:00 +02:00
Timothy 83fb97c301 IPCCompiler: Add include parsing for endpoints
This will find all lines at the start of the file beginning with # and
copy them straight through.
2021-07-03 12:16:00 +02:00
Max Wipfli 9cc35d1ba3 AK: Implement String::find_any_of() and StringView::find_any_of()
This implements StringUtils::find_any_of() and uses it in
String::find_any_of() and StringView::find_any_of(). All uses of
find_{first,last}_of have been replaced with find_any_of(), find() or
find_last(). find_{first,last}_of have subsequently been removed.
2021-07-02 21:54:21 +02:00
Hendiadyoin1 59eea93d2a Userland: Disable Hackstudio and UE on x86_64 2021-06-30 19:05:51 +02:00
Max Wipfli d8be530397 AK+Everywhere: Remove "null state" of LexicalPath
This removes the default constructor of LexicalPath, and subsequently
modifies all its users to accommodate the change.
2021-06-30 11:13:54 +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
Max Wipfli 9b8f35259c AK: Remove the LexicalPath::is_valid() API
Since this is always set to true on the non-default constructor and
subsequently never modified, it is somewhat pointless. Furthermore,
there are arguably no invalid relative paths.
2021-06-30 11:13:54 +02:00
Max Wipfli f45273649f AK+Everywhere: Change int to size_t in JsonObject and JsonArray 2021-06-29 13:18:03 +02:00
Itamar ab3aa0759a LanguageServers: Don't VERIFY that set_todo_entries callback exists
The callback may not exist if the CodeComprehensionEngine is running
in the context of tests (i.e CppLanguageServer -t).
2021-06-29 00:07:19 +04:30
Itamar ccb52b005e CppLanguageServer: Make properties_of_type return any property
Previously, CppComprehensionEngine::properties_of_type only returned
variables.
2021-06-29 00:07:19 +04:30
Itamar d7aa831a43 LibCpp: Differentiate between Type and NamedType
This adds a new ASTNode type called 'NamedType' which inherits from
the Type node.

Previously every Type node had a name field, but it was not logically
accurate. For example, pointer types do not have a name
(the pointed-to type may have one).
2021-06-29 00:07:19 +04:30
Andreas Kling dff3439ad0 Profiler: Cache the timeline histograms instead of recomputing on paint
There was an aggressive amount of work happening on every paint. :^)
2021-06-27 12:05:28 +02:00
Itamar e16c24bb95 HackStudio: Do not create a new LanguageClient unless needed
Previously, whenever Editor::set_document() was called, we destroyed
the previous LanguageClient instance of the editor and created a new
one.

We now check if the language of the existing LanguageClient matches the
new document, and if so we do not create a new LanguageClient instance.

This fixes an issue where doing "goto definition" would crash
HackStudio. This was probably introduced in 44418cb351.

The crash occurred because when doing "goto definition", we called a
AK::Function callback from the LanguageClient, which internally called
Editor::set_document().

Editor::set_document() destroyed the existing LanguageClient, which
cased a VERIFY in Function::clear() to fail because we were trying to
destroy the AK::Function object while executing inside it.
2021-06-25 18:58:34 +02:00
Itamar 743157348d HackStudio: Add LanguageClient::Language() getter 2021-06-25 18:58:34 +02:00
Andreas Kling e59bf87374 Userland: Replace VERIFY(is<T>) with verify_cast<T>
Instead of doing a VERIFY(is<T>(x)) and *then* casting it to T, we can
just do the cast right away with verify_cast<T>. :^)
2021-06-24 21:13:09 +02:00
Gunnar Beutner f2eb759901 Profiler: Use u32 when constructing InstructionData
When constructing values of the InstructionData type we assume that
the event_count field is a size_t while it actually is a u32. On x86_64
this fails because those are different types.
2021-06-24 09:27:13 +02:00
Gunnar Beutner ac650d2362 Userland: Remove dummy IPC methods
They're not used anywhere and are unnecessary boilerplate code. So let's
remove them and update IPCCompiler to allow for empty endpoint
declarations.
2021-06-24 00:38:58 +02:00
Federico Guerinoni e0f1c237d2 HackStudio: Make TODO entries clickable
Now you can click a TODO entry to set focus on that position of that
file.
2021-06-23 19:00:11 +01:00
Federico Guerinoni 935c7b2f4b HackStudio: Add TODO entries widget 2021-06-23 19:00:11 +01:00
Federico Guerinoni 26a7356e90 LanguageServers: Add function to collect TODO entries in a document 2021-06-23 19:00:11 +01:00
Hendiadyoin1 5d24b5f4be UserspaceEmulator: Add a simple debugging Console
For now this only allows us to single-step through execution and inspect
part of the execution environment for debugging
This also allows to run to function return and sending signals to the VM

This changes the behavior of SIGINT for UE to pause execution and then
terminate if already paused

A way of setting a watchpoint for a function would be a good addition in
the future, the scaffold for this is already present, we only need to
figure out a way to find the address of a function

On a side note I have changed all occurences of west-const to east const
2021-06-23 12:41:37 +04:30
Gunnar Beutner 92fdc5bd69 Playground: Prompt to save changes after the user picked a file to open
There's no point in saving the file - and potentially having to ask the
user for a file name - if the user abandons the 'Open' action by
clicking 'Cancel' in the file picker. This now also matches TextEditor's
behavior.
2021-06-22 22:56:22 +02:00
Gunnar Beutner c2ae25967a Playground: Add a menu action to save the file
There was already 'Save As' and now we also have 'Save'.
2021-06-22 22:56:22 +02:00
Gunnar Beutner de84b3fa1c Playground: Ask to save changes even when the document was never saved
This makes sure to ask the user whether they want to save changes to
their current document when opening a file even if the document has
never been saved before.
2021-06-22 22:56:22 +02:00
Idan Horowitz dcb55db99b LibJS: Replace boolean without_side_effects parameters with an enum 2021-06-17 16:52:15 +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
Dmitrii Ubskii d5828dbecb HackStudio: Indicate git changes in the editor's gutter
"+" for added lines, "!" for changed, "-" for removed.
2021-06-13 12:33:15 +01:00
Dmitrii Ubskii 8501617fcb LibGUI+HackStudio: Make gutter a first class element
Gutter -- a space left of the text, before the ruler -- is not a part of
the ruler, nor should it be treated as such. This commit implements
gutter handling in LibGUI::TextEditor as part of mild cleaning up of the
gutter handling (breakpoint icons) in HackStudio's Editor.

This commit also enables separate theming of the gutter.
2021-06-13 12:33:15 +01:00
Gunnar Beutner 1fd547bf0b IPCCompiler: Avoid copies for IPC method return values
Fixes #8017.
2021-06-13 10:33:09 +02:00
NonStdModel c93f73c617 HackStudio: Remove unnecessary unveil in ShellLanguageServer
Remove unveil on / with only browse permissions. Unveil will be sealed
later when the root path of project is known.
2021-06-12 22:49:20 +04:30
Andreas Kling dc65f54c06 AK: Rename Vector::append(Vector) => Vector::extend(Vector)
Let's make it a bit more clear when we're appending the elements from
one vector to the end of another vector.
2021-06-12 13:24:45 +02:00
networkException 592bc1e331 HackStudio: Add "Show in File Manager" Action to project TreeView
This shows all selected inodes in their parent directory.

Currently, each selection makes a seperate call to LaunchServer
and opens a seperate FileManager window. In the future selections
with a shared parent could share windows.
2021-06-12 00:47:37 +01:00
Hendiadyoin1 5ffe23e4f3 AK+LibX86: Generalize u128/256 to AK::UFixedBigInt
Doing these as custom classes might be faster, especially when writing
them in SSE, but this would cause a lot of Code duplication and due to
the nature of constexprs and the intelligence of the compiler they might
be using SSE/MMX either way
2021-06-11 18:14:11 +04:30
Itamar dcdb0c7035 LibCpp: Support non-field class members
Previously, we had a special ASTNode for class members,
"MemberDeclaration", which only represented fields.

This commit removes MemberDeclaration and instead uses regular
Declaration nodes for representing the members of a class.

This means that we can now also parse methods, inner-classes, and other
declarations that appear inside of a class.
2021-06-09 22:26:46 +02:00
Ali Mohammad Pur 7ac196974d Everywhere: Replace Vector<T*> with nonnull entries with Vector<T&> 2021-06-08 19:14:24 +02:00
Jelle Raaijmakers a32fe8df33 UserspaceEmulator: Stop parsing options on first non-option 2021-06-08 11:30:58 +02:00
Ali Mohammad Pur 51c2c69357 AK+Everywhere: Disallow constructing Functions from incompatible types
Previously, AK::Function would accept _any_ callable type, and try to
call it when called, first with the given set of arguments, then with
zero arguments, and if all of those failed, it would simply not call the
function and **return a value-constructed Out type**.
This lead to many, many, many hard to debug situations when someone
forgot a `const` in their lambda argument types, and many cases of
people taking zero arguments in their lambdas to ignore them.
This commit reworks the Function interface to not include any such
surprising behaviour, if your function instance is not callable with
the declared argument set of the Function, it can simply not be
assigned to that Function instance, end of story.
2021-06-06 00:27:30 +04:30
Max Wipfli cb5a50d3f7 LibGUI: Fix off-by-one error in Lexer tokens
This changes the INI and GML lexers to conform to the now-fixed
rendering of syntax highlighting spans in GUI::TextEditor.

The other user of GMLToken::m_end, GMLAutocompleteProvider, has been
modified to take into account that end position columns have been
incremented by one.
2021-06-05 00:32:28 +04:30
Itamar fdaec58f59 HackStudio: Add comment about lexicographical insertion to ClassView 2021-06-04 19:29:22 +02:00
Itamar c1b2003687 HackStudio: Use Node's name when inserting to the ClassView tree
Previously, when traversing the ClassView tree to find the parent of a
new node, we used the name of the node's declaration to find the path
to the parent in the tree.

However, some nodes in the tree do not have a matching declaration,
which caused a VERIFY failure.

To fix this, we now use the node's name when walking the tree.
We can do this because the node's name should be identical to the name
of its declaration.

Closes #7702.
2021-06-04 19:29:22 +02:00
DhruvMaroo 6c3d601e87 Profiler: Show the duration of the time interval chosen 2021-06-04 09:30:22 +02:00