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

Dwarf Debugging #169

Open
Tracked by #126
thesuhas opened this issue Sep 12, 2024 · 1 comment · May be fixed by #137
Open
Tracked by #126

Dwarf Debugging #169

thesuhas opened this issue Sep 12, 2024 · 1 comment · May be fixed by #137

Comments

@thesuhas
Copy link
Owner

thesuhas commented Sep 12, 2024

Need to update dwarf debugging post instrumentation to make it consistent with updated wasm binary. User must not see any debugging information related to injected code. Any debugging information present before injection must translate and give identical outcomes.

When it comes to individual debug sections:

  • debug_info: Copy it across but information related to debug_line must be updated.
  • debug_line: Update the addresses with the new locations in the wasm binary. Will need to store metadata for this.
  • All other sections: just copy

In order to generate dwarf data for handwritten .wat files, can use wasm-tools parse --generate-dwarf full

@thesuhas thesuhas linked a pull request Sep 12, 2024 that will close this issue
@thesuhas
Copy link
Owner Author

thesuhas commented Sep 15, 2024

In order to get the location information of a function, the following information can be stored.

  • At the module level, store the start location of the code section.
  • At a function level, store the start location of the function. This can be: body.range().start - number of bits used to represent function body size.
  • We must also store the end of the function. This can be from body.range().end
  • At an instruction level, store the offset in the function.

While encoding:

  • Update the start location of the code_section.
  • As you iterate through the injected instructions, calculate the offset to be applied to later instructions and functions.
  • Now, new location of functions/instructions will just be: code_section_start + injected_delta + original_offset.

Note: Must be careful to update the functions' size and use the updated size of that u32.
Note 2: If locals were added to a function, need to take into account the extra space taken by them.

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 a pull request may close this issue.

1 participant