aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/processor/address_map_unittest.cc3
-rw-r--r--src/processor/basic_source_line_resolver_unittest.cc3
-rw-r--r--src/processor/contained_range_map_unittest.cc4
-rw-r--r--src/processor/logging.h23
-rw-r--r--src/processor/minidump_dump.cc20
-rw-r--r--src/processor/minidump_processor_unittest.cc3
-rw-r--r--src/processor/minidump_stackwalk.cc5
-rw-r--r--src/processor/pathname_stripper_unittest.cc3
-rw-r--r--src/processor/postfix_evaluator_unittest.cc3
-rw-r--r--src/processor/range_map_unittest.cc3
-rw-r--r--src/processor/stackwalker_selftest.cc6
11 files changed, 61 insertions, 15 deletions
diff --git a/src/processor/address_map_unittest.cc b/src/processor/address_map_unittest.cc
index 3c865895..f64a8984 100644
--- a/src/processor/address_map_unittest.cc
+++ b/src/processor/address_map_unittest.cc
@@ -36,6 +36,7 @@
#include "processor/address_map-inl.h"
#include "processor/linked_ptr.h"
+#include "processor/logging.h"
#define ASSERT_TRUE(condition) \
if (!(condition)) { \
@@ -189,5 +190,7 @@ static bool RunTests() {
} // namespace
int main(int argc, char **argv) {
+ BPLOG_INIT(&argc, &argv);
+
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/basic_source_line_resolver_unittest.cc b/src/processor/basic_source_line_resolver_unittest.cc
index 63b38456..95595a85 100644
--- a/src/processor/basic_source_line_resolver_unittest.cc
+++ b/src/processor/basic_source_line_resolver_unittest.cc
@@ -33,6 +33,7 @@
#include "google_breakpad/processor/code_module.h"
#include "google_breakpad/processor/stack_frame.h"
#include "processor/linked_ptr.h"
+#include "processor/logging.h"
#include "processor/scoped_ptr.h"
#include "processor/stack_frame_info.h"
@@ -202,6 +203,8 @@ static bool RunTests() {
} // namespace
int main(int argc, char **argv) {
+ BPLOG_INIT(&argc, &argv);
+
if (!RunTests()) {
return 1;
}
diff --git a/src/processor/contained_range_map_unittest.cc b/src/processor/contained_range_map_unittest.cc
index 136af196..6b65b4e1 100644
--- a/src/processor/contained_range_map_unittest.cc
+++ b/src/processor/contained_range_map_unittest.cc
@@ -35,6 +35,8 @@
#include "processor/contained_range_map-inl.h"
+#include "processor/logging.h"
+
#define ASSERT_TRUE(condition) \
if (!(condition)) { \
@@ -255,5 +257,7 @@ static bool RunTests() {
int main(int argc, char **argv) {
+ BPLOG_INIT(&argc, &argv);
+
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/logging.h b/src/processor/logging.h
index 03753575..40738836 100644
--- a/src/processor/logging.h
+++ b/src/processor/logging.h
@@ -46,6 +46,12 @@
// be specified by the BP_LOGGING_INCLUDE macro. If defined, this header
// will #include the header specified by that macro.
//
+// If any initialization is needed before logging, it can be performed by
+// a function called through the BPLOG_INIT macro. Each main function of
+// an executable program in the Breakpad processor library calls
+// BPLOG_INIT(&argc, &argv); before any logging can be performed; define
+// BPLOG_INIT appropriately if initialization is required.
+//
// Author: Mark Mentovai
#ifndef PROCESSOR_LOGGING_H__
@@ -114,6 +120,10 @@ int ErrnoString(std::string *error_string);
} // namespace google_breakpad
+#ifndef BPLOG_INIT
+#define BPLOG_INIT(pargc, pargv)
+#endif // BPLOG_INIT
+
#ifndef BPLOG
#define BPLOG(severity) BPLOG_ ## severity
#endif // BPLOG
@@ -122,19 +132,22 @@ int ErrnoString(std::string *error_string);
#ifndef BPLOG_INFO_STREAM
#define BPLOG_INFO_STREAM std::clog
#endif // BPLOG_INFO_STREAM
-#define BPLOG_INFO LogStream(BPLOG_INFO_STREAM, LogStream::SEVERITY_INFO, \
- __FILE__, __LINE__)
+#define BPLOG_INFO google_breakpad::LogStream(BPLOG_INFO_STREAM, \
+ google_breakpad::LogStream::SEVERITY_INFO, \
+ __FILE__, __LINE__)
#endif // BPLOG_INFO
#ifndef BPLOG_ERROR
#ifndef BPLOG_ERROR_STREAM
#define BPLOG_ERROR_STREAM std::cerr
#endif // BPLOG_ERROR_STREAM
-#define BPLOG_ERROR LogStream(BPLOG_ERROR_STREAM, LogStream::SEVERITY_ERROR, \
- __FILE__, __LINE__)
+#define BPLOG_ERROR google_breakpad::LogStream(BPLOG_ERROR_STREAM, \
+ google_breakpad::LogStream::SEVERITY_ERROR, \
+ __FILE__, __LINE__)
#endif // BPLOG_ERROR
#define BPLOG_IF(severity, condition) \
- !(condition) ? (void) 0 : LogMessageVoidify() & BPLOG(severity)
+ !(condition) ? (void) 0 : \
+ google_breakpad::LogMessageVoidify() & BPLOG(severity)
#endif // PROCESSOR_LOGGING_H__
diff --git a/src/processor/minidump_dump.cc b/src/processor/minidump_dump.cc
index 554529b5..12a699de 100644
--- a/src/processor/minidump_dump.cc
+++ b/src/processor/minidump_dump.cc
@@ -35,6 +35,7 @@
#include <cstdio>
#include "google_breakpad/processor/minidump.h"
+#include "processor/logging.h"
namespace {
@@ -50,7 +51,7 @@ using google_breakpad::MinidumpBreakpadInfo;
static bool PrintMinidumpDump(const char *minidump_file) {
Minidump minidump(minidump_file);
if (!minidump.Read()) {
- fprintf(stderr, "minidump.Read() failed\n");
+ BPLOG(ERROR) << "minidump.Read() failed";
return false;
}
minidump.Print();
@@ -60,7 +61,7 @@ static bool PrintMinidumpDump(const char *minidump_file) {
MinidumpThreadList *thread_list = minidump.GetThreadList();
if (!thread_list) {
++errors;
- printf("minidump.GetThreadList() failed\n");
+ BPLOG(ERROR) << "minidump.GetThreadList() failed";
} else {
thread_list->Print();
}
@@ -68,7 +69,7 @@ static bool PrintMinidumpDump(const char *minidump_file) {
MinidumpModuleList *module_list = minidump.GetModuleList();
if (!module_list) {
++errors;
- printf("minidump.GetModuleList() failed\n");
+ BPLOG(ERROR) << "minidump.GetModuleList() failed";
} else {
module_list->Print();
}
@@ -76,15 +77,14 @@ static bool PrintMinidumpDump(const char *minidump_file) {
MinidumpMemoryList *memory_list = minidump.GetMemoryList();
if (!memory_list) {
++errors;
- printf("minidump.GetMemoryList() failed\n");
+ BPLOG(ERROR) << "minidump.GetMemoryList() failed";
} else {
memory_list->Print();
}
MinidumpException *exception = minidump.GetException();
if (!exception) {
- // Exception info is optional, so don't treat this as an error.
- printf("minidump.GetException() failed\n");
+ BPLOG(INFO) << "minidump.GetException() failed";
} else {
exception->Print();
}
@@ -92,7 +92,7 @@ static bool PrintMinidumpDump(const char *minidump_file) {
MinidumpSystemInfo *system_info = minidump.GetSystemInfo();
if (!system_info) {
++errors;
- printf("minidump.GetSystemInfo() failed\n");
+ BPLOG(ERROR) << "minidump.GetSystemInfo() failed";
} else {
system_info->Print();
}
@@ -100,7 +100,7 @@ static bool PrintMinidumpDump(const char *minidump_file) {
MinidumpMiscInfo *misc_info = minidump.GetMiscInfo();
if (!misc_info) {
++errors;
- printf("minidump.GetMiscInfo() failed\n");
+ BPLOG(ERROR) << "minidump.GetMiscInfo() failed";
} else {
misc_info->Print();
}
@@ -108,7 +108,7 @@ static bool PrintMinidumpDump(const char *minidump_file) {
MinidumpBreakpadInfo *breakpad_info = minidump.GetBreakpadInfo();
if (!breakpad_info) {
// Breakpad info is optional, so don't treat this as an error.
- printf("minidump.GetBreakpadInfo() failed\n");
+ BPLOG(INFO) << "minidump.GetBreakpadInfo() failed";
} else {
breakpad_info->Print();
}
@@ -119,6 +119,8 @@ static bool PrintMinidumpDump(const char *minidump_file) {
} // namespace
int main(int argc, char **argv) {
+ BPLOG_INIT(&argc, &argv);
+
if (argc != 2) {
fprintf(stderr, "usage: %s <file>\n", argv[0]);
return 1;
diff --git a/src/processor/minidump_processor_unittest.cc b/src/processor/minidump_processor_unittest.cc
index e0513436..06fa5408 100644
--- a/src/processor/minidump_processor_unittest.cc
+++ b/src/processor/minidump_processor_unittest.cc
@@ -40,6 +40,7 @@
#include "google_breakpad/processor/process_state.h"
#include "google_breakpad/processor/stack_frame.h"
#include "google_breakpad/processor/symbol_supplier.h"
+#include "processor/logging.h"
#include "processor/scoped_ptr.h"
namespace {
@@ -204,6 +205,8 @@ static bool RunTests() {
} // namespace
int main(int argc, char *argv[]) {
+ BPLOG_INIT(&argc, &argv);
+
if (!RunTests()) {
return 1;
}
diff --git a/src/processor/minidump_stackwalk.cc b/src/processor/minidump_stackwalk.cc
index 6be2551e..299dd0e7 100644
--- a/src/processor/minidump_stackwalk.cc
+++ b/src/processor/minidump_stackwalk.cc
@@ -45,6 +45,7 @@
#include "google_breakpad/processor/minidump_processor.h"
#include "google_breakpad/processor/process_state.h"
#include "google_breakpad/processor/stack_frame_cpu.h"
+#include "processor/logging.h"
#include "processor/pathname_stripper.h"
#include "processor/scoped_ptr.h"
#include "processor/simple_symbol_supplier.h"
@@ -416,7 +417,7 @@ static bool PrintMinidumpProcess(const string &minidump_file,
ProcessState process_state;
if (minidump_processor.Process(minidump_file, &process_state) !=
MinidumpProcessor::PROCESS_OK) {
- fprintf(stderr, "MinidumpProcessor::Process failed\n");
+ BPLOG(ERROR) << "MinidumpProcessor::Process failed";
return false;
}
@@ -438,6 +439,8 @@ static void usage(const char *program_name) {
}
int main(int argc, char **argv) {
+ BPLOG_INIT(&argc, &argv);
+
if (argc < 2) {
usage(argv[0]);
return 1;
diff --git a/src/processor/pathname_stripper_unittest.cc b/src/processor/pathname_stripper_unittest.cc
index 6db9b7f0..957c94f2 100644
--- a/src/processor/pathname_stripper_unittest.cc
+++ b/src/processor/pathname_stripper_unittest.cc
@@ -28,6 +28,7 @@
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "processor/pathname_stripper.h"
+#include "processor/logging.h"
#define ASSERT_TRUE(condition) \
if (!(condition)) { \
@@ -78,5 +79,7 @@ static bool RunTests() {
} // namespace
int main(int argc, char **argv) {
+ BPLOG_INIT(&argc, &argv);
+
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/postfix_evaluator_unittest.cc b/src/processor/postfix_evaluator_unittest.cc
index 18b1daf0..d687cc83 100644
--- a/src/processor/postfix_evaluator_unittest.cc
+++ b/src/processor/postfix_evaluator_unittest.cc
@@ -39,6 +39,7 @@
#include "google_breakpad/common/breakpad_types.h"
#include "google_breakpad/processor/memory_region.h"
+#include "processor/logging.h"
namespace {
@@ -296,5 +297,7 @@ static bool RunTests() {
int main(int argc, char **argv) {
+ BPLOG_INIT(&argc, &argv);
+
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/range_map_unittest.cc b/src/processor/range_map_unittest.cc
index 150ed2dd..5b5ce573 100644
--- a/src/processor/range_map_unittest.cc
+++ b/src/processor/range_map_unittest.cc
@@ -38,6 +38,7 @@
#include "processor/range_map-inl.h"
#include "processor/linked_ptr.h"
+#include "processor/logging.h"
#include "processor/scoped_ptr.h"
@@ -487,5 +488,7 @@ static bool RunTests() {
int main(int argc, char **argv) {
+ BPLOG_INIT(&argc, &argv);
+
return RunTests() ? 0 : 1;
}
diff --git a/src/processor/stackwalker_selftest.cc b/src/processor/stackwalker_selftest.cc
index 27dda9dc..913bb0ab 100644
--- a/src/processor/stackwalker_selftest.cc
+++ b/src/processor/stackwalker_selftest.cc
@@ -61,6 +61,7 @@
#include "google_breakpad/processor/memory_region.h"
#include "google_breakpad/processor/stack_frame.h"
#include "google_breakpad/processor/stack_frame_cpu.h"
+#include "processor/logging.h"
#include "processor/scoped_ptr.h"
using google_breakpad::BasicSourceLineResolver;
@@ -292,6 +293,8 @@ static bool Recursor(unsigned int depth, unsigned int parent_callers) {
// be inlined anyway.
int main(int argc, char** argv) __attribute__((noinline));
int main(int argc, char** argv) {
+ BPLOG_INIT(&argc, &argv);
+
return Recursor(RECURSION_DEPTH, CountCallerFrames()) ? 0 : 1;
}
@@ -302,8 +305,11 @@ int main(int argc, char** argv) {
int main(int argc, char **argv) {
+ BPLOG_INIT(&argc, &argv);
+
// "make check" interprets an exit status of 77 to mean that the test is
// not supported.
+ BPLOG(ERROR) << "Selftest not supported here";
return 77;
}