Commit graph

7348 commits

Author SHA1 Message Date
Andreas Kling
4697195645 LibGUI: Use set_layout<LayoutType>() in lots of client code 2020-03-04 13:49:48 +01:00
Andreas Kling
03e0ddce52 LibGUI: Some more convenience functions for constructing widgets
This patch adds two new API's:

- WidgetType& GUI::Window::set_main_widget<WidgetType>();

  This creates a new main widget for a window, assigns it, and returns
  it to you as a WidgetType&.

- LayoutType& GUI::Widget::set_layout<LayoutType>();

  Same basic idea, creates a new layout, assigns it, and returns it to
  you as a LayoutType&.
2020-03-03 22:37:48 +01:00
Andreas Kling
0cafbbf09c LibGUI: Save some more state from AbstractButton
The more stuff we save in save_to() overrides, the more interesting it
becomes inspecting GUI programs. :^)
2020-03-03 22:37:48 +01:00
marprok
86812af077 Userland: Speed up the execution of the cut command.
Avoid creating SingleIndexes in case of byte ranges. This, boosts
the performance significantly in case a byte range is too big(e.g 666-123123).
Also, claim copyright over this mess since I am the one responsible for it.
2020-03-03 20:19:21 +01:00
Ben Wiederhake
4dd4dd2f3c Kernel: Fix race in clock_nanosleep
This is a complete fix of clock_nanosleep, because the thread holds the
process lock again when returning from sleep()/sleep_until().
Therefore, no further concurrent invalidation can occur.
2020-03-03 20:13:32 +01:00
Ben Wiederhake
28e1da344d Kernel: Demonstrate race condition in clock_nanosleep
This adds a test for the race condition in clock_nanosleep.
The crux is that clock_nanosleep verifies that the output buffer
is writable *before* sleeping, and writes to it *after* sleeping.
In the meantime, a concurrent thread can make the output buffer
unwritable, e.g. by deallocating it.

This testcase is needlessly complex because pthread_kill is
not implemented yet.  I tried to keep it as simple as possible.

Here is the relevant part of dmesg:
[nanosleep-race-outbuf-munmap(22:22)]: Unblock nanosleep-race-outbuf-munmap(20:20) due to signal
nanosleep-race-outbuf-munmap(20:20) Unrecoverable page fault, write to address 0x02130016
CRASH: Page Fault. Process: nanosleep-race-outbuf-munmap(20)
[nanosleep-race-outbuf-munmap(20:20)]: 0xc01160ff  memcpy +44
[nanosleep-race-outbuf-munmap(20:20)]: 0xc014de64  Kernel::Process::crash(int, unsigned int) +782
[nanosleep-race-outbuf-munmap(20:20)]: 0xc01191b5  illegal_instruction_handler +0
[nanosleep-race-outbuf-munmap(20:20)]: 0xc011965b  page_fault_handler +649
[nanosleep-race-outbuf-munmap(20:20)]: 0xc0117233  page_fault_asm_entry +22
[nanosleep-race-outbuf-munmap(20:20)]: 0xc011616b  copy_to_user +102
[nanosleep-race-outbuf-munmap(20:20)]: 0xc015911f  Kernel::Process::sys(Kernel::Syscall::SC_clock_nanosleep_params const*) +457
[nanosleep-race-outbuf-munmap(20:20)]: 0xc015daad  syscall_handler +1130
[nanosleep-race-outbuf-munmap(20:20)]: 0xc015d597  syscall_asm_entry +29
[nanosleep-race-outbuf-munmap(20:20)]: 0x08048437  main +146
[nanosleep-race-outbuf-munmap(20:20)]: 0x08048573  _start +94

Most importantly, note that it crashes *inside*
Kernel::Process::sys.
Instead, the correct behavior is to return -EFAULT.
2020-03-03 20:13:32 +01:00
Andreas Kling
a26b63a958 LibGUI: Remove Button& parameter from Button::on_click hook
There was but a single user of this parameter and it's a bit tedious
to write it out every time, so let's get rid of it.
2020-03-03 17:02:38 +01:00
Andreas Kling
b1d35248e4 SystemMenu: Fix bad behavior in shutdown dialog
The selected option was stored in a captured stack variable which was
long gone by the time we looked at it, so this dialog didn't really
behave the way you'd expect. Put it in a member instead. :^)
2020-03-03 16:46:39 +01:00
Andreas Kling
71e96ee728 Base: Add anon user to the phys group
This allows anon to shut down and reboot the system.

Fixes #775.
2020-03-03 16:39:06 +01:00
Andreas Kling
686ade6b5a AK: Make quick_sort() a little more ergonomic
Now it actually defaults to "a < b" comparison, instead of forcing you
to provide a trivial less-than comparator. Also you can pass in any
collection type that has .begin() and .end() and we'll sort it for you.
2020-03-03 16:02:58 +01:00
Andreas Kling
058cd1241e ProfileViewer: Add mode that shows percentages instead of sample counts
Sometimes it's much nicer to work with percentages than raw sample
counts when browsing through a profile. :^)
2020-03-02 23:05:04 +01:00
Andreas Kling
8effe0b632 ProfileView: Show "self" sample counts in profiles
The "self" sample count is the number of samples that had this specific
frame as its innermost stack frame (leaf nodes in the profile tree.)
2020-03-02 23:05:04 +01:00
Andreas Kling
8e8e8c801c LibGUI: Fix broken TreeView rendering with more than two columns
The computation of the tree column x offset was not taking padding into
account. This patch fixes that and collects the logic in a helper.
2020-03-02 23:05:04 +01:00
Andreas Kling
2719d6d502 SystemMonitor: Unbreak the in-table progress bars showing disk usage 2020-03-02 23:05:04 +01:00
Andreas Kling
e7f8c8a342 ProfileViewer: Parse the JSON input directly to Profile::Event
We were going from "new JSON format" => "old JSON format" => Event.
This made loading longer profiles unnecessarily slow. It's still pretty
slow, and we should... profile it! :^)
2020-03-02 23:05:04 +01:00
Andreas Kling
8eaac171d7 ProfileViewer: Rename Profile::Sample => Profile::Event 2020-03-02 23:05:04 +01:00
Liav A
251b7f3776 CPU: Change debug messages to fit the latest changes 2020-03-02 22:23:39 +01:00
Liav A
f0ca29eb4b Kernel: Run clang-format on various files 2020-03-02 22:23:39 +01:00
Liav A
0fc60e41dd Kernel: Use klog() instead of kprintf()
Also, duplicate data in dbg() and klog() calls were removed.
In addition, leakage of virtual address to kernel log is prevented.
This is done by replacing kprintf() calls to dbg() calls with the
leaked data instead.
Also, other kprintf() calls were replaced with klog().
2020-03-02 22:23:39 +01:00
Liav A
19aa53e1f9 Kernel: Use IOAddress class in PATAChannel class
This change make the code a bit more readable. Also, kprintf() calls
are replaced with klog() calls.
2020-03-02 22:23:39 +01:00
Liav A
15dfca4a79 Kernel: Use IOAddress class in Network adapters' drivers
Also, kprintf() calls were replaced with klog() calls.
2020-03-02 22:23:39 +01:00
Liav A
7d39e380f9 LibBareMetal: Add IOAddress class 2020-03-02 22:23:39 +01:00
Liav A
9440c45d6e AK: Add support for Kernel Log Stream 2020-03-02 22:23:39 +01:00
Liav A
dc01a71fac LibBareMetal: Add support for kernel log stream 2020-03-02 22:23:39 +01:00
Andreas Kling
214f934465 Meta: Adjust some copyright dates by Fei Wu 2020-03-02 14:24:25 +01:00
Andreas Kling
f5b78c2a1c AK: Add missing copyright headers to StringUtils.{cpp,h} 2020-03-02 14:23:11 +01:00
howar6hill
d75fa80a7b
AK: Move to_int(), to_uint() implementations to StringUtils (#1338)
Provide wrappers in String and StringView. Add some tests for the
implementations.
2020-03-02 14:19:33 +01:00
Andreas Kling
918ebabf60 Kernel: MemoryManager should create cacheable regions by default 2020-03-02 13:04:17 +01:00
Andreas Kling
47beab926d Kernel: Remove ability to create kernel-only regions at user addresses
This was only used by the mechanism for mapping executables into each
process's own address space. Now that we remap executables on demand
when needed for symbolication, this can go away.
2020-03-02 11:20:34 +01:00
Andreas Kling
e56f8706ce Kernel: Map executables at a kernel address during ELF load
This is both simpler and more robust than mapping them in the process
address space.
2020-03-02 11:20:34 +01:00
Andreas Kling
678c87087d Kernel: Load executables on demand when symbolicating
Previously we would map the entire executable of a program in its own
address space (but make it unavailable to userspace code.)

This patch removes that and changes the symbolication code to remap
the executable on demand (and into the kernel's own address space
instead of the process address space.)

This opens up a couple of further simplifications that will follow.
2020-03-02 11:20:34 +01:00
howar6hill
055344f346 AK: Move the wildcard-matching implementation to StringUtils
Provide wrappers in the String and StringView classes, and add some tests.
2020-03-02 10:38:08 +01:00
howar6hill
2a30a020c1
AK: Add enqueue_begin() for the CircularDeque class (#1320)
Also add tests for CircularDeque.
2020-03-02 09:50:43 +01:00
howar6hill
4ed2ba264d
AK: Remove superfluous explicit in Bitmap (#1337) 2020-03-02 09:50:22 +01:00
Nicolas Van Bossuyt
12504b52d2
CI: Update .travis.yml (#1334)
According to the Travis build config validation, the `sudo` key does
nothing and `os` should be specified.
2020-03-02 06:26:34 +01:00
Andreas Kling
0acac186fb Kernel: Make the "entire executable" region shared
This makes Region::clone() do the right thing with it on fork().
2020-03-02 06:13:29 +01:00
Andreas Kling
5c2a296a49 Kernel: Mark read-only PT_LOAD mappings as shared regions
This makes Region::clone() do the right thing for these now that we
differentiate based on Region::is_shared().
2020-03-01 21:26:36 +01:00
Andreas Kling
ecfde5997b Kernel: Use SharedInodeVMObject for executables after all
I had the wrong idea about this. Thanks to Sergey for pointing it out!

Here's what he says (reproduced for posterity):

> Private mappings protect the underlying file from the changes made by
> you, not the other way around. To quote POSIX, "If MAP_PRIVATE is
> specified, modifications to the mapped data by the calling process
> shall be visible only to the calling process and shall not change the
> underlying object. It is unspecified whether modifications to the
> underlying object done after the MAP_PRIVATE mapping is established
> are visible through the MAP_PRIVATE mapping." In practice that means
> that the pages that were already paged in don't get updated when the
> underlying file changes, and the pages that weren't paged in yet will
> load the latest data at that moment.
> The only thing MAP_FILE | MAP_PRIVATE is really useful for is mapping
> a library and performing relocations; it's definitely useless (and
> actively harmful for the system memory usage) if you only read from
> the file.

This effectively reverts e2697c2ddd.
2020-03-01 21:16:27 +01:00
Andreas Kling
bb7dd63f74 Kernel: Run clang-format on Process.cpp 2020-03-01 21:16:27 +01:00
Andreas Kling
7e6c2068bf Kernel: Fix suspicious local shadowing in PerformanceEventBuffer 2020-03-01 21:08:04 +01:00
Andreas Kling
687b52ceb5 Kernel: Name perfcore files "perfcore.PID"
This way we can trace many things and we get one perfcore file per
process instead of everyone trying to write to "perfcore"
2020-03-01 20:59:02 +01:00
Andreas Kling
6fa5df783b ps: Add some options and slim down the default output style
The following options are now available:

    -e: Show every process (not just the ones on your TTY)
    -f: Full format (instead of the short format)

We should definitely support more options and formats, I just wanted to
get away from the static single style of output. :^)
2020-03-01 17:46:06 +01:00
Andreas Kling
24a5a6cd2c Shell: Remove bogus assertion 2020-03-01 17:08:49 +01:00
Andreas Kling
2695773dd2 Shell: Handle the "delete" key correctly
We were deleting the wrong character in the line buffer, oopsie!
2020-03-01 16:32:35 +01:00
Andreas Kling
ecdd9a5bc6 Kernel: Reduce code duplication a little bit in Region allocation
This patch reduces the number of code paths that lead to the allocation
of a Region object. It's quite hard to follow the various ways in which
this can happen, so this is an effort to simplify.
2020-03-01 15:56:23 +01:00
Andreas Kling
5e0c4d689f Kernel: Move ProcessPagingScope to its own files 2020-03-01 15:38:09 +01:00
Andreas Kling
2839bb0be1 Kernel: Restore the previous thread state on SIGCONT after SIGSTOP
When stopping a thread with the SIGSTOP signal, we now store the thread
state in Thread::m_stop_state. That state is then restored on SIGCONT.
This fixes an issue where previously-blocked threads would unblock
upon resume. Now they simply resume in the Blocked state, and it's up
to the regular unblocking mechanism to unblock them.

Fixes #1326.
2020-03-01 15:14:17 +01:00
Andreas Kling
fbe9aad70a WindowServer: Clear the current resize candidate when in menus
While the menu system is swallowing mouse events, just clear any resize
candidate we had set. This ensures that we don't end up with a resize
cursor when slipping into a menu-controlled part of the screen.

Fixes #1306.
2020-03-01 14:21:38 +01:00
Andreas Kling
1e6ec22017 WindowServer: Remove a whole bunch of unused WindowManager members 2020-03-01 14:13:05 +01:00
Andreas Kling
042baa4e8d WindowServer: Put some WindowManager debug spam inside #ifdefs 2020-03-01 13:58:29 +01:00