Skip to content

llvm: improve emitted debug info - #13675

Merged
Vexu merged 1 commit into
ziglang:masterfrom
Vexu:di
Nov 28, 2022
Merged

llvm: improve emitted debug info#13675
Vexu merged 1 commit into
ziglang:masterfrom
Vexu:di

Conversation

@Vexu

@VexuVexu commented Nov 28, 2022

Copy link
Copy Markdown
Member
  • ensure parameter debug info is in the subroutine di scope
  • slit sub file path into basename and dirname

Closes#12257
Closes#12665

Might also resolve the following: #13224 and #13315 but I haven't been able to reproduce those.

* ensure parameter debug info is in the subroutine di scope
* slit sub file path into basename and dirname
Closesziglang#12257Closesziglang#12665
@kubkon

Copy link
Copy Markdown
Member

I think I should be able to quickly verify if #13315 is fixed. @nektro could you verify that #13224 is fixed with Vexu's patch?

@kubkon

Copy link
Copy Markdown
Member

The issue #13315 still persists:

❯ ./zld Segmentation fault at address 0x300
???:?:?: 0x7ff80223c572 in ??? (???)
/Users/jakubkonka/dev/tracy/public/common/../client/TracyProfiler.hpp:697:94: 0x109ee8029 in SendString (/Users/jakubkonka/dev/tracy/public/TracyClient.cpp)
void SendString( uint64_t str, const char* ptr, QueueType type ) { SendString( str, ptr, strlen( ptr ), type ); }
^
/Users/jakubkonka/dev/tracy/public/client/TracyProfiler.cpp:3340:9: 0x109ede4f9 in HandleServerQuery (/Users/jakubkonka/dev/tracy/public/TracyClient.cpp)
SendString( ptr, (const char*)ptr, QueueType::StringData );
^
/Users/jakubkonka/dev/tracy/public/client/TracyProfiler.cpp:1865:30: 0x109edbdb4 in Worker (/Users/jakubkonka/dev/tracy/public/TracyClient.cpp)
connActive = HandleServerQuery();
^
/Users/jakubkonka/dev/tracy/public/common/../client/TracyProfiler.hpp:754:63: 0x109eda794 in LaunchWorker (/Users/jakubkonka/dev/tracy/public/TracyClient.cpp)
static void LaunchWorker( void* ptr ) { ((Profiler*)ptr)->Worker(); }
^
/Users/jakubkonka/dev/tracy/public/common/../client/TracyThread.hpp:80:40: 0x109efbc7c in Launch (/Users/jakubkonka/dev/tracy/public/TracyClient.cpp)
static void* Launch( void* ptr ) { ((Thread*)ptr)->m_func( ((Thread*)ptr)->m_ptr ); return nullptr; }
^
???:?:?: 0x7ff802214258 in ??? (???)
???:?:?: 0x7ff80220fc7a in ??? (???)
???:?:?: 0x0 in ??? (???)
./zld: line 3: 24471 Abort trap: 6 /Users/jakubkonka/dev/zld/zig-out/bin/ld64 -dynamic -arch x86_64 -platform_version macos 13.0.0 13.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -o redis-server -L/usr/local/lib adlist.o quicklist.o ae.o anet.o dict.o server.o sds.o zmalloc.o lzf_c.o lzf_d.o pqsort.o zipmap.o sha1.o ziplist.o release.o networking.o util.o object.o db.o replication.o rdb.o t_string.o t_list.o t_set.o t_zset.o t_hash.o config.o aof.o pubsub.o multi.o debug.o sort.o intset.o syncio.o cluster.o crc16.o endianconv.o slowlog.o scripting.o bio.o rio.o rand.o memtest.o crc64.o bitops.o sentinel.o notify.o setproctitle.o blocked.o hyperloglog.o latency.o sparkline.o redis-check-rdb.o redis-check-aof.o geo.o lazyfree.o module.o evict.o expire.o geohash.o geohash_helper.o childinfo.o defrag.o siphash.o rax.o t_stream.o listpack.o localtime.o lolwut.o lolwut5.o lolwut6.o acl.o gopher.o tracking.o connection.o tls.o sha256.o ../deps/hiredis/libhiredis.a ../deps/lua/src/liblua.a -lm -ldl -lSystem /Library/Developer/CommandLineTools/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.osx.a

@nektro

Copy link
Copy Markdown
Contributor

13224 currently fails with panic: Zig compiler bug: attempted to destroy declaration with an attached error on 0.11.0.dev

@Vexu

Vexu commented Nov 28, 2022

Copy link
Copy Markdown
MemberAuthor

But do you get a stack trace?

@nektro

Copy link
Copy Markdown
Contributor

https://bpa.st/raw/2EMA yeah but thats even on master, so the issue no longer repros for me with that input

@Vexu
Vexu merged commit a660df4 into ziglang:masterNov 28, 2022
@Vexu
Vexu deleted the di branch November 28, 2022 19:58
@micahswitzer

Copy link
Copy Markdown
Contributor

The change to how the LLVM backend emits the path to the source file leads to a duplicated parent directory with correct DWARF parsing. This can be observed with llvm-dwarfdump and/or my patch to fix std.dwarf's parsing logic (#13540)

There's more context as to my changes to the DWARF parsing code on Discord: https://discord.com/channels/605571803288698900/1041373573908021248/1041386215733215352

Example:

// src/main.zigconstb=@import("a/b.zig");
pubfnmain() void {
b.doTest();
}
// src/a/b.zigpubfndoTest() void {
@panic("test");
}

Before this patch:

$ llvm-dwarfdump -n doTest mainmain: file format elf64-x86-640x000041c6: DW_TAG_subprogram DW_AT_low_pc (0x000000000020bc30) DW_AT_high_pc (0x000000000020bc56) DW_AT_frame_base (DW_OP_reg6 RBP) DW_AT_linkage_name ("a.b.doTest") DW_AT_name ("doTest") DW_AT_decl_file ("src/a/b.zig") DW_AT_decl_line (1) DW_AT_type (0x00003ccd "void")

With this patch:

$ llvm-dwarfdump -n doTest mainmain: file format elf64-x86-640x00004156: DW_TAG_subprogram DW_AT_low_pc (0x000000000020bc30) DW_AT_high_pc (0x000000000020bc56) DW_AT_frame_base (DW_OP_reg6 RBP) DW_AT_linkage_name ("a.b.doTest") DW_AT_name ("doTest") DW_AT_decl_file ("src/src/a/b.zig") DW_AT_decl_line (1) DW_AT_type (0x00003c79 "void")

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stack traces don't contain source lines from codegen/llvm.zig Self hosted compiler produces worse debug info for parameters

5 participants

@Vexu@kubkon@nektro@micahswitzer@andrewrk