Commit Graph

7084 Commits

Author SHA1 Message Date
Shannon Booth
90f40a80f4 Shell: Make some functions const 2020-02-22 21:36:54 +01:00
Shannon Booth
859c1669f9 Shell: Add basic tilde expansion
This does not work with shell completion yet, but the basics of being
able a cd being able to expand "~" to the current user's home directory,
and "~foo" to the home directory of user "foo" is added in this commit

Work towards: #115
2020-02-22 21:36:54 +01:00
Shannon Booth
a52b3e8f2a LibC: Implement strchrnul() 2020-02-22 21:36:54 +01:00
Shannon Booth
ba9313111f AK: Add StringBuilder::is_empty() 2020-02-22 21:36:54 +01:00
Shannon Booth
854f0b9e1a AK: Add StringView::starts_with(char) & StringView::ends_with(char)
This is simply meant to be a more efficient implementation in the
case that we only need to check a single character.
2020-02-22 21:36:54 +01:00
Andreas Kling
a406a8c7d2 LibGUI: Remove debug spam when resizing table columns 2020-02-22 21:27:08 +01:00
Andreas Kling
a731ccd4a0 Kernel: Build without debugging symbols by default
Compiling with -g adds roughly 30% to kernel build times. Anyone who
wants this can turn it on locally instead.
2020-02-22 21:27:08 +01:00
Brian Gianforcaro
edb66f214d SystemMonitor: Fix display of file system size column.
The Size column in the "File systems" tab of SystemMonitor
had a rendering artifact where the bounding box outline would
be drawn in the same location as the text. This makes the text
look strange and hard to read.

Pad the size with a signle space character on either side to
give the text a gap on each side.
2020-02-22 21:25:00 +01:00
Brian Gianforcaro
c0ee0bdc46 TTYServer: Use unveil() 2020-02-22 21:19:58 +01:00
Brian Gianforcaro
540d9caa8e head: Use pledge() 2020-02-22 21:17:06 +01:00
Andreas Kling
21c78e2fc3 SystemMenu: Silence debug spam on startup 2020-02-22 17:01:06 +01:00
Andreas Kling
28f1486627 LibCore: Log a more helpful message when Socket::connect() fails
Fixes #1272.
2020-02-22 16:41:31 +01:00
Andreas Kling
82fd09e8fe LibCore: Fix wrong return value in Core::Socket::destination_address() 2020-02-22 16:38:10 +01:00
Andreas Kling
97e9deccf0 Ext2FS: Add Missing HashMap.h include 2020-02-22 16:37:51 +01:00
Andreas Kling
e334c36757 Kernel: Remove unnecessary allocation metadata from kmalloc() chunks
Each allocation header was tracking its index into the chunk bitmap,
but that index can be computed from the allocation address anyway.

Removing this means that each allocation gets 4 more bytes of memory
and this avoids allocating an extra chunk in many cases. :^)
2020-02-22 15:11:31 +01:00
Andreas Kling
99978b771d LibGUI: Take scroll offset into account when manipulating table headers
Fixes #1271.
2020-02-22 15:04:02 +01:00
Andreas Kling
3e973bfe14 Kernel: Make FileDescription slab-allocated 2020-02-22 14:37:58 +01:00
Andreas Kling
9fc54ba931 Kernel: Tweak SlabAllocator's slab sizes
Nobody was using the 8-byte slab size, so get rid of it and move all of
its capacity to the new 64-byte slab size (which replaces 48-byte.)
2020-02-22 14:36:45 +01:00
Andreas Kling
6428669a37 Kernel: Make Custody slab-allocated 2020-02-22 14:33:51 +01:00
Andreas Kling
ba83bf8a0d Kernel: Increase kmalloc chunk size from 8 bytes to 32 bytes
This gives a huge speedup when running "git status" in a SerenityOS
repository directory. Most of the time was spent allocating strings.
2020-02-22 14:18:34 +01:00
Andreas Kling
fc5ebe2a50 Kernel: Disown shared buffers on sys$execve()
When committing to a new executable, disown any shared buffers that the
process was previously co-owning.

Otherwise accessing the same shared buffer ID from the new program
would cause the kernel to find a cached (and stale!) reference to the
previous program's VM region corresponding to that shared buffer,
leading to a Region* use-after-free.

Fixes #1270.
2020-02-22 12:29:38 +01:00
Andreas Kling
af02d0ee97 ProfileViewer: Fix treeview selection looking unselected on Left key
When pressing the Left arrow key, we now travel to the parent_index()
of the currently selected index. Our implementation of parent_index()
was always returning an index with column 0, instead of using the
same column as the current index.

This prevented the selected item from looking selected.
2020-02-22 11:27:09 +01:00
Andreas Kling
bb7d6fb310 ProfileViewer: Remove loading code for the old file format
We're still jumping through all kinds of silly hoops to load the new
format, and this commit only gets rid of the API for loading old files.
2020-02-22 11:26:40 +01:00
Andreas Kling
34b81f17c2 LibELF: Avoid unnecessarily recomputing loop boundaries over and over 2020-02-22 11:25:15 +01:00
Andreas Kling
e81bde4a3d ProfileViewer: Symbolicate unknown addresses as "??" for now
This makes unknown addresses accumulate their children together in the
treeview, which turns out to be a bit more useful than having hundreds
of unique garbage addresses each with their own subtree.
2020-02-22 11:11:07 +01:00
Andreas Kling
ece2971112 Kernel: Disable profiling during the critical section of sys$execve()
Since we're gonna throw away these stacks at the end of exec anyway,
we might as well disable profiling before starting to mess with the
process page tables. One less weird situation to worry about in the
sampling code.
2020-02-22 11:09:03 +01:00
Andreas Kling
4420284125 profile: Allow launching a command with profiling enabled
You can now profile a program from start to finish by doing:

    $ profile -c "cat /etc/passwd"

The old "enable or disable profiling for a PID" mode is accessible via:

    $ profile -p <PID> -e    # Enable profiling for PID
    $ profile -p <PID> -d    # Disable profiling for PID

The generated profile is available via /proc/profile like before.
This is far from perfect, but it at least makes profiling a lot nicer
to use since you don't have to hurry and attach to something when you
want to profile the whole thing anyway.
2020-02-22 11:01:37 +01:00
Andreas Kling
d7a13dbaa7 Kernel: Reset profiling state on exec() (but keep it going)
We now log the new executable on exec() and throw away all the samples
we've accumulated so far. But profiling keeps going.
2020-02-22 10:54:50 +01:00
Andreas Kling
647d0b9e0f ProfileViewer: Symbolicate kernel addresses when possible
ProfileViewer will now attempt to open /boot/kernel and use that to
symbolicate kernel addresses (anything above the 3GB mark.)

In other words, if you run ProfileViewer as root, on a profile that
was generated by root, you can now see kernel functions properly
as well. This is not available to non-privileged users.
2020-02-22 10:09:54 +01:00
Andreas Kling
983b4bd9f2 Kernel+ProfileViewer: Move symbolication to userspace for time profiles
This makes the time profiles look like the memory profiles so we can
use the userspace symbolication code in ProfileViewer.
2020-02-22 10:09:54 +01:00
Andreas Kling
94652fd2fb Kernel: Fully validate pointers when walking stack during profiling
It's not enough to just check that things wouldn't page fault, we also
need to verify that addresses are accessible to the profiled thread.
2020-02-22 10:09:54 +01:00
Andreas Kling
f020081a38 Kernel: Put "Couldn't find user region" spam behind MM_DEBUG
This basically never tells us anything actionable anyway, and it's a
real annoyance when doing something validation-heavy like profiling.
2020-02-22 10:09:54 +01:00
Tibor Nagy
ba7281a7b2 WindowServer: Use system theme for the drag and drop popups 2020-02-21 20:19:06 +01:00
Tibor Nagy
2eb9620415 LibGUI: Improve TreeView keyboard navigation
This commit adds two new behaviour to the key event handler of
the TreeView widget:

Pressing left now jumps to the parent node if the current treenode
is closed or has no children.

Pressing right now jumps to the first children node if the current
treenode is open.
2020-02-21 20:18:44 +01:00
Andreas Kling
b6887bd9cd Ext2FS: The max current block count of a file is size/block_size
Turns out that i_blocks does not take block list holes into account.
2020-02-21 19:07:23 +01:00
Andreas Kling
b298c01e92 Kernel: Log instead of crashing when getting a page fault during IRQ
This is definitely a bug, but it seems to happen randomly every now
and then and we need more info to track it down, so let's log for now.
2020-02-21 19:05:45 +01:00
Andreas Kling
c4c1ad2289 Toolchain: Build demangling into LibC except during toolchain build 2020-02-21 18:54:57 +01:00
Andreas Kling
59c052a72a Ext2FS: Allow holes in block lists
Linux creates holes in block lists for all-zero content. This is very
reasonable and we can now handle that situation as well.

Note that we're not smart enough to generate these holes ourselves yet,
but now we can at least read from such files.
2020-02-21 17:50:51 +01:00
Andreas Kling
4198061534 LibELF: Use the ELF_STRTAB string constant instead of hard-coding 2020-02-21 16:16:23 +01:00
Andreas Kling
04e40da188 Kernel: Fix crash when reading /proc/PID/vmobjects
InodeVMObjects can have nulled-out physical page slots. That just means
we haven't cached that page from disk right now.
2020-02-21 16:03:56 +01:00
Andreas Kling
59b9e49bcd Kernel: Don't trigger page faults during profiling stack walk
The kernel sampling profiler will walk thread stacks during the timer
tick handler. Since it's not safe to trigger page faults during IRQ's,
we now avoid this by checking the page tables manually before accessing
each stack location.
2020-02-21 15:49:39 +01:00
Andreas Kling
f9a138aa4b Kernel: Commit the profiling sample buffer memory up front
This avoids getting page faults while storing samples in the timer IRQ.
2020-02-21 15:49:37 +01:00
Andreas Kling
8047ff8205 Kernel: Expose the underlying Region of a KBuffer 2020-02-21 15:49:35 +01:00
Andreas Kling
d46071c08f Kernel: Assert on page fault during IRQ
We're not equipped to deal with page faults during an IRQ handler,
so add an assertion so we can immediately tell what's wrong.

This is why profiling sometimes hangs the system -- walking the stack
of the profiled thread causes a page fault and things fall apart.
2020-02-21 15:49:34 +01:00
Andreas Kling
2a679f228e Kernel: Fix bitrotted DEBUG_IO logging 2020-02-21 15:49:30 +01:00
howar6hill
a78ae917d8 mv: Use ArgsParser, and check lstat for failure 2020-02-21 15:16:28 +01:00
Sergey Bugaev
1d2986ea15 Kernel: Fix a panic in VFS::rename()
If we get an -ENOENT when resolving the target because of some part, that is not
the very last part, missing, we should just return the error instead of panicking
later :^)

To test:
    $ mkdir /tmp/foo/
    $ mv /tmp/foo/ /tmp/bar/

Related to https://github.com/SerenityOS/serenity/issues/1253
2020-02-20 19:13:20 +01:00
Sergey Bugaev
3439498744 Kernel: Support trailing slashes in VFS::mkdir()
This is apparently a special case unlike any other, so let's handle it
directly in VFS::mkdir() instead of adding an alternative code path into
VFS::resolve_path().

Fixes https://github.com/SerenityOS/serenity/issues/1253
2020-02-20 19:13:20 +01:00
howar6hill
7ff256aab6 Base: Add a man page for lspci 2020-02-20 15:13:42 +01:00
howar6hill
e352ee23e5 Userland: Fix nullptr dereference if we fail to open the PCIDB
In the code below, db could be null, and would cause UB.
Instead of crashing, let's simply skip symbolicating names.

Fixes #1247
2020-02-20 15:13:42 +01:00