Handle CACHE instructions in decompyle, and suppress them in disassembly by default.

Showing CACHE instructions and the extra PyCode fields in pycdas is now
controlled by command-line arguments.
This commit is contained in:
Michael Hansen
2023-01-19 14:50:55 -08:00
parent 5d855f0bd2
commit 60e4eb6316
4 changed files with 50 additions and 32 deletions

View File

@@ -345,7 +345,7 @@ void bc_next(PycBuffer& source, PycModule* mod, int& opcode, int& operand, int&
}
}
void bc_disasm(PycRef<PycCode> code, PycModule* mod, int indent)
void bc_disasm(PycRef<PycCode> code, PycModule* mod, int indent, unsigned flags)
{
static const char *cmp_strings[] = {
"<", "<=", "==", "!=", ">", ">=", "in", "not in", "is", "is not",
@@ -358,12 +358,14 @@ void bc_disasm(PycRef<PycCode> code, PycModule* mod, int indent)
int opcode, operand;
int pos = 0;
while (!source.atEof()) {
int start_pos = pos;
bc_next(source, mod, opcode, operand, pos);
if (opcode == Pyc::CACHE && (flags & Pyc::DISASM_SHOW_CACHES) == 0)
continue;
for (int i=0; i<indent; i++)
fputs(" ", pyc_output);
fprintf(pyc_output, "%-7d ", pos); // Current bytecode position
bc_next(source, mod, opcode, operand, pos);
fprintf(pyc_output, "%-30s", Pyc::OpcodeName(opcode));
fprintf(pyc_output, "%-7d %-30s", start_pos, Pyc::OpcodeName(opcode));
if (opcode >= Pyc::PYC_HAVE_ARG) {
if (Pyc::IsConstArg(opcode)) {