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

No dwarf #51

Merged
merged 5 commits into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/module/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::module::Module;
/// Configuration for a `Module` which currently affects parsing.
#[derive(Clone, Debug, Default)]
pub struct ModuleConfig {
pub(crate) generate_dwarf: bool,
pub(crate) generate_names: bool,
pub(crate) skip_strict_validate: bool,
}
Expand All @@ -14,6 +15,17 @@ impl ModuleConfig {
ModuleConfig::default()
}

/// Sets a flag to whether DWARF debug sections are generated for this
/// module.
///
/// By default this flag is `false`. Note that any emitted DWARF is
/// currently wildly incorrect and buggy, and is also larger than the wasm
/// itself!
pub fn generate_dwarf(&mut self, generate: bool) -> &mut ModuleConfig {
self.generate_dwarf = generate;
self
}

/// Sets a flag to whether debugging names are generated for
/// locals/functions/etc when parsing and running passes for this module.
///
Expand Down
10 changes: 9 additions & 1 deletion src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,17 @@ impl Module {
self.funcs.emit(&mut cx);
self.data.emit(&mut cx);

emit_name_section(&mut cx);
if self.config.generate_names {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh so the generate_names here was intended for debugging passes in walrus itself, so a lot of debug information is tied to this currently. I think we may want a separate flag (on by default whereas the generate_names flag is off by default) to emit the name section?

emit_name_section(&mut cx);
}

self.producers.emit(&mut cx);
for section in self.custom.iter() {
if !self.config.generate_dwarf && section.name.starts_with(".debug") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if this should also be skipped when parsing to avoid keeping the dwarf sections in memory?

log::debug!("skipping DWARF custom section {}", section.name);
continue;
}

log::debug!("emitting custom section {}", section.name);
cx.custom_section(&section.name).encoder.raw(&section.value);
}
Expand Down