Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIDE_DEBUG option: emit DWARF in a wasm on the side #10568

Merged
merged 8 commits into from
Feb 26, 2020
Merged

SIDE_DEBUG option: emit DWARF in a wasm on the side #10568

merged 8 commits into from
Feb 26, 2020

Conversation

kripken
Copy link
Member

@kripken kripken commented Feb 25, 2020

When used, the main wasm file has no dwarf in it, but a
.debug.wasm file on the side does. This is similar to
split-dwarf in gcc/clang, but simpler. We may evolve this
further but for now it should be useful.

@kripken kripken requested a review from dschuff February 25, 2020 21:40
Copy link
Member

@dschuff dschuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine for now, although eventually it would maybe be nicer if the flag were a -gsomething flag like clang's -gsplit-dwarf

tools/shared.py Outdated Show resolved Hide resolved
tools/shared.py Outdated Show resolved Hide resolved
@dschuff
Copy link
Member

dschuff commented Feb 25, 2020

Oh, one other thing I forgot; we should add the external_debug_info section as in https://yurydelendik.github.io/webassembly-dwarf/#external-DWARF (or propose some other way to encode the section). This is probably most easily done by emitting the section data to a file and using llvm-objcopy --add-section=external_debug_info=filename to append it to the output wasm.

+cc @pfaffe
Using -s SIDE_DEBUG will emit a debug-stripped wasm file as the "primary" output and a wasm file with debug info alongside it. A future change will make it so the debug info file on the side will contain only debug info (currently it also has the code)

@kripken
Copy link
Member Author

kripken commented Feb 25, 2020

Thanks, comments addressed, including adding the new section.

@@ -2821,6 +2821,11 @@ def check_bad_eq(arg):
newargs[i] = '-g'
shared.Settings.FULL_DWARF = 1
shared.warning('gforce_dwarf is a temporary option that will eventually disappear')
elif requested_level.startswith('side'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still suffer from the problem that -g after -gside negates the SIDE_DEBUG setting?
Actually looking at the code, I don't really see how that happens. FULL_DWARF will get set to 1, but then nothing unsets it when the -g is later processed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that flag mixup was something else I think. @pfaffe let me know if that's still an issue and if I can help there.

Overall -g can't override the two new flags we added, so this should be ok.

contents = asbytes(wasm_file_with_dwarf)
section_size = len(section_name) + len(contents)
with open(wasm_file, 'ab') as f:
f.write(b'\0') # user section is code 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit isn't necessary. The section header is created by objcopy. We only need the payload here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(the alternative of course would be to create the header here too and then just directly append to the file rather than using objcopy at all)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't use objcopy to add the new section - it just appends the bytes itself manually, so we emit all the parts. (We do similar things for a few other custom sections, like the dylink section, see make_shared_library().)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh oops, I didn't read it closely enough :D

@kripken kripken merged commit 4a15aed into master Feb 26, 2020
@kripken kripken deleted the dwo branch February 26, 2020 00:10
@sbc100
Copy link
Collaborator

sbc100 commented Feb 26, 2020

I think SIDE_DEBUG is maybe a bit misleading as ppl might thing it relates to SIDE_MODULE. Whats wrong with SPLIT_DEBUG?

@dschuff
Copy link
Member

dschuff commented Feb 26, 2020

I'm not a huge fan of the term either. Split is good but -gsplit-dwarf exists already and means something a bit different (it leaves the debug info in the object files).

@kripken
Copy link
Member Author

kripken commented Feb 26, 2020

Perhaps we can stress that the normal usage is -gside, and move the new setting to the internal settings file, would that be better?

@sbc100
Copy link
Collaborator

sbc100 commented Feb 26, 2020

Yeah, I would say if here is a corresponding regular option we should always prefer settings_internal.

How about -gseparate ? I'm mostly trying to avoid the word side.

@kripken
Copy link
Member Author

kripken commented Feb 27, 2020

Sounds good, I opened #10588

Sign up for free to 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.

3 participants