Commit graph

22463 commits

Author SHA1 Message Date
Itamar 835efa1b6a LibDebug: Add DwarfInfo::get_cached_die_at_offset
This function returns a DIE object from the cache with the given offset
in the debug_info section.
2021-06-19 14:51:18 +02:00
Itamar fb31aae20d LibDebug:: Add DwarfInfo::get_die_at_address
This function returns the die object whose address range intersects
with the given address.

This function will also construct the DIE cache, if it hasn't been
constructed yet.
2021-06-19 14:51:18 +02:00
Itamar 92d4962d04 LibDebug: Add caches of DIE objects to DwarfInfo
There is one cache that indexes DIE objects by the start address of
their range, and another cache that indexes by their offset in the
debug_info section.

Both caches are implemented with RedBlackTree, and are optional - they
will only be populated if 'build_cached_dies' is invoked.
2021-06-19 14:51:18 +02:00
Itamar a5f69efa5c LibDebug: Store optional parent_offset in Dwarf::DIE objects
In the current implementation, only DIE objects that are created via
DIE::for_each_child() will have parent offsets.

DIE objects that are created with CompilationUnit::get_die_at_offset()
do not currently store a parent offset.

We may improve this in the future, but this is enough for what we
currently need.
2021-06-19 14:51:18 +02:00
Itamar 84609aecc1 LibDebug: Add AttributeForm field to Dwarf::AttributeValue
In some contexts, it's helpful to also know the "Attribute Form",
in addition to the "Attribute Type".

An example for such context is the interpretation of the
"DW_AT_high_pc" attribute, which has different meaning if the form
is an address or a constant.
2021-06-19 14:51:18 +02:00
Itamar a45ce0c6eb LibCoreDump: Use "eip - 1" when creating backtrace entries
We need to do this because the return address from a function frame is
the instruction that comes after the 'call' instruction.
2021-06-19 14:51:18 +02:00
Itamar d26f4f9e8c AK: Add RedBlackTree::find_largest_not_above_iterator
It's a version of find_largest_not_above that returns an iterator.
2021-06-19 14:51:18 +02:00
Itamar 98a774a68d LibDebug: Add LineProgram::get_directory_and_file(size_t)
This function returns the directory path & filename for a given file
index.
2021-06-19 14:51:18 +02:00
Itamar 0d89f70b66 LibDebug: Move Dwarf::LineProgram into Dwarf::CompilationUnit
Previously, the LineProgram objects were short-lived, and only created
inside DebugInfo::prepare_lines() to create a vector of sorted LineInfo
data.

However, Dwarf::LineProgram also contains other useful data, such as
index-to-string mapping of source directories and filenames.

This commit makes each Dwarf::CompilationUnit own its
Dwarf::LineProgram.
DebugInfo::prepare_lines() then iterates over the compilation units to
prepare its sorted vector of lines.
2021-06-19 14:51:18 +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
Itamar edd79ddd00 LibDebug: Move Dwarf::AttributeValue to a separate file 2021-06-19 14:51:18 +02:00
Itamar fea9bb8c51 LibDebug: Move get_die_at_offset to Dwarf::CompilationUnit 2021-06-19 14:51:18 +02:00
Itamar 15b3957885 LibDebug: Remove unused DebugInfo::for_each_source_position 2021-06-19 14:51:18 +02:00
Itamar 68ff0788e5 LibDebug: Fix typo in DebugInfo::get_source_position 2021-06-19 14:51:18 +02:00
Gunnar Beutner 3c3a1726df Kernel: Make sure threads which don't do any syscalls are terminated
Steps to reproduce:

$ cat loop.c
int main() { for (;;); }
$ gcc -o loop loop.c
$ ./loop

Terminating this process wasn't previously possible because we only
checked whether the thread should be terminated on syscall exit.
2021-06-19 12:55:00 +02:00
Gunnar Beutner c980a51776 Kernel: Make sure the kernel's ELF PHDRs don't use rwx
This doesn't really matter in terms of writability for the kernel text
because we set up proper page mappings anyway which prohibit writing
to the text segment. However, this makes the profiler happy which
previously died when validating the kernel's ELF program headers.
2021-06-19 12:54:33 +02:00
Andreas Kling f86e241699 LibJS: Object.getOwnPropertyNames() should enumerate String's .length
We were incorrectly aborting property name enumeration after generating
names for all the indexable properties in the underlying string.
2021-06-19 11:46:08 +02:00
Andreas Kling 686213c2b8 LibJS: Make Object.getOwnPropertyDescriptor() work on String subscripts
String objects are a bit special since the indexed properties are
overridden by the contents of the underlying PrimitiveString.

getOwnPropertyDescriptor() was not taking this into account, and would
instead return undefined when asked about an indexed property in a
String object.
2021-06-19 11:34:19 +02:00
Matthew Olsson 25baefdd1e LibJS: Support object rest elements in the bytecode interpreter 2021-06-19 09:38:26 +02:00
Matthew Olsson 57b9a228ab LibJS: Support array rest elements in the bytecode interpreter 2021-06-19 09:38:26 +02:00
Matthew Olsson 7983324639 LibJS: Implement array destructuring for the bytecode interpreter 2021-06-19 09:38:26 +02:00
Matthew Olsson 14fff5df06 LibJS: Implement more IteratorOperations and organize file
Implemented IteratorComplete and IteratorValue, and sorted functions
based on their spec ordering.
2021-06-19 09:38:26 +02:00
Matthew Olsson 1f8e643ef0 LibJS: Support object destructuring in the bytecode interpreter 2021-06-19 09:38:26 +02:00
Matthew Olsson f39ab2e60a LibJS: Add JumpUndefined bytecode 2021-06-19 09:38:26 +02:00
Matthew Olsson 3ee627909a LibJS: Ensure GetBy{Id,Value} never load <empty> into the accumulator 2021-06-19 09:38:26 +02:00
Matthew Olsson ce04c2259f LibJS: Restructure and fully implement BindingPatterns 2021-06-19 09:38:26 +02:00
Matthew Olsson 10372b8118 LibJS: Remove bad spread check in declaration parsing
This would allow assignments such as `let ...{ a } = { a: 20 }`
2021-06-19 09:38:26 +02:00
Liav A 29f9a38f76 Kernel: Don't use naked new statements in init process
Instead, try to create the device objects in separate static methods,
and if we fail for some odd reason to allocate memory for such devices,
just panic with that reason.
2021-06-19 09:30:43 +02:00
Linus Groh fba3c77a04 LibJS: Add missing exception checks to Number() constructor 2021-06-19 02:03:37 +01:00
Linus Groh 8e26c7a1dd LibJS: Make Number() constructor spec compliant
By using to_numeric() and adding BigInt handling, we get support for
`Number(123n)`.

Fixes #8125.
2021-06-19 01:34:17 +01:00
Linus Groh 7f8245439b LibJS: Add a bunch more missing ECMA-262 section/title/URL comments 2021-06-19 00:38:41 +01:00
Matthew Olsson 7f97e33778 LibJS: Disallow 'yield' identifier initializer in GeneratorFunctions 2021-06-19 00:04:57 +01:00
Matthew Olsson 9253fa1bad LibJS: Implement GeneratorFunctionConstructor::construct 2021-06-19 00:04:57 +01:00
Matthew Olsson 22b17219ff LibJS: Add the remaining generator objects
- %GeneratorFunction%
- %GeneratorFunction.prototype%
- %GeneratorFunction.prototype.prototype%
- %Generator%.prototype
2021-06-19 00:04:57 +01:00
DexesTTP b205c9814a LibCrypto: Fix Hash::MD5's movability
Because MD5 stored a "Bytes {}" wrapper to its internal data buffer,
it was not actually movable. However, its use in several parts of
the system (such as HashManager) assumed it was, leading to crashes.

Fixes #8135
2021-06-19 01:29:21 +04:30
Luke f29036dc98 Lagom/Fuzzers: Add fuzzers for all current hashing functions
Namely MD5, SHA1, SHA256, SHA384 and SHA512.
2021-06-18 21:44:56 +01:00
Idan Horowitz 4dc63896de LibJS: Add and use the ArraySpeciesCreate abstract operation
This ensures that the Array.prototype methods produce results using the
constructor of the derived object if it is one instead of always using
the default constructor.
2021-06-18 21:25:16 +01:00
Idan Horowitz 271eeadf25 LibJS: Bring FlattenIntoArray closer to the specification
This fixes the incorrect exception order and missing exception checks
that were caused by the implementation not conforming exactly to the
specification.
2021-06-18 21:25:16 +01:00
Linus Groh 597cf88c08 LibJS: Implement the 'Hashbang Grammar for JS' proposal
Stage 3 since August 2019 - we already have shebang stripping
implemented in js(1), so this removes it from there in favor of adding
support to the lexer directly.

Most straightforward proposal and implementation I've ever seen :^)

https://github.com/tc39/proposal-hashbang
2021-06-18 20:35:23 +01:00
Linus Groh 299c3069c1 LibJS/Tests: Use eval() for toEvalTo(), not Function()
Since we have had eval() for a while now, we can finally use it here -
this allows us to get rid of the confusing return statements in tested
source code.
2021-06-18 20:35:23 +01:00
Idan Horowitz 2e9f665bda LibJS: Throw on detached viewed ArrayBuffer when validating TypedArrays 2021-06-18 20:17:45 +01:00
Idan Horowitz d5c836dd64 LibJS: Add the TypedArray.prototype.toString property
This is initialized to be the same function object as the initial value
of the Array.prototype.toString generic function.
2021-06-18 20:17:45 +01:00
Idan Horowitz 57db27bcc4 LibJS: Add the TypedArray.prototype.join method 2021-06-18 20:17:45 +01:00
Idan Horowitz 2922a6c053 LibJS: Add the TypedArray.prototype[Symbol.toString] getter accessor 2021-06-18 20:17:45 +01:00
sin-ack c5073cb287 LibJS: Do not trim whitespace from property names when they're numbers
Fixes #7803.
2021-06-18 19:18:15 +01:00
sin-ack 3abcfcc178 AK: Add a way to disable the trimming of whitespace in to_*int
This behavior might not always be desirable, and so this patch adds a
way to disable it.
2021-06-18 19:18:15 +01:00
Luke 8be7bdaac3 LibJS: Add %TypedArray%.prototype.some 2021-06-18 18:13:31 +01:00
Luke 68f11a272b LibJS: Add %TypedArray%.prototype.forEach 2021-06-18 18:13:31 +01:00
Luke 91af985718 LibJS: Add %TypedArray%.prototype.findIndex 2021-06-18 18:13:31 +01:00
Luke 61a8c19556 LibJS: Add %TypedArray%.prototype.find 2021-06-18 18:13:31 +01:00