rename dprintf to dbgpritnf, in order to fix build with glibc (which already defines dprintf in stdio.h

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91775 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nuno Lopes 2009-12-19 12:07:00 +00:00
parent 014dc70907
commit 392bbd99b6

View File

@ -219,14 +219,14 @@ CONSUME_FUNC(consumeUInt32, uint32_t)
CONSUME_FUNC(consumeUInt64, uint64_t) CONSUME_FUNC(consumeUInt64, uint64_t)
/* /*
* dprintf - Uses the logging function provided by the user to log a single * dbgprintf - Uses the logging function provided by the user to log a single
* message, typically without a carriage-return. * message, typically without a carriage-return.
* *
* @param insn - The instruction containing the logging function. * @param insn - The instruction containing the logging function.
* @param format - See printf(). * @param format - See printf().
* @param ... - See printf(). * @param ... - See printf().
*/ */
static inline void dprintf(struct InternalInstruction* insn, static inline void dbgprintf(struct InternalInstruction* insn,
const char* format, const char* format,
...) { ...) {
char buffer[256]; char buffer[256];
@ -299,7 +299,7 @@ static int readPrefixes(struct InternalInstruction* insn) {
BOOL hasAdSize = FALSE; BOOL hasAdSize = FALSE;
BOOL hasOpSize = FALSE; BOOL hasOpSize = FALSE;
dprintf(insn, "readPrefixes()"); dbgprintf(insn, "readPrefixes()");
while (isPrefix) { while (isPrefix) {
prefixLocation = insn->readerCursor; prefixLocation = insn->readerCursor;
@ -312,7 +312,7 @@ static int readPrefixes(struct InternalInstruction* insn) {
case 0xf2: /* REPNE/REPNZ */ case 0xf2: /* REPNE/REPNZ */
case 0xf3: /* REP or REPE/REPZ */ case 0xf3: /* REP or REPE/REPZ */
if (prefixGroups[0]) if (prefixGroups[0])
dprintf(insn, "Redundant Group 1 prefix"); dbgprintf(insn, "Redundant Group 1 prefix");
prefixGroups[0] = TRUE; prefixGroups[0] = TRUE;
setPrefixPresent(insn, byte, prefixLocation); setPrefixPresent(insn, byte, prefixLocation);
break; break;
@ -345,20 +345,20 @@ static int readPrefixes(struct InternalInstruction* insn) {
unreachable("Unhandled override"); unreachable("Unhandled override");
} }
if (prefixGroups[1]) if (prefixGroups[1])
dprintf(insn, "Redundant Group 2 prefix"); dbgprintf(insn, "Redundant Group 2 prefix");
prefixGroups[1] = TRUE; prefixGroups[1] = TRUE;
setPrefixPresent(insn, byte, prefixLocation); setPrefixPresent(insn, byte, prefixLocation);
break; break;
case 0x66: /* Operand-size override */ case 0x66: /* Operand-size override */
if (prefixGroups[2]) if (prefixGroups[2])
dprintf(insn, "Redundant Group 3 prefix"); dbgprintf(insn, "Redundant Group 3 prefix");
prefixGroups[2] = TRUE; prefixGroups[2] = TRUE;
hasOpSize = TRUE; hasOpSize = TRUE;
setPrefixPresent(insn, byte, prefixLocation); setPrefixPresent(insn, byte, prefixLocation);
break; break;
case 0x67: /* Address-size override */ case 0x67: /* Address-size override */
if (prefixGroups[3]) if (prefixGroups[3])
dprintf(insn, "Redundant Group 4 prefix"); dbgprintf(insn, "Redundant Group 4 prefix");
prefixGroups[3] = TRUE; prefixGroups[3] = TRUE;
hasAdSize = TRUE; hasAdSize = TRUE;
setPrefixPresent(insn, byte, prefixLocation); setPrefixPresent(insn, byte, prefixLocation);
@ -369,7 +369,7 @@ static int readPrefixes(struct InternalInstruction* insn) {
} }
if (isPrefix) if (isPrefix)
dprintf(insn, "Found prefix 0x%hhx", byte); dbgprintf(insn, "Found prefix 0x%hhx", byte);
} }
if (insn->mode == MODE_64BIT) { if (insn->mode == MODE_64BIT) {
@ -377,14 +377,14 @@ static int readPrefixes(struct InternalInstruction* insn) {
uint8_t opcodeByte; uint8_t opcodeByte;
if(lookAtByte(insn, &opcodeByte) || ((opcodeByte & 0xf0) == 0x40)) { if(lookAtByte(insn, &opcodeByte) || ((opcodeByte & 0xf0) == 0x40)) {
dprintf(insn, "Redundant REX prefix"); dbgprintf(insn, "Redundant REX prefix");
return -1; return -1;
} }
insn->rexPrefix = byte; insn->rexPrefix = byte;
insn->necessaryPrefixLocation = insn->readerCursor - 2; insn->necessaryPrefixLocation = insn->readerCursor - 2;
dprintf(insn, "Found REX prefix 0x%hhx", byte); dbgprintf(insn, "Found REX prefix 0x%hhx", byte);
} else { } else {
unconsumeByte(insn); unconsumeByte(insn);
insn->necessaryPrefixLocation = insn->readerCursor - 1; insn->necessaryPrefixLocation = insn->readerCursor - 1;
@ -437,14 +437,14 @@ static int readOpcode(struct InternalInstruction* insn) {
uint8_t current; uint8_t current;
dprintf(insn, "readOpcode()"); dbgprintf(insn, "readOpcode()");
insn->opcodeType = ONEBYTE; insn->opcodeType = ONEBYTE;
if (consumeByte(insn, &current)) if (consumeByte(insn, &current))
return -1; return -1;
if (current == 0x0f) { if (current == 0x0f) {
dprintf(insn, "Found a two-byte escape prefix (0x%hhx)", current); dbgprintf(insn, "Found a two-byte escape prefix (0x%hhx)", current);
insn->twoByteEscape = current; insn->twoByteEscape = current;
@ -452,7 +452,7 @@ static int readOpcode(struct InternalInstruction* insn) {
return -1; return -1;
if (current == 0x38) { if (current == 0x38) {
dprintf(insn, "Found a three-byte escape prefix (0x%hhx)", current); dbgprintf(insn, "Found a three-byte escape prefix (0x%hhx)", current);
insn->threeByteEscape = current; insn->threeByteEscape = current;
@ -461,7 +461,7 @@ static int readOpcode(struct InternalInstruction* insn) {
insn->opcodeType = THREEBYTE_38; insn->opcodeType = THREEBYTE_38;
} else if (current == 0x3a) { } else if (current == 0x3a) {
dprintf(insn, "Found a three-byte escape prefix (0x%hhx)", current); dbgprintf(insn, "Found a three-byte escape prefix (0x%hhx)", current);
insn->threeByteEscape = current; insn->threeByteEscape = current;
@ -470,7 +470,7 @@ static int readOpcode(struct InternalInstruction* insn) {
insn->opcodeType = THREEBYTE_3A; insn->opcodeType = THREEBYTE_3A;
} else { } else {
dprintf(insn, "Didn't find a three-byte escape prefix"); dbgprintf(insn, "Didn't find a three-byte escape prefix");
insn->opcodeType = TWOBYTE; insn->opcodeType = TWOBYTE;
} }
@ -598,7 +598,7 @@ static int getID(struct InternalInstruction* insn) {
uint8_t attrMask; uint8_t attrMask;
uint16_t instructionID; uint16_t instructionID;
dprintf(insn, "getID()"); dbgprintf(insn, "getID()");
attrMask = ATTR_NONE; attrMask = ATTR_NONE;
@ -718,7 +718,7 @@ static int readSIB(struct InternalInstruction* insn) {
SIBBase sibBaseBase; SIBBase sibBaseBase;
uint8_t index, base; uint8_t index, base;
dprintf(insn, "readSIB()"); dbgprintf(insn, "readSIB()");
if (insn->consumedSIB) if (insn->consumedSIB)
return 0; return 0;
@ -727,7 +727,7 @@ static int readSIB(struct InternalInstruction* insn) {
switch (insn->addressSize) { switch (insn->addressSize) {
case 2: case 2:
dprintf(insn, "SIB-based addressing doesn't work in 16-bit mode"); dbgprintf(insn, "SIB-based addressing doesn't work in 16-bit mode");
return -1; return -1;
break; break;
case 4: case 4:
@ -815,7 +815,7 @@ static int readDisplacement(struct InternalInstruction* insn) {
int16_t d16; int16_t d16;
int32_t d32; int32_t d32;
dprintf(insn, "readDisplacement()"); dbgprintf(insn, "readDisplacement()");
if (insn->consumedDisplacement) if (insn->consumedDisplacement)
return 0; return 0;
@ -857,7 +857,7 @@ static int readDisplacement(struct InternalInstruction* insn) {
static int readModRM(struct InternalInstruction* insn) { static int readModRM(struct InternalInstruction* insn) {
uint8_t mod, rm, reg; uint8_t mod, rm, reg;
dprintf(insn, "readModRM()"); dbgprintf(insn, "readModRM()");
if (insn->consumedModRM) if (insn->consumedModRM)
return 0; return 0;
@ -1067,7 +1067,7 @@ static int fixupReg(struct InternalInstruction *insn,
struct OperandSpecifier *op) { struct OperandSpecifier *op) {
uint8_t valid; uint8_t valid;
dprintf(insn, "fixupReg()"); dbgprintf(insn, "fixupReg()");
switch ((OperandEncoding)op->encoding) { switch ((OperandEncoding)op->encoding) {
default: default:
@ -1104,7 +1104,7 @@ static int fixupReg(struct InternalInstruction *insn,
* ModR/M extension; useful for escape opcodes * ModR/M extension; useful for escape opcodes
*/ */
static void readOpcodeModifier(struct InternalInstruction* insn) { static void readOpcodeModifier(struct InternalInstruction* insn) {
dprintf(insn, "readOpcodeModifier()"); dbgprintf(insn, "readOpcodeModifier()");
if (insn->consumedOpcodeModifier) if (insn->consumedOpcodeModifier)
return; return;
@ -1136,7 +1136,7 @@ static void readOpcodeModifier(struct InternalInstruction* insn) {
* RAX. * RAX.
*/ */
static void readOpcodeRegister(struct InternalInstruction* insn, uint8_t size) { static void readOpcodeRegister(struct InternalInstruction* insn, uint8_t size) {
dprintf(insn, "readOpcodeRegister()"); dbgprintf(insn, "readOpcodeRegister()");
readOpcodeModifier(insn); readOpcodeModifier(insn);
@ -1184,7 +1184,7 @@ static int readImmediate(struct InternalInstruction* insn, uint8_t size) {
uint32_t imm32; uint32_t imm32;
uint64_t imm64; uint64_t imm64;
dprintf(insn, "readImmediate()"); dbgprintf(insn, "readImmediate()");
if (insn->numImmediatesConsumed == 2) if (insn->numImmediatesConsumed == 2)
unreachable("Already consumed two immediates"); unreachable("Already consumed two immediates");
@ -1232,7 +1232,7 @@ static int readImmediate(struct InternalInstruction* insn, uint8_t size) {
static int readOperands(struct InternalInstruction* insn) { static int readOperands(struct InternalInstruction* insn) {
int index; int index;
dprintf(insn, "readOperands()"); dbgprintf(insn, "readOperands()");
for (index = 0; index < X86_MAX_OPERANDS; ++index) { for (index = 0; index < X86_MAX_OPERANDS; ++index) {
switch (insn->spec->operands[index].encoding) { switch (insn->spec->operands[index].encoding) {
@ -1251,7 +1251,7 @@ static int readOperands(struct InternalInstruction* insn) {
case ENCODING_CP: case ENCODING_CP:
case ENCODING_CO: case ENCODING_CO:
case ENCODING_CT: case ENCODING_CT:
dprintf(insn, "We currently don't hande code-offset encodings"); dbgprintf(insn, "We currently don't hande code-offset encodings");
return -1; return -1;
case ENCODING_IB: case ENCODING_IB:
if (readImmediate(insn, 1)) if (readImmediate(insn, 1))
@ -1296,7 +1296,7 @@ static int readOperands(struct InternalInstruction* insn) {
case ENCODING_DUP: case ENCODING_DUP:
break; break;
default: default:
dprintf(insn, "Encountered an operand with an unknown encoding."); dbgprintf(insn, "Encountered an operand with an unknown encoding.");
return -1; return -1;
} }
} }
@ -1351,11 +1351,11 @@ int decodeInstruction(struct InternalInstruction* insn,
insn->length = insn->readerCursor - insn->startLocation; insn->length = insn->readerCursor - insn->startLocation;
dprintf(insn, "Read from 0x%llx to 0x%llx: length %llu", dbgprintf(insn, "Read from 0x%llx to 0x%llx: length %llu",
startLoc, insn->readerCursor, insn->length); startLoc, insn->readerCursor, insn->length);
if (insn->length > 15) if (insn->length > 15)
dprintf(insn, "Instruction exceeds 15-byte limit"); dbgprintf(insn, "Instruction exceeds 15-byte limit");
return 0; return 0;
} }