Commit Graph

45 Commits

Author SHA1 Message Date
Dan Klishch
7b88363490 Meta+Userland: Make LibELF a proper library on Serenity
Dynamically loaded LibC doesn't need LibELF definitions, so let's not
put them there.
2024-04-26 19:08:13 -06:00
Dan Klishch
b5f1a48a7c AK+Everywhere: Remove JsonValue APIs with implicit default values 2024-01-21 15:47:53 -07:00
Shannon Booth
e2e7c4d574 Everywhere: Use to_number<T> instead of to_{int,uint,float,double}
In a bunch of cases, this actually ends up simplifying the code as
to_number will handle something such as:

```
Optional<I> opt;
if constexpr (IsSigned<I>)
    opt = view.to_int<I>();
else
    opt = view.to_uint<I>();
```

For us.

The main goal here however is to have a single generic number conversion
API between all of the String classes.
2023-12-23 20:41:07 +01:00
Ali Mohammad Pur
5e1499d104 Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
2023-12-17 18:25:10 +03:30
kleines Filmröllchen
062e0db46c LibCore: Make MappedFile OwnPtr-based
Since it will become a stream in a little bit, it should behave like all
non-trivial stream classes, who are not primarily intended to have
shared ownership to make closing behavior more predictable. Across all
uses of MappedFile, there is only one use case of shared mapped files in
LibVideo, which now uses the thin SharedMappedFile wrapper.
2023-09-27 03:22:56 +02:00
Liav A
aee5f4e4b2 Kernel: Remove the /sys/kernel/constants directory
The name for this directory is a bit awkward. Also, the distinction of
constant information is not really valuable as I thought it would be, so
let's bring that information back into the /sys/kernel directory.
2023-08-27 22:50:22 +02:00
Lucas CHOLLET
309a15e2aa LibSymbolication: Use Core::File instead of Core::DeprecatedFile 2023-04-27 07:27:14 +02:00
Cameron Youell
1d24f394c6 Everywhere: Use LibFileSystem where trivial 2023-03-21 19:03:21 +00:00
Liav A
61f4914d6e Kernel+Userland: Add constants subdirectory at /sys/kernel directory
This subdirectory is meant to hold all constant data related to the
kernel. This means that this data is never meant to updated and is
relevant from system boot to system shutdown.
Move the inodes of "load_base", "cmdline" and "system_mode" to that
directory. All nodes under this new subdirectory are generated during
boot, and therefore don't require calling kmalloc each time we need to
read them. Locking is also not necessary, because these nodes and their
data are completely static once being generated.
2023-02-19 13:47:11 +01:00
Tim Schumacher
d43a7eae54 LibCore: Rename File to DeprecatedFile
As usual, this removes many unused includes and moves used includes
further down the chain.
2023-02-13 00:50:07 +00:00
Sam Atkins
783251b98a LibSymbolication: Replace uses of JsonObject::get_deprecated()/get_ptr() 2023-01-26 09:57:14 -05:00
Tim Schumacher
e62269650a LibDebug: Propagate errors throughout DWARF parsing
Splitting this into a separate commit was an afterthought, so this does
not yet feature any fallible operations.
2023-01-22 19:12:26 +01:00
Sam Atkins
1dd6b7f5b7 AK+Everywhere: Rename JsonObject::get() to ::get_deprecated()
This is a preparatory step to making `get()` return `ErrorOr`.
2023-01-17 19:52:52 -05:00
Liav A
a4c87fac56 LibELF+LibSymbolication: Remove i686 support 2022-12-28 11:53:41 +01:00
Linus Groh
57dc179b1f Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time
while we convert code, and tracking down remaining uses.

One big exception is Value::to_string() in LibJS, where the name is
dictated by the ToString AO.
2022-12-06 08:54:33 +01:00
Linus Groh
6e19ab2bbc AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
2022-12-06 08:54:33 +01:00
Tim Schumacher
ce2f1b845f Everywhere: Mark dependencies of most targets as PRIVATE
Otherwise, we end up propagating those dependencies into targets that
link against that library, which creates unnecessary link-time
dependencies.

Also included are changes to readd now missing dependencies to tools
that actually need them.
2022-11-01 14:49:09 +00:00
Liav A
b579d9518c LibSymbolication: Use new global variables at /sys/kernel/ directory 2022-10-25 15:33:34 -06:00
Undefine
97cc33ca47 Everywhere: Make the codebase more architecture aware 2022-07-27 21:46:42 +00:00
sin-ack
3f3f45580a Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
2022-07-12 23:11:35 +02:00
Idan Horowitz
086969277e Everywhere: Run clang-format 2022-04-01 21:24:45 +01:00
Andreas Kling
58fb3ebf66 LibCore+AK: Move MappedFile from AK to LibCore
MappedFile is strictly a userspace thing, so it doesn't belong in AK
(which is supposed to be user/kernel agnostic.)
2021-11-23 11:33:36 +01:00
Andreas Kling
587f9af960 AK: Make JSON parser return ErrorOr<JsonValue> (instead of Optional)
Also add slightly richer parse errors now that we can include a string
literal with returned errors.

This will allow us to use TRY() when working with JSON data.
2021-11-17 00:21:10 +01:00
Andreas Kling
0f5477c721 AK: Use ErrorOr<T> for MappedFile factories
Replace Result<T, E> with ErrorOr<T> and propagate the error to callers.
2021-11-08 00:35:27 +01:00
Rodrigo Tobar
08428aadad LibSymbolication: Skip source position calculation if requested
Calculating source code positions can be expensive, and some
applications (like SystemMonitor's Stack tab) don't even show this
information, making these calculations wasteful.

This commit adds a new enumerated flag to the `symbolicate` functions
for callers to specify whether source positions should be included in
the results; it defaults to "Yes" to preserve old behavior for existing
applications.
2021-10-17 22:07:10 -07:00
Rodrigo Tobar
9199f0836a LibSymbolication: Make Symbol comparable
All its members are comparable themselves, so this can be defaulted.
Making it comparable will allow us, among other things, to check if a
list of symbols (i.e., the result of calling the symbolicate functions)
is equal or not to another, which in turn will allow us to avoid
refreshing the SystemMonitor's Stack tab when successive symbolicated
stacks are the same.
2021-10-15 22:10:03 -07:00
Rodrigo Tobar
840822b8f1 LibSymbolication+SystemMonitor: Show ELF object in stack
This small patch allows SystemMonitor's Stack tab to show the name of
the ELF object to which the displayed address refers to. This gives a
bit more of contextual information to the viewer.

A better to show this is probably a table, but I'm not that familiar yet
with the GUI framework in general, so I'm keeping things simple.
2021-09-30 00:51:08 +02:00
Rodrigo Tobar
12e18e44ae LibSymbolication: Look for libraries under /usr/local/lib
While trying to investigate a problem with the ssl module in the python
port I found that the SystemMonitor Stack tab for a process wouldn't
show the symbols for the libssl and libcrypto shared libraries that are
installed under /usr/local/lib. The main reason for this is that
LibSymbolication didn't look for libraries under /usr/local/lib.

This commit adds support for looking for libraries under /usr/local/lib.
Absolute paths are still respected, and lookup gives precedence to
/usr/lib, just like dynamic linker does.
2021-09-28 10:55:14 +02:00
Rodrigo Tobar
f4ebcf4867 LibSymbolication: Return empty value on error
This was probably the intended behavior, but a return statement was
missing.
2021-09-28 10:55:14 +02:00
Andreas Kling
24ef8b118a LibSymbolication: Unbreak symbolication with -z separate-code linking
We were incorrectly assuming that the mapped .text segment for an ELF
image was always at the base of the image mapping. Now that we have
.rodata mappings as well, it's possible for one of them to come before
the .text.
2021-09-04 20:30:56 +02:00
Ali Mohammad Pur
c4437e19bd LibDebug+Everywhere: Make DebugInfo not own the ELF image
This is required to avoid copying the image where otherwise a reference
would be enough.
2021-08-06 01:14:03 +02:00
Gunnar Beutner
57417a3d6e Kernel: Support loading the kernel at almost arbitrary virtual addresses
This enables further work on implementing KASLR by adding relocation
support to the pre-kernel and updating the kernel to be less dependent
on specific virtual memory layouts.
2021-07-27 13:15:16 +02:00
Gunnar Beutner
e3d2ca6bd2 LibSymbolication: Fix integer overflow when calculating region addresses 2021-07-27 13:15:16 +02:00
Gunnar Beutner
60d6137e73 Userland: Use /proc/kernel_base to determine the kernel base address
This removes all the hard-coded kernel base addresses from userspace
tools.

One downside for this is that e.g. Profiler no longer uses a different
color for kernel symbols when run as a non-root user.
2021-07-22 21:38:23 +02:00
Gunnar Beutner
11e02f222d AK: Add a getter to JsonValue to get machine-native addresses 2021-07-22 08:57:01 +02:00
Gunnar Beutner
60b52cfb02 Userland: Hardcode the x86_64 kernel base address for now 2021-07-20 15:12:19 +02:00
Gunnar Beutner
98f8ecd9d2 Kernel: Split debug symbols into a separate file
This speeds up the boot process considerably when specifying the kernel
image via -initrd.
2021-07-18 17:31:13 +02:00
Gunnar Beutner
1ae7d68885 LibSymbolication: Fix incorrect argument type for symbolicate() 2021-06-24 09:27:13 +02:00
Gunnar Beutner
25c73159ce LibCoreDump: Don't subtract one from the first stack frame's EIP
The first stack frame represents the current instruction pointer
rather than the return address so we shouldn't subtract one
from it.

Fixes #8162.
2021-06-20 10:19:02 +01:00
Gunnar Beutner
a6ba05b02b LibSymbolication+Utilities: Show inlined functions for bt 2021-06-19 22:04:19 +02:00
Itamar
e9e4358a93 LibDebug: Store LibDebug objects on the heap & make them non-copyable
This fixes an issue were some LibDebug objects (for example,
Dwarf::CompilationUnit) held a reference to their parent
Dwarf::DwarfInfo object, which was constructed on the stack and later
moved to the heap.
2021-06-19 14:51:18 +02:00
Andreas Kling
5d6252b29e LibSymbolication: Rename Client.{cpp,h} => Symbolication.{cpp,h} 2021-05-22 18:54:22 +02:00
Andreas Kling
b00b9e699c LibSymbolication: Name the shared object libsymbolication.so 2021-05-22 18:54:22 +02:00
Andreas Kling
252cb54310 LibSymbolication+SystemMonitor+bt: Move symbolication back in-process
Process-separated symbolication was cute, but ultimately the threat
model is kinda silly. We're already *running* the binary, but we're
afraid to parse its symbol table? :^)

This commit makes SystemMonitor and bt do symbolication in-process.
SymbolServer and the symbol user will be removed separately.
2021-05-22 18:54:22 +02:00
Andreas Kling
d783076a30 Userland: Rename LibSymbolClient => LibSymbolication 2021-05-22 18:54:22 +02:00