aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e>2008-02-25 19:32:00 +0000
committermmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e>2008-02-25 19:32:00 +0000
commitc27cf3e3959189f78fe2de40405987c3f33488ce (patch)
tree7014e194ce872f38e6dac38172d4d4292bc563c0
parentissue 238 - missing includes compiling with gcc 4.3. patch by taras glek, r=me (diff)
downloadbreakpad-c27cf3e3959189f78fe2de40405987c3f33488ce.tar.xz
Use "%" PRIx64 instead of "%llx" (#241). r=bryner
http://groups.google.com/group/google-breakpad-dev/browse_thread/thread/327dc5326077e48d git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@241 4c0a9323-5329-0410-9bdc-e9ce6186880e
-rw-r--r--src/google_breakpad/common/breakpad_types.h9
-rw-r--r--src/processor/logging.cc2
-rw-r--r--src/processor/minidump.cc98
-rw-r--r--src/processor/minidump_stackwalk.cc66
-rw-r--r--src/processor/stackwalker_selftest.cc2
5 files changed, 94 insertions, 83 deletions
diff --git a/src/google_breakpad/common/breakpad_types.h b/src/google_breakpad/common/breakpad_types.h
index 8911557c..a66434f6 100644
--- a/src/google_breakpad/common/breakpad_types.h
+++ b/src/google_breakpad/common/breakpad_types.h
@@ -43,6 +43,8 @@
#ifndef _WIN32
#include <sys/types.h>
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
#if defined(__SUNPRO_CC) || (defined(__GNUC__) && defined(__sun__))
typedef uint8_t u_int8_t;
@@ -69,4 +71,11 @@ typedef struct {
typedef u_int64_t breakpad_time_t;
+/* Try to get PRIx64 from inttypes.h, but if it's not defined, fall back to
+ * llx, which is the format string for "long long" - this is a 64-bit
+ * integral type on many systems. */
+#ifndef PRIx64
+#define PRIx64 "llx"
+#endif /* !PRIx64 */
+
#endif /* GOOGLE_BREAKPAD_COMMON_BREAKPAD_TYPES_H__ */
diff --git a/src/processor/logging.cc b/src/processor/logging.cc
index b96e4c78..8842df35 100644
--- a/src/processor/logging.cc
+++ b/src/processor/logging.cc
@@ -80,7 +80,7 @@ std::string HexString(u_int32_t number) {
std::string HexString(u_int64_t number) {
char buffer[19];
- snprintf(buffer, sizeof(buffer), "0x%llx", number);
+ snprintf(buffer, sizeof(buffer), "0x%" PRIx64, number);
return std::string(buffer);
}
diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc
index 0330da7e..f7bc7f31 100644
--- a/src/processor/minidump.cc
+++ b/src/processor/minidump.cc
@@ -850,7 +850,7 @@ void MinidumpContext::Print() {
for (unsigned int fpr_index = 0;
fpr_index < MD_FLOATINGSAVEAREA_PPC_FPR_COUNT;
++fpr_index) {
- printf(" float_save.fpregs[%2d] = 0x%llx\n",
+ printf(" float_save.fpregs[%2d] = 0x%" PRIx64 "\n",
fpr_index, context_ppc->float_save.fpregs[fpr_index]);
}
printf(" float_save.fpscr = 0x%x\n",
@@ -858,7 +858,7 @@ void MinidumpContext::Print() {
// TODO(mmentovai): print the 128-bit quantities in
// context_ppc->vector_save. This isn't done yet because printf
// doesn't support 128-bit quantities, and printing them using
- // %llx as two 64-bit quantities requires knowledge of the CPU's
+ // PRIx64 as two 64-bit quantities requires knowledge of the CPU's
// byte ordering.
printf(" vector_save.save_vrvalid = 0x%x\n",
context_ppc->vector_save.save_vrvalid);
@@ -870,17 +870,17 @@ void MinidumpContext::Print() {
case MD_CONTEXT_AMD64: {
const MDRawContextAMD64* context_amd64 = GetContextAMD64();
printf("MDRawContextAMD64\n");
- printf(" p1_home = 0x%llx\n",
+ printf(" p1_home = 0x%" PRIx64 "\n",
context_amd64->p1_home);
- printf(" p2_home = 0x%llx\n",
+ printf(" p2_home = 0x%" PRIx64 "\n",
context_amd64->p2_home);
- printf(" p3_home = 0x%llx\n",
+ printf(" p3_home = 0x%" PRIx64 "\n",
context_amd64->p3_home);
- printf(" p4_home = 0x%llx\n",
+ printf(" p4_home = 0x%" PRIx64 "\n",
context_amd64->p4_home);
- printf(" p5_home = 0x%llx\n",
+ printf(" p5_home = 0x%" PRIx64 "\n",
context_amd64->p5_home);
- printf(" p6_home = 0x%llx\n",
+ printf(" p6_home = 0x%" PRIx64 "\n",
context_amd64->p6_home);
printf(" context_flags = 0x%x\n",
context_amd64->context_flags);
@@ -893,29 +893,29 @@ void MinidumpContext::Print() {
printf(" gs = 0x%x\n", context_amd64->gs);
printf(" ss = 0x%x\n", context_amd64->ss);
printf(" eflags = 0x%x\n", context_amd64->eflags);
- printf(" dr0 = 0x%llx\n", context_amd64->dr0);
- printf(" dr1 = 0x%llx\n", context_amd64->dr1);
- printf(" dr2 = 0x%llx\n", context_amd64->dr2);
- printf(" dr3 = 0x%llx\n", context_amd64->dr3);
- printf(" dr6 = 0x%llx\n", context_amd64->dr6);
- printf(" dr7 = 0x%llx\n", context_amd64->dr7);
- printf(" rax = 0x%llx\n", context_amd64->rax);
- printf(" rcx = 0x%llx\n", context_amd64->rcx);
- printf(" rdx = 0x%llx\n", context_amd64->rdx);
- printf(" rbx = 0x%llx\n", context_amd64->rbx);
- printf(" rsp = 0x%llx\n", context_amd64->rsp);
- printf(" rbp = 0x%llx\n", context_amd64->rbp);
- printf(" rsi = 0x%llx\n", context_amd64->rsi);
- printf(" rdi = 0x%llx\n", context_amd64->rdi);
- printf(" r8 = 0x%llx\n", context_amd64->r8);
- printf(" r9 = 0x%llx\n", context_amd64->r9);
- printf(" r10 = 0x%llx\n", context_amd64->r10);
- printf(" r11 = 0x%llx\n", context_amd64->r11);
- printf(" r12 = 0x%llx\n", context_amd64->r12);
- printf(" r13 = 0x%llx\n", context_amd64->r13);
- printf(" r14 = 0x%llx\n", context_amd64->r14);
- printf(" r15 = 0x%llx\n", context_amd64->r15);
- printf(" rip = 0x%llx\n", context_amd64->rip);
+ printf(" dr0 = 0x%" PRIx64 "\n", context_amd64->dr0);
+ printf(" dr1 = 0x%" PRIx64 "\n", context_amd64->dr1);
+ printf(" dr2 = 0x%" PRIx64 "\n", context_amd64->dr2);
+ printf(" dr3 = 0x%" PRIx64 "\n", context_amd64->dr3);
+ printf(" dr6 = 0x%" PRIx64 "\n", context_amd64->dr6);
+ printf(" dr7 = 0x%" PRIx64 "\n", context_amd64->dr7);
+ printf(" rax = 0x%" PRIx64 "\n", context_amd64->rax);
+ printf(" rcx = 0x%" PRIx64 "\n", context_amd64->rcx);
+ printf(" rdx = 0x%" PRIx64 "\n", context_amd64->rdx);
+ printf(" rbx = 0x%" PRIx64 "\n", context_amd64->rbx);
+ printf(" rsp = 0x%" PRIx64 "\n", context_amd64->rsp);
+ printf(" rbp = 0x%" PRIx64 "\n", context_amd64->rbp);
+ printf(" rsi = 0x%" PRIx64 "\n", context_amd64->rsi);
+ printf(" rdi = 0x%" PRIx64 "\n", context_amd64->rdi);
+ printf(" r8 = 0x%" PRIx64 "\n", context_amd64->r8);
+ printf(" r9 = 0x%" PRIx64 "\n", context_amd64->r9);
+ printf(" r10 = 0x%" PRIx64 "\n", context_amd64->r10);
+ printf(" r11 = 0x%" PRIx64 "\n", context_amd64->r11);
+ printf(" r12 = 0x%" PRIx64 "\n", context_amd64->r12);
+ printf(" r13 = 0x%" PRIx64 "\n", context_amd64->r13);
+ printf(" r14 = 0x%" PRIx64 "\n", context_amd64->r14);
+ printf(" r15 = 0x%" PRIx64 "\n", context_amd64->r15);
+ printf(" rip = 0x%" PRIx64 "\n", context_amd64->rip);
//TODO: print xmm, vector, debug registers
printf("\n");
break;
@@ -929,25 +929,25 @@ void MinidumpContext::Print() {
for (unsigned int g_r_index = 0;
g_r_index < MD_CONTEXT_SPARC_GPR_COUNT;
++g_r_index) {
- printf(" g_r[%2d] = 0x%llx\n",
+ printf(" g_r[%2d] = 0x%" PRIx64 "\n",
g_r_index, context_sparc->g_r[g_r_index]);
}
- printf(" ccr = 0x%llx\n", context_sparc->ccr);
- printf(" pc = 0x%llx\n", context_sparc->pc);
- printf(" npc = 0x%llx\n", context_sparc->npc);
- printf(" y = 0x%llx\n", context_sparc->y);
- printf(" asi = 0x%llx\n", context_sparc->asi);
- printf(" fprs = 0x%llx\n", context_sparc->fprs);
+ printf(" ccr = 0x%" PRIx64 "\n", context_sparc->ccr);
+ printf(" pc = 0x%" PRIx64 "\n", context_sparc->pc);
+ printf(" npc = 0x%" PRIx64 "\n", context_sparc->npc);
+ printf(" y = 0x%" PRIx64 "\n", context_sparc->y);
+ printf(" asi = 0x%" PRIx64 "\n", context_sparc->asi);
+ printf(" fprs = 0x%" PRIx64 "\n", context_sparc->fprs);
for (unsigned int fpr_index = 0;
fpr_index < MD_FLOATINGSAVEAREA_SPARC_FPR_COUNT;
++fpr_index) {
- printf(" float_save.regs[%2d] = 0x%llx\n",
+ printf(" float_save.regs[%2d] = 0x%" PRIx64 "\n",
fpr_index, context_sparc->float_save.regs[fpr_index]);
}
- printf(" float_save.filler = 0x%llx\n",
+ printf(" float_save.filler = 0x%" PRIx64 "\n",
context_sparc->float_save.filler);
- printf(" float_save.fsr = 0x%llx\n",
+ printf(" float_save.fsr = 0x%" PRIx64 "\n",
context_sparc->float_save.fsr);
break;
}
@@ -1265,8 +1265,8 @@ void MinidumpThread::Print() {
printf(" suspend_count = %d\n", thread_.suspend_count);
printf(" priority_class = 0x%x\n", thread_.priority_class);
printf(" priority = 0x%x\n", thread_.priority);
- printf(" teb = 0x%llx\n", thread_.teb);
- printf(" stack.start_of_memory_range = 0x%llx\n",
+ printf(" teb = 0x%" PRIx64 "\n", thread_.teb);
+ printf(" stack.start_of_memory_range = 0x%" PRIx64 "\n",
thread_.stack.start_of_memory_range);
printf(" stack.memory.data_size = 0x%x\n",
thread_.stack.memory.data_size);
@@ -2050,7 +2050,7 @@ void MinidumpModule::Print() {
}
printf("MDRawModule\n");
- printf(" base_of_image = 0x%llx\n",
+ printf(" base_of_image = 0x%" PRIx64 "\n",
module_.base_of_image);
printf(" size_of_image = 0x%x\n",
module_.size_of_image);
@@ -2602,7 +2602,7 @@ void MinidumpMemoryList::Print() {
MDMemoryDescriptor* descriptor = &(*descriptors_)[region_index];
printf("region[%d]\n", region_index);
printf("MDMemoryDescriptor\n");
- printf(" start_of_memory_range = 0x%llx\n",
+ printf(" start_of_memory_range = 0x%" PRIx64 "\n",
descriptor->start_of_memory_range);
printf(" memory.data_size = 0x%x\n", descriptor->memory.data_size);
printf(" memory.rva = 0x%x\n", descriptor->memory.rva);
@@ -2732,16 +2732,16 @@ void MinidumpException::Print() {
exception_.exception_record.exception_code);
printf(" exception_record.exception_flags = 0x%x\n",
exception_.exception_record.exception_flags);
- printf(" exception_record.exception_record = 0x%llx\n",
+ printf(" exception_record.exception_record = 0x%" PRIx64 "\n",
exception_.exception_record.exception_record);
- printf(" exception_record.exception_address = 0x%llx\n",
+ printf(" exception_record.exception_address = 0x%" PRIx64 "\n",
exception_.exception_record.exception_address);
printf(" exception_record.number_parameters = %d\n",
exception_.exception_record.number_parameters);
for (unsigned int parameterIndex = 0;
parameterIndex < exception_.exception_record.number_parameters;
++parameterIndex) {
- printf(" exception_record.exception_information[%2d] = 0x%llx\n",
+ printf(" exception_record.exception_information[%2d] = 0x%" PRIx64 "\n",
parameterIndex,
exception_.exception_record.exception_information[parameterIndex]);
}
@@ -3439,7 +3439,7 @@ void Minidump::Print() {
strftime(timestr, 20, "%Y-%m-%d %H:%M:%S", &timestruct);
printf(" time_date_stamp = 0x%x %s\n", header_.time_date_stamp,
timestr);
- printf(" flags = 0x%llx\n", header_.flags);
+ printf(" flags = 0x%" PRIx64 "\n", header_.flags);
printf("\n");
for (unsigned int stream_index = 0;
diff --git a/src/processor/minidump_stackwalk.cc b/src/processor/minidump_stackwalk.cc
index 785d6512..c4598515 100644
--- a/src/processor/minidump_stackwalk.cc
+++ b/src/processor/minidump_stackwalk.cc
@@ -121,18 +121,19 @@ static void PrintStack(const CallStack *stack, const string &cpu) {
printf("!%s", frame->function_name.c_str());
if (!frame->source_file_name.empty()) {
string source_file = PathnameStripper::File(frame->source_file_name);
- printf(" [%s : %d + 0x%llx]", source_file.c_str(),
- frame->source_line,
- frame->instruction -
- frame->source_line_base);
+ printf(" [%s : %d + 0x%" PRIx64 "]",
+ source_file.c_str(),
+ frame->source_line,
+ frame->instruction - frame->source_line_base);
} else {
- printf(" + 0x%llx", frame->instruction - frame->function_base);
+ printf(" + 0x%" PRIx64, frame->instruction - frame->function_base);
}
} else {
- printf(" + 0x%llx", frame->instruction - frame->module->base_address());
+ printf(" + 0x%" PRIx64,
+ frame->instruction - frame->module->base_address());
}
} else {
- printf("0x%llx", frame->instruction);
+ printf("0x%" PRIx64, frame->instruction);
}
int sequence = 0;
@@ -213,35 +214,36 @@ static void PrintStackMachineReadable(int thread_num, const CallStack *stack) {
printf("%c%s", kOutputSeparator,
StripSeparator(frame->function_name).c_str());
if (!frame->source_file_name.empty()) {
- printf("%c%s%c%d%c0x%llx", kOutputSeparator,
- StripSeparator(frame->source_file_name)
- .c_str(),
- kOutputSeparator,
- frame->source_line,
- kOutputSeparator,
- frame->instruction -
- frame->source_line_base);
+ printf("%c%s%c%d%c0x%" PRIx64,
+ kOutputSeparator,
+ StripSeparator(frame->source_file_name).c_str(),
+ kOutputSeparator,
+ frame->source_line,
+ kOutputSeparator,
+ frame->instruction - frame->source_line_base);
} else {
- printf("%c%c%c0x%llx", kOutputSeparator, // empty source file
- kOutputSeparator, // empty source line
- kOutputSeparator,
- frame->instruction - frame->function_base);
+ printf("%c%c%c0x%" PRIx64,
+ kOutputSeparator, // empty source file
+ kOutputSeparator, // empty source line
+ kOutputSeparator,
+ frame->instruction - frame->function_base);
}
} else {
- printf("%c%c%c%c0x%llx", kOutputSeparator, // empty function name
- kOutputSeparator, // empty source file
- kOutputSeparator, // empty source line
- kOutputSeparator,
- frame->instruction -
- frame->module->base_address());
+ printf("%c%c%c%c0x%" PRIx64,
+ kOutputSeparator, // empty function name
+ kOutputSeparator, // empty source file
+ kOutputSeparator, // empty source line
+ kOutputSeparator,
+ frame->instruction - frame->module->base_address());
}
} else {
// the printf before this prints a trailing separator for module name
- printf("%c%c%c%c0x%llx", kOutputSeparator, // empty function name
- kOutputSeparator, // empty source file
- kOutputSeparator, // empty source line
- kOutputSeparator,
- frame->instruction);
+ printf("%c%c%c%c0x%" PRIx64,
+ kOutputSeparator, // empty function name
+ kOutputSeparator, // empty source file
+ kOutputSeparator, // empty source line
+ kOutputSeparator,
+ frame->instruction);
}
printf("\n");
}
@@ -331,7 +333,7 @@ static void PrintProcessState(const ProcessState& process_state) {
// Print crash information.
if (process_state.crashed()) {
printf("Crash reason: %s\n", process_state.crash_reason().c_str());
- printf("Crash address: 0x%llx\n", process_state.crash_address());
+ printf("Crash address: 0x%" PRIx64 "\n", process_state.crash_address());
} else {
printf("No crash\n");
}
@@ -384,7 +386,7 @@ static void PrintProcessStateMachineReadable(const ProcessState& process_state)
// Crash|{Crash Reason}|{Crash Address}|{Crashed Thread}
printf("Crash%c", kOutputSeparator);
if (process_state.crashed()) {
- printf("%s%c0x%llx%c",
+ printf("%s%c0x%" PRIx64 "%c",
StripSeparator(process_state.crash_reason()).c_str(),
kOutputSeparator, process_state.crash_address(), kOutputSeparator);
} else {
diff --git a/src/processor/stackwalker_selftest.cc b/src/processor/stackwalker_selftest.cc
index 247b37ce..6b71a6a8 100644
--- a/src/processor/stackwalker_selftest.cc
+++ b/src/processor/stackwalker_selftest.cc
@@ -345,7 +345,7 @@ static unsigned int CountCallerFrames() {
frame_index < stack.frames()->size();
++frame_index) {
StackFrame *frame = stack.frames()->at(frame_index);
- printf("frame %-3d instruction = 0x%08llx",
+ printf("frame %-3d instruction = 0x%08" PRIx64,
frame_index, frame->instruction);
#if defined(__i386__)
StackFrameX86 *frame_x86 = reinterpret_cast<StackFrameX86*>(frame);