Skip to content

Commit

Permalink
Add a configuration for generating the custom "name" section
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen committed Feb 14, 2019
1 parent 71fbe9b commit 3d64daa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
21 changes: 20 additions & 1 deletion src/module/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@ use crate::module::Module;
#[derive(Clone, Debug, Default)]
pub struct ModuleConfig {
pub(crate) generate_dwarf: bool,
pub(crate) generate_name_section: bool,
pub(crate) generate_synthetic_names_for_anonymous_items: bool,
pub(crate) skip_strict_validate: bool,
}

impl ModuleConfig {
/// Creates a fresh new configuration with default settings.
pub fn new() -> ModuleConfig {
ModuleConfig::default()
ModuleConfig {
generate_dwarf: false,
generate_name_section: true,

This comment has been minimized.

Copy link
@alexcrichton

alexcrichton Feb 14, 2019

Collaborator

Oh as a heads up I was keeping this as ::default() to ideally not have to specify the default and just let the default default be the default. That's why some are positive above and some are negative (positive config names are false by default and negative config names are "true" by default for their action)

generate_synthetic_names_for_anonymous_items: false,
skip_strict_validate: false,
}
}

/// Sets a flag to whether DWARF debug sections are generated for this
Expand All @@ -26,6 +32,19 @@ impl ModuleConfig {
self
}

/// Sets a flag to whether the custom "name" section is generated for this
/// module.
///
/// The "name" section contains symbol names for the module, functions, and
/// locals. When enabled, stack traces will use these names, instead of
/// `wasm-function[123]`.
///
/// By default this flag is `true`.
pub fn generate_name_section(&mut self, generate: bool) -> &mut ModuleConfig {
self.generate_name_section = generate;
self
}

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

emit_name_section(&mut cx);
if self.config.generate_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") {
Expand Down

0 comments on commit 3d64daa

Please sign in to comment.