11597 Commits

Author SHA1 Message Date
mlugg
7601b397ef
fix bad merge
The API of `std.debug.Pdb` changed.
2025-09-30 13:44:53 +01:00
mlugg
02a0ade138
std.debug: never attempt FP unwind under fomit-frame-pointer 2025-09-30 13:44:53 +01:00
mlugg
4e45362529
link.Elf: fix static PIE
We mustn't emit the DT_PLTGOT entry in `.dynamic` in a statically-linked
PIE, because there's no dl to relocate it (and `std.pie.relocate`, or
the PIE relocator in libc, won't touch it). In that case, there cannot
be any PLT entries, so there's no point emitting the `.got.plt` section
at all. If we just don't create that section, `link.Elf` already knows
not to add the DT_PLTGOT entry to `.dynamic`.

Co-authored-by: Jacob Young <jacobly0@users.noreply.github.com>
2025-09-30 13:44:53 +01:00
mlugg
1123741fd5
Dwarf: use 'gpa' terminology 2025-09-30 13:44:52 +01:00
mlugg
bfbbda7751
compiler: fix new panic handler in release builds 2025-09-30 13:44:52 +01:00
mlugg
c1a30bd0d8
std: replace debug.Dwarf.ElfModule with debug.ElfFile
This abstraction isn't really tied to DWARF at all! Really, we're just
loading some information from an ELF file which is useful for debugging.
That *includes* DWARF, but it also includes other information. For
instance, the other change here:

Now, if DWARF information is missing, `debug.SelfInfo.ElfModule` will
name symbols by finding a matching symtab entry. We actually already do
this on Mach-O, so it makes obvious sense to do the same on ELF! This
change is what motivated the restructuring to begin with.

The symtab work is derived from #22077.

Co-authored-by: geemili <opensource@geemili.xyz>
2025-09-30 13:44:52 +01:00
mlugg
f798048739
std.debug: don't include dumpCurrentStackTrace frame
If it's not given, we should set `first_address` to the return address
of `dumpCurrentStackTrace` to avoid the call to `writeCurrentStackTrace`
appearing in the trace. However, we must only do that if no `context` is
given; if there's a context then we're starting the stack unwind
elsewhere.
2025-09-30 13:44:52 +01:00
mlugg
e6adddf80c
small reasonable change 2025-09-30 13:44:52 +01:00
mlugg
2743fdb7ce
std.debug: try removing a probably-redundant condition 2025-09-30 13:44:52 +01:00
mlugg
229f0a01b8
std.debug: handle ThreadContext slightly better
It's now user-overrideable, and uses `noreturn` types to neatly stop
analysis.
2025-09-30 13:44:52 +01:00
mlugg
1392a7af17
std.debug: unwinding on Windows
...using `RtlVirtualUnwind` on x86_64 and aarch64, and
`RtaCaptureStackBackTrace` on x86.
2025-09-30 13:44:52 +01:00
mlugg
ac4d633ed6
std: fix debug.Info and debug.Coverage 2025-09-30 13:44:52 +01:00
mlugg
3a561da38d
std: doc comments and tweaks 2025-09-30 13:44:51 +01:00
mlugg
0c7b2a7bd5
fix compiler ftbfs from std.macho and std.dwarf changes 2025-09-30 13:44:51 +01:00
mlugg
202aeacc05
std: fixes 2025-09-30 13:44:51 +01:00
mlugg
f1215adeda
SelfInfo.DarwinModule: rename field 2025-09-30 13:44:51 +01:00
mlugg
253fdfce70
SelfInfo: be honest about how general unwinding is
...in that it isn't: it's currently very specialized to DWARF unwinding.

Also, make a type unmanaged.
2025-09-30 13:44:51 +01:00
mlugg
9859440d83
add freestanding support IN THEORY
untested because this branch has errors rn
2025-09-30 13:44:51 +01:00
mlugg
c2ada49354
replace usages of old std.debug APIs
src/crash_handler.zig is still TODO though, i am planning bigger changes there
2025-09-30 13:44:51 +01:00
mlugg
5709369d05
std.debug: improve the APIs and stuff 2025-09-30 13:44:51 +01:00
mlugg
d4f710791f
tweaks 2025-09-30 13:44:51 +01:00
mlugg
67fa5664b7
std.posix: mark getcontext as unsupported by default 2025-09-30 13:44:51 +01:00
mlugg
ba5d9d5a41
remove redundant test
turns out this actually has coverage in std.debug
2025-09-30 13:44:50 +01:00
mlugg
405075f745
SelfInfo: load eh_frame/debug_frame from ELF file if eh_frame_hdr omitted 2025-09-30 13:44:50 +01:00
mlugg
c895aa7a35
std.debug.SelfInfo: concrete error sets
The downside of this commit is that more precise errors are no longer
propagated up. However, these errors were pretty useless in isolation
due to them having no context; and regardless, we intentionally swallow
most of them in `std.debug` anyway. Therefore, this is better in
practice, because it allows `std.debug` to give slightly more useful
warnings when handling errors. This commit does that for unwind errors,
for instance, which differentiate between the unwind info being corrupt
vs missing vs inaccessible vs unsupported.

A better solution would be to also include more detailed information via
the diagnostics pattern, but this commit is an incremental improvement.
2025-09-30 13:44:50 +01:00
mlugg
dd9cb1beea
doc comments 2025-09-30 13:44:50 +01:00
mlugg
5e6a1919c7
fix aarch64-macos DWARF unwinding
turns out this isn't technically specific to that target at all; other
targets just don't emit mid-function 'ret' instructions as much so
certain CFI instruction patterns were only seen on aarch64.

thanks to jacob for finding the bug <3
2025-09-30 13:44:50 +01:00
mlugg
4b47a37717
stash? more like no 2025-09-30 13:44:50 +01:00
mlugg
665f13b0cd
SelfInfo deinit magic 2025-09-30 13:44:50 +01:00
mlugg
ba3f38959a
split SelfInfo into a file per impl 2025-09-30 13:44:50 +01:00
mlugg
1397b95143
std.debug.Dwarf: eliminate host pointer size dependency 2025-09-30 13:44:50 +01:00
mlugg
b762cd30fd
remove TODOs which are done or which i'm not actually gonna do lol 2025-09-30 13:44:50 +01:00
mlugg
e4dbfc109b
dont dupe state you silly billy 2025-09-30 13:44:50 +01:00
mlugg
8fdcdb8c69
the world if Dwarf.ElfModule was like REALLY good: 2025-09-30 13:44:49 +01:00
mlugg
84b65860cf
the world if ElfModule didn't suck: 2025-09-30 13:44:49 +01:00
mlugg
55a7affea4
me when i did a thing 2025-09-30 13:44:49 +01:00
mlugg
25e02bed4c
less hacky :D 2025-09-30 13:44:49 +01:00
mlugg
55ae6747e2
names 2025-09-30 13:44:49 +01:00
mlugg
3f6a90766c
sky pirates! which are even better! 2025-09-30 13:44:49 +01:00
mlugg
89d862180f
yet more 2025-09-30 13:44:49 +01:00
mlugg
fb88dab4c9
more still 2025-09-30 13:44:49 +01:00
mlugg
ed6ed62c42
more stuff 2025-09-30 13:44:49 +01:00
mlugg
b750e7cf9e
change one million things 2025-09-30 13:44:49 +01:00
Jacob Young
b706949736
debug: refactor stack frame capturing 2025-09-30 13:44:48 +01:00
Alex Rønne Petersen
fe468e4fa3
std.os.linux: delete restore and restore_rt for hexagon, loongarch, mips, riscv 2025-09-28 18:24:04 +02:00
Alex Rønne Petersen
42e4411377
std.os.linux: delete SA.RESTORER and k_sigaction.restorer for hexagon, loongarch, mips, riscv
The kABIs for these architectures don't define these concepts.
2025-09-28 18:23:58 +02:00
Alex Rønne Petersen
1b0bde0d8d
Merge pull request #25373 from mneumann/fix-dragonfly-bootstrap
Fix DragonFly bootstrap
2025-09-27 20:05:40 +02:00
Alex Rønne Petersen
b7ab625409
Merge pull request #25362 from alexrp/aro-valist
`aro`: `TypeStore`: synchronize `__va_list_tag` logic with Zig's `std.builtin.VaList`
2025-09-27 12:57:47 +02:00
Michael Neumann
035219132b lib/std/c: sync "struct stat" for DragonFly
* Add missing functions like ISDIR() or ISREG(). This is required to
  build the zig compiler

* Use octal notation for the S_ constants. This is how it is done for
  ".freebsd" and it is also the notation used by DragonFly in
  "sys/stat.h"

* Reorder S_ constants in the same order as ".freebsd" does. Again, this
  follows the ordering within "sys/stat.h"
2025-09-27 10:00:40 +02:00
Alex Rønne Petersen
d16ff4d049
std.builtin: define VaList as *u8 for uefi 2025-09-26 16:20:24 +02:00