Add dump symbols options#538
Open
Dragorn421 wants to merge 3 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds two options that get used when the existing
dump_symbolsis true,dump_symbols_segmentsanddump_symbols_references:As a reminder, the existing
dump_symbolsoption enables dumping symbols to the following files into.splat/:spim_context.csv,spim_context_unksegment.csv,splat_symbols.csvThe two new options serve to add columns to the
splat_symbols.csvfile.dump_symbols_segmentsadds the following columns:segment,subsegment,subsegment_type, wheresegmentis the splat name of the symbol's segment (as defined from the yaml), orNoneif the symbol is not tied to a segmentsubsegmentis the splat name of the subsegment the symbol is in, if any, orNonesubsegment_typeis the type of that subsegment (such asasm,c,data, ...) orNoneif there's no tied subsegmentdump_symbols_referencesadds the following column:referenced_byreferenced_byis a|-separated list of symbol names that reference the symbol of the current csv line. For examplefunc_801C77C8for a symbol referenced by a single function,func_801C77C8leoCommand|D_801D95F0|leomain|LeoResetfor a symbol referenced by three functions and a data symbolUse case
These options are useful in order to visualize the relationships between symbols, which helps identify how to split asm and rodata sections and how to associate them.
As an example, take the following python script:
Details
This script reads the contents of
.splat/splat_symbols.csv, and given a segment name will output a graph in dot language of the symbols of that segment and their relationships. The symbols will also be visually clustered by subsegment. Optionally, the script can take a--section section1 [section2 ...]argument to restrict the visualization to just text and the given sections (text,data,rodata,bss)As an example, here is the result of
(using graphviz'
neatoto render from dot language to svg)n64dd.dot.svg:
Details
We can see two columns: the left column is the text section, and the right column is the rodata section. (since the script received
--section rodata, only text and rodata are shown)text symbols and outgoing references (represented by the arrows) are colored differently per subsegment.
Subsegments are also clustered and highlighted by black rectangles, and the name of each subsegment can be seen at their top