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

PCode: Expose default case address for switch statements in Ghidra API #7029

Open
inetbowser opened this issue Oct 9, 2024 · 0 comments · May be fixed by #7308
Open

PCode: Expose default case address for switch statements in Ghidra API #7029

inetbowser opened this issue Oct 9, 2024 · 0 comments · May be fixed by #7308
Assignees
Labels
Status: Triage Information is being gathered

Comments

@inetbowser
Copy link

Is your feature request related to a problem? Please describe.
I'm currently trying to write a script for exporting the PCode representation of a program
for use in a different project of mine. While writing the script, I noticed that basic blocks
representing switch-case blocks do not contain information describing which outgoing basic block
corresponds to which switch-case label.

Depending on what proposal is more favorable, I can also work on a pull request implementing
the feature.

Describe the solution you'd like
Proposal 1.)
Expose the default case address in JumpTable for the corresponding switch-case block. This can be
either done by defining a new field (like Address defaultCase = null;) in the class or adding a
case address to the cases field, specifying that the last entry always corresponds to the default case.

Proposal 2.)
Expose the default case through the label field in BlockEdge. Right now, the field seems to be unused
even though in the decompiler the field gets populated (and also has a flag marking the default switch case).

Describe alternatives you've considered
See above.

Additional context
20241009_16h26m24s_grim
code from Ghidra/Features/Decompiler/src/decompile/cpp/block.cc: label is populated but does not get encoded.

@inetbowser inetbowser changed the title PCode: Expose default case address for switch statements PCode: Expose default case address for switch statements in Ghidra API Oct 9, 2024
@ryanmkurtz ryanmkurtz added the Status: Triage Information is being gathered label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Triage Information is being gathered
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants