Commit Graph

1122 Commits

Author SHA1 Message Date
Andreas Kling
27b2c6f440 HackStudio: Alt shortcuts and book title capitalization in menus 2021-04-10 10:19:25 +02:00
Algot Axelzon
fa9f5c9799 HackStudio: Make actions with project tree selections work as expected
Creating a file while having a file or directory selected will now
create the file under the selected directory, or in same directory as
a selected file.
Creating directories works the same way.

Right click -> Open on selected files will now open the selected files.

Deleting selected files will now delete the selected files.

As suggested by sagefarrenholz this was accomplished by adding a private
function HackStudioWidget::selected_file_paths() that returns a
Vector<String> of the current project tree selection.

Function HackStudioWidget::selected_file_names() is removed due to not being used.
2021-04-09 09:32:04 +02:00
Hendiadyoin1
2469e07784 UE: only write libc and libsystem location once
This is important when emulating UE itself, which maps these files
two times, and then we forget the original location of it.
2021-04-08 23:57:16 +02:00
Hendiadyoin1
58e373c0f2 UE: Use AK's bit_cast and not reimplement it 2021-04-08 23:57:16 +02:00
Hendiadyoin1
74de4795dc UE: Default initialize regionmap 2021-04-08 23:57:16 +02:00
Brendan Coles
779f0c6e91 CppLanguageServer: is_empty_property: Return false for null node parent 2021-04-07 09:53:42 +02:00
Itamar
9e2e36724d LibCpp: Add TemplatizedName
This type represents templatized names, and replaces our previous use
of 'TemplatizedType' and 'TemplatizedFunctionCall'.

Also, we now parse function calls as secondary expressions.
2021-04-06 21:51:58 +02:00
Itamar
510b5073de LanguageServers/Cpp: Refactor logic of find declaration 2021-04-06 21:51:58 +02:00
Itamar
3295609aea LibCpp: Add AST::Name
A Name node is basically an identifier with an optional scope,
e.g Core::File.
2021-04-06 21:51:58 +02:00
Itamar
9288dfced8 LanguageServers/Cpp: Don't include declarations bellow the current line 2021-04-06 21:51:58 +02:00
Andreas Kling
52de9b1753 LibGUI: Do AbstractView::set_column_hidden() => set_column_visible()
This API felt backwards, so let's change it.
2021-04-05 11:57:47 +02:00
Tim Waterhouse
7648f6aa7b HackStudio: File search box stays opened after closing
Fix ##5061 by passing the parent widget down to the locator object
and having the locator object parent it's window to it.
2021-04-04 16:13:14 +02:00
AnotherTest
cbd62c472e UserspaceEmulator: Default-initialize the siginfo struct used in waitid
Otherwise it'll have some random value from the stack, and the kernel
will not bother setting it to zero.
Also add a debug print and tweak the FIXME message.
2021-03-31 23:49:26 +02:00
Idan Horowitz
77601e09c8 FontEditor+TextEditor+Playground: Refuse to load device files
This prevents the undefined behaviour that would come up as a result of
doing so. (For example: opening "infinite" devices like /dev/full will
result in an infinite loop until exhaustion of memory)
2021-03-30 11:29:52 +02:00
Edgar Araújo
76d4b2c5a4 Playground: Autocomplete after empty {}
Enable the oportunity to show name autocompletion
after an empty class, which does not have the redundant
empty {}.
2021-03-29 09:10:23 +02:00
Edgar Araújo
5c1cd50c9a Playground: Move AutocompleteProvider to a separate file 2021-03-29 09:10:23 +02:00
Andreas Kling
78b12e1521 Userland: Turn all application menus into window menus :^) 2021-03-25 22:14:09 +01:00
Idan Horowitz
0deb0c6891 UserspaceEmulator: Update virt$lseek and virt$ftruncate for 64bit off_t
The syscalls' prototypes were recently changed in preparation for 64bit
storage in serenity, so update them here as well :^)
2021-03-23 19:56:13 +01:00
Itamar
84e34d76d8 HackStudio+LanguageServers/Cpp: Show scope of symbols in Locator 2021-03-23 18:32:39 +01:00
Itamar
6054a418e5 LanguageServers/Cpp: Declarations inside namespaces are globally visible
This includes declarations inside namespaces in the globally visible
declarations of a cpp document.
2021-03-23 18:32:39 +01:00
Brendan Coles
7191098356 UserspaceEmulator: Add support for SC_abort syscall 2021-03-22 07:43:44 +01:00
Itamar
dee0c46c9b HackStudio: Display warning when opening binary files
We now detect and display a warning when we can't render the text of an
opened file.

Closes #5062.
2021-03-21 09:46:21 +01:00
Brendan Coles
4915cf5ab0 UE: Add killpg, getsockname, getpeername, shutdown, sync syscalls 2021-03-18 21:47:51 +01:00
Vyacheslav Pukhanov
663fd9abb4 CppLanguageServer: Make preprocessor ignore unsupported keywords
During typing the entered keywords can be incomplete and crash
preprocessor. We enable the newly introduced option to prevent
that crash.
2021-03-18 07:49:18 +01:00
Andreas Kling
f59ad2dc57 Everywhere: Remove pessimizing and redundant move() 2021-03-17 16:30:15 +01:00
Brendan Coles
46c7f52896 UserspaceEmulator: Add symlink, rename, set_coredump_metadata syscalls 2021-03-16 21:57:13 +01:00
Brendan Coles
fe97aec8c3 UserspaceEmulator: Print PID in mmap nullptr with MAP_FIXED reportln() 2021-03-16 21:48:29 +01:00
Andreas Kling
e0f32626bc LibGfx: Rename 32-bit BitmapFormats to BGRA8888 and BGRx888x
The previous names (RGBA32 and RGB32) were misleading since that's not
the actual byte order in memory. The new names reflect exactly how the
color values get laid out in bitmap data.
2021-03-16 11:50:03 +01:00
Brendan Coles
7156b61d57 UserspaceEmulator: downgrade TODO to dbgln for invalid fcntl cmd arg 2021-03-15 16:07:31 +01:00
Brendan Coles
1eccd78e3a UserspaceEmulator: Add SC_rmdir syscall 2021-03-14 21:36:36 +01:00
Brendan Coles
ab9f66a069 UserspaceEmulator: Increase stack size from 64 * KiB to 1 * MiB 2021-03-14 13:55:29 +01:00
Brendan Coles
2c24c0e451 UserspaceEmulator: SoftCPU: Add support for FPTAN instruction 2021-03-14 09:45:22 +01:00
Itamar
8688259ed9 LanguageServers/Cpp: Support jumping to declaration of preprocessor
.. definitions.
2021-03-13 10:17:02 +01:00
Itamar
7bf6eca9d8 LanguageServers/Cpp: Complete Preprocessor definitions
Preprocessor definitions now appear in the AutoComplete suggestions box
as well as in the Locator.
2021-03-13 10:17:02 +01:00
Itamar
8a102fe3ec LibCpp: Implement Parser::text_in_range using text of tokens
It was previously implemented by directly iterating over the program's
source.
2021-03-13 10:17:02 +01:00
Itamar
5cd1c69b96 LibCpp: Access Cpp::Token members via getter functions 2021-03-13 10:17:02 +01:00
Itamar
3658c4c567 LibCpp: Replace defined preprocessor values when parsing 2021-03-13 10:17:02 +01:00
Andreas Kling
ef1e5db1d0 Everywhere: Remove klog(), dbg() and purge all LogStream usage :^)
Good-bye LogStream. Long live AK::Format!
2021-03-12 17:29:37 +01:00
Andreas Kling
0c35c664e6 UserspaceEmulator: Convert a weird klog(!) to dbgln() 2021-03-12 11:23:26 +01:00
Brendan Coles
ec1fdef818 UserspaceEmulator: SoftCPU: Add support for several x86 FPU instructions
F2XM1
FYL2X
FYL2XP1
FDECSTP
FINCSTP
FSCALE
2021-03-12 09:59:45 +01:00
Ben Wiederhake
292871c4bc UserspaceEmulator: Handle MAP_FIXED with invalid addresses better
Old behavior: Crash due to VERIFY, unless we're completely and entirely out of
memory (m_available_ranges being empty), in which case it would return -ENOMEM.

New behavior: Return ENOMEM (and don't crash). In the case of nullptr,
also emit a helpful diagnostic.

Note that MAP_FIXED with nullptr is technically okay, but tends to be a sign
that something went wrong.

Also, this should improve mmap performance marginally, as it pulls the check out
of a loop that does not modify any parts of the check.

UE is now self-hosting! Fixes #5709.

However, this still needs some love: "ue UserspaceEmulator true" spits out tons
of error messages, probably false-positives, and takes about 229 seconds to run.
Then again, true-in-ue-in-ue-in-Qemu is three levels of emulation, so no wonder
it takes a long time! :D
2021-03-11 08:54:54 +01:00
Ben Wiederhake
22d9bd0c45 UserspaceEmulator: Do not pass MAP_FIXED to Kernel
Since there is usually no correlation between guest memory-layout and UE memory-layout,
this option does not make any sense. Especially since we provide nullptr.
2021-03-11 08:54:54 +01:00
Ben Wiederhake
d5925f33aa UserspaceEmulator: Implement set_process_name syscall 2021-03-11 08:54:54 +01:00
Ben Wiederhake
ec8e3edd05 UserspaceEmulator: Split large file into logical pieces 2021-03-11 08:54:54 +01:00
Andreas Kling
ced8dfa037 UserspaceEmulator: Remove debug spam about tracked malloc blocks 2021-03-10 15:21:26 +01:00
Andreas Kling
82aea65bd3 UserspaceEmulator: Add fast-path for is<MmapRegion>()
Don't use default RTTI for these since they are performance-sensitive.
2021-03-09 15:17:15 +01:00
Andreas Kling
656cd477c2 UserspaceEmulator+LibX86: Sprinkle some [[unlikely]] and ALWAYS_INLINE 2021-03-09 15:10:08 +01:00
Andreas Kling
c192b6c61d Emulator: Use libc.so bounds to fast-reject non-malloc addresses
The auditing code always starts by checking if we're in one of the
ignored code ranges (malloc, free, realloc, syscall, etc.)

To reduce the number of checks needed, we can cache the bounds of
the LibC text segment. This allows us to fast-reject addresses that
cannot possibly be a LibC function.
2021-03-09 15:01:08 +01:00
Brendan Coles
0c46918b73 UserspaceEmulator: Support FLDL2E / FLDPI, fix typos, use M_LN2 constant 2021-03-09 14:57:55 +01:00
Andreas Kling
54bd2ee738 UserspaceEmulator: Add Emulator::dump_regions() helper function 2021-03-09 14:44:54 +01:00
Andreas Kling
397f564144 UserspaceEmulator: Honor alignment requests in virt$mmap(MAP_RANDOMIZED) 2021-03-09 14:42:49 +01:00
Andreas Kling
0bf457f715 UserspaceEmulator: Add partial support for some more x87 instructions
Patch by @bcoles
2021-03-09 14:30:30 +01:00
Andreas Kling
57142a29a0 UserspaceEmulator: Don't set the MmapRegion malloc-block bit too early
We were setting it before the malloc metadata had been instantiated.

Fixes #5707.
2021-03-09 13:57:17 +01:00
Andreas Kling
1381720d1d UserspaceEmulator: Don't assume entire malloc block is chunked
Accesses in the header (or trailing padding) of a malloc block should
not be associated with any mallocation since only the chunk-sized slots
actually get returned by malloc.

Basically, allow address-to-chunk lookup to fail, and handle such
failures gracefully at call sites.

Fixes #5706.
2021-03-09 13:29:41 +01:00
Andreas Kling
38fc522f5d UserspaceEmulator: Don't audit accesses in calloc() and libsystem.so
These generate a lot of false positives and nothing of value.
2021-03-09 13:24:03 +01:00
Andreas Kling
a457b90733 UserspaceEmulator: Tidy up the MallocRegionMetadata construction a bit
Use designated initializers to make it very obvious what's being set,
and also give the metadata a backpointer to the region for convenience.
2021-03-09 12:00:53 +01:00
Andreas Kling
915e8dbe71 UserspaceEmulator: Defer marking MmapRegion as malloc block
We don't want to audit accesses into the region *while* we're setting
up malloc tracking for it. Fetching the chunk size from the header
was tripping up the auditing code.
2021-03-09 11:41:28 +01:00
Andreas Kling
0b5a915725 UserspaceEmulator: Keep the MMU regions list sorted 2021-03-09 11:31:18 +01:00
Andreas Kling
728d947601 UserspaceEmulator: Remember VM region names for MAP_ANONYMOUS
For some reason we only remembered the names of MAP_FILE mmap regions.
2021-03-09 11:31:18 +01:00
Andreas Kling
735a6482ac UserspaceEmulator: Implement sys$set_mmap_name() 2021-03-09 11:31:18 +01:00
Andreas Kling
b940dd4fa8 UserspaceEmulator: Never try to mprotect(PROT_EXEC) MmapRegion backing
We never want to map host memory executable anyway, so let's always
mask off the PROT_EXEC bit.
2021-03-09 11:31:18 +01:00
Andreas Kling
9588f01739 UserspaceEmulator+LibC: Use sys$emuctl() to pass malloc info to UE
Get rid of the awkward secret handshake sequence between malloc and UE
and simply use sys$emuctl() to notify UE of malloc, free and realloc.
2021-03-09 11:31:18 +01:00
Andreas Kling
84725ef3a5 Kernel+UserspaceEmulator: Add sys$emuctl() system call
This returns ENOSYS if you are running in the real kernel, and some
other result if you are running in UserspaceEmulator.

There are other ways we could check if we're inside an emulator, but
it seemed easier to just ask. :^)
2021-03-09 08:58:26 +01:00
Bui Quang Minh
ec063f4f63 HackStudio: Add language client check in identifier click 2021-03-09 07:54:30 +01:00
Ben Wiederhake
1e857de263 UserspaceEmulator: Support munmap/mprotect with partial mappings
Fixes #5663.
2021-03-08 22:57:36 +01:00
Ben Wiederhake
45443f24ec UserspaceEmulator: Enable splitting regions at arbitrary points
This is not yet useful in and of itself, but enables the feature in the next commit.
2021-03-08 22:57:36 +01:00
Ben Wiederhake
7cc8f20a30 UserspaceEmulator: Convert backing storage from malloc to mmap
This saves a few bytes for each guest-mmaped region, especially since these are likely to be page-aligned.
2021-03-08 22:57:36 +01:00
Emanuele Torre
1f81bc6879 Everywhere: Remove unnecessary whitespace at the end of some lines. 2021-03-08 09:20:53 +01:00
Itamar
cfa100cb65 HackStudio: Restart LanguageServer if it crashes
We now restart the language server transparently if it crashes.
If the language server crashes too frequently (current threshold is
twice within 3 seconds), we give up and will not attempt to restart it
again. HackStudio will still work fine, but features that depend on the
language server will not function.

To support this change we use a new class, 'ServerConnectionWrapper',
that holds the actual ServerConnection and is responsible for restarting
the language-server if it crashes.

Closes #5574.
2021-03-06 09:40:33 +01:00
Itamar
4223f03b2b LanguageServers: Support calling SetFileContent with not-yet open files
Also, use dbgln_if
2021-03-06 09:40:33 +01:00
Itamar
6f7ef4ec65 LanguageServers: Tweak FileDB API
- FileDB::get() now returns nullptr if the file is not in the FileDB
- Added FileDB::get_or_create_from_filesystem()
- Added FileDB::add() version that receives that file's content as a
parameter
2021-03-06 09:40:33 +01:00
Itamar
684cc5f027 HackStudio: Add ProjectFile::create_if_needed 2021-03-06 09:40:33 +01:00
Itamar
ba6cbf160b HackStudio: Create Language enum from file extension or language name 2021-03-06 09:40:33 +01:00
Itamar
1edaefca3a HackStudio: Remove redundant null check when creating a new project file
Project::get_file returns a NonNullRefPtr
2021-03-06 09:40:33 +01:00
Itamar
fa4d9da237 HackStudio: Make sure project files are created with an absolute path
This fixes an issue were "Find in Files" would not use the up-to-date
content of a file with unsaved changes.

The issue existed because 'FindInFilesWidget' uses
Project::for_each_text_file, which retrieves files by their absolute
path. However, when a file is opened in an Editor, it is created with
a relative path.

This caused us to store two ProjectFile objects that refer to the same
file - one with a relative path and one with an absolute path.
2021-03-06 09:40:33 +01:00
Itamar
74070ef74d HackStudio: Map connections to langauge-servers by language name
HackStudio keeps a map that stores the different ServerConnection
instances we have open.

Previously, that map was indexed by a project's root path.
This did not make much sense because we only support opening a single
project with each instance of the HackStudio program.

We now index the different ServerConnections by the language name, which
allows us to support talking to multiple language-servers in the same
project (e.g C++ and Shell).

This also fixes an issue where if you first opened a Shell file, and
then a C++ file in the same project, then C++ language-server features
would not work.
2021-03-06 09:40:33 +01:00
Itamar
3f0ace6670 LanguageServers/Cpp: Allow the creation of DocumentData objects to fail
This fixes langauge-server crashes when trying to parse non-existant
header files, such as #include <new>.
Closes #5569.
2021-03-06 09:40:33 +01:00
Linus Groh
50ea0c3500 Profiler: Get perfcore file from ArgsParser
Fixes #5641.
2021-03-05 09:52:22 +01:00
Andreas Kling
1208fc7d37 AK: Simplify Bitmap and implement in terms of BitmapView
Add Bitmap::view() and forward most of the calls to BitmapView since
the code was identical.

Bitmap is now primarily concerned with its dynamically allocated
backing store and BitmapView deals with the rest.
2021-03-04 11:25:45 +01:00
AnotherTest
e59a631511 HackStudio/LanguageServers: Move some components out of Cpp
This makes them available for use by other language servers.
Also as a bonus, update the Shell language server to discover some
symbols and add go-to-definition functionality :^)
2021-03-04 11:21:43 +01:00
Andreas Kling
373a595c56 Profiler: Symbolicate addresses in non-PIE ELF objects
This is a little bit messy, but basically if an ELF object is non-PIE,
we have to account for the executable mapping being at a hard-coded
offset and subtract that when doing symbolication.

There's probably a nicer way to solve this, I just hacked this together
so we can see "cc1plus" and friends in profiles. :^)
2021-03-03 23:13:26 +01:00
Andreas Kling
0fc3983c8d Profiler: Cache and reuse mapped ELF objects
In multi-process profiles, the same ELF objects tend to occur many
times (everyone has libc.so for example) so we will quickly run out
of VM if we map each object once per process that uses it.

Fix this by adding a "mapped object cache" that maps the path of
an ELF object to a cached memory mapping and wrapping ELF::Image.
2021-03-03 22:57:45 +01:00
Bui Quang Minh
faed0e63dc HackStudio: Allow multi-selection in project view tree 2021-03-03 21:59:22 +01:00
Andreas Kling
5e7abea31e Kernel+Profiler: Capture metadata about all profiled processes
The perfcore file format was previously limited to a single process
since the pid/executable/regions data was top-level in the JSON.

This patch moves the process-specific data into a top-level array
named "processes" and we now add entries for each process that has
been sampled during the profile run.

This makes it possible to see samples from multiple threads when
viewing a perfcore file with Profiler. This is extremely cool! :^)
2021-03-02 22:38:06 +01:00
Bui Quang Minh
ee7c8fbd7b HackStudio: Implement removing file from disk 2021-03-02 14:45:18 +01:00
Itamar
05c48cc8d8 LanguageServers/Cpp: Fix nullptr dereference in ~LanguageClient
The WeakPtr to the ServerConnection is nullified if the server crashes.

Closes #5570.
2021-03-02 13:37:26 +01:00
Itamar
17e6287333 LanguageServers/Cpp: Fix typo 2021-03-02 12:50:37 +01:00
Brian Gianforcaro
007b6edce4 Profiler: Print addresses as pointers in new Samples view
The previous formatting was missing the "0x" prefix.
2021-03-01 11:12:53 +01:00
thislooksfun
225baa3cb7 Profiler: remove unimplemented Profile::LibraryMetadata::symbolicate() definition
The implementation of Profile::LibraryMetadata::symbolicate() was
removed in 340180ba05, but the
corresponding public declaration was not.
2021-02-28 15:28:08 +01:00
Andreas Kling
1fb1279cfd Profiler: Add a new "Samples" view to the main UI
You can now view the individual samples in a profile one by one with
the new "Samples" view. The "old" main view moves into a "Call Tree"
tab (but it remains the default view.)

When you select a sample in the samples view, we show you the full
symbolicated backtrace in a separate view on the right hand side. :^)
2021-02-27 18:34:21 +01:00
Andreas Kling
2c1f71055f LibVT: Put TerminalWidget in the VT namespace :^) 2021-02-27 17:49:08 +01:00
Andreas Kling
340180ba05 Profiler: Move ELF object name to its own profile graph column
This way you don't have to look at all the library names if you don't
want to. Since we're pretty good about namespacing our things, the
library names are slightly redundant information.
2021-02-27 17:45:41 +01:00
Andreas Kling
2f0ea9ae33 Profiler: Unbreak DisassemblyModel after shared library introduction
This was failing to take the library base address into account when
tallying up the samples at each instruction.
2021-02-27 17:26:57 +01:00
Itamar
54bc9114b3 HackStudio: Support searching symbol declarations in the Locator
The Locator now keeps a cache of the declared symbol in a document.
The language client updates that cache whenever it gets an update from
the language server about declared symbols.

This allows searching for symbol declarations in the Locator, in
addition to file names.

Closes #5478
2021-02-27 16:37:35 +01:00
Itamar
a94b5376bc LanguageServers/Cpp: Update client asynchronously about symbols
As a document is parsed, the language server updates the client
asynchronously about symbol declarations it finds.
2021-02-27 16:37:35 +01:00
Itamar
71c7597130 LanguageServers/Cpp: Add type to Declarations 2021-02-27 16:37:35 +01:00
Itamar
4b483071fb LanguageServers: Add ProjectLoaction, Declaration types and use in IPC
With this we can avoid passing (name, line, column) tuples in many
different places.
2021-02-27 16:37:35 +01:00
Itamar
e20cd1d8db LanguageServers/Cpp: Don't VERIFY that a file could be found
... when creating a new DocumentData
2021-02-26 21:14:41 +01:00
Linus Groh
e265054c12 Everywhere: Remove a bunch of redundant 'AK::' namespace prefixes
This is basically just for consistency, it's quite strange to see
multiple AK container types next to each other, some with and some
without the namespace prefix - we're 'using AK::Foo;' a lot and should
leverage that. :^)
2021-02-26 16:59:56 +01:00
thankyouverycool
885c17b583 HackStudio: Set correct icons, text and location in menus
Adds correct icon to New Project, moves Wrapping Mode to more
traditional View, and truncates overly verbose Project entries
2021-02-26 13:50:00 +01:00
Brendan Coles
0ffc06b795 Profiler: Add help documentation 2021-02-24 20:40:00 +01:00
Sahan Fernando
bf68939bcc Profiler: Make sure rendered timestamps don't overflow
If you drag-select a slice of the profile off of the side of the
Profiler window, the profiler will try to render a negative start time,
which will overflow. This commit fixes that bug by clamping timestamps
to the start/end of the profile before rendering.
2021-02-24 12:19:01 +01:00
Andreas Kling
5d180d1f99 Everywhere: Rename ASSERT => VERIFY
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED)

Since all of these checks are done in release builds as well,
let's rename them to VERIFY to prevent confusion, as everyone is
used to assertions being compiled out in release.

We can introduce a new ASSERT macro that is specifically for debug
checks, but I'm doing this wholesale conversion first since we've
accumulated thousands of these already, and it's not immediately
obvious which ones are suitable for ASSERT.
2021-02-23 20:56:54 +01:00
AnotherTest
29c8d34be7 HackStudio: Fix a misuse of dbgln() intended as dbgln_if()
This currently works accidentally, just because there's an overload for
`dbgln<bool>(...)` - it just bypasses the compiletime checks.
2021-02-23 13:59:33 +01:00
AnotherTest
1c4e15117d UserspaceEmulator: Fix an outln() format bug 2021-02-23 13:59:33 +01:00
Brendan Coles
501834ba45 Inspector: Add help documentation 2021-02-23 13:52:16 +01:00
Ivan Hansgaard Hansen
c9cd96894b
HackStudio: Fix opened files appearing empty (#5480)
When files where placed in outside of the project root, they would
appear empty because the label in the tree would differ from the
actual file path relative to the root.

Fixes #5471.
2021-02-22 23:00:57 +01:00
Itamar
5bc82c0185 LanguageServers/Cpp: Add 'FindDeclaration' capability
The C++ LanguageServer can now find the matching declaration for
variable names, function calls, struct/class types and properties.

When clicking on one of the above with Ctrl pressed, HackStudio will
ask the language server to find a matching declaration, and navigate
to the result in the Editor. :^)
2021-02-20 15:53:37 +01:00
Itamar
d3ff82ba80 LibCpp: Store filename in ASTNodes
As part of the position information, we now also store the filename the
ASTNode belongs to.
2021-02-20 15:53:37 +01:00
Itamar
c4139be461 HackStudio: Always use relative paths when opening project files 2021-02-20 15:53:37 +01:00
Itamar
50f887c9d5 HackStudio: Display identifiers as clickable
This extends the "navigate to include" feature to also display
identifiers as clickable when they're hovered over while left control
is pressed.
2021-02-20 15:53:37 +01:00
Linus Groh
3583b62ad3 LibGUI: Swap order of InputBox value and parent window args
This is now consistent with the other dialog classes.
2021-02-20 12:19:46 +01:00
Andreas Kling
4f0be55770 LibGUI: Remove GUI::FilePicker::file_exists()
I have no idea why this existed but everyone should just use
Core::File::exists() instead. :^)
2021-02-19 23:46:54 +01:00
Andreas Kling
781d29a337 Kernel+Userland: Give sys$recvfd() an options argument for O_CLOEXEC
@bugaevc pointed out that we shouldn't be setting this flag in
userspace, and he's right of course.
2021-02-14 10:39:48 +01:00
Itamar
c2e5bc442d LanguageServers/cpp: Use parser-based autocomplete engine by default 2021-02-13 19:50:09 +01:00
Itamar
715933ce8b HackStudio: Handle crash of the LanguageServer gracefully
Previously, HackStudio exited whenever a LanguageServer crashed.

Now, we disconnect all clients from that language server instance and
show a nice notification.
2021-02-13 19:50:09 +01:00
Itamar
2da5ecba41 LanguageServers/Cpp: Handle autocomplete request on an empty line 2021-02-13 19:50:09 +01:00
Itamar
18a9b66f10 HackStudio: Set icon for 'make is not available' notification 2021-02-13 19:50:09 +01:00
Nick Vella
b671577223 HackStudio: Project templates and New Project dialog
This commit adds a simple project template system to HackStudio,
as well as a pretty New Project dialog, inspired by early VS.NET
and MS Office.
2021-02-13 19:49:30 +01:00
Itamar
ef9bfbd383 LanguageServers/Cpp: Autocomplete declarations from included headers
We now also look at the available declarations from included header
files when autocompleting names.

Additionally, you can now request autocomplete on an empty token, which
brings up all available names, starting from the inner-most scope.
2021-02-10 23:09:40 +01:00
Itamar
64c80f6ea4 LanguageServers/Cpp: Autocomplete function and struct/class names 2021-02-10 23:09:40 +01:00
Itamar
e42b9e879c HackStudio: Show notification if 'make' is not available
We previously popped a MessageBox for this, but a notification is less
disruptive.
2021-02-10 23:04:54 +01:00
Itamar
72fdab7bfb LanguageServers/Cpp: ParserAutoComplete engine inspects header files
... and performs preprocessing on the source code before parsing.

To support this, we are now able to keep track of multiple
files in the autocomplete engine. We re-parse a file whenever it is
edited.
2021-02-08 23:10:38 +01:00
Itamar
02038a0ede LanguageServers/Cpp: Use FileDB and AutoCompleteEngine base class 2021-02-08 23:10:38 +01:00
Itamar
bed06b13f3 LanguageServers/Cpp: Add FileDB and pass project_root in Greet()
FileDB wraps the access to the contents of project files.

When asked to fetch a file, FileDB will either return its in-memory
model of the file if it has been "opened" by the language-server
protocol, or otherwise fetch it from the filesystem.

Previously, the cpp language server did not pledge "rpath" and got
access to the contents of files whenever they were opened by the
language client.
However, features like inspection of header files require the language
server to get the content of files that were not opened by the client.

The language server now pledges rpath but makes sure to only unveil
the project's directory and /usr/include.
2021-02-08 23:10:38 +01:00
AnotherTest
09a43969ba Everywhere: Replace dbgln<flag>(...) with dbgln_if(flag, ...)
Replacement made by `find Kernel Userland -name '*.h' -o -name '*.cpp' | sed -i -Ee 's/dbgln\b<(\w+)>\(/dbgln_if(\1, /g'`
2021-02-08 18:08:55 +01:00
AnotherTest
b68e34cc2e UserspaceEmulator: Use vdbgln() instead of dbgln() when reporting
This will avoid conflict with the upcoming compiletime checks.
2021-02-08 18:08:55 +01:00
Ben Wiederhake
0a2304ba05 Everywhere: Fix weird includes 2021-02-08 18:03:57 +01:00
Ben Wiederhake
7961e09c29 Everywhere: Add semantically-missing includes
For example, FindInFilesWidget.h mentions GUI::TableView, but did not include
it. On the other hand, all source files that include FindInFilesWidget.h
also include TableView.h, so the issue is only cosmetical.
2021-02-08 18:03:57 +01:00
Andreas Kling
50308f6fda Shell: Move Shell syntax highlighter LibShell 2021-02-07 17:07:33 +01:00
Andreas Kling
ddbf20ecf6 LibSyntax+LibGUI+LibJS: Move JS syntax highlighter to LibJS
This is a little bit messy but the basic idea is:

Syntax::Highlighter now has a Syntax::HighlighterClient to talk to the
outside world. It mostly communicates in LibGUI primitives that are
available in headers, so inlineable.

GUI::TextEditor inherits from Syntax::HighlighterClient.

This let us to move GUI::JSSyntaxHighlighter to JS::SyntaxHighlighter
and remove LibGUI's dependency on LibJS.
2021-02-07 16:56:02 +01:00
Andreas Kling
43c7d7d285 LibSyntax: Move GUI::Highlighter to Syntax::Highlighter in LibSyntax
This is a move towards dropping more LibGUI dependencies.
2021-02-07 15:15:10 +01:00
Andreas Kling
ff2438e0ce LibGUI+LibCpp: Move C++ syntax highlighter to LibCpp
This makes LibGUI not depend on LibCpp.
2021-02-07 14:40:36 +01:00
Andreas Kling
89483a9408 UserspaceEmulator: Implement a proper VM allocator
This patch brings Kernel::RangeAllocator to UserspaceEmulator in a
slightly simplified form.

It supports the basic three allocation types needed by virt$mmap():
allocate_anywhere, allocate_specific, and allocate_randomized.

Porting virt$mmap() and virt$munmap() to use the allocator makes
UE work correctly once again. :^)
2021-02-06 23:15:44 +01:00
Andreas Kling
9dacd7c0ec UserspaceEmulator: Stub out virt$msyscall()
This is a no-op inside UE for now.
2021-02-06 23:15:44 +01:00
Sahan Fernando
7e9122950e Profiler: Display timing information in ProfileTimelineWidget
Currently, there is no way to know when in a profile's duration a
sample was taken. This commit adds a basic timestamp to the timeline
widget, and a black bar to show where the cursor is hovering over.
2021-02-06 08:55:34 +01:00
Andreas Kling
e87eac9273 Userland: Add LibSystem and funnel all syscalls through it
This achieves two things:

- Programs can now intentionally perform arbitrary syscalls by calling
  syscall(). This allows us to work on things like syscall fuzzing.

- It restricts the ability of userspace to make syscalls to a single
  4KB page of code. In order to call the kernel directly, an attacker
  must now locate this page and call through it.
2021-02-05 12:23:39 +01:00
Zac
cc2f35badd TextEditor: Implement word wrapping
Add a new wrapping mode to the TextEditor that will wrap lines at the
spaces between words.

Replace the previous menubar checkbox 'Wrapping Mode' in HackStudio and
the TextEditor with an exclusive submenu which allows switching between
'No wrapping', 'Wrap anywhere' and 'Wrap at words'. 'Wrap anywhere' (the
new 'Wrap lines') is still the default mode.

Setting the wrapping mode in the constructors of the TextEditorWidget
and HackStudio has been removed, it is now set when constructing the
menubar actions.
2021-02-03 10:33:23 +01:00
Matteo Sozzi
2031baebce HackStudio: do not open empty directories as file
When _double clicking_ or _right click > Open_ in the tree view, the
selected directory, if empty, was open in the editor section as file.
2021-02-03 10:15:09 +01:00
Matteo Sozzi
a8dfba6348 HackStudio: tree_view on_activiation changes
When opening a file in the tree view with _double click_, the file name
was not the same as opening the same file with _right click > Open_.

This caused the opne_files_view to have the same file in it, but with
two different names.
2021-02-03 10:15:09 +01:00
Andreas Kling
1ce03f4f34 LibIPC: Stop sending client ID to clients
The client ID is not useful to normal clients anymore, so stop telling
everyone what their ID is.
2021-02-01 11:32:00 +01:00
Matteo Sozzi
40da077f6c HackStudio: added new directory action
Added the possibility to create a new directory in the current project.
2021-02-01 09:52:13 +01:00
Brendan Coles
50092ea0ca Inspector: Exit if inspected process has not pledged accept 2021-01-31 09:08:51 +01:00
Matteo Sozzi
32a363ded5 HackStudio: removed toggle_index
Removed `m_project_tree_view->toggle_index()` when adding new file to
project.
2021-01-30 22:59:59 +01:00
Brendan Coles
58abdde2e4 Inspector: Allow browsing inspection data in UI after process exits 2021-01-30 14:10:10 +01:00
Matteo Sozzi
f80b40b411 HackStudio: do not toggle_index in open_project
When opening a new project `m_prject_tree_view->toggle_index()` is not
needed because `m_project_tree_view->set_model()` already updates the
indexes.
2021-01-30 14:08:41 +01:00
Itamar
fa18010477 HackStudio: Integate with C++ parser-based autocomplete
By default, C++ auto completion will still be performed by the
lexer-based logic.
However, the parser-based logic can be switched on via the menubar.
2021-01-27 21:10:57 +01:00
Itamar
8ed96eb27c HackStudio: Attach previous Language Client when detaching
Previously, if a new LanguageClient was created & destroyed, the
ServerConnection to the language server would be left without an
attached LanguageClient.
As a result, auto-completion results would not be updated in the UI.

Starting with this commit, the LanguageClient holds a WeakPtr to the
previous LanguageClient that was attached to the ServerConnection,
and re-attaches it after detaching itself.
2021-01-27 21:10:57 +01:00
Itamar
c85dad2383 HackStudio: Add parser-based c++ autocomplete engine 2021-01-27 21:10:57 +01:00
asynts
eea72b9b5c Everywhere: Hook up remaining debug macros to Debug.h. 2021-01-25 09:47:36 +01:00
asynts
8465683dcf Everywhere: Debug macros instead of constexpr.
This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/dbgln<debug_([a-z_]+)>/dbgln<\U\1_DEBUG>/' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/if constexpr \(debug_([a-z0-9_]+)/if constexpr \(\U\1_DEBUG/' {} \;
2021-01-25 09:47:36 +01:00
asynts
bb483f7ef4 Everywhere: Name debug macros more consistently.
Personally, I prefer the naming convention DEBUG_FOO over FOO_DEBUG, but
the majority of the debug macros are already named in the latter naming
convention, so I just enforce consistency here.

This was done with the following script:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/DEBUG_PATH/PATH_DEBUG/' {} \;
2021-01-25 09:47:36 +01:00
asynts
acdcf59a33 Everywhere: Remove unnecessary debug comments.
It would be tempting to uncomment these statements, but that won't work
with the new changes.

This was done with the following commands:

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/#define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/#define/ { toggle = 1 }' {} \;

    find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec awk -i inplace '$0 !~ /\/\/ #define/ { if (!toggle) { print; } else { toggle = !toggle } } ; $0 ~/\/\/ #define/ { toggle = 1 }' {} \;
2021-01-25 09:47:36 +01:00
asynts
1a3a0836c0 Everywhere: Use CMake to generate AK/Debug.h.
This was done with the help of several scripts, I dump them here to
easily find them later:

    awk '/#ifdef/ { print "#cmakedefine01 "$2 }' AK/Debug.h.in

    for debug_macro in $(awk '/#ifdef/ { print $2 }' AK/Debug.h.in)
    do
        find . \( -name '*.cpp' -o -name '*.h' -o -name '*.in' \) -not -path './Toolchain/*' -not -path './Build/*' -exec sed -i -E 's/#ifdef '$debug_macro'/#if '$debug_macro'/' {} \;
    done

    # Remember to remove WRAPPER_GERNERATOR_DEBUG from the list.
    awk '/#cmake/ { print "set("$2" ON)" }' AK/Debug.h.in
2021-01-25 09:47:36 +01:00
Ben Wiederhake
9058a8367f UserspaceEmulator: Improve error message for typos 2021-01-23 16:47:09 +01:00
Ben Wiederhake
792fa9f9fd UserspaceEmulator: Implement chown
Now we can run 'ue chown anon ReadMe.md' :^)
2021-01-23 16:47:09 +01:00
Andreas Kling
c5df0532c0 HackStudio: Handle failed fork() in TerminalWrapper a bit better 2021-01-23 08:39:59 +01:00
asynts
27bc48e06c Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it
easier to find potentially introduced bugs with git bisect.
2021-01-22 22:14:30 +01:00
Andreas Kling
bf0719092f Kernel+Userland: Remove shared buffers (shbufs)
All users of this mechanism have been switched to anonymous files and
passing file descriptors with sendfd()/recvfd().

Shbufs got us where we are today, but it's time we say good-bye to them
and welcome a much more idiomatic replacement. :^)
2021-01-17 09:07:32 +01:00
Andreas Kling
cc8b3c92ba Everywhere: Remove a bunch of now-unnecessary shared_buffer pledges 2021-01-17 09:07:32 +01:00
Andreas Kling
05dbfe9ab6 Kernel: Remove sys$shbuf_seal() and userland wrappers
There are no remaining users of this syscall so let it go. :^)
2021-01-17 00:18:01 +01:00
Andreas Kling
b818cf898e Kernel+Userland: Remove sys$shbuf_allow_all() and userland wrappers
Nobody is using globally shared shbufs anymore, so let's remove them.
2021-01-16 22:43:03 +01:00
Ben Wiederhake
7ed002d1ca UserlandEmulator: Fix data loss in realpath/readlink
This 'data loss' was introduced in 809a8ee693, because
I hoped we could eventually outlaw overlong paths entirely. This sparked some discussion:
https://github.com/SerenityOS/serenity/discussions/4357
Among other things, we agree that yeah, the Kernel can and should be able to return
paths of arbitrary length. This means that the 'arbitrary' maximum of PATH_MAX in
UserspaceEmulator should be considered to be unnecessary data loss, and as such, needs to
be fixed.
2021-01-16 22:40:53 +01:00
Andreas Kling
d312011708 Everywhere: Drop "shared_buffer" in most GUI programs, pledge "recvfd"
Now that WindowServer broadcasts the system theme using an anonymous
file, we need clients to pledge "recvfd" so they can receive it.

Some programs keep the "shared_buffer" pledge since it's still used for
a handful of things.
2021-01-16 19:30:32 +01:00
Andreas Kling
de31e82f97 Kernel: Remove sys$shbuf_set_volatile() and userland wrappers
There are no remaining users of this syscall so let's remove it! :^)
2021-01-16 14:52:04 +01:00
Andreas Kling
c71807a3fc Everywhere: Convert a handful of String::format() => formatted() 2021-01-16 14:52:04 +01:00
Andreas Kling
12879184ce UserspaceEmulator: Support the anon_create, sendfd and recvfd syscalls 2021-01-15 14:17:19 +01:00
Andreas Kling
20915795a8 Everywhere: Pledge "sendfd" in WindowServer client programs
This is needed for the new way we transfer window backing stores.
2021-01-15 14:10:32 +01:00
Andreas Kling
7f2d8e8884 LibIPC: Close received IPC::File fd's by default unless taken
When receiving a file descriptor over IPC, the receiver must now call
take_fd() on the IPC::File to take over the descriptor. Otherwise,
IPC::File will close the file on destruction.
2021-01-14 09:50:14 +01:00
Andreas Kling
384d047e3e IPCCompiler: Use move semantics in generated IPC message constructors
This allows us to use move-only types as IPC message parameters.
2021-01-14 09:50:14 +01:00
Andreas Kling
1a08ac72ad LibC+Everywhere: Remove open_with_path_length() in favor of open()
This API was a mostly gratuitous deviation from POSIX that gave up some
portability in exchange for avoiding the occasional strlen().

I don't think that was actually achieving anything valuable, so let's
just chill out and have the same open() API as everyone else. :^)
2021-01-12 23:34:01 +01:00
Andreas Kling
4055b03291 DevTools: Move to Userland/DevTools/ 2021-01-12 12:18:55 +01:00