Commit Graph

510 Commits

Author SHA1 Message Date
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