From fd3ef55763831929a4e4f9c57dc7ed657b09a0d2 Mon Sep 17 00:00:00 2001 From: Max Wang Date: Tue, 16 Dec 2014 14:54:23 -0800 Subject: [PATCH] Make HPHP::opcodeToName(HPHP::Op)::namesArr static Summary: This lets us find the symbol in GDB. Reviewed By: @edwinsmith Differential Revision: D1743854 Signature: t1:1743854:1418825809:0fd888994356968e3df30870e4cd6a38bf3ede28 --- hphp/runtime/vm/hhbc.cpp | 2 +- hphp/tools/gdb/hhbc.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/hphp/runtime/vm/hhbc.cpp b/hphp/runtime/vm/hhbc.cpp index 9b3588d37ae..78c7d80b941 100644 --- a/hphp/runtime/vm/hhbc.cpp +++ b/hphp/runtime/vm/hhbc.cpp @@ -1069,7 +1069,7 @@ OPCODES } const char* opcodeToName(Op op) { - const char* namesArr[] = { + static const char* namesArr[] = { #define O(name, imm, inputs, outputs, flags) \ #name , OPCODES diff --git a/hphp/tools/gdb/hhbc.py b/hphp/tools/gdb/hhbc.py index 40a94cc4e48..2a2fc92f419 100644 --- a/hphp/tools/gdb/hhbc.py +++ b/hphp/tools/gdb/hhbc.py @@ -68,6 +68,14 @@ class HHBC: """ @staticmethod + def op_name(op): + """Return the name of HPHP::Op `op'.""" + + table_name = 'HPHP::opcodeToName(HPHP::Op)::namesArr' + table_type = T('char').pointer().pointer() + return op_table(table_name).cast(table_type)[as_idx(op)] + + @staticmethod def num_imms(op): """Return the number of immediates for HPHP::Op `op'.""" @@ -216,12 +224,9 @@ remains where it left off after the previous call. bcstart = self.bcpos - self.bcoff - op_names = gdb.parse_and_eval( - "(char **)*(uint32_t*)('HPHP::opcodeToName(HPHP::Op)' + 10)") - for i in xrange(0, self.count): instr = HHBC.instr_info(self.bcpos) - name = op_names[as_idx(self.bcpos.dereference())].string() + name = HHBC.op_name(self.bcpos.dereference()).string() out = "%s+%d: %s" % (str(bcstart), self.bcoff, name) for imm in instr['imms']: -- 2.11.4.GIT