Skip to content

Commit

Permalink
Add an environment variable to disassemble with AT&T syntax
Browse files Browse the repository at this point in the history
Setting HHVM_ATT_DISAS before running hhvm or tc-print will
result in any disassembled instructions being printed with AT&T
syntax. The default is still Intel.
  • Loading branch information
swtaarrs authored and sgolemon committed Dec 8, 2012
1 parent 662f380 commit 1f4f65f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/runtime/vm/translator/hopt/ir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,9 @@ static void error(std::string msg) {
#define MAX_INSTR_ASM_LEN 128
xed_state_t xed_state;

static const xed_syntax_enum_t s_xed_syntax =
getenv("HHVM_ATT_DISAS") ? XED_SYNTAX_ATT : XED_SYNTAX_INTEL;

void printInstructions(xed_uint8_t* codeStartAddr,
xed_uint8_t* codeEndAddr,
bool printAddr) {
Expand All @@ -918,8 +921,8 @@ void printInstructions(xed_uint8_t* codeStartAddr,
if (xed_error != XED_ERROR_NONE) error("disasm error: xed_decode failed");

// Get disassembled instruction in codeStr
if (!xed_format_context(XED_SYNTAX_INTEL, &xedd, codeStr, MAX_INSTR_ASM_LEN,
ip, NULL)) {
if (!xed_format_context(s_xed_syntax, &xedd, codeStr,
MAX_INSTR_ASM_LEN, ip, NULL)) {
error("disasm error: xed_format_context failed");
}

Expand Down

0 comments on commit 1f4f65f

Please sign in to comment.