Repository navigation
printer: Use std dwarf implementation - #1115
Conversation
| const maybe_src_loc = di.getLineNumberInfo(gpa, text_arena.allocator(), elf.endian, compile_unit, address) catch null; | ||
|
|
||
| try output_location_info(terminal, address, maybe_name, maybe_src_loc); | ||
| if (maybe_src_loc) |src_loc| try output_source_line(io, terminal, src_loc); |
There was a problem hiding this comment.
maybe outside the scope of this PR and up for debate, but why not just make this shaped more like output_location_info, let it take an optional maybe_src_loc, and handle the logic there?
There was a problem hiding this comment.
It is more like a style preference. Inspired from TIGERSTYLE:
Centralize control flow. When splitting a large function, try to keep all switch/if statements in the "parent" function, and move non-branchy logic fragments to helper functions. Divide responsibility. All control flow should be handled by one function, the rest shouldn't care about control flow at all. In other words, "push ifs up and fors down".
There was a problem hiding this comment.
yeah that makes sense, the inconsistency is what stuck out to me. output_location_info still needs the maybe you I guess you can't do it there. That's fine by me. Ship it!
There was a problem hiding this comment.
I didn't know this was tiger style, but since we're in a nitty mood, this is definitely how I like to do things.
There was a problem hiding this comment.
@Grazfather I did some more refactoring to clear the control flow a bit. We probably don't want to print only question marks in the annotation (in case both symbol name and source loc is null) :) I wonder if there is a situation where you get a symbol name but no source location 🤔 For now I refactored so we only print if we have all the info.
| run: zig build test | ||
| working-directory: tools/esp-image | ||
|
|
||
| test-printer: |
There was a problem hiding this comment.
Could we get a build for the test printer and the example so that we at least smoke test here? Also is there anything from the removed tests that we could keep around?
There was a problem hiding this comment.
Good idea :) All the previous tests were for the dwarf parser.
There was a problem hiding this comment.
Interesting.. the windows build is failing. What do you suggest? Should we wait on this PR until std.debug.Info is truly cross platform? The problem is that std.debug.ElfFile isn't yet updated to use std.Io.File.MemoryMap
There was a problem hiding this comment.
Hmm let's just test on the other ones and cut a ticket to check back in later. Lame, but AFAIK no one is using this yet, when that happens we can always revert.
There was a problem hiding this comment.
I've made a PR to make it truly cross platform (by applying the changes on 0.17.1 I can compile to windows): https://codeberg.org/ziglang/zig/pulls/37592
There was a problem hiding this comment.
Great work! I'll cut a ticket to turn on windows when we get to 0.18
There was a problem hiding this comment.
I removed windows from CI
7b1e2a7 to
d34c041
Compare
Tested on an esp32c3 stack trace, it gives the same results as before