Provide for logging initialization routines (#179). r=bryner

http://groups.google.com/group/google-breakpad-dev/browse_thread/thread/4b196ca0b6d7f9a6


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@177 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
mmentovai 2007-05-25 18:04:17 +00:00
parent 1ef60aaa6c
commit 32b802dba3
11 changed files with 61 additions and 15 deletions

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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,7 +132,8 @@ 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, \
#define BPLOG_INFO google_breakpad::LogStream(BPLOG_INFO_STREAM, \
google_breakpad::LogStream::SEVERITY_INFO, \
__FILE__, __LINE__)
#endif // BPLOG_INFO
@ -130,11 +141,13 @@ int ErrnoString(std::string *error_string);
#ifndef BPLOG_ERROR_STREAM
#define BPLOG_ERROR_STREAM std::cerr
#endif // BPLOG_ERROR_STREAM
#define BPLOG_ERROR LogStream(BPLOG_ERROR_STREAM, LogStream::SEVERITY_ERROR, \
#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__

View file

@ -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;

View file

@ -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;
}

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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;
}