Commit Graph

341 Commits

Author SHA1 Message Date
Andreas Kling
a345a1f4a1 Userland: Mark subclasses of IPC::{Client,Server}Connection final 2021-05-23 09:53:55 +02:00
Andreas Kling
c1c252ddb2 LibIPC: Remove unnecessary IPC::ServerConnection::handshake()
This is no longer used by any of our IPC pairs.
2021-05-23 09:53:55 +02:00
Andreas Kling
0af69e8917 HackStudio: Greet language servers asynchronously
There's no need to wait for a response after we've sent the project
path to a newly connected language server.
2021-05-23 09:53:55 +02:00
Andreas Kling
03df8882df InspectorServer: Remove unnecessary greet() message 2021-05-23 09:53:55 +02:00
Andreas Kling
62819df713 Profiler: Allow scaling the timeline with Ctrl+MouseWheel :^) 2021-05-22 23:20:31 +02:00
Andreas Kling
4a843f7405 Profiler: Allow scrolling through full range of profile timeline
We were not taking the width of the process headers into account when
computing the scrollable content size of the timeline.

Fix this by passing the header width to AbstractScrollableWidget's
set_size_occupied_by_fixed_elements().
2021-05-22 23:02:51 +02:00
Andreas Kling
29e00cda2e Profiler: Add a "Show Disassembly" action (and hide it by default) 2021-05-22 22:49:19 +02:00
Andreas Kling
863ac3af97 Profiler: Add some helpful debug output if a process is missing
I've had a couple of instances where a profile was missing process
creation events for a PID. I don't know how to reproduce it yet,
so this patch merely adds a helpful debug message so you know why
Profiler is failing to load the file.
2021-05-22 22:23:52 +02:00
Andreas Kling
8a5c78e93b Profiler: Split the call tree into one subtree per process
This patch adds an additional level of hierarchy to the call tree:
Every process gets its own top-level node. :^)

Before this, selecting multiple processes would get quite confusing
as all the call stacks from different processes were combined together
into one big tree.
2021-05-22 22:23:52 +02:00
Andreas Kling
b5d73c834f Userland: Rename LibThread => LibThreading
Also rename the "LibThread" namespace to "Threading"
2021-05-22 18:54:22 +02:00
Itamar
6738a966ec CppLanguageServer: Add test case for auto-completing include paths 2021-05-22 15:52:11 +02:00
Itamar
c003c3c76d CppLanguageServer+LibGUI: Autocomplete #include paths
The C++ language-server can now autocomplete include paths.

Paths that start with '<' will be searched in /usr/include, and paths
that start with '"' will be searched in the project's root directory.
2021-05-22 15:52:11 +02:00
Itamar
c4ff7c6f8e LanguageServers: Add FileDB::project_root() getter 2021-05-22 15:52:11 +02:00
Itamar
b50eaf75eb CppLanguageServer: Rename Optional<> autocomplete* to try_autocomplete*
autocomplete_property => try_autocomplete_property
autocomplete_name => try_autocomplete_name

This makes it more clear that these variants may fail because e.g
the node is not a property / not a name.
2021-05-22 15:52:11 +02:00
Itamar
1c3c043cd3 CppLanguageServer: Rename all_definitions=>preprocessor_definitions 2021-05-22 15:52:11 +02:00
Itamar
1f96d9b03a CppLanguageServer: remove no-op move() 2021-05-22 15:52:11 +02:00
Lenny Maiorani
6ac454e70a DevTools: Remove redundant default destructor and forward declarations
Problem:
- Default destructors (and constructors) are in `.cpp` files. This
  prevents the compiler's optimizer from inlining them when it thinks
  inlining is appropriate (unless LTO is used).
- Forward declarations can prevent some optimizations, such as
  inlining of constructors and destructors.

Solution:
- Remove them or set them to `= default` and let the compiler handle
  the generation of them.
- Remove unneeded forward declarations.
2021-05-21 22:53:33 +01:00
Max Wipfli
229414b002 Applications: Use titlecase and distinct underlined characters in menus
This changes (context) menus across the system to conform to titlecase
capitalization and to not underline the same character twice (for
accessing actions with Alt).
2021-05-21 18:41:28 +01:00
Lenny Maiorani
68f76b9e37 Userland: Change typedef to using directive
Problem:
- `typedef`s are read backwards making it confusing.
- `using` statements can be used in template aliases.
- `using` provides similarity to most other C++ syntax.

- C++ core guidelines say to prefer `using` over `typedef`:
  https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rt-using

Solution:
- Switch these where appropriate.
2021-05-21 10:07:22 +01:00
Andreas Kling
6a012ad79f LibGfx: Remove Gfx::FontDatabase::default_bold_font()
Instead use default_font().bold_variant() in cases where we want a bold
variant of the default font. :^)
2021-05-20 20:55:29 +02:00
Anand
4a2dd5bf66 Inspector: Throw an error when inspecting a process it has no access to 2021-05-20 08:21:48 +02:00
Itamar
402483ec1f LibCpp: Generalize ASTNode::dump() to support redirecting its output
Previously, ASTNode::dump() used outln() for output, which meant it
always wrote its output to stdout.

After this commit, ASTNode::dump() receives an 'output' argument (which
is stdout by default). This enables writing the output to somewhere
else.

This will be useful for testing the LibCpp Parser with the output of
ASTNode::dump.
2021-05-19 23:19:07 +02:00
Itamar
eeb98335d5 CppLanguageServer: Put cpp test files in /home/anon/cpp-tests/
This is similar to the LibJS test data that resides in
/home/anon/js-tests.
It's more convenient than storing the test programs as raw strings
in the code.
2021-05-19 23:19:07 +02:00
Gunnar Beutner
6ac1ca5a9a Profiler: Remove ability to filter Kernel::Scheduler::yield() frames
Hiding those frames doesn't really make sense. They're a major
contributor to a process' spent CPU time and show up in a lot of
profiles. That however is because those processes really do spend
quite a bit of time in the scheduler by doing lots of context
switches, like WindowServer when responding to IPC calls.

Instead of hiding these for aesthetic reasons we should instead
improve the scheduler.
2021-05-19 22:51:42 +02:00
Gunnar Beutner
572bbf28cc Kernel+LibC: Add support for filtering profiling events
This adds the -t command-line argument for the profile tool. Using this
argument you can filter which event types you want in your profile.
2021-05-19 22:51:42 +02:00
Gunnar Beutner
d954c11f66 Everywhere: Add missing includes for <AK/OwnPtr.h>
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to
change though. This patch fixes a few build problems that will occur
when that change happens.
2021-05-19 21:36:57 +02:00
Andreas Kling
7957f13e98 Revert "LibC: Simplify malloc size classes"
This reverts commit f91bcb8895.
2021-05-18 08:32:05 +02:00
Lenny Maiorani
f91bcb8895 LibC: Simplify malloc size classes
Problem:
- `size_classes` is a C-style array which makes it difficult to use in
  algorithms.
- `all_of` algorithm is re-written for the specific implementation.

Solution:
- Change `size_classes` to be an `Array`.
- Directly use the generic `all_of` algorithm instead of
  reimplementing.
2021-05-18 08:06:01 +02:00
faxe1008
bfcc53a879 Playground: Show the modified state in the window title
Similar to how updating the title is implemented within TextEditor,
GML-Playground now also shows the modified state and requests for
saving before closing a modified document.
2021-05-17 21:04:54 +01:00
Gunnar Beutner
ee6600ea24 UE: Don't look up binaries in PATH when the user specified a full path
When the user specifies a path such as ./test we'd incorrectly look for
the binary in the PATH environment variable and end up executing an
incorrect binary (e.g. /bin/test). We should only look up binaries in
PATH if the user-specified path does not contain a slash.
2021-05-17 19:34:53 +02:00
Gunnar Beutner
26e711f953 UE: Use Vector<String> for the command-line arguments
Core::ArgsParser gained support for String a while ago. So let's use
that.
2021-05-17 19:34:53 +02:00
Linus Groh
0aab774343 Everywhere: Fix a bunch of typos 2021-05-17 17:48:55 +01:00
Gunnar Beutner
52054eb922 UE: Make sure we return the right values for get{peer,sock}name
These two functions didn't previously return error codes correctly and
would crash when an invalid address buffer was specified.
2021-05-17 13:32:19 +02:00
Gunnar Beutner
89956cb0d6 Kernel+Userspace: Implement the accept4() system call
Unlike accept() the new accept4() system call lets the caller specify
flags for the newly accepted socket file descriptor, such as
SOCK_CLOEXEC and SOCK_NONBLOCK.
2021-05-17 13:32:19 +02:00
Gunnar Beutner
529f605ac8 UE: Make sure the buffers for get{sock,peer}name() are large enough
Previously struct sockaddr was used which isn't guaranteed to be
large enough to hold the socket address get{sock,peer}name() returns.

Also, the addrlen argument was initialized incorrectly and should
instead use the address length specified by the caller.
2021-05-17 13:32:19 +02:00
Itamar
400d3ddb08 LanguageServers: Rename AutoCompleteEngine => CodeComprehensionEngine
This feels like a better name since the "autocomplete engine" can, in
addition to providing autocomplete suggestions, also find declarations
of symbols and report back the symbols that are defined in a document.

Also, Cpp/ParserAutoComplete has been renamed to CppComprehensionEngine
and Shell/AutoComplete has been renamed to ShellComprehensionEngine.
2021-05-16 16:39:21 +02:00
Itamar
b1531b78f6 HackStudio+CppLanguageServer: Remove lexer-based autocomplete engine
The parser-based autocomplete engine is at a point where it's stable
enough that I don't think there's a need for the lexer-based
alternative anymore.
2021-05-16 16:39:21 +02:00
Daniel Bertalan
be519022c3 LibVT: Implement new ANSI escape sequence parser
This commit replaces the former, hand-written parser with a new one that
can be generated automatically according to a state change diagram.

The new `EscapeSequenceParser` class provides a more ergonomic interface
to dealing with escape sequences. This interface has been inspired by
Alacritty's [vte library](https://github.com/alacritty/vte/).

I tried to avoid changing the application logic inside the `Terminal`
class. While this code has not been thoroughly tested, I can't find
regressions in the basic command line utilities or `vttest`.

`Terminal` now displays nicer debug messages when it encounters an
unknown escape sequence. Defensive programming and bounds checks have
been added where we access parameters, and as a result, we can now
endure 4-5 seconds of `cat /dev/urandom`. :D

We generate EscapeSequenceStateMachine.h when building the in-kernel
LibVT, and we assume that the file is already in place when the userland
library is being built. This will probably cause problems later on, but
I can't find a way to do it nicely.
2021-05-16 11:50:56 +02:00
Daniel Bertalan
22195d965f DevTools: Add StateMachineGenerator utility
This program turns a description of a state machine that takes its input
byte-by-byte into C++ code. The state machine is described in a custom
format as specified below:

```
// Comments are started by two slashes, and cause the rest of the line
// to be ignored

@name ExampleStateMachine // sets the name of the generated class
@namespace Test           // sets the namespace (optional)
@begin Begin              // sets the state the parser will start in

// The rest of the file contains one or more states and an optional
// @anywhere directive. Each of these is a curly bracket delimited set
// of state transitions. State transitions contain a selector, the
// literal "=>" and a (new_state, action) tuple. Examples:
//     0x0a => (Begin, PrintLine)
//     [0x00..0x1f] => (_, Warn)      // '_' means no change
//     [0x41..0x5a] => (BeginWord, _) // '_' means no action

// Rules common to all states. These take precedence over rules in the
// specific states.
@anywhere {
    0x0a         => (Begin, PrintLine)
    [0x00..0x1f] => (_, Warn)
}

Begin {
    [0x41..0x5a] => (Word, _)
    [0x61..0x7a] => (Word, _)
    // For missing values, the transition (_, _) is implied
}

Word {
    // The entry action is run when we transition to this state from a
    // *different* state. @anywhere can't have this
    @entry IncreaseWordCount
    0x09 => (Begin, _)
    0x20 => (Begin, _)

    // The exit action is run before we transition to any *other* state
    // from here. @anywhere can't have this
    @exit EndOfWord
}
```

The generated code consists of a single class which takes a
`Function<Action, u8>` as a parameter in its constructor. This gets
called whenever an action is to be done. This is because some input
might not produce an action, but others might produce up to 3 (exit,
state transition, entry). The actions allow us to build a more
advanced parser over the simple state machine.

The sole public method, `void advance(u8)`, handles the input
byte-by-byte, managing the state changes and requesting the appropriate
Action from the handler.

Internally, the state transitions are resolved via a lookup table. This
is a bit wasteful for more complex state machines, therefore the
generator is designed to be easily extendable with a switch-based
resolver; only the private `lookup_state_transition` method needs to be
re-implemented.

My goal for this tool is to use it for implementing a standard-compliant
ANSI escape sequence parser for LibVT, as described on
<https://vt100.net/emu/dec_ansi_parser>
2021-05-16 11:50:56 +02:00
Itamar
35d28b29b3 CppLanguageServer: Fix syntax of a test case program 2021-05-15 23:28:50 +02:00
Itamar
c54238f65c CppLanguageServer: Make autocomplete logic consider scopes
When returning autocomplete suggestions, we now consider the scope of
the name that is being completed.

For example, when requested to complete an expression like
'MyNamespace::', we will only suggest things that are in the
'MyNamespace' namespace.

This commit also has some general refactoring of the autocomplete
logic.
2021-05-15 23:28:50 +02:00
Itamar
9408013177 CppLanguageServer: Only re-create DocumentData in file_opened if needed 2021-05-15 23:28:50 +02:00
Itamar
f9b8e9c01c CppLanguageServer: Autocomplete namespaces 2021-05-15 23:28:50 +02:00
Itamar
f89f4af0b3 CppLanguageServer: Don't suggest inaccessible declarations
Previously, declarations that are not available in the global
namespace, such as member functions of a class, would also appear in
the autocomplete suggestions list.

To fix this, we now only recurse into scopes of namespaces and classes
when fetching declarations if we want to retrieve all the available
declarations in the document (For the use of Locator & ClassView).
2021-05-15 23:28:50 +02:00
Ömer Kurttekin
e0a68d4b6e
HackStudio: Pledge "fattr"
HackStudio's pledges recently tightened due to changes in
Core::EventLoop. However, it still needs the fattr pledge to be able to
create a new project and set its permissions.
2021-05-15 13:00:23 +01:00
Jean-Baptiste Boric
9853a4393c IPCCompiler: Fix declaration of static functions 2021-05-14 22:24:02 +02:00
Andreas Kling
3ed5a73ede Profiler: Mark model columns as non-sortable
This removes the ability to click on the column headers to resort.
Resorting didn't do anything anyway.
2021-05-14 17:17:17 +02:00
Itamar
6329e9fce6 LanguageServer/Cpp: Add tests
The Cpp LanguageServer tests can be run with: CppLanguageServer -t

The tests now only cover some very simple autocomplete and
"find declaration" use cases, but it's a start :)
2021-05-14 13:27:47 +02:00
Itamar
e9fc5d6cc3 LanguageServers: Allow set_declarations_of_document callback to be null 2021-05-14 13:27:47 +02:00
Itamar
545b6af305 LanguageServers/FileDB: Allow m_project_root to be null 2021-05-14 13:27:47 +02:00