Commit graph

337 commits

Author SHA1 Message Date
Jacob Young
b55377a5ab x86_64: pass more tests
* 128-bit integer multiplication with overflow
 * more instruction encodings used by std inline asm
 * implement the `try_ptr` air instruction
 * follow correct stack frame abi
 * enable full panic handler
 * enable stack traces
2023-10-25 04:28:30 -04:00
Jacob Young
27fe945a00 Revert "Revert "Merge pull request #17637 from jacobly0/x86_64-test-std""
This reverts commit 6f0198cadb.
2023-10-22 15:46:43 -04:00
Andrew Kelley
6f0198cadb Revert "Merge pull request #17637 from jacobly0/x86_64-test-std"
This reverts commit 0c99ba1eab, reversing
changes made to 5f92b070bf.

This caused a CI failure when it landed in master branch due to a
128-bit `@byteSwap` in std.mem.
2023-10-22 12:16:35 -07:00
Jacob Young
0c99ba1eab
Merge pull request #17637 from jacobly0/x86_64-test-std
x86_64: start to enable `test-std` and `test-compiler-rt` testing
2023-10-22 08:06:47 -04:00
JustinWayland
c45af2af61
Fix simple doc mistakes. (#17624)
* Add missing period in Stack's description

This looks fine in the source, but looks bad when seen on the documentation website.

* Correct documentation for attachSegfaultHandler()

The description for attachSegfaultHandler() looks pretty bad without indicating that the stuff at the end is code

* Added missing 'the's in Queue.put's documentation

* Fixed several errors in Stack's documentation

`push()` and `pop()` were not styled as code

There was no period after `pop()`, which looks bad on the documentation.

* Fix multiple problems in base64.zig

Both "invalid"s in Base64.decoder were not capitalized.

Missing period in documentation of Base64DecoderWithIgnore.calcSizeUpperBound.

* Fix capitalization typos in bit_set.zig

In DynamicBitSetUnmanaged.deinit's and DynamicBitSet.deinit's documentation, "deinitializes" was uncapitalized.

* Fix typos in fifo.zig's documentation

Added a previously missing period to the end of the first line of LinearFifo.writableSlice's documentation.
Added missing periods to both lines of LinearFifo.pump's documentation.

* Fix typos in fmt.bufPrint's documentation

The starts of both lines were not capitalized.

* Fix minor documentation problems in fs/file.zig

Missing periods in documentation for Permissions.setReadOnly, PermissionsWindows.setReadOnly, MetadataUnix.created, MetadataLinux.created, and MetadataWindows.created.

* Fix a glaring typo in enums.zig

* Correct errors in fs.zig

* Fixed documentation problems in hash_map.zig

The added empty line in verify_context's documentation is needed, otherwise autodoc for some reason assumes that the list hasn't been terminated and continues reading off the rest of the documentation as if it were part of the second list item.

* Added lines between consecutive URLs in http.zig

Makes the documentation conform closer to what was intended.

* Fix wrongfully ended sentence in Uri.zig

* Handle wrongly entered comma in valgrind.zig.

* Add missing periods in wasm.zig's documentation

* Fix odd spacing in event/loop.zig

* Add missing period in http/Headers.zig

* Added missing period in io/limited_reader.zig

This isn't in the documentation due to what I guess is a limitation of autodoc, but it's clearly supposed to be. If it was, it would look pretty bad.

* Correct documentation in math/big/int.zig

* Correct formatting in math/big/rational.zig

* Create an actual link to ZIGNOR's paper.

* Fixed grammatical issues in sort/block.zig

This will not show up in the documentation currently.

* Fix typo in hash_map.zig
2023-10-21 21:24:55 +00:00
Jacob Young
32e85d44eb x86_64: disable failing tests, enable test-std testing 2023-10-21 10:55:41 -04:00
Stephen Gregoratto
285970982a Add illumos OS tag
- Adds `illumos` to the `Target.Os.Tag` enum. A new function,
  `isSolarish` has been added that returns true if the tag is either
  Solaris or Illumos. This matches the naming convention found in Rust's
  `libc` crate[1].
- Add the tag wherever `.solaris` is being checked against.
- Check for the C pre-processor macro `__illumos__` in CMake to set the
  proper target tuple. Illumos distros patch their compilers to have
  this in the "built-in" set (verified with `echo | cc -dM -E -`).

  Alternatively you could check the output of `uname -o`.

Right now, both Solaris and Illumos import from `c/solaris.zig`. In the
future it may be worth putting the shared ABI bits in a base file, and
mixing that in with specific `c/solaris.zig`/`c/illumos.zig` files.

[1]: 6e02a329a2/src/unix/solarish
2023-10-02 15:31:49 -06:00
mlugg
09a57583a4
compiler: preserve result type information through address-of operator
This commit introduces the new `ref_coerced_ty` result type into AstGen.
This represents a expression which we want to treat as an lvalue, and
the pointer will be coerced to a given type.

This change gives known result types to many expressions, in particular
struct and array initializations. This allows certain casts to work
which previously required explicitly specifying types via `@as`. It also
eliminates our dependence on anonymous struct types for expressions of
the form `&.{ ... }` - this paves the way for #16865, and also results
in less Sema magic happening for such initializations, also leading to
potentially better runtime code.

As part of these changes, this commit also implements #17194 by
disallowing RLS on explicitly-typed struct and array initializations.
Apologies for linking these changes - it seemed rather pointless to try
and separate them, since they both make big changes to struct and array
initializations in AstGen. The rationale for this change can be found in
the proposal - in essence, performing RLS whilst maintaining the
semantics of the intermediary type is a very difficult problem to solve.

This allowed the problematic `coerce_result_ptr` ZIR instruction to be
completely eliminated, which in turn also simplified the logic for
inferred allocations in Sema - thanks to this, we almost break even on
line count!

In doing this, the ZIR instructions surrounding these initializations
have been restructured - some have been added and removed, and others
renamed for clarity (and their semantics changed slightly). In order to
optimize ZIR tag count, the `struct_init_anon_ref` and
`array_init_anon_ref` instructions have been removed in favour of using
`ref` on a standard anonymous value initialization, since these
instructions are now virtually never used.

Lastly, it's worth noting that this commit introduces a slightly strange
source of generic poison types: in the expression `@as(*anyopaque, &x)`,
the sub-expression `x` has a generic poison result type, despite no
generic code being involved. This turns out to be a logical choice,
because we don't know the result type for `x`, and the generic poison
type represents precisely this case, providing the semantics we need.

Resolves: #16512
Resolves: #17194
2023-09-23 22:01:08 +01:00
Andrew Kelley
5ae5dc507b
Merge pull request #16824 from mikdusan/bsd
de-bitrot the BSDs
2023-08-17 12:14:30 -07:00
Michael Dusan
e288c54699
std.debug: openbsd does not have getcontext 2023-08-17 10:55:39 -04:00
Michael Dusan
c685b675e5
std.debug: avoid os.getFdPath
Commit ea9917d9bd introduced usage
of fs.Dir.realpath which eventually calls os.getFdpath which is
forbidden to be used by the compiler. It causes building zig to fail on
OpenBsd, NetBSD and older versions of FreeBSD and DragonFly.

This patch substitutes with os.realpath on libc targets and eventually
calls c.realpath and allows zig to build. Any use of realpath is not
desired but this is the lesser evil.
2023-08-15 17:29:35 -04:00
kcbanner
8a5f331ec8 coff: handle the case of there being no PDB path 2023-08-15 10:20:11 -04:00
kcbanner
5b86180ae3 debug: support looking up debug symbols in both PDB and DWARF debug info, instead of only using DWARF if .debug_info is present
coff: support reading from memory loaded by the loader, or a mapped file
2023-08-15 10:20:11 -04:00
Zachary Raineri
49244dc0ca
std: remove some unused imports (#16710) 2023-08-06 15:18:50 -04:00
David Gonzalez Martin
9c05810be6 debug: expose module debug info deinitialization
Before this commit, you could use readElfDebugInfo independently with
one catch: the data is not freed since the deinitialization functions
for ModuleDebugInfo are private. This change makes them public so the
    users of such function and similar can free the memory after the
    debug symbols have been used.
2023-08-04 09:24:11 +02:00
kcbanner
78449b6d98 debug: skip unwind error printing on platforms that don't have_ucontext 2023-07-26 22:10:22 -04:00
kcbanner
a84826115f debug: print unwind errors if they occur on the first iteration, and differentiate between missing info and an actual unwind error in the message 2023-07-26 20:58:29 -04:00
kcbanner
b1d86db7b4 dwarf: move macho unwind code from macho -> dwarf
dwarf: fixup unchecked .eh_frame CIE offset subtraction
2023-07-20 22:58:16 -04:00
kcbanner
8e6a62ba10 test: disable omit_frame_pointer unwinding tests on aarch64-macos
dwarf: handle signal frame CIE flag
2023-07-20 22:58:16 -04:00
kcbanner
6d87bb370a debug: disable the new unwinder on aarch64-macos 2023-07-20 22:58:16 -04:00
kcbanner
97bda56306 macho: don't scan all eh_frame entries, instead follow the offset from the __unwind_info directly 2023-07-20 22:58:16 -04:00
kcbanner
774dc2fdb7 dwarf: add explicit_fde_offset to support more optimal __unwind_info dwarf lookups 2023-07-20 22:58:16 -04:00
kcbanner
2c76020e77 debug: load the macho unwind sections from the already-mapped image 2023-07-20 22:58:16 -04:00
kcbanner
618b0eb3d3 dwarf: fixup integer overflow in readEhPointer
debug: handle the possibility of eh_frame / debug_frame being mapped in memory or loaded from disk
2023-07-20 22:58:16 -04:00
kcbanner
5e399d97d7 use eh_frame from the mapped binary if available 2023-07-20 22:58:16 -04:00
kcbanner
9549b4acf6 debug: fixup an inconsistency in the getcontext implementation on aarch64-macos 2023-07-20 22:58:16 -04:00
kcbanner
b18031335a dwarf: use cie.return_address_register instead of assuming it's in the IP register 2023-07-20 22:58:16 -04:00
kcbanner
9b25bee42c debug: fixup have_getcontext 2023-07-20 22:58:15 -04:00
kcbanner
e5aa2bb224 debug: fixup last_error being printed too many times 2023-07-20 22:58:15 -04:00
kcbanner
891fa3b8b5 debug: fix initialization of the optional fields on StackIterator
dwarf: documentation fixups
target: enable unwind tables on macho
2023-07-20 22:58:15 -04:00
kcbanner
5dfb159e15 macho: add aarch64 implementation to unwindFrame
dwarf: map the V registers in abi.regBytes
test: add test case that exercises the stack-indirect __unwind_info mode in x86_64
2023-07-20 22:58:15 -04:00
kcbanner
203d96ae97 debug: add relocateContext
dwarf: fixup tests that used a ThreadContext
2023-07-20 22:58:15 -04:00
kcbanner
94354aa6aa macho: add unwindFrame which can unwind stack frames using the __unwind_info section
dwarf: fixup missing error
2023-07-20 22:58:15 -04:00
kcbanner
d226b74ae8 dwarf: add ExpressionError to work around the compiler not being able to infer it
dwarf: implement OP.entry_value, add tests
2023-07-20 22:58:15 -04:00
kcbanner
21d0154139 dwarf: skip register tests on unimplemented arch / os, add tests for type convesions
debug: dupeContext -> copyContext
2023-07-20 22:58:15 -04:00
kcbanner
54ca62fef4 dwarf: fixup regBytes for the case where there is no context support
expressions: add more tests, fix tests for mipsel
debug: add lookupModuleName implementation for macos
2023-07-20 22:58:15 -04:00
kcbanner
5c0d4cef1a debug: add dupeContext, store a pointer to a copy of ThreadContext on UnwindContext 2023-07-20 22:58:15 -04:00
kcbanner
5f72c6508d debug: rename StackTraceContext to ThreadContext
dwarf: use ThreadContext instead of os.ucontext_t
dwarf: add regBytes impl for windows
dwarf: fixup expression types for non-native
2023-07-20 22:58:15 -04:00
kcbanner
ad5f74c0b1 dwarf: introduce ExpressionContext, add more expression opcodes 2023-07-20 22:58:14 -04:00
kcbanner
576ffaa329 darwin: update mcontext_t definition for aarch64 to add neon state 2023-07-20 22:58:14 -04:00
kcbanner
412cd789bf debug: fixup base address calculations for macho
dwarf: fixup x86 register mapping logic
dwarf: change the register context update to update in-place instead of copying
debug: always print the unwind error type
2023-07-20 22:58:14 -04:00
kcbanner
b85f84061a dwarf: don't dupe function names, as they are backed by the memory mapped sections
dwarf: const-correctness fixups
dwarf: implement the remaining register rules
dwarf: start implmenting the DWARF expression stack machine
2023-07-20 22:58:14 -04:00
kcbanner
62598c2187 debug: rework how unwind errors are printed, and add module name lookup for linux
This change enhances stack trace output to include a note that debug info was missing,
and therefore the stack trace may not be accurate. For example, if the user is using a libc
compiled with -fomit-frame-pointer and doesn't have debug symbols installed, any traces
that begin in a libc function may not unwind correctly. This allows the user to notice this and
potentially install debug symbols to improve the output.
2023-07-20 22:58:14 -04:00
kcbanner
6a5e2b713f debug: de-duplicate some code in macos ModuleDebugInfo 2023-07-20 22:58:14 -04:00
kcbanner
ccc9f82068 c: fixup getcontext
debug: supports_context -> have_ucontext, supports_getcontext -> have_getcontext
test: rework dwarf_unwind test case to also test the non-libc path
2023-07-20 22:58:14 -04:00
kcbanner
23d9b59b86 c: add getcontext
debug: make getContext public
2023-07-20 22:58:14 -04:00
kcbanner
f991b9dc05 debug: fix reading -gdwarf generated debug sections in COFF files
I had accidentally regressed support for -gdwarf in 461fb499f3 when I changed the logic to
use the already-mapped exe/dll image instead of loading it from disk. The string table is mapped as all zeroes by the loader,
so if a section header's name is longer than 8 bytes (like the ones generated by -gdwarf), then the name can't be read.

Now, if any section headers require the string table, the file is mapped from disk.

windows: Add NtCreateSection/NtMapViewOfSection/NtUnmapViewOfSection
2023-07-20 22:58:14 -04:00
kcbanner
caa334712f linux: rework getcontext to closer match the specification (saved IP/SP match the state after it would return)
debug: fixup ucontext_t check
2023-07-20 22:58:14 -04:00
kcbanner
89ef004646 debug: x86 unwinding support, more unwinding fixes
- Fix unwindFrame using the previous FDE row instead of the current one
- Handle unwinding through noreturn functions
- Add x86-linux getcontext
- Fixup x86_64-linux getcontext not restoring the fp env
- Fix start_addr filtering on x86-windows
2023-07-20 22:58:14 -04:00
kcbanner
5cd8ab2473 debug: enhance writeCurrentStackTrace to use context-based unwinding when available 2023-07-20 22:58:14 -04:00