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

Debugging support sysfs-style for arbitrary crate variables #34

Open
kevinaboos opened this issue Jun 22, 2018 · 3 comments
Open

Debugging support sysfs-style for arbitrary crate variables #34

kevinaboos opened this issue Jun 22, 2018 · 3 comments

Comments

@kevinaboos
Copy link
Member

Expose all static crate variables as sysfs-style entries, to aid in debugging and analysis of program states.
Inspired by Cristiano Giuffrida's PeekFS (which I cannot find any public references to).

We can parse the debug_ sections of each object file and then use the DWARF DIE trees to get the string name of the variable symbol and it's type. And based on the sysfs directory we're in, we'll know which crate to look it.

Speaking of, the sysfs root will have a namespaces directory, which will have all of the CrateNamespaces, and each CrateNamespace has a list of LoadedCrates. In each LoadedCrate, there is a list of LoadedSections, each of which will comprise another directory.

Finally, in each LoadedCrate, there will be a directory for every static variable defined in that crate. Within each variable's directory, there will be a debug__ and display__ file that you can cat to invoke the Display or Debug traits implementations for that variable type.

Stretch goal: show the variable type's struct members as subdirectories in the variable's directory, so we can recurse into each member to further explore the struct. This should be do-able since we'll know what the type of the struct is; though we might not be able to read the struct definition directly (unless it's in the Dwarf debug sections somewhere?).

@kevinaboos
Copy link
Member Author

the gimli crate for parsing DWARF is relevant: https://github.com/gimli-rs/gimli

@kevinaboos
Copy link
Member Author

As of late September 2019, around commit d4ca13c, we have full support for parsing DWARF-formatted sections and obtaining debug information, so it should be quite straightforward to leverage it to get type information at runtime.

We can use this both for outputting symbol debug files to use with GDB externally (e.g., a GDB instance connected to QEMU running Theseus), as well as for the above PeekFS-style filesystem state explorer.

@kevinaboos
Copy link
Member Author

Commit 8133ac5 adds initial support for parsing DWARF debug info, so this should now be pretty easy to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant