When the filesystem model is updated, it is rebuilt. This means dangling
indexes inside the TreeView metadata table will have old information and random
directories will toggle open. Clearing the table alleviates this issue.
The kernel now supports basic profiling of all the threads in a process
by calling profiling_enable(pid_t). You finish the profiling by calling
profiling_disable(pid_t).
This all works by recording thread stacks when the timer interrupt
fires and the current thread is in a process being profiled.
Note that symbolication is deferred until profiling_disable() to avoid
adding more noise than necessary to the profile.
A simple "/bin/profile" command is included here that can be used to
start/stop profiling like so:
$ profile 10 on
... wait ...
$ profile 10 off
After a profile has been recorded, it can be fetched in /proc/profile
There are various limits (or "bugs") on this mechanism at the moment:
- Only one process can be profiled at a time.
- We allocate 8MB for the samples, if you use more space, things will
not work, and probably break a bit.
- Things will probably fall apart if the profiled process dies during
profiling, or while extracing /proc/profile
When a GAction is activated by a menu, or by a toolbar button, you can
now use GAction::activator() to get a pointer to whomever activated it.
This can be used to implement context-specific behaviors in situations
where the same action is exposed through multiple paths.
This addresses an issue that was brought up in #826.
We now take advantage of SharedBuffers being purgeable memory by
setting the volatile flag on window back buffers while not painting
into them.
This means that one of the two backing stores used by each window
is purgeable+volatile most of the time, allowing the kernel to purge
it to recover memory if needed.
Note that this is only relevant when double-buffering is turned on,
but since that is the default, this does affect most apps. :^)
This patch makes SharedBuffer use a PurgeableVMObject as its underlying
memory object.
A new syscall is added to control the volatile flag of a SharedBuffer.
This patch exposes some fields about purgeable memory regions.
We now also show total purgeable volatile and non-volatile memory in
the big process table.
It's now possible to get purgeable memory by using mmap(MAP_PURGEABLE).
Purgeable memory has a "volatile" flag that can be set using madvise():
- madvise(..., MADV_SET_VOLATILE)
- madvise(..., MADV_SET_NONVOLATILE)
When in the "volatile" state, the kernel may take away the underlying
physical memory pages at any time, without notifying the owner.
This gives you a guilt discount when caching very large things. :^)
Setting a purgeable region to non-volatile will return whether or not
the memory has been taken away by the kernel while being volatile.
Basically, if madvise(..., MADV_SET_NONVOLATILE) returns 1, that means
the memory was purged while volatile, and whatever was in that piece
of memory needs to be reconstructed before use.
Using int was a mistake. This patch changes String, StringImpl,
StringView and StringBuilder to use size_t instead of int for lengths.
Obviously a lot of code needs to change as a result of this.
This bitmap is displayed alongside the dragged text underneath the
mouse cursor while dragging.
This will be a perfect fit for dragging e.g files around. :^)
This function returns the bitmap itself if it's already backed by a
SharedBuffer object, otherwise it creates a shareable copy of itself
and returns that.
This patch enables basic drag&drop between applications.
You initiate a drag by creating a GDragOperation object and calling
exec() on it. This creates a nested event loop in the calling program
that only returns once the drag operation has ended.
On the receiving side, you get a call to GWidget::drop_event() with
a GDropEvent containing information about the dropped data.
The only data passed right now is a piece of text that's also used
to visually indicate that a drag is happening (by showing the text in
a little box that follows the mouse cursor around.)
There are things to fix here, but we're off to a nice start. :^)
These should be the last thing needed to make SDL build with threads
support. I think we can survive just fine with stubs of these for now,
especially given that the kernel doesn't care super much about thread
priorities anyway.
This patch adds pthread_key_create() and pthread_{get,set}specific().
There's a maximum of 64 thread-specific keys for simplicity.
Key destructors are not invoked on thread exit.
This feels like a pretty naive implementation, but I think it can work.
Basically each waiter creates an object on its stack that is then
added to a linked list inside by the pthread_cond_t.
Signalling is then done by walking the list and unsetting the "waiting"
flag on as many of the waiters as you like.
Instead of passing the PIDs back and forth in a handshake "Greet"
message, just use getsockopt(SO_PEERCRED) on both sides to get the same
information from the kernel.
This is a nice little simplification of the IPC protocol, although it
does not get rid of the handshake since we still have to pass the
"client ID" from the server to each client so they know how to refer
to themselves. This might not be necessary and we might be able to get
rid of this later on.
This extends the opportunistic protection of empty-but-kept-around to
also cover BigAllocationBlocks. Since we only cache 4KB BAB's at the
moment, this sees limited use, but it does work.
We now keep a separate queue of empty ChunkedBlocks in each allocator.
The underlying memory for each block is mprotect'ed with PROT_NONE to
provoke crashes on use-after-free.
This is not going to catch *all* use-after-frees, but if it catches
some, that's still pretty nice. :^)
The malloc memory region names are now updated to reflect their reuse
status: "malloc: ChunkedBlock(size) (free/reused)"
If a client sends an invalid window ID or similar to the WindowServer,
we'll now immediately mark them as misbehaving and disconnect them.
This might be too aggressive in some cases (window management, ...)
but it's just a place to start.
When draining the socket in IServerConnection, we would previously
handle each incoming (local endpoint) message as it came in.
This would cause unexpected things to happen while blocked waiting
for a synchronous response. That's definitely not what we want,
so this patch puts all of the incoming messages in a queue and does
a separate pass over the queue to handle everything in order.
This matches what we're already calling the server-side subclasses
better, though we'll probably want to find some better names for the
client-side classes eventually.
This patch introduces code generation for the WindowServer IPC with
its clients. The client/server endpoints are defined by the two .ipc
files in Servers/WindowServer/: WindowServer.ipc and WindowClient.ipc
It now becomes significantly easier to add features and capabilities
to WindowServer since you don't have to know nearly as much about all
the intricate paths that IPC messages take between LibGUI and WSWindow.
The new system also uses significantly less IPC bandwidth since we're
now doing packed serialization instead of passing fixed-sized structs
of ~600 bytes for each message.
Some repaint coalescing optimizations are lost in this conversion and
we'll need to look at how to implement those in the new world.
The old CoreIPC::Client::Connection and CoreIPC::Server::Connection
classes are removed by this patch and replaced by use of ConnectionNG,
which will be renamed eventually.
Goodbye, old WindowServer IPC. You served us well :^)
This patch adds these I/O counters to each thread:
- (Inode) file read bytes
- (Inode) file write bytes
- Unix socket read bytes
- Unix socket write bytes
- IPv4 socket read bytes
- IPv4 socket write bytes
These are then exposed in /proc/all and seen in SystemMonitor.
We never want to alpha blend when rendering the terminal buffer, so we
can just use clear_rect() and avoid trouble.
This fixes an issue with inconsistent translucency in the terminal app
when setting a custom background opacity.
This patch adds InsertTextCommand and RemoveTextCommand.
These two commands are used to ... insert and remove text :^)
The bulk of the logic is moved into GTextDocument, and we now use the
command's redo() virtual to perform the action. Or in other words, when
you type into the text editor, we create an InsertTextCommand, push it
onto the undo stack, and call redo() on it immediately. That's how the
text gets inserted.
This makes it quite easy to implement more commands, as there is no
distinction between a redo() and the initial application.
This patch converts the undo stack from GTextDocument into GUndoStack,
and GTextDocumentUndoCommand now inherits from GCommand.
Let's turn this into a generic mechanism that can be used to implement
undo/redo in any application. :^)
Callers of draw_pixel() are not expecting it to apply translation since
they will have already done that themselves.
This was causing draw_line() with thickness>1 to have an offset applied
in case the painter was already translated.
It's now possible to load a .o file into the kernel via a syscall.
The kernel will perform all the necessary ELF relocations, and then
call the "module_init" symbol in the loaded module.
Painter::draw_line() now has an optional "bool dotted" parameter that
causes it to only render every other pixel.
Note that this only works with horizontal and vertical lines at the
moment and we'll assert if called with dotted=true for a diagonal line.
This is going to be quite boring to do by hand for every single CSS
property. We'll probably want to come up with a way to auto-generate
some/most of the shorthand expansion code.
This patch moves the Selector object model closer to the specification
objects in Selectors Level 4.
A "Selector" in LibHTML is now a { Vector<ComplexSelector> }, which is
a { Relation, CompoundSelector }. A CompoundSelector is really just
a Vector<SimpleSelector>, and SimpleSelector is "Component" renamed.
This makes a lot more selectors actually match on the Ubuntu Apache2
default homepage. :^)
After resorting, we now re-map every selected index so it matches the
new row mappings. This makes the process table view in SystemMonitor
behave normally again :^)
Turns out we can use abi::__cxa_demangle() for this, and all we need to
provide is sprintf(), realloc() and free(), so this patch exposes them.
We now have fully demangled C++ backtraces :^)
Previously it was not possible to see what each thread in a process was
up to, or how much CPU it was consuming. This patch fixes that.
SystemMonitor and "top" now show threads instead of just processes.
"ps" is gonna need some more fixing, but it at least builds for now.
Fixes#66.
SystemServer can now create sockets on behalf of services before spawning any
of them, and pass the open socket fd as fd 3. CLocalServer gains a method to
complete the takeover and listen on the passed fd.
This is not used by any services at the moment.
Long ago, there was a fourth stdio default stream, stddbg, connected to the
debug console. It has since been replaced by the dbgputstr() and dbgputch()
syscalls.
3fce2fb205
Remove the last remains of stddbg, as fd 3 is soon going to be reused for socket
takeover.
This patch adds "submit" inputs and default (text box) inputs, as well
as form elements that can be submitted.
Layout of input elements is implemented via a new LayoutWidget class
that allows you to put an arbitrary GWidget in the layout tree.
At the moment, the DOM node sets the initial size of the LayoutWidget,
and then the positioning is done by the normal layout algorithm.
We also now support submitting a <form method="GET">, which does a full
replacing load with a URL based on the form's action + a query string
built from the name/value of input elements within the submitted form.
This is pretty neat! :^)
Before this patch, all of the excess spacing caused by line-height was
"padding" the line boxes below the text.
To fix this, we make line box fragments use the font height as their
height, and then let the inline layout algorithm adjust the Y positions
to distribute the vertical space.
Always paint border edges so they join nicely with their buddy edges.
This makes borders look nice even if all sides have different widths.
Also switch the border code to using floating point numbers since
otherwise things get very ugly very fast.
The borders still look very wrong with any border-width other than 1,
but at least we can see that they have the right color, and end up in
mostly the right place :^)
I broke semi-transparent terminals when I added support for alpha
blending to Painter::fill_rect().
When we fill the terminal widget background, we don't want blending to
take place, we're just looking to replace with an exact color, so now
we can use Painter::clear_rect() for that.
LibProtocol::Client::start_download() now gives you a Download object
with convenient hooks (on_finish & on_progress).
Also, the IPC handshake is snuck into the Client constructor, so you
don't need to perform it after instantiating a Client.
This makes using LibProtocol much more pleasant. :^)
The DownloadFinished message from the server now includes a buffer ID
that can be mapped into the client program.
To avoid prematurely destroying the buffer, the server will hang on to
it until the client lets it know that they're all good. That's what the
ProtocolServer::DisownSharedBuffer message is about.
In the future it would be nice if the kernel had a mechanism to allow
passing ownership of a shared buffer along with an IPC message somehow.
This patch adds ProtocolServer, a server that handles network requests
on behalf of its clients. The first protocol implemented is HTTP.
The idea here is to use a plug-in architecture where any number of
protocols can be added and implemented without having to mess around
with each client program that wants to use the protocol.
A simple client API is provided through LibProtocol::Client. :^)
Here comes the first part of a GIF decoder. It decodes up to the point
of gathering all the LZW-compressed data. The next step is to implement
decompression, and then turn the decompressed data into a bitmap using
the color maps, etc.
Client-side connection objects must now provide both client and server
endpoint types. When a message is received from the server side, we try
to decode it using both endpoint types and then send it to the right
place for handling.
This now makes it possible for AudioServer to send unsolicited messages
to its clients. This opens up a ton of possibilities :^)
This patch adds muting to ASMixer, which works by substituting what we
would normally send to the sound card with zero-filled memory instead.
We do it this way to ensure that the queued sample buffers keep getting
played (silently.)
This is obviously not the perfect way of doing this, and in the future
we should improve on this, and also find a way to utilize any hardware
mixing functions in the sound card.
This patch adds a[foo] and a[foo=bar] attribute selectors.
Note that an attribute selector is an optional part of a selector
component, and not a component on its own.
We were not producing the correct DOM attribute in either of those
cases. "<div attr>" would produce no attribute, and the other would
produce an attribute with null value (instead of an empty value.)
Previously they would resort based on the column immediately when you
mousedown on them. Now we track the click event and show the header
in a pressed state, etc. The usual button stuff :^)
Instead of implicitly copying whatever you select, and pasting when you
middle-click, let's have traditional copy and paste actions bound to
Ctrl+Shift+C and Ctrl+Shift+V respectively.
This code was using the text from the DOM as a reference for how much
whitespace to remove from the end of a line box.
Since the DOM may contain uncollapsed whitespace, it would sometimes
be out of sync with the collapsed text used by the rest of the layout
system.
This works for C++ syntax highlighted text documents by caching the C++
token type in a new "arbitrary data" member of GTextDocumentSpan.
When the cursor is placed immediately before a '{' or immediately after
a '}', we highlight both of these brace buddies by changing their
corresponding spans to have a different background color.
..and spans can also now have a custom background color. :^)
Instead of trying to build the host-side code generator helpers right
before we need them in the LibHTML build process, just build them ahead
of time in makeall.sh, like we already do for {IPC,Form}Compiler.
It's no longer possible to build LibHTML on the host machine since it
depends on LibGUI now. This patch gets rid of the dual Makefiles in
LibHTML since we only support Serenity builds anyway.
Also clean the code generator directory before building it.
These CSS properties constrain the computed width of a block-level box
to a maximum, followed by a minimum value.
This makes the "better mother fricken website" look more like it's
intended to (which helps makes the author's point, I suppose.)
This is a very bulky way of doing this, and doesn't seem sustainable to
implement every shorthand property this way, but it's a place to start.
The "margin" CSS property now expands into its four longhands as far as
my understanding of the specs.
Note that shorthand expansion happens when we *resolve* style, not when
we parse CSS. I'm not sure this is correct anymore, I think other UA's
may actually expand shorthands into the declaration directly at parse
these days. If so, we should do this at parsing as well.
Code for parsing and stringifying CSS properties is now generated based
on LibHTML/CSS/Properties.json
At the moment, the file tells us three things:
- The name of a property
- Its initial value
- Whether it's inherited
Also, for shorthand properties, it provides a list of all the longhand
properties it may expand too. This is not actually used in the engine
yet though.
This *finally* makes layout tree dumps show the names of CSS properties
in effect, instead of "CSS::PropertyID(32)" and such. :^)
Add an initial implementation of pthread attributes for:
* detach state (joinable, detached)
* schedule params (just priority)
* guard page size (as skeleton) (requires kernel support maybe?)
* stack size and user-provided stack location (4 or 8 MB only, must be aligned)
Add some tests too, to the thread test program.
Also, LibC: Move pthread declarations to sys/types.h, where they belong.
This can be implemented entirely in userspace by calling tcgetattr().
To avoid screwing up the syscall indexes, this patch also adds a
mechanism for removing a syscall without shifting the index of other
syscalls.
Note that ports will still have to be rebuilt after this change,
as their LibC code will try to make the isatty() syscall on startup.
Have pthread_create() allocate a stack and passing it to the kernel
instead of this work happening in the kernel. The more of this we can
do in userspace, the better.
This patch also unexposes the raw create_thread() and exit_thread()
syscalls since they are now only used by LibPthread anyway.
VM regions can now be marked as stack regions, which is then validated
on syscall, and on page fault.
If a thread is caught with its stack pointer pointing into anything
that's *not* a Region with its stack bit set, we'll crash the whole
process with SIGSTKFLT.
Userspace must now allocate custom stacks by using mmap() with the new
MAP_STACK flag. This mechanism was first introduced in OpenBSD, and now
we have it too, yay! :^)
This patch adds these API's:
- pthread_mutex_init()
- pthread_mutex_lock()
- pthread_mutex_unlock()
No mutex attributes are supported yet, so we only do the simplest mutex
wihout recursive locking.
It's now possible to block until another thread in the same process has
exited. We can also retrieve its exit value, which is whatever value it
passed to pthread_exit(). :^)
This patch adds pthread_create() and pthread_exit(), which currently
simply wrap our existing create_thread() and exit_thread() syscalls.
LibThread is also ported to using LibPthread.
The Launcher's functionality has been replaced by the app shortcuts in
the system menu.
There were various window management hacks to ensure that the launcher
stayed below all other windows while also being movable, etc.
POSIX's openat() is very similar to open(), except you also provide a
file descriptor referring to a directory from which relative paths
should be resolved.
Passing it the magical fd number AT_FDCWD means "resolve from current
directory" (which is indeed also what open() normally does.)
This fixes libarchive's bsdtar, since it was trying to do something
extremely wrong in the absence of openat() support. The issue has
recently been fixed upstream in libarchive:
https://github.com/libarchive/libarchive/issues/1239
However, we should have openat() support anyway, so I went ahead and
implemented it. :^)
Fixes#748.
This just copies the short char into the wide char without any decoding
whatsoever. A proper implementation should look at the current LC_CTYPE
and implement multi-byte decoding.
To protect the layout system from negative input values, we were using
an empty Rect() whenever an empty rect (width/height <= 0) was provided
to set_relative_rect().
This caused Terminal's scrollbar code to fail, since it relies on first
setting only the scrollbar width on startup, and then setting up the
proper geometry in response to the initial resize event.
Fixes#753.
You can now register a GWidget subclass with REGISTER_GWIDGET(class)
and it will be available for factory construction through the new
GWidgetClassRegistration interface.
To obtain a GWidgetClassRegistration for a given class name, you call
GWidgetClassRegistration::find(class_name). You can also iterate over
all the registered classes using GWCR::for_each(callback).
This will be very useful for implementing a proper GUI designer, and
also in the future for things like script bindings.
NOTE: All of the registrations are done in GWidget.cpp at the moment
since I ran into trouble with the fricken linker pruning the global
constructors this mechanism relies on. :^)
GTreeView was forgetting to call to base in did_update_selection().
This prevented GAbstractView from firing the on_selection hook and we
ended up with only the on_selection_change hook firing.
There's currently a small paint glitch for vertical toolbars due to the
way StylePainter::paint_surface() draws a MidGray line at the bottom of
whatever a "surface" is supposed to be.
You can now press Ctrl+Shift+Up/Down in a GTextEditor and the currently
selected line(s) will all move together one step up/down.
If there is no selection, we move the line with the cursor on it. :^)
Since on_change handlers can alter the text document we're working on,
we have to make sure they've been run before we try looking at spans.
This fixes some flakiness when a paint happened before HackStudio had
a chance to re-highlight some C++ while editing it.
The design where clients of GTextEditor perform syntax highlighting in
the "arbitrary code execution" on_change callback is not very good.
We should find a way to move highlighting closer to the editor.
It should be possible for the CSS parser to fail, and we'll know it
failed if it returns nullptr. Returning RefPtr's makes it actually
possible to return nullptr. :^)
This simple helper escapes '<', '>' and '&' so they can be used in HTML
text without interfering with the parser.
Use this in IRCClient to prevent incoming messages from messing with
the DOM :^)
This function parses a partial DOM and returns it wrapped in a document
fragment node (DocumentFragment.)
There are now two entrances into the HTML parser, one for parsing full
documents, and one for parsing fragments. Internally the both wrap the
same parsing function.
Add LayoutPosition and LayoutRange classes. The layout tree root node
now has a selection() LayoutRange. It's essentially a start and end
LayoutPosition.
A LayoutPosition is a LayoutNode, and an optional index into that node.
The index is only relevant for text nodes, where it's the character
index into the rendered text.
HtmlView now updates the selection start/end of the LayoutDocument when
clicking and dragging with the left mouse button.
We don't paint the selection yet, and there's no way to copy what's
selected. It only exists as a LayoutRange.
When adding a widget to a parent, you don't always want to append it to
the set of existing children, but instead insert it before one of them.
This patch makes that possible by adding CObject::insert_child_before()
which also produces a ChildAdded event with an additional before_child
pointer. This pointer is then used by GWidget to make sure that any
layout present maintains the correct order. (Without doing that, newly
added children would still be appended into the layout order, despite
having a different widget sibling order.)
Renamed "Position" to "Elapsed". "channel/channels" automatically
changes now when more than one channel exist. The current file name
is now displayed in the window title.
m_loaded_samples was incremented with the value of the processed
buffer. This causes m_loaded_samples to be bigger at some point
than m_total_samples when downsampling, as the buffer would contain
more samples than actually loaded.
Files opened with O_DIRECT will now bypass the disk cache in read/write
operations (though metadata operations will still hit the disk cache.)
This will allow us to test actual disk performance instead of testing
disk *cache* performance, if that's what we want. :^)
There's room for improvment here, we're very aggressively flushing any
dirty cache entries for the specific block before reading/writing that
block. This is done by walking the entire cache, which may be slow.