Commit graph

1154 commits

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