toolkit/crashreporter/breakpad-patches/10-logging.patch

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 changeset: 126589:636cfcab9682
michael@0 2 user: Julian Seward <jseward@acm.org>
michael@0 3 date: Thu Mar 28 18:06:39 2013 +0100
michael@0 4 summary: Bug 853851 - Transition some breakpad logging to BPLOG. r=ted
michael@0 5
michael@0 6 diff --git -r 85dd7094b78d -r 636cfcab9682 src/common/dwarf_cfi_to_module.cc
michael@0 7 --- a/src/common/dwarf_cfi_to_module.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 8 +++ b/src/common/dwarf_cfi_to_module.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 9 @@ -30,18 +30,20 @@
michael@0 10 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 11
michael@0 12 // Original author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com>
michael@0 13
michael@0 14 // Implementation of google_breakpad::DwarfCFIToModule.
michael@0 15 // See dwarf_cfi_to_module.h for details.
michael@0 16
michael@0 17 #include <sstream>
michael@0 18 +#include <iomanip>
michael@0 19
michael@0 20 #include "common/dwarf_cfi_to_module.h"
michael@0 21 +#include "common/logging.h"
michael@0 22
michael@0 23 namespace google_breakpad {
michael@0 24
michael@0 25 using std::ostringstream;
michael@0 26
michael@0 27 vector<const UniqueString*> DwarfCFIToModule::RegisterNames::MakeVector(
michael@0 28 const char* const* strings,
michael@0 29 size_t size) {
michael@0 30 @@ -226,36 +228,42 @@ bool DwarfCFIToModule::ValExpressionRule
michael@0 31
michael@0 32 bool DwarfCFIToModule::End() {
michael@0 33 module_->AddStackFrameEntry(entry_);
michael@0 34 entry_ = NULL;
michael@0 35 return true;
michael@0 36 }
michael@0 37
michael@0 38 void DwarfCFIToModule::Reporter::UnnamedRegister(size_t offset, int reg) {
michael@0 39 - fprintf(stderr, "%s, section '%s': "
michael@0 40 - "the call frame entry at offset 0x%zx refers to register %d,"
michael@0 41 - " whose name we don't know\n",
michael@0 42 - file_.c_str(), section_.c_str(), offset, reg);
michael@0 43 + BPLOG(INFO) << file_ << ", section '" << section_
michael@0 44 + << "': the call frame entry at offset 0x"
michael@0 45 + << std::setbase(16) << offset << std::setbase(10)
michael@0 46 + << " refers to register " << reg << ", whose name we don't know";
michael@0 47 }
michael@0 48
michael@0 49 void DwarfCFIToModule::Reporter::UndefinedNotSupported(
michael@0 50 size_t offset,
michael@0 51 const UniqueString* reg) {
michael@0 52 - fprintf(stderr, "%s, section '%s': "
michael@0 53 - "the call frame entry at offset 0x%zx sets the rule for "
michael@0 54 - "register '%s' to 'undefined', but the Breakpad symbol file format"
michael@0 55 - " cannot express this\n",
michael@0 56 - file_.c_str(), section_.c_str(), offset, FromUniqueString(reg));
michael@0 57 + BPLOG(INFO) << file_ << ", section '" << section_
michael@0 58 + << "': the call frame entry at offset 0x"
michael@0 59 + << std::setbase(16) << offset << std::setbase(10)
michael@0 60 + << " sets the rule for register '" << FromUniqueString(reg)
michael@0 61 + << "' to 'undefined', but the Breakpad symbol file format cannot "
michael@0 62 + << " express this";
michael@0 63 }
michael@0 64
michael@0 65 void DwarfCFIToModule::Reporter::ExpressionsNotSupported(
michael@0 66 size_t offset,
michael@0 67 const UniqueString* reg) {
michael@0 68 - fprintf(stderr, "%s, section '%s': "
michael@0 69 - "the call frame entry at offset 0x%zx uses a DWARF expression to"
michael@0 70 - " describe how to recover register '%s', "
michael@0 71 - " but this translator cannot yet translate DWARF expressions to"
michael@0 72 - " Breakpad postfix expressions\n",
michael@0 73 - file_.c_str(), section_.c_str(), offset, FromUniqueString(reg));
michael@0 74 + static uint64_t n_complaints = 0; // This isn't threadsafe
michael@0 75 + n_complaints++;
michael@0 76 + if (!is_power_of_2(n_complaints))
michael@0 77 + return;
michael@0 78 + BPLOG(INFO) << file_ << ", section '" << section_
michael@0 79 + << "': the call frame entry at offset 0x"
michael@0 80 + << std::setbase(16) << offset << std::setbase(10)
michael@0 81 + << " uses a DWARF expression to describe how to recover register '"
michael@0 82 + << FromUniqueString(reg) << "', but this translator cannot yet "
michael@0 83 + << "translate DWARF expressions to Breakpad postfix expressions (shown "
michael@0 84 + << n_complaints << " times)";
michael@0 85 }
michael@0 86
michael@0 87 } // namespace google_breakpad
michael@0 88 diff --git -r 85dd7094b78d -r 636cfcab9682 src/common/dwarf_cu_to_module.cc
michael@0 89 --- a/src/common/dwarf_cu_to_module.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 90 +++ b/src/common/dwarf_cu_to_module.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 91 @@ -38,23 +38,24 @@
michael@0 92
michael@0 93 #include "common/dwarf_cu_to_module.h"
michael@0 94
michael@0 95 #include <assert.h>
michael@0 96 #if !defined(__ANDROID__)
michael@0 97 #include <cxxabi.h>
michael@0 98 #endif
michael@0 99 #include <inttypes.h>
michael@0 100 -#include <stdio.h>
michael@0 101
michael@0 102 #include <algorithm>
michael@0 103 #include <set>
michael@0 104 #include <utility>
michael@0 105 +#include <iomanip>
michael@0 106
michael@0 107 #include "common/dwarf_line_to_module.h"
michael@0 108 +#include "common/logging.h"
michael@0 109
michael@0 110 namespace google_breakpad {
michael@0 111
michael@0 112 using std::map;
michael@0 113 using std::pair;
michael@0 114 using std::set;
michael@0 115 using std::sort;
michael@0 116 using std::vector;
michael@0 117 @@ -553,84 +554,89 @@ dwarf2reader::DIEHandler *DwarfCUToModul
michael@0 118 default:
michael@0 119 return NULL;
michael@0 120 }
michael@0 121 }
michael@0 122
michael@0 123 void DwarfCUToModule::WarningReporter::CUHeading() {
michael@0 124 if (printed_cu_header_)
michael@0 125 return;
michael@0 126 - fprintf(stderr, "%s: in compilation unit '%s' (offset 0x%llx):\n",
michael@0 127 - filename_.c_str(), cu_name_.c_str(), cu_offset_);
michael@0 128 + BPLOG(INFO)
michael@0 129 + << filename_ << ": in compilation unit '" << cu_name_
michael@0 130 + << "' (offset 0x" << std::setbase(16) << cu_offset_ << std::setbase(10)
michael@0 131 + << "):";
michael@0 132 printed_cu_header_ = true;
michael@0 133 }
michael@0 134
michael@0 135 void DwarfCUToModule::WarningReporter::UnknownSpecification(uint64 offset,
michael@0 136 uint64 target) {
michael@0 137 CUHeading();
michael@0 138 - fprintf(stderr, "%s: the DIE at offset 0x%llx has a DW_AT_specification"
michael@0 139 - " attribute referring to the die at offset 0x%llx, which either"
michael@0 140 - " was not marked as a declaration, or comes later in the file\n",
michael@0 141 - filename_.c_str(), offset, target);
michael@0 142 + BPLOG(INFO)
michael@0 143 + << filename_ << ": the DIE at offset 0x"
michael@0 144 + << std::setbase(16) << offset << std::setbase(10)
michael@0 145 + << " has a DW_AT_specification attribute referring to the die at offset 0x"
michael@0 146 + << std::setbase(16) << target << std::setbase(10)
michael@0 147 + << ", which either was not marked as a declaration, or comes "
michael@0 148 + << "later in the file";
michael@0 149 }
michael@0 150
michael@0 151 void DwarfCUToModule::WarningReporter::UnknownAbstractOrigin(uint64 offset,
michael@0 152 uint64 target) {
michael@0 153 CUHeading();
michael@0 154 - fprintf(stderr, "%s: the DIE at offset 0x%llx has a DW_AT_abstract_origin"
michael@0 155 - " attribute referring to the die at offset 0x%llx, which either"
michael@0 156 - " was not marked as an inline, or comes later in the file\n",
michael@0 157 - filename_.c_str(), offset, target);
michael@0 158 + BPLOG(INFO)
michael@0 159 + << filename_ << ": the DIE at offset 0x"
michael@0 160 + << std::setbase(16) << offset << std::setbase(10)
michael@0 161 + << " has a DW_AT_abstract_origin attribute referring to the die at"
michael@0 162 + << " offset 0x" << std::setbase(16) << target << std::setbase(10)
michael@0 163 + << ", which either was not marked as an inline, or comes "
michael@0 164 + << "later in the file";
michael@0 165 }
michael@0 166
michael@0 167 void DwarfCUToModule::WarningReporter::MissingSection(const string &name) {
michael@0 168 CUHeading();
michael@0 169 - fprintf(stderr, "%s: warning: couldn't find DWARF '%s' section\n",
michael@0 170 - filename_.c_str(), name.c_str());
michael@0 171 + BPLOG(INFO) << filename_ << ": warning: couldn't find DWARF '"
michael@0 172 + << name << "' section";
michael@0 173 }
michael@0 174
michael@0 175 void DwarfCUToModule::WarningReporter::BadLineInfoOffset(uint64 offset) {
michael@0 176 CUHeading();
michael@0 177 - fprintf(stderr, "%s: warning: line number data offset beyond end"
michael@0 178 - " of '.debug_line' section\n",
michael@0 179 - filename_.c_str());
michael@0 180 + BPLOG(INFO) << filename_ << ": warning: line number data offset beyond "
michael@0 181 + << "end of '.debug_line' section";
michael@0 182 }
michael@0 183
michael@0 184 void DwarfCUToModule::WarningReporter::UncoveredHeading() {
michael@0 185 if (printed_unpaired_header_)
michael@0 186 return;
michael@0 187 CUHeading();
michael@0 188 - fprintf(stderr, "%s: warning: skipping unpaired lines/functions:\n",
michael@0 189 - filename_.c_str());
michael@0 190 + BPLOG(INFO) << filename_ << ": warning: skipping unpaired lines/functions:";
michael@0 191 printed_unpaired_header_ = true;
michael@0 192 }
michael@0 193
michael@0 194 void DwarfCUToModule::WarningReporter::UncoveredFunction(
michael@0 195 const Module::Function &function) {
michael@0 196 if (!uncovered_warnings_enabled_)
michael@0 197 return;
michael@0 198 UncoveredHeading();
michael@0 199 - fprintf(stderr, " function%s: %s\n",
michael@0 200 - function.size == 0 ? " (zero-length)" : "",
michael@0 201 - function.name.c_str());
michael@0 202 + BPLOG(INFO) << " function" << (function.size == 0 ? " (zero-length)" : "")
michael@0 203 + << ": " << function.name;
michael@0 204 }
michael@0 205
michael@0 206 void DwarfCUToModule::WarningReporter::UncoveredLine(const Module::Line &line) {
michael@0 207 if (!uncovered_warnings_enabled_)
michael@0 208 return;
michael@0 209 UncoveredHeading();
michael@0 210 - fprintf(stderr, " line%s: %s:%d at 0x%" PRIx64 "\n",
michael@0 211 - (line.size == 0 ? " (zero-length)" : ""),
michael@0 212 - line.file->name.c_str(), line.number, line.address);
michael@0 213 + BPLOG(INFO) << " line" << (line.size == 0 ? " (zero-length)" : "")
michael@0 214 + << ": " << line.file->name << ":" << line.number
michael@0 215 + << " at 0x" << std::setbase(16) << line.address << std::setbase(10);
michael@0 216 }
michael@0 217
michael@0 218 void DwarfCUToModule::WarningReporter::UnnamedFunction(uint64 offset) {
michael@0 219 CUHeading();
michael@0 220 - fprintf(stderr, "%s: warning: function at offset 0x%llx has no name\n",
michael@0 221 - filename_.c_str(), offset);
michael@0 222 + BPLOG(INFO) << filename_ << ": warning: function at offset 0x"
michael@0 223 + << std::setbase(16) << offset << std::setbase(10) << " has no name";
michael@0 224 }
michael@0 225
michael@0 226 DwarfCUToModule::DwarfCUToModule(FileContext *file_context,
michael@0 227 LineToModuleHandler *line_reader,
michael@0 228 WarningReporter *reporter)
michael@0 229 : line_reader_(line_reader), has_source_line_info_(false) {
michael@0 230 cu_context_ = new CUContext(file_context, reporter);
michael@0 231 child_context_ = new DIEContext();
michael@0 232 diff --git -r 85dd7094b78d -r 636cfcab9682 src/common/dwarf_line_to_module.cc
michael@0 233 --- a/src/common/dwarf_line_to_module.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 234 +++ b/src/common/dwarf_line_to_module.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 235 @@ -27,22 +27,21 @@
michael@0 236 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 237 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 238
michael@0 239 // Original author: Jim Blandy <jimb@mozilla.com> <jimb@red-bean.com>
michael@0 240
michael@0 241 // dwarf_line_to_module.cc: Implementation of DwarfLineToModule class.
michael@0 242 // See dwarf_line_to_module.h for details.
michael@0 243
michael@0 244 -#include <stdio.h>
michael@0 245 -
michael@0 246 #include <string>
michael@0 247
michael@0 248 #include "common/dwarf_line_to_module.h"
michael@0 249 #include "common/using_std_string.h"
michael@0 250 +#include "common/logging.h"
michael@0 251
michael@0 252 // Trying to support Windows paths in a reasonable way adds a lot of
michael@0 253 // variations to test; it would be better to just put off dealing with
michael@0 254 // it until we actually have to deal with DWARF on Windows.
michael@0 255
michael@0 256 // Return true if PATH is an absolute path, false if it is relative.
michael@0 257 static bool PathIsAbsolute(const string &path) {
michael@0 258 return (path.size() >= 1 && path[0] == '/');
michael@0 259 @@ -84,18 +83,18 @@ void DwarfLineToModule::DefineFile(const
michael@0 260 // an attribute on the compilation unit, rather than in the program table.
michael@0 261 dir_name = compilation_dir_;
michael@0 262 } else {
michael@0 263 DirectoryTable::const_iterator directory_it = directories_.find(dir_num);
michael@0 264 if (directory_it != directories_.end()) {
michael@0 265 dir_name = directory_it->second;
michael@0 266 } else {
michael@0 267 if (!warned_bad_directory_number_) {
michael@0 268 - fprintf(stderr, "warning: DWARF line number data refers to undefined"
michael@0 269 - " directory numbers\n");
michael@0 270 + BPLOG(INFO) << "warning: DWARF line number data refers to undefined"
michael@0 271 + << " directory numbers";
michael@0 272 warned_bad_directory_number_ = true;
michael@0 273 }
michael@0 274 }
michael@0 275 }
michael@0 276
michael@0 277 string full_name = ExpandPath(name, dir_name);
michael@0 278
michael@0 279 // Find a Module::File object of the given name, and add it to the
michael@0 280 @@ -120,18 +119,18 @@ void DwarfLineToModule::AddLine(uint64 a
michael@0 281 } else {
michael@0 282 omitted_line_end_ = 0;
michael@0 283 }
michael@0 284
michael@0 285 // Find the source file being referred to.
michael@0 286 Module::File *file = files_[file_num];
michael@0 287 if (!file) {
michael@0 288 if (!warned_bad_file_number_) {
michael@0 289 - fprintf(stderr, "warning: DWARF line number data refers to "
michael@0 290 - "undefined file numbers\n");
michael@0 291 + BPLOG(INFO) << "warning: DWARF line number data refers to "
michael@0 292 + << "undefined file numbers";
michael@0 293 warned_bad_file_number_ = true;
michael@0 294 }
michael@0 295 return;
michael@0 296 }
michael@0 297 Module::Line line;
michael@0 298 line.address = address;
michael@0 299 // We set the size when we get the next line or the EndSequence call.
michael@0 300 line.size = length;
michael@0 301 diff --git -r 85dd7094b78d -r 636cfcab9682 src/common/linux/dump_symbols.cc
michael@0 302 --- a/src/common/linux/dump_symbols.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 303 +++ b/src/common/linux/dump_symbols.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 304 @@ -63,16 +63,17 @@
michael@0 305 #include "common/linux/file_id.h"
michael@0 306 #include "common/module.h"
michael@0 307 #include "common/scoped_ptr.h"
michael@0 308 #ifndef NO_STABS_SUPPORT
michael@0 309 #include "common/stabs_reader.h"
michael@0 310 #include "common/stabs_to_module.h"
michael@0 311 #endif
michael@0 312 #include "common/using_std_string.h"
michael@0 313 +#include "common/logging.h"
michael@0 314
michael@0 315 // This namespace contains helper functions.
michael@0 316 namespace {
michael@0 317
michael@0 318 using google_breakpad::DwarfCFIToModule;
michael@0 319 using google_breakpad::DwarfCUToModule;
michael@0 320 using google_breakpad::DwarfLineToModule;
michael@0 321 using google_breakpad::ElfClass;
michael@0 322 @@ -523,16 +524,19 @@ bool LoadSymbols(const string& obj_file,
michael@0 323 const bool read_gnu_debug_link,
michael@0 324 LoadSymbolsInfo<ElfClass>* info,
michael@0 325 SymbolData symbol_data,
michael@0 326 Module* module) {
michael@0 327 typedef typename ElfClass::Addr Addr;
michael@0 328 typedef typename ElfClass::Phdr Phdr;
michael@0 329 typedef typename ElfClass::Shdr Shdr;
michael@0 330
michael@0 331 + BPLOG(INFO) << "";
michael@0 332 + BPLOG(INFO) << "LoadSymbols: BEGIN " << obj_file;
michael@0 333 +
michael@0 334 Addr loading_addr = GetLoadingAddress<ElfClass>(
michael@0 335 GetOffset<ElfClass, Phdr>(elf_header, elf_header->e_phoff),
michael@0 336 elf_header->e_phnum);
michael@0 337 module->SetLoadAddress(loading_addr);
michael@0 338 info->set_loading_addr(loading_addr, obj_file);
michael@0 339
michael@0 340 const Shdr* sections =
michael@0 341 GetOffset<ElfClass, Shdr>(elf_header, elf_header->e_shoff);
michael@0 342 @@ -592,16 +596,18 @@ bool LoadSymbols(const string& obj_file,
michael@0 343 // information, the other debugging information could be perfectly
michael@0 344 // useful.
michael@0 345 info->LoadedSection(".debug_frame");
michael@0 346 bool result =
michael@0 347 LoadDwarfCFI<ElfClass>(obj_file, elf_header, ".debug_frame",
michael@0 348 dwarf_cfi_section, false, 0, 0, big_endian,
michael@0 349 module);
michael@0 350 found_usable_info = found_usable_info || result;
michael@0 351 + if (result)
michael@0 352 + BPLOG(INFO) << "LoadSymbols: read CFI from .debug_frame";
michael@0 353 }
michael@0 354
michael@0 355 // Linux C++ exception handling information can also provide
michael@0 356 // unwinding data.
michael@0 357 const Shdr* eh_frame_section =
michael@0 358 FindElfSectionByName<ElfClass>(".eh_frame", SHT_PROGBITS,
michael@0 359 sections, names, names_end,
michael@0 360 elf_header->e_shnum);
michael@0 361 @@ -618,16 +624,18 @@ bool LoadSymbols(const string& obj_file,
michael@0 362 elf_header->e_shnum);
michael@0 363 info->LoadedSection(".eh_frame");
michael@0 364 // As above, ignore the return value of this function.
michael@0 365 bool result =
michael@0 366 LoadDwarfCFI<ElfClass>(obj_file, elf_header, ".eh_frame",
michael@0 367 eh_frame_section, true,
michael@0 368 got_section, text_section, big_endian, module);
michael@0 369 found_usable_info = found_usable_info || result;
michael@0 370 + if (result)
michael@0 371 + BPLOG(INFO) << "LoadSymbols: read CFI from .eh_frame";
michael@0 372 }
michael@0 373 }
michael@0 374
michael@0 375 if (!found_debug_info_section && symbol_data != ONLY_CFI) {
michael@0 376 fprintf(stderr, "%s: file contains no debugging information"
michael@0 377 " (no \".stab\" or \".debug_info\" sections)\n",
michael@0 378 obj_file.c_str());
michael@0 379
michael@0 380 @@ -685,24 +693,29 @@ bool LoadSymbols(const string& obj_file,
michael@0 381 ElfClass::kAddrSize,
michael@0 382 module);
michael@0 383 found_usable_info = found_usable_info || result;
michael@0 384 }
michael@0 385 }
michael@0 386
michael@0 387 // Return true if some usable information was found, since
michael@0 388 // the caller doesn't want to use .gnu_debuglink.
michael@0 389 + BPLOG(INFO) << "LoadSymbols: "
michael@0 390 + << (found_usable_info ? "SUCCESS " : "FAILURE ")
michael@0 391 + << obj_file;
michael@0 392 return found_usable_info;
michael@0 393 }
michael@0 394
michael@0 395 // No debug info was found, let the user try again with .gnu_debuglink
michael@0 396 // if present.
michael@0 397 + BPLOG(INFO) << "LoadSymbols: FAILURE " << obj_file;
michael@0 398 return false;
michael@0 399 }
michael@0 400
michael@0 401 + BPLOG(INFO) << "LoadSymbols: SUCCESS " << obj_file;
michael@0 402 return true;
michael@0 403 }
michael@0 404
michael@0 405 // Return the breakpad symbol file identifier for the architecture of
michael@0 406 // ELF_HEADER.
michael@0 407 template<typename ElfClass>
michael@0 408 const char* ElfArchitecture(const typename ElfClass::Ehdr* elf_header) {
michael@0 409 typedef typename ElfClass::Half Half;
michael@0 410 diff --git -r 85dd7094b78d -r 636cfcab9682 src/common/logging.cc
michael@0 411 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 412 +++ b/src/common/logging.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 413 @@ -0,0 +1,139 @@
michael@0 414 +// Copyright (c) 2007, Google Inc.
michael@0 415 +// All rights reserved.
michael@0 416 +//
michael@0 417 +// Redistribution and use in source and binary forms, with or without
michael@0 418 +// modification, are permitted provided that the following conditions are
michael@0 419 +// met:
michael@0 420 +//
michael@0 421 +// * Redistributions of source code must retain the above copyright
michael@0 422 +// notice, this list of conditions and the following disclaimer.
michael@0 423 +// * Redistributions in binary form must reproduce the above
michael@0 424 +// copyright notice, this list of conditions and the following disclaimer
michael@0 425 +// in the documentation and/or other materials provided with the
michael@0 426 +// distribution.
michael@0 427 +// * Neither the name of Google Inc. nor the names of its
michael@0 428 +// contributors may be used to endorse or promote products derived from
michael@0 429 +// this software without specific prior written permission.
michael@0 430 +//
michael@0 431 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 432 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 433 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 434 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 435 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 436 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 437 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 438 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 439 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 440 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 441 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 442 +
michael@0 443 +// logging.cc: Breakpad logging
michael@0 444 +//
michael@0 445 +// See logging.h for documentation.
michael@0 446 +//
michael@0 447 +// Author: Mark Mentovai
michael@0 448 +
michael@0 449 +#include <assert.h>
michael@0 450 +#include <errno.h>
michael@0 451 +#include <stdio.h>
michael@0 452 +#include <string.h>
michael@0 453 +#include <time.h>
michael@0 454 +
michael@0 455 +#include <string>
michael@0 456 +
michael@0 457 +#include "common/using_std_string.h"
michael@0 458 +#include "common/logging.h"
michael@0 459 +#include "common/pathname_stripper.h"
michael@0 460 +
michael@0 461 +#ifdef _WIN32
michael@0 462 +#define snprintf _snprintf
michael@0 463 +#endif
michael@0 464 +
michael@0 465 +#ifdef __ANDROID__
michael@0 466 +# include <android/log.h>
michael@0 467 +#endif
michael@0 468 +
michael@0 469 +namespace google_breakpad {
michael@0 470 +
michael@0 471 +LogStream::LogStream(std::ostream &stream, Severity severity,
michael@0 472 + const char *file, int line)
michael@0 473 + : stream_(stream) {
michael@0 474 + time_t clock;
michael@0 475 + time(&clock);
michael@0 476 + struct tm tm_struct;
michael@0 477 +#ifdef _WIN32
michael@0 478 + localtime_s(&tm_struct, &clock);
michael@0 479 +#else
michael@0 480 + localtime_r(&clock, &tm_struct);
michael@0 481 +#endif
michael@0 482 + char time_string[20];
michael@0 483 + strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", &tm_struct);
michael@0 484 +
michael@0 485 + const char *severity_string = "UNKNOWN_SEVERITY";
michael@0 486 + switch (severity) {
michael@0 487 + case SEVERITY_INFO:
michael@0 488 + severity_string = "INFO";
michael@0 489 + break;
michael@0 490 + case SEVERITY_ERROR:
michael@0 491 + severity_string = "ERROR";
michael@0 492 + break;
michael@0 493 + }
michael@0 494 +
michael@0 495 + str_ << time_string << ": " << PathnameStripper::File(file) << ":" <<
michael@0 496 + line << ": " << severity_string << ": ";
michael@0 497 +}
michael@0 498 +
michael@0 499 +LogStream::~LogStream() {
michael@0 500 +#ifdef __ANDROID__
michael@0 501 + __android_log_print(ANDROID_LOG_ERROR,
michael@0 502 + "Profiler", "%s", str_.str().c_str());
michael@0 503 +#else
michael@0 504 + stream_ << str_.str();
michael@0 505 + stream_ << std::endl;
michael@0 506 +#endif
michael@0 507 +}
michael@0 508 +
michael@0 509 +string HexString(uint32_t number) {
michael@0 510 + char buffer[11];
michael@0 511 + snprintf(buffer, sizeof(buffer), "0x%x", number);
michael@0 512 + return string(buffer);
michael@0 513 +}
michael@0 514 +
michael@0 515 +string HexString(uint64_t number) {
michael@0 516 + char buffer[19];
michael@0 517 + snprintf(buffer, sizeof(buffer), "0x%" PRIx64, number);
michael@0 518 + return string(buffer);
michael@0 519 +}
michael@0 520 +
michael@0 521 +string HexString(int number) {
michael@0 522 + char buffer[19];
michael@0 523 + snprintf(buffer, sizeof(buffer), "0x%x", number);
michael@0 524 + return string(buffer);
michael@0 525 +}
michael@0 526 +
michael@0 527 +int ErrnoString(string *error_string) {
michael@0 528 + assert(error_string);
michael@0 529 +
michael@0 530 + // strerror isn't necessarily thread-safe. strerror_r would be preferrable,
michael@0 531 + // but GNU libc uses a nonstandard strerror_r by default, which returns a
michael@0 532 + // char* (rather than an int success indicator) and doesn't necessarily
michael@0 533 + // use the supplied buffer.
michael@0 534 + error_string->assign(strerror(errno));
michael@0 535 + return errno;
michael@0 536 +}
michael@0 537 +
michael@0 538 +} // namespace google_breakpad
michael@0 539 +
michael@0 540 +bool is_power_of_2(uint64_t x_in)
michael@0 541 +{
michael@0 542 + uint64_t x = x_in;
michael@0 543 + x = x | (x >> 1);
michael@0 544 + x = x | (x >> 2);
michael@0 545 + x = x | (x >> 4);
michael@0 546 + x = x | (x >> 8);
michael@0 547 + x = x | (x >> 16);
michael@0 548 + x = x | (x >> 32);
michael@0 549 + x = x - (x >> 1);
michael@0 550 + // x has now been rounded down to the nearest power of 2 <= x_in.
michael@0 551 + return x == x_in;
michael@0 552 +}
michael@0 553 diff --git -r 85dd7094b78d -r 636cfcab9682 src/common/logging.h
michael@0 554 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 555 +++ b/src/common/logging.h Thu Apr 04 21:02:11 2013 +0200
michael@0 556 @@ -0,0 +1,182 @@
michael@0 557 +// Copyright (c) 2007, Google Inc.
michael@0 558 +// All rights reserved.
michael@0 559 +//
michael@0 560 +// Redistribution and use in source and binary forms, with or without
michael@0 561 +// modification, are permitted provided that the following conditions are
michael@0 562 +// met:
michael@0 563 +//
michael@0 564 +// * Redistributions of source code must retain the above copyright
michael@0 565 +// notice, this list of conditions and the following disclaimer.
michael@0 566 +// * Redistributions in binary form must reproduce the above
michael@0 567 +// copyright notice, this list of conditions and the following disclaimer
michael@0 568 +// in the documentation and/or other materials provided with the
michael@0 569 +// distribution.
michael@0 570 +// * Neither the name of Google Inc. nor the names of its
michael@0 571 +// contributors may be used to endorse or promote products derived from
michael@0 572 +// this software without specific prior written permission.
michael@0 573 +//
michael@0 574 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 575 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 576 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 577 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 578 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 579 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 580 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 581 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 582 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 583 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 584 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 585 +
michael@0 586 +// logging.h: Breakpad logging
michael@0 587 +//
michael@0 588 +// Breakpad itself uses Breakpad logging with statements of the form:
michael@0 589 +// BPLOG(severity) << "message";
michael@0 590 +// severity may be INFO, ERROR, or other values defined in this file.
michael@0 591 +//
michael@0 592 +// BPLOG is an overridable macro so that users can customize Breakpad's
michael@0 593 +// logging. Left at the default, logging messages are sent to stderr along
michael@0 594 +// with a timestamp and the source code location that produced a message.
michael@0 595 +// The streams may be changed by redefining BPLOG_*_STREAM, the logging
michael@0 596 +// behavior may be changed by redefining BPLOG_*, and the entire logging
michael@0 597 +// system may be overridden by redefining BPLOG(severity). These
michael@0 598 +// redefinitions may be passed to the preprocessor as a command-line flag
michael@0 599 +// (-D).
michael@0 600 +//
michael@0 601 +// If an additional header is required to override Breakpad logging, it can
michael@0 602 +// be specified by the BP_LOGGING_INCLUDE macro. If defined, this header
michael@0 603 +// will #include the header specified by that macro.
michael@0 604 +//
michael@0 605 +// If any initialization is needed before logging, it can be performed by
michael@0 606 +// a function called through the BPLOG_INIT macro. Each main function of
michael@0 607 +// an executable program in the Breakpad processor library calls
michael@0 608 +// BPLOG_INIT(&argc, &argv); before any logging can be performed; define
michael@0 609 +// BPLOG_INIT appropriately if initialization is required.
michael@0 610 +//
michael@0 611 +// Author: Mark Mentovai
michael@0 612 +
michael@0 613 +#ifndef PROCESSOR_LOGGING_H__
michael@0 614 +#define PROCESSOR_LOGGING_H__
michael@0 615 +
michael@0 616 +#include <iostream>
michael@0 617 +#include <sstream>
michael@0 618 +#include <string>
michael@0 619 +
michael@0 620 +#include "common/using_std_string.h"
michael@0 621 +#include "google_breakpad/common/breakpad_types.h"
michael@0 622 +
michael@0 623 +#ifdef BP_LOGGING_INCLUDE
michael@0 624 +#include BP_LOGGING_INCLUDE
michael@0 625 +#endif // BP_LOGGING_INCLUDE
michael@0 626 +
michael@0 627 +#ifndef THIRD_PARTY_BREAKPAD_GOOGLE_GLUE_LOGGING_H_
michael@0 628 +namespace base_logging {
michael@0 629 +
michael@0 630 +// The open-source copy of logging.h has diverged from Google's internal copy
michael@0 631 +// (temporarily, at least). To support the transition to structured logging
michael@0 632 +// a definition for base_logging::LogMessage is needed, which is a ostream-
michael@0 633 +// like object for streaming arguments to construct a log message.
michael@0 634 +typedef std::ostream LogMessage;
michael@0 635 +
michael@0 636 +} // namespace base_logging
michael@0 637 +#endif // THIRD_PARTY_BREAKPAD_GOOGLE_GLUE_LOGGING_H_
michael@0 638 +
michael@0 639 +namespace google_breakpad {
michael@0 640 +
michael@0 641 +// These are defined in Microsoft headers.
michael@0 642 +#ifdef SEVERITY_ERROR
michael@0 643 +#undef SEVERITY_ERROR
michael@0 644 +#endif
michael@0 645 +
michael@0 646 +#ifdef ERROR
michael@0 647 +#undef ERROR
michael@0 648 +#endif
michael@0 649 +
michael@0 650 +class LogStream {
michael@0 651 + public:
michael@0 652 + enum Severity {
michael@0 653 + SEVERITY_INFO,
michael@0 654 + SEVERITY_ERROR
michael@0 655 + };
michael@0 656 +
michael@0 657 + // Begin logging a message to the stream identified by |stream|, at the
michael@0 658 + // indicated severity. The file and line parameters should be set so as to
michael@0 659 + // identify the line of source code that is producing a message.
michael@0 660 + LogStream(std::ostream &stream, Severity severity,
michael@0 661 + const char *file, int line);
michael@0 662 +
michael@0 663 + // Finish logging by printing a newline and flushing the output stream.
michael@0 664 + ~LogStream();
michael@0 665 +
michael@0 666 + // Accumulate text in the str_. It will be emitted to stream_ when
michael@0 667 + // the object is destructed.
michael@0 668 + template<typename T> std::ostream& operator<<(const T &t) {
michael@0 669 + return str_ << t;
michael@0 670 + }
michael@0 671 +
michael@0 672 + private:
michael@0 673 + std::ostream &stream_;
michael@0 674 + std::ostringstream str_;
michael@0 675 +
michael@0 676 + // Disallow copy constructor and assignment operator
michael@0 677 + explicit LogStream(const LogStream &that);
michael@0 678 + void operator=(const LogStream &that);
michael@0 679 +};
michael@0 680 +
michael@0 681 +// This class is used to explicitly ignore values in the conditional logging
michael@0 682 +// macros. This avoids compiler warnings like "value computed is not used"
michael@0 683 +// and "statement has no effect".
michael@0 684 +class LogMessageVoidify {
michael@0 685 + public:
michael@0 686 + LogMessageVoidify() {}
michael@0 687 +
michael@0 688 + // This has to be an operator with a precedence lower than << but higher
michael@0 689 + // than ?:
michael@0 690 + void operator&(base_logging::LogMessage &) {}
michael@0 691 +};
michael@0 692 +
michael@0 693 +// Returns number formatted as a hexadecimal string, such as "0x7b".
michael@0 694 +string HexString(uint32_t number);
michael@0 695 +string HexString(uint64_t number);
michael@0 696 +string HexString(int number);
michael@0 697 +
michael@0 698 +// Returns the error code as set in the global errno variable, and sets
michael@0 699 +// error_string, a required argument, to a string describing that error
michael@0 700 +// code.
michael@0 701 +int ErrnoString(string *error_string);
michael@0 702 +
michael@0 703 +} // namespace google_breakpad
michael@0 704 +
michael@0 705 +// Useful for doing exponential backoff of error reporting
michael@0 706 +bool is_power_of_2(uint64_t);
michael@0 707 +
michael@0 708 +#ifndef BPLOG_INIT
michael@0 709 +#define BPLOG_INIT(pargc, pargv)
michael@0 710 +#endif // BPLOG_INIT
michael@0 711 +
michael@0 712 +#ifndef BPLOG
michael@0 713 +#define BPLOG(severity) BPLOG_ ## severity
michael@0 714 +#endif // BPLOG
michael@0 715 +
michael@0 716 +#ifndef BPLOG_INFO
michael@0 717 +#ifndef BPLOG_INFO_STREAM
michael@0 718 +#define BPLOG_INFO_STREAM std::clog
michael@0 719 +#endif // BPLOG_INFO_STREAM
michael@0 720 +#define BPLOG_INFO google_breakpad::LogStream(BPLOG_INFO_STREAM, \
michael@0 721 + google_breakpad::LogStream::SEVERITY_INFO, \
michael@0 722 + __FILE__, __LINE__)
michael@0 723 +#endif // BPLOG_INFO
michael@0 724 +
michael@0 725 +#ifndef BPLOG_ERROR
michael@0 726 +#ifndef BPLOG_ERROR_STREAM
michael@0 727 +#define BPLOG_ERROR_STREAM std::cerr
michael@0 728 +#endif // BPLOG_ERROR_STREAM
michael@0 729 +#define BPLOG_ERROR google_breakpad::LogStream(BPLOG_ERROR_STREAM, \
michael@0 730 + google_breakpad::LogStream::SEVERITY_ERROR, \
michael@0 731 + __FILE__, __LINE__)
michael@0 732 +#endif // BPLOG_ERROR
michael@0 733 +
michael@0 734 +#define BPLOG_IF(severity, condition) \
michael@0 735 + !(condition) ? (void) 0 : \
michael@0 736 + google_breakpad::LogMessageVoidify() & BPLOG(severity)
michael@0 737 +
michael@0 738 +#endif // PROCESSOR_LOGGING_H__
michael@0 739 diff --git -r 85dd7094b78d -r 636cfcab9682 src/common/pathname_stripper.cc
michael@0 740 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 741 +++ b/src/common/pathname_stripper.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 742 @@ -0,0 +1,56 @@
michael@0 743 +// Copyright (c) 2006, Google Inc.
michael@0 744 +// All rights reserved.
michael@0 745 +//
michael@0 746 +// Redistribution and use in source and binary forms, with or without
michael@0 747 +// modification, are permitted provided that the following conditions are
michael@0 748 +// met:
michael@0 749 +//
michael@0 750 +// * Redistributions of source code must retain the above copyright
michael@0 751 +// notice, this list of conditions and the following disclaimer.
michael@0 752 +// * Redistributions in binary form must reproduce the above
michael@0 753 +// copyright notice, this list of conditions and the following disclaimer
michael@0 754 +// in the documentation and/or other materials provided with the
michael@0 755 +// distribution.
michael@0 756 +// * Neither the name of Google Inc. nor the names of its
michael@0 757 +// contributors may be used to endorse or promote products derived from
michael@0 758 +// this software without specific prior written permission.
michael@0 759 +//
michael@0 760 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 761 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 762 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 763 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 764 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 765 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 766 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 767 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 768 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 769 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 770 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 771 +
michael@0 772 +// pathname_stripper.cc: Manipulates pathnames into their component parts.
michael@0 773 +//
michael@0 774 +// See pathname_stripper.h for documentation.
michael@0 775 +//
michael@0 776 +// Author: Mark Mentovai
michael@0 777 +
michael@0 778 +#include "common/pathname_stripper.h"
michael@0 779 +
michael@0 780 +namespace google_breakpad {
michael@0 781 +
michael@0 782 +// static
michael@0 783 +string PathnameStripper::File(const string &path) {
michael@0 784 + string::size_type slash = path.rfind('/');
michael@0 785 + string::size_type backslash = path.rfind('\\');
michael@0 786 +
michael@0 787 + string::size_type file_start = 0;
michael@0 788 + if (slash != string::npos &&
michael@0 789 + (backslash == string::npos || slash > backslash)) {
michael@0 790 + file_start = slash + 1;
michael@0 791 + } else if (backslash != string::npos) {
michael@0 792 + file_start = backslash + 1;
michael@0 793 + }
michael@0 794 +
michael@0 795 + return path.substr(file_start);
michael@0 796 +}
michael@0 797 +
michael@0 798 +} // namespace google_breakpad
michael@0 799 diff --git -r 85dd7094b78d -r 636cfcab9682 src/common/pathname_stripper.h
michael@0 800 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 801 +++ b/src/common/pathname_stripper.h Thu Mar 28 18:06:39 2013 +0100
michael@0 802 @@ -0,0 +1,53 @@
michael@0 803 +// Copyright (c) 2006, Google Inc.
michael@0 804 +// All rights reserved.
michael@0 805 +//
michael@0 806 +// Redistribution and use in source and binary forms, with or without
michael@0 807 +// modification, are permitted provided that the following conditions are
michael@0 808 +// met:
michael@0 809 +//
michael@0 810 +// * Redistributions of source code must retain the above copyright
michael@0 811 +// notice, this list of conditions and the following disclaimer.
michael@0 812 +// * Redistributions in binary form must reproduce the above
michael@0 813 +// copyright notice, this list of conditions and the following disclaimer
michael@0 814 +// in the documentation and/or other materials provided with the
michael@0 815 +// distribution.
michael@0 816 +// * Neither the name of Google Inc. nor the names of its
michael@0 817 +// contributors may be used to endorse or promote products derived from
michael@0 818 +// this software without specific prior written permission.
michael@0 819 +//
michael@0 820 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 821 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 822 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 823 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 824 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 825 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 826 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 827 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 828 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 829 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 830 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 831 +
michael@0 832 +// pathname_stripper.h: Manipulates pathnames into their component parts.
michael@0 833 +//
michael@0 834 +// Author: Mark Mentovai
michael@0 835 +
michael@0 836 +#ifndef PROCESSOR_PATHNAME_STRIPPER_H__
michael@0 837 +#define PROCESSOR_PATHNAME_STRIPPER_H__
michael@0 838 +
michael@0 839 +#include <string>
michael@0 840 +
michael@0 841 +#include "common/using_std_string.h"
michael@0 842 +
michael@0 843 +namespace google_breakpad {
michael@0 844 +
michael@0 845 +class PathnameStripper {
michael@0 846 + public:
michael@0 847 + // Given path, a pathname with components separated by slashes (/) or
michael@0 848 + // backslashes (\), returns the trailing component, without any separator.
michael@0 849 + // If path ends in a separator character, returns an empty string.
michael@0 850 + static string File(const string &path);
michael@0 851 +};
michael@0 852 +
michael@0 853 +} // namespace google_breakpad
michael@0 854 +
michael@0 855 +#endif // PROCESSOR_PATHNAME_STRIPPER_H__
michael@0 856 diff --git -r 85dd7094b78d -r 636cfcab9682 src/common/pathname_stripper_unittest.cc
michael@0 857 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 858 +++ b/src/common/pathname_stripper_unittest.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 859 @@ -0,0 +1,87 @@
michael@0 860 +// Copyright (c) 2006, Google Inc.
michael@0 861 +// All rights reserved.
michael@0 862 +//
michael@0 863 +// Redistribution and use in source and binary forms, with or without
michael@0 864 +// modification, are permitted provided that the following conditions are
michael@0 865 +// met:
michael@0 866 +//
michael@0 867 +// * Redistributions of source code must retain the above copyright
michael@0 868 +// notice, this list of conditions and the following disclaimer.
michael@0 869 +// * Redistributions in binary form must reproduce the above
michael@0 870 +// copyright notice, this list of conditions and the following disclaimer
michael@0 871 +// in the documentation and/or other materials provided with the
michael@0 872 +// distribution.
michael@0 873 +// * Neither the name of Google Inc. nor the names of its
michael@0 874 +// contributors may be used to endorse or promote products derived from
michael@0 875 +// this software without specific prior written permission.
michael@0 876 +//
michael@0 877 +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 878 +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 879 +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 880 +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 881 +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 882 +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 883 +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 884 +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 885 +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 886 +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 887 +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 888 +
michael@0 889 +#include <stdio.h>
michael@0 890 +
michael@0 891 +#include "processor/pathname_stripper.h"
michael@0 892 +#include "processor/logging.h"
michael@0 893 +
michael@0 894 +#define ASSERT_TRUE(condition) \
michael@0 895 + if (!(condition)) { \
michael@0 896 + fprintf(stderr, "FAIL: %s @ %s:%d\n", #condition, __FILE__, __LINE__); \
michael@0 897 + return false; \
michael@0 898 + }
michael@0 899 +
michael@0 900 +#define ASSERT_EQ(e1, e2) ASSERT_TRUE((e1) == (e2))
michael@0 901 +
michael@0 902 +namespace {
michael@0 903 +
michael@0 904 +using google_breakpad::PathnameStripper;
michael@0 905 +
michael@0 906 +static bool RunTests() {
michael@0 907 + ASSERT_EQ(PathnameStripper::File("/dir/file"), "file");
michael@0 908 + ASSERT_EQ(PathnameStripper::File("\\dir\\file"), "file");
michael@0 909 + ASSERT_EQ(PathnameStripper::File("/dir\\file"), "file");
michael@0 910 + ASSERT_EQ(PathnameStripper::File("\\dir/file"), "file");
michael@0 911 + ASSERT_EQ(PathnameStripper::File("dir/file"), "file");
michael@0 912 + ASSERT_EQ(PathnameStripper::File("dir\\file"), "file");
michael@0 913 + ASSERT_EQ(PathnameStripper::File("dir/\\file"), "file");
michael@0 914 + ASSERT_EQ(PathnameStripper::File("dir\\/file"), "file");
michael@0 915 + ASSERT_EQ(PathnameStripper::File("file"), "file");
michael@0 916 + ASSERT_EQ(PathnameStripper::File("dir/"), "");
michael@0 917 + ASSERT_EQ(PathnameStripper::File("dir\\"), "");
michael@0 918 + ASSERT_EQ(PathnameStripper::File("dir/dir/"), "");
michael@0 919 + ASSERT_EQ(PathnameStripper::File("dir\\dir\\"), "");
michael@0 920 + ASSERT_EQ(PathnameStripper::File("dir1/dir2/file"), "file");
michael@0 921 + ASSERT_EQ(PathnameStripper::File("dir1\\dir2\\file"), "file");
michael@0 922 + ASSERT_EQ(PathnameStripper::File("dir1/dir2\\file"), "file");
michael@0 923 + ASSERT_EQ(PathnameStripper::File("dir1\\dir2/file"), "file");
michael@0 924 + ASSERT_EQ(PathnameStripper::File(""), "");
michael@0 925 + ASSERT_EQ(PathnameStripper::File("1"), "1");
michael@0 926 + ASSERT_EQ(PathnameStripper::File("1/2"), "2");
michael@0 927 + ASSERT_EQ(PathnameStripper::File("1\\2"), "2");
michael@0 928 + ASSERT_EQ(PathnameStripper::File("/1/2"), "2");
michael@0 929 + ASSERT_EQ(PathnameStripper::File("\\1\\2"), "2");
michael@0 930 + ASSERT_EQ(PathnameStripper::File("dir//file"), "file");
michael@0 931 + ASSERT_EQ(PathnameStripper::File("dir\\\\file"), "file");
michael@0 932 + ASSERT_EQ(PathnameStripper::File("/dir//file"), "file");
michael@0 933 + ASSERT_EQ(PathnameStripper::File("\\dir\\\\file"), "file");
michael@0 934 + ASSERT_EQ(PathnameStripper::File("c:\\dir\\file"), "file");
michael@0 935 + ASSERT_EQ(PathnameStripper::File("c:\\dir\\file.ext"), "file.ext");
michael@0 936 +
michael@0 937 + return true;
michael@0 938 +}
michael@0 939 +
michael@0 940 +} // namespace
michael@0 941 +
michael@0 942 +int main(int argc, char **argv) {
michael@0 943 + BPLOG_INIT(&argc, &argv);
michael@0 944 +
michael@0 945 + return RunTests() ? 0 : 1;
michael@0 946 +}
michael@0 947 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/Makefile.in
michael@0 948 --- a/src/processor/Makefile.in Thu Mar 28 18:38:05 2013 +0100
michael@0 949 +++ b/src/processor/Makefile.in Thu Mar 28 18:06:39 2013 +0100
michael@0 950 @@ -5,44 +5,32 @@
michael@0 951 DEPTH = @DEPTH@
michael@0 952 topsrcdir = @top_srcdir@
michael@0 953 srcdir = @srcdir@
michael@0 954 VPATH = @srcdir@
michael@0 955
michael@0 956 include $(DEPTH)/config/autoconf.mk
michael@0 957
michael@0 958 LIBRARY_NAME = breakpad_sps_common_s
michael@0 959 -ifdef MOZ_CRASHREPORTER
michael@0 960 -HOST_LIBRARY_NAME = host_breakpad_sps_common_s
michael@0 961 -endif
michael@0 962
michael@0 963 LOCAL_INCLUDES = -I$(srcdir)/../.. -I$(srcdir)/..
michael@0 964
michael@0 965 CPPSRCS = \
michael@0 966 stackwalker.cc \
michael@0 967 stackwalker_amd64.cc \
michael@0 968 stackwalker_arm.cc \
michael@0 969 stackwalker_ppc.cc \
michael@0 970 stackwalker_x86.cc \
michael@0 971 stackwalker_sparc.cc \
michael@0 972 minidump.cc \
michael@0 973 basic_source_line_resolver.cc \
michael@0 974 basic_code_modules.cc \
michael@0 975 cfi_frame_info.cc \
michael@0 976 call_stack.cc \
michael@0 977 - logging.cc \
michael@0 978 - pathname_stripper.cc \
michael@0 979 tokenize.cc \
michael@0 980 source_line_resolver_base.cc \
michael@0 981 stack_frame_symbolizer.cc \
michael@0 982 $(NULL)
michael@0 983
michael@0 984 -ifdef MOZ_CRASHREPORTER
michael@0 985 -HOST_CPPSRCS = \
michael@0 986 - logging.cc \
michael@0 987 - pathname_stripper.cc \
michael@0 988 - $(NULL)
michael@0 989 -endif
michael@0 990 -
michael@0 991 # need static lib
michael@0 992 FORCE_STATIC_LIB = 1
michael@0 993
michael@0 994 include $(topsrcdir)/config/rules.mk
michael@0 995 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/address_map-inl.h
michael@0 996 --- a/src/processor/address_map-inl.h Thu Mar 28 18:38:05 2013 +0100
michael@0 997 +++ b/src/processor/address_map-inl.h Thu Mar 28 18:06:39 2013 +0100
michael@0 998 @@ -35,17 +35,17 @@
michael@0 999
michael@0 1000 #ifndef PROCESSOR_ADDRESS_MAP_INL_H__
michael@0 1001 #define PROCESSOR_ADDRESS_MAP_INL_H__
michael@0 1002
michael@0 1003 #include "processor/address_map.h"
michael@0 1004
michael@0 1005 #include <assert.h>
michael@0 1006
michael@0 1007 -#include "processor/logging.h"
michael@0 1008 +#include "common/logging.h"
michael@0 1009
michael@0 1010 namespace google_breakpad {
michael@0 1011
michael@0 1012 template<typename AddressType, typename EntryType>
michael@0 1013 bool AddressMap<AddressType, EntryType>::Store(const AddressType &address,
michael@0 1014 const EntryType &entry) {
michael@0 1015 // Ensure that the specified address doesn't conflict with something already
michael@0 1016 // in the map.
michael@0 1017 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/basic_code_modules.cc
michael@0 1018 --- a/src/processor/basic_code_modules.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1019 +++ b/src/processor/basic_code_modules.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 1020 @@ -35,17 +35,17 @@
michael@0 1021 // Author: Mark Mentovai
michael@0 1022
michael@0 1023 #include "processor/basic_code_modules.h"
michael@0 1024
michael@0 1025 #include <assert.h>
michael@0 1026
michael@0 1027 #include "google_breakpad/processor/code_module.h"
michael@0 1028 #include "processor/linked_ptr.h"
michael@0 1029 -#include "processor/logging.h"
michael@0 1030 +#include "common/logging.h"
michael@0 1031 #include "processor/range_map-inl.h"
michael@0 1032
michael@0 1033 namespace google_breakpad {
michael@0 1034
michael@0 1035 BasicCodeModules::BasicCodeModules(const CodeModules *that)
michael@0 1036 : main_address_(0),
michael@0 1037 map_(new RangeMap<uint64_t, linked_ptr<const CodeModule> >()) {
michael@0 1038 BPLOG_IF(ERROR, !that) << "BasicCodeModules::BasicCodeModules requires "
michael@0 1039 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/contained_range_map-inl.h
michael@0 1040 --- a/src/processor/contained_range_map-inl.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1041 +++ b/src/processor/contained_range_map-inl.h Thu Mar 28 18:06:39 2013 +0100
michael@0 1042 @@ -35,17 +35,17 @@
michael@0 1043
michael@0 1044 #ifndef PROCESSOR_CONTAINED_RANGE_MAP_INL_H__
michael@0 1045 #define PROCESSOR_CONTAINED_RANGE_MAP_INL_H__
michael@0 1046
michael@0 1047 #include "processor/contained_range_map.h"
michael@0 1048
michael@0 1049 #include <assert.h>
michael@0 1050
michael@0 1051 -#include "processor/logging.h"
michael@0 1052 +#include "common/logging.h"
michael@0 1053
michael@0 1054
michael@0 1055 namespace google_breakpad {
michael@0 1056
michael@0 1057
michael@0 1058 template<typename AddressType, typename EntryType>
michael@0 1059 ContainedRangeMap<AddressType, EntryType>::~ContainedRangeMap() {
michael@0 1060 // Clear frees the children pointed to by the map, and frees the map itself.
michael@0 1061 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/logging.cc
michael@0 1062 --- a/src/processor/logging.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1063 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 1064 @@ -1,115 +0,0 @@
michael@0 1065 -// Copyright (c) 2007, Google Inc.
michael@0 1066 -// All rights reserved.
michael@0 1067 -//
michael@0 1068 -// Redistribution and use in source and binary forms, with or without
michael@0 1069 -// modification, are permitted provided that the following conditions are
michael@0 1070 -// met:
michael@0 1071 -//
michael@0 1072 -// * Redistributions of source code must retain the above copyright
michael@0 1073 -// notice, this list of conditions and the following disclaimer.
michael@0 1074 -// * Redistributions in binary form must reproduce the above
michael@0 1075 -// copyright notice, this list of conditions and the following disclaimer
michael@0 1076 -// in the documentation and/or other materials provided with the
michael@0 1077 -// distribution.
michael@0 1078 -// * Neither the name of Google Inc. nor the names of its
michael@0 1079 -// contributors may be used to endorse or promote products derived from
michael@0 1080 -// this software without specific prior written permission.
michael@0 1081 -//
michael@0 1082 -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 1083 -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 1084 -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 1085 -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 1086 -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 1087 -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 1088 -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 1089 -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 1090 -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 1091 -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 1092 -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 1093 -
michael@0 1094 -// logging.cc: Breakpad logging
michael@0 1095 -//
michael@0 1096 -// See logging.h for documentation.
michael@0 1097 -//
michael@0 1098 -// Author: Mark Mentovai
michael@0 1099 -
michael@0 1100 -#include <assert.h>
michael@0 1101 -#include <errno.h>
michael@0 1102 -#include <stdio.h>
michael@0 1103 -#include <string.h>
michael@0 1104 -#include <time.h>
michael@0 1105 -
michael@0 1106 -#include <string>
michael@0 1107 -
michael@0 1108 -#include "common/using_std_string.h"
michael@0 1109 -#include "processor/logging.h"
michael@0 1110 -#include "processor/pathname_stripper.h"
michael@0 1111 -
michael@0 1112 -#ifdef _WIN32
michael@0 1113 -#define snprintf _snprintf
michael@0 1114 -#endif
michael@0 1115 -
michael@0 1116 -namespace google_breakpad {
michael@0 1117 -
michael@0 1118 -LogStream::LogStream(std::ostream &stream, Severity severity,
michael@0 1119 - const char *file, int line)
michael@0 1120 - : stream_(stream) {
michael@0 1121 - time_t clock;
michael@0 1122 - time(&clock);
michael@0 1123 - struct tm tm_struct;
michael@0 1124 -#ifdef _WIN32
michael@0 1125 - localtime_s(&tm_struct, &clock);
michael@0 1126 -#else
michael@0 1127 - localtime_r(&clock, &tm_struct);
michael@0 1128 -#endif
michael@0 1129 - char time_string[20];
michael@0 1130 - strftime(time_string, sizeof(time_string), "%Y-%m-%d %H:%M:%S", &tm_struct);
michael@0 1131 -
michael@0 1132 - const char *severity_string = "UNKNOWN_SEVERITY";
michael@0 1133 - switch (severity) {
michael@0 1134 - case SEVERITY_INFO:
michael@0 1135 - severity_string = "INFO";
michael@0 1136 - break;
michael@0 1137 - case SEVERITY_ERROR:
michael@0 1138 - severity_string = "ERROR";
michael@0 1139 - break;
michael@0 1140 - }
michael@0 1141 -
michael@0 1142 - stream_ << time_string << ": " << PathnameStripper::File(file) << ":" <<
michael@0 1143 - line << ": " << severity_string << ": ";
michael@0 1144 -}
michael@0 1145 -
michael@0 1146 -LogStream::~LogStream() {
michael@0 1147 - stream_ << std::endl;
michael@0 1148 -}
michael@0 1149 -
michael@0 1150 -string HexString(uint32_t number) {
michael@0 1151 - char buffer[11];
michael@0 1152 - snprintf(buffer, sizeof(buffer), "0x%x", number);
michael@0 1153 - return string(buffer);
michael@0 1154 -}
michael@0 1155 -
michael@0 1156 -string HexString(uint64_t number) {
michael@0 1157 - char buffer[19];
michael@0 1158 - snprintf(buffer, sizeof(buffer), "0x%" PRIx64, number);
michael@0 1159 - return string(buffer);
michael@0 1160 -}
michael@0 1161 -
michael@0 1162 -string HexString(int number) {
michael@0 1163 - char buffer[19];
michael@0 1164 - snprintf(buffer, sizeof(buffer), "0x%x", number);
michael@0 1165 - return string(buffer);
michael@0 1166 -}
michael@0 1167 -
michael@0 1168 -int ErrnoString(string *error_string) {
michael@0 1169 - assert(error_string);
michael@0 1170 -
michael@0 1171 - // strerror isn't necessarily thread-safe. strerror_r would be preferrable,
michael@0 1172 - // but GNU libc uses a nonstandard strerror_r by default, which returns a
michael@0 1173 - // char* (rather than an int success indicator) and doesn't necessarily
michael@0 1174 - // use the supplied buffer.
michael@0 1175 - error_string->assign(strerror(errno));
michael@0 1176 - return errno;
michael@0 1177 -}
michael@0 1178 -
michael@0 1179 -} // namespace google_breakpad
michael@0 1180 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/logging.h
michael@0 1181 --- a/src/processor/logging.h Thu Apr 04 21:00:31 2013 +0200
michael@0 1182 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 1183 @@ -1,175 +0,0 @@
michael@0 1184 -// Copyright (c) 2007, Google Inc.
michael@0 1185 -// All rights reserved.
michael@0 1186 -//
michael@0 1187 -// Redistribution and use in source and binary forms, with or without
michael@0 1188 -// modification, are permitted provided that the following conditions are
michael@0 1189 -// met:
michael@0 1190 -//
michael@0 1191 -// * Redistributions of source code must retain the above copyright
michael@0 1192 -// notice, this list of conditions and the following disclaimer.
michael@0 1193 -// * Redistributions in binary form must reproduce the above
michael@0 1194 -// copyright notice, this list of conditions and the following disclaimer
michael@0 1195 -// in the documentation and/or other materials provided with the
michael@0 1196 -// distribution.
michael@0 1197 -// * Neither the name of Google Inc. nor the names of its
michael@0 1198 -// contributors may be used to endorse or promote products derived from
michael@0 1199 -// this software without specific prior written permission.
michael@0 1200 -//
michael@0 1201 -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 1202 -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 1203 -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 1204 -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 1205 -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 1206 -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 1207 -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 1208 -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 1209 -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 1210 -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 1211 -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 1212 -
michael@0 1213 -// logging.h: Breakpad logging
michael@0 1214 -//
michael@0 1215 -// Breakpad itself uses Breakpad logging with statements of the form:
michael@0 1216 -// BPLOG(severity) << "message";
michael@0 1217 -// severity may be INFO, ERROR, or other values defined in this file.
michael@0 1218 -//
michael@0 1219 -// BPLOG is an overridable macro so that users can customize Breakpad's
michael@0 1220 -// logging. Left at the default, logging messages are sent to stderr along
michael@0 1221 -// with a timestamp and the source code location that produced a message.
michael@0 1222 -// The streams may be changed by redefining BPLOG_*_STREAM, the logging
michael@0 1223 -// behavior may be changed by redefining BPLOG_*, and the entire logging
michael@0 1224 -// system may be overridden by redefining BPLOG(severity). These
michael@0 1225 -// redefinitions may be passed to the preprocessor as a command-line flag
michael@0 1226 -// (-D).
michael@0 1227 -//
michael@0 1228 -// If an additional header is required to override Breakpad logging, it can
michael@0 1229 -// be specified by the BP_LOGGING_INCLUDE macro. If defined, this header
michael@0 1230 -// will #include the header specified by that macro.
michael@0 1231 -//
michael@0 1232 -// If any initialization is needed before logging, it can be performed by
michael@0 1233 -// a function called through the BPLOG_INIT macro. Each main function of
michael@0 1234 -// an executable program in the Breakpad processor library calls
michael@0 1235 -// BPLOG_INIT(&argc, &argv); before any logging can be performed; define
michael@0 1236 -// BPLOG_INIT appropriately if initialization is required.
michael@0 1237 -//
michael@0 1238 -// Author: Mark Mentovai
michael@0 1239 -
michael@0 1240 -#ifndef PROCESSOR_LOGGING_H__
michael@0 1241 -#define PROCESSOR_LOGGING_H__
michael@0 1242 -
michael@0 1243 -#include <iostream>
michael@0 1244 -#include <string>
michael@0 1245 -
michael@0 1246 -#include "common/using_std_string.h"
michael@0 1247 -#include "google_breakpad/common/breakpad_types.h"
michael@0 1248 -
michael@0 1249 -#ifdef BP_LOGGING_INCLUDE
michael@0 1250 -#include BP_LOGGING_INCLUDE
michael@0 1251 -#endif // BP_LOGGING_INCLUDE
michael@0 1252 -
michael@0 1253 -#ifndef THIRD_PARTY_BREAKPAD_GOOGLE_GLUE_LOGGING_H_
michael@0 1254 -namespace base_logging {
michael@0 1255 -
michael@0 1256 -// The open-source copy of logging.h has diverged from Google's internal copy
michael@0 1257 -// (temporarily, at least). To support the transition to structured logging
michael@0 1258 -// a definition for base_logging::LogMessage is needed, which is a ostream-
michael@0 1259 -// like object for streaming arguments to construct a log message.
michael@0 1260 -typedef std::ostream LogMessage;
michael@0 1261 -
michael@0 1262 -} // namespace base_logging
michael@0 1263 -#endif // THIRD_PARTY_BREAKPAD_GOOGLE_GLUE_LOGGING_H_
michael@0 1264 -
michael@0 1265 -namespace google_breakpad {
michael@0 1266 -
michael@0 1267 -// These are defined in Microsoft headers.
michael@0 1268 -#ifdef SEVERITY_ERROR
michael@0 1269 -#undef SEVERITY_ERROR
michael@0 1270 -#endif
michael@0 1271 -
michael@0 1272 -#ifdef ERROR
michael@0 1273 -#undef ERROR
michael@0 1274 -#endif
michael@0 1275 -
michael@0 1276 -class LogStream {
michael@0 1277 - public:
michael@0 1278 - enum Severity {
michael@0 1279 - SEVERITY_INFO,
michael@0 1280 - SEVERITY_ERROR
michael@0 1281 - };
michael@0 1282 -
michael@0 1283 - // Begin logging a message to the stream identified by |stream|, at the
michael@0 1284 - // indicated severity. The file and line parameters should be set so as to
michael@0 1285 - // identify the line of source code that is producing a message.
michael@0 1286 - LogStream(std::ostream &stream, Severity severity,
michael@0 1287 - const char *file, int line);
michael@0 1288 -
michael@0 1289 - // Finish logging by printing a newline and flushing the output stream.
michael@0 1290 - ~LogStream();
michael@0 1291 -
michael@0 1292 - template<typename T> std::ostream& operator<<(const T &t) {
michael@0 1293 - return stream_ << t;
michael@0 1294 - }
michael@0 1295 -
michael@0 1296 - private:
michael@0 1297 - std::ostream &stream_;
michael@0 1298 -
michael@0 1299 - // Disallow copy constructor and assignment operator
michael@0 1300 - explicit LogStream(const LogStream &that);
michael@0 1301 - void operator=(const LogStream &that);
michael@0 1302 -};
michael@0 1303 -
michael@0 1304 -// This class is used to explicitly ignore values in the conditional logging
michael@0 1305 -// macros. This avoids compiler warnings like "value computed is not used"
michael@0 1306 -// and "statement has no effect".
michael@0 1307 -class LogMessageVoidify {
michael@0 1308 - public:
michael@0 1309 - LogMessageVoidify() {}
michael@0 1310 -
michael@0 1311 - // This has to be an operator with a precedence lower than << but higher
michael@0 1312 - // than ?:
michael@0 1313 - void operator&(base_logging::LogMessage &) {}
michael@0 1314 -};
michael@0 1315 -
michael@0 1316 -// Returns number formatted as a hexadecimal string, such as "0x7b".
michael@0 1317 -string HexString(uint32_t number);
michael@0 1318 -string HexString(uint64_t number);
michael@0 1319 -string HexString(int number);
michael@0 1320 -
michael@0 1321 -// Returns the error code as set in the global errno variable, and sets
michael@0 1322 -// error_string, a required argument, to a string describing that error
michael@0 1323 -// code.
michael@0 1324 -int ErrnoString(string *error_string);
michael@0 1325 -
michael@0 1326 -} // namespace google_breakpad
michael@0 1327 -
michael@0 1328 -#ifndef BPLOG_INIT
michael@0 1329 -#define BPLOG_INIT(pargc, pargv)
michael@0 1330 -#endif // BPLOG_INIT
michael@0 1331 -
michael@0 1332 -#ifndef BPLOG
michael@0 1333 -#define BPLOG(severity) BPLOG_ ## severity
michael@0 1334 -#endif // BPLOG
michael@0 1335 -
michael@0 1336 -#ifndef BPLOG_INFO
michael@0 1337 -#ifndef BPLOG_INFO_STREAM
michael@0 1338 -#define BPLOG_INFO_STREAM std::clog
michael@0 1339 -#endif // BPLOG_INFO_STREAM
michael@0 1340 -#define BPLOG_INFO google_breakpad::LogStream(BPLOG_INFO_STREAM, \
michael@0 1341 - google_breakpad::LogStream::SEVERITY_INFO, \
michael@0 1342 - __FILE__, __LINE__)
michael@0 1343 -#endif // BPLOG_INFO
michael@0 1344 -
michael@0 1345 -#ifndef BPLOG_ERROR
michael@0 1346 -#ifndef BPLOG_ERROR_STREAM
michael@0 1347 -#define BPLOG_ERROR_STREAM std::cerr
michael@0 1348 -#endif // BPLOG_ERROR_STREAM
michael@0 1349 -#define BPLOG_ERROR google_breakpad::LogStream(BPLOG_ERROR_STREAM, \
michael@0 1350 - google_breakpad::LogStream::SEVERITY_ERROR, \
michael@0 1351 - __FILE__, __LINE__)
michael@0 1352 -#endif // BPLOG_ERROR
michael@0 1353 -
michael@0 1354 -#define BPLOG_IF(severity, condition) \
michael@0 1355 - !(condition) ? (void) 0 : \
michael@0 1356 - google_breakpad::LogMessageVoidify() & BPLOG(severity)
michael@0 1357 -
michael@0 1358 -#endif // PROCESSOR_LOGGING_H__
michael@0 1359 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/minidump.cc
michael@0 1360 --- a/src/processor/minidump.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1361 +++ b/src/processor/minidump.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 1362 @@ -58,17 +58,17 @@
michael@0 1363 #include <map>
michael@0 1364 #include <vector>
michael@0 1365
michael@0 1366 #include "processor/range_map-inl.h"
michael@0 1367
michael@0 1368 #include "common/scoped_ptr.h"
michael@0 1369 #include "processor/basic_code_module.h"
michael@0 1370 #include "processor/basic_code_modules.h"
michael@0 1371 -#include "processor/logging.h"
michael@0 1372 +#include "common/logging.h"
michael@0 1373
michael@0 1374
michael@0 1375
michael@0 1376 namespace google_breakpad {
michael@0 1377
michael@0 1378
michael@0 1379 using std::istream;
michael@0 1380 using std::ifstream;
michael@0 1381 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/pathname_stripper.cc
michael@0 1382 --- a/src/processor/pathname_stripper.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1383 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 1384 @@ -1,56 +0,0 @@
michael@0 1385 -// Copyright (c) 2006, Google Inc.
michael@0 1386 -// All rights reserved.
michael@0 1387 -//
michael@0 1388 -// Redistribution and use in source and binary forms, with or without
michael@0 1389 -// modification, are permitted provided that the following conditions are
michael@0 1390 -// met:
michael@0 1391 -//
michael@0 1392 -// * Redistributions of source code must retain the above copyright
michael@0 1393 -// notice, this list of conditions and the following disclaimer.
michael@0 1394 -// * Redistributions in binary form must reproduce the above
michael@0 1395 -// copyright notice, this list of conditions and the following disclaimer
michael@0 1396 -// in the documentation and/or other materials provided with the
michael@0 1397 -// distribution.
michael@0 1398 -// * Neither the name of Google Inc. nor the names of its
michael@0 1399 -// contributors may be used to endorse or promote products derived from
michael@0 1400 -// this software without specific prior written permission.
michael@0 1401 -//
michael@0 1402 -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 1403 -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 1404 -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 1405 -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 1406 -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 1407 -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 1408 -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 1409 -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 1410 -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 1411 -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 1412 -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 1413 -
michael@0 1414 -// pathname_stripper.cc: Manipulates pathnames into their component parts.
michael@0 1415 -//
michael@0 1416 -// See pathname_stripper.h for documentation.
michael@0 1417 -//
michael@0 1418 -// Author: Mark Mentovai
michael@0 1419 -
michael@0 1420 -#include "processor/pathname_stripper.h"
michael@0 1421 -
michael@0 1422 -namespace google_breakpad {
michael@0 1423 -
michael@0 1424 -// static
michael@0 1425 -string PathnameStripper::File(const string &path) {
michael@0 1426 - string::size_type slash = path.rfind('/');
michael@0 1427 - string::size_type backslash = path.rfind('\\');
michael@0 1428 -
michael@0 1429 - string::size_type file_start = 0;
michael@0 1430 - if (slash != string::npos &&
michael@0 1431 - (backslash == string::npos || slash > backslash)) {
michael@0 1432 - file_start = slash + 1;
michael@0 1433 - } else if (backslash != string::npos) {
michael@0 1434 - file_start = backslash + 1;
michael@0 1435 - }
michael@0 1436 -
michael@0 1437 - return path.substr(file_start);
michael@0 1438 -}
michael@0 1439 -
michael@0 1440 -} // namespace google_breakpad
michael@0 1441 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/pathname_stripper.h
michael@0 1442 --- a/src/processor/pathname_stripper.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1443 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 1444 @@ -1,53 +0,0 @@
michael@0 1445 -// Copyright (c) 2006, Google Inc.
michael@0 1446 -// All rights reserved.
michael@0 1447 -//
michael@0 1448 -// Redistribution and use in source and binary forms, with or without
michael@0 1449 -// modification, are permitted provided that the following conditions are
michael@0 1450 -// met:
michael@0 1451 -//
michael@0 1452 -// * Redistributions of source code must retain the above copyright
michael@0 1453 -// notice, this list of conditions and the following disclaimer.
michael@0 1454 -// * Redistributions in binary form must reproduce the above
michael@0 1455 -// copyright notice, this list of conditions and the following disclaimer
michael@0 1456 -// in the documentation and/or other materials provided with the
michael@0 1457 -// distribution.
michael@0 1458 -// * Neither the name of Google Inc. nor the names of its
michael@0 1459 -// contributors may be used to endorse or promote products derived from
michael@0 1460 -// this software without specific prior written permission.
michael@0 1461 -//
michael@0 1462 -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 1463 -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 1464 -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 1465 -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 1466 -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 1467 -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 1468 -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 1469 -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 1470 -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 1471 -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 1472 -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 1473 -
michael@0 1474 -// pathname_stripper.h: Manipulates pathnames into their component parts.
michael@0 1475 -//
michael@0 1476 -// Author: Mark Mentovai
michael@0 1477 -
michael@0 1478 -#ifndef PROCESSOR_PATHNAME_STRIPPER_H__
michael@0 1479 -#define PROCESSOR_PATHNAME_STRIPPER_H__
michael@0 1480 -
michael@0 1481 -#include <string>
michael@0 1482 -
michael@0 1483 -#include "common/using_std_string.h"
michael@0 1484 -
michael@0 1485 -namespace google_breakpad {
michael@0 1486 -
michael@0 1487 -class PathnameStripper {
michael@0 1488 - public:
michael@0 1489 - // Given path, a pathname with components separated by slashes (/) or
michael@0 1490 - // backslashes (\), returns the trailing component, without any separator.
michael@0 1491 - // If path ends in a separator character, returns an empty string.
michael@0 1492 - static string File(const string &path);
michael@0 1493 -};
michael@0 1494 -
michael@0 1495 -} // namespace google_breakpad
michael@0 1496 -
michael@0 1497 -#endif // PROCESSOR_PATHNAME_STRIPPER_H__
michael@0 1498 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/pathname_stripper_unittest.cc
michael@0 1499 --- a/src/processor/pathname_stripper_unittest.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
michael@0 1501 @@ -1,87 +0,0 @@
michael@0 1502 -// Copyright (c) 2006, Google Inc.
michael@0 1503 -// All rights reserved.
michael@0 1504 -//
michael@0 1505 -// Redistribution and use in source and binary forms, with or without
michael@0 1506 -// modification, are permitted provided that the following conditions are
michael@0 1507 -// met:
michael@0 1508 -//
michael@0 1509 -// * Redistributions of source code must retain the above copyright
michael@0 1510 -// notice, this list of conditions and the following disclaimer.
michael@0 1511 -// * Redistributions in binary form must reproduce the above
michael@0 1512 -// copyright notice, this list of conditions and the following disclaimer
michael@0 1513 -// in the documentation and/or other materials provided with the
michael@0 1514 -// distribution.
michael@0 1515 -// * Neither the name of Google Inc. nor the names of its
michael@0 1516 -// contributors may be used to endorse or promote products derived from
michael@0 1517 -// this software without specific prior written permission.
michael@0 1518 -//
michael@0 1519 -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
michael@0 1520 -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
michael@0 1521 -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
michael@0 1522 -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
michael@0 1523 -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@0 1524 -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@0 1525 -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
michael@0 1526 -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
michael@0 1527 -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
michael@0 1528 -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
michael@0 1529 -// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
michael@0 1530 -
michael@0 1531 -#include <stdio.h>
michael@0 1532 -
michael@0 1533 -#include "processor/pathname_stripper.h"
michael@0 1534 -#include "processor/logging.h"
michael@0 1535 -
michael@0 1536 -#define ASSERT_TRUE(condition) \
michael@0 1537 - if (!(condition)) { \
michael@0 1538 - fprintf(stderr, "FAIL: %s @ %s:%d\n", #condition, __FILE__, __LINE__); \
michael@0 1539 - return false; \
michael@0 1540 - }
michael@0 1541 -
michael@0 1542 -#define ASSERT_EQ(e1, e2) ASSERT_TRUE((e1) == (e2))
michael@0 1543 -
michael@0 1544 -namespace {
michael@0 1545 -
michael@0 1546 -using google_breakpad::PathnameStripper;
michael@0 1547 -
michael@0 1548 -static bool RunTests() {
michael@0 1549 - ASSERT_EQ(PathnameStripper::File("/dir/file"), "file");
michael@0 1550 - ASSERT_EQ(PathnameStripper::File("\\dir\\file"), "file");
michael@0 1551 - ASSERT_EQ(PathnameStripper::File("/dir\\file"), "file");
michael@0 1552 - ASSERT_EQ(PathnameStripper::File("\\dir/file"), "file");
michael@0 1553 - ASSERT_EQ(PathnameStripper::File("dir/file"), "file");
michael@0 1554 - ASSERT_EQ(PathnameStripper::File("dir\\file"), "file");
michael@0 1555 - ASSERT_EQ(PathnameStripper::File("dir/\\file"), "file");
michael@0 1556 - ASSERT_EQ(PathnameStripper::File("dir\\/file"), "file");
michael@0 1557 - ASSERT_EQ(PathnameStripper::File("file"), "file");
michael@0 1558 - ASSERT_EQ(PathnameStripper::File("dir/"), "");
michael@0 1559 - ASSERT_EQ(PathnameStripper::File("dir\\"), "");
michael@0 1560 - ASSERT_EQ(PathnameStripper::File("dir/dir/"), "");
michael@0 1561 - ASSERT_EQ(PathnameStripper::File("dir\\dir\\"), "");
michael@0 1562 - ASSERT_EQ(PathnameStripper::File("dir1/dir2/file"), "file");
michael@0 1563 - ASSERT_EQ(PathnameStripper::File("dir1\\dir2\\file"), "file");
michael@0 1564 - ASSERT_EQ(PathnameStripper::File("dir1/dir2\\file"), "file");
michael@0 1565 - ASSERT_EQ(PathnameStripper::File("dir1\\dir2/file"), "file");
michael@0 1566 - ASSERT_EQ(PathnameStripper::File(""), "");
michael@0 1567 - ASSERT_EQ(PathnameStripper::File("1"), "1");
michael@0 1568 - ASSERT_EQ(PathnameStripper::File("1/2"), "2");
michael@0 1569 - ASSERT_EQ(PathnameStripper::File("1\\2"), "2");
michael@0 1570 - ASSERT_EQ(PathnameStripper::File("/1/2"), "2");
michael@0 1571 - ASSERT_EQ(PathnameStripper::File("\\1\\2"), "2");
michael@0 1572 - ASSERT_EQ(PathnameStripper::File("dir//file"), "file");
michael@0 1573 - ASSERT_EQ(PathnameStripper::File("dir\\\\file"), "file");
michael@0 1574 - ASSERT_EQ(PathnameStripper::File("/dir//file"), "file");
michael@0 1575 - ASSERT_EQ(PathnameStripper::File("\\dir\\\\file"), "file");
michael@0 1576 - ASSERT_EQ(PathnameStripper::File("c:\\dir\\file"), "file");
michael@0 1577 - ASSERT_EQ(PathnameStripper::File("c:\\dir\\file.ext"), "file.ext");
michael@0 1578 -
michael@0 1579 - return true;
michael@0 1580 -}
michael@0 1581 -
michael@0 1582 -} // namespace
michael@0 1583 -
michael@0 1584 -int main(int argc, char **argv) {
michael@0 1585 - BPLOG_INIT(&argc, &argv);
michael@0 1586 -
michael@0 1587 - return RunTests() ? 0 : 1;
michael@0 1588 -}
michael@0 1589 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/postfix_evaluator-inl.h
michael@0 1590 --- a/src/processor/postfix_evaluator-inl.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1591 +++ b/src/processor/postfix_evaluator-inl.h Thu Mar 28 18:06:39 2013 +0100
michael@0 1592 @@ -41,17 +41,17 @@
michael@0 1593
michael@0 1594 #include "processor/postfix_evaluator.h"
michael@0 1595
michael@0 1596 #include <stdio.h>
michael@0 1597
michael@0 1598 #include <sstream>
michael@0 1599
michael@0 1600 #include "google_breakpad/processor/memory_region.h"
michael@0 1601 -#include "processor/logging.h"
michael@0 1602 +#include "common/logging.h"
michael@0 1603
michael@0 1604 namespace google_breakpad {
michael@0 1605
michael@0 1606 using std::istringstream;
michael@0 1607 using std::ostringstream;
michael@0 1608
michael@0 1609
michael@0 1610 // A small class used in Evaluate to make sure to clean up the stack
michael@0 1611 @@ -147,17 +147,17 @@ bool PostfixEvaluator<ValueType>::Evalua
michael@0 1612 if (!memory_) {
michael@0 1613 BPLOG(ERROR) << "Attempt to dereference without memory: " <<
michael@0 1614 expression;
michael@0 1615 return false;
michael@0 1616 }
michael@0 1617
michael@0 1618 ValueType address;
michael@0 1619 if (!PopValue(&address)) {
michael@0 1620 - BPLOG(ERROR) << "Could not PopValue to get value to derefence: " <<
michael@0 1621 + BPLOG(ERROR) << "Could not PopValue to get value to dereference: " <<
michael@0 1622 expression;
michael@0 1623 return false;
michael@0 1624 }
michael@0 1625
michael@0 1626 ValueType value;
michael@0 1627 if (!memory_->GetMemoryAtAddress(address, &value)) {
michael@0 1628 BPLOG(ERROR) << "Could not dereference memory at address " <<
michael@0 1629 HexString(address) << ": " << expression;
michael@0 1630 @@ -305,18 +305,23 @@ bool PostfixEvaluator<ValueType>::Evalua
michael@0 1631 case Module::kExprSimple:
michael@0 1632 case Module::kExprSimpleMem: {
michael@0 1633 // Look up the base value
michael@0 1634 bool found = false;
michael@0 1635 ValueType v = dictionary_->get(&found, expr.ident_);
michael@0 1636 if (!found) {
michael@0 1637 // The identifier wasn't found in the dictionary. Don't imply any
michael@0 1638 // default value, just fail.
michael@0 1639 - BPLOG(INFO) << "Identifier " << FromUniqueString(expr.ident_)
michael@0 1640 - << " not in dictionary (kExprSimple{Mem})";
michael@0 1641 + static uint64_t n_complaints = 0; // This isn't threadsafe.
michael@0 1642 + n_complaints++;
michael@0 1643 + if (is_power_of_2(n_complaints)) {
michael@0 1644 + BPLOG(INFO) << "Identifier " << FromUniqueString(expr.ident_)
michael@0 1645 + << " not in dictionary (kExprSimple{Mem})"
michael@0 1646 + << " (shown " << n_complaints << " times)";
michael@0 1647 + }
michael@0 1648 return false;
michael@0 1649 }
michael@0 1650
michael@0 1651 // Form the sum
michael@0 1652 ValueType sum = v + (int64_t)expr.offset_;
michael@0 1653
michael@0 1654 // and dereference if necessary
michael@0 1655 if (expr.how_ == Module::kExprSimpleMem) {
michael@0 1656 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/range_map-inl.h
michael@0 1657 --- a/src/processor/range_map-inl.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1658 +++ b/src/processor/range_map-inl.h Thu Mar 28 18:06:39 2013 +0100
michael@0 1659 @@ -35,17 +35,17 @@
michael@0 1660
michael@0 1661 #ifndef PROCESSOR_RANGE_MAP_INL_H__
michael@0 1662 #define PROCESSOR_RANGE_MAP_INL_H__
michael@0 1663
michael@0 1664
michael@0 1665 #include <assert.h>
michael@0 1666
michael@0 1667 #include "processor/range_map.h"
michael@0 1668 -#include "processor/logging.h"
michael@0 1669 +#include "common/logging.h"
michael@0 1670
michael@0 1671
michael@0 1672 namespace google_breakpad {
michael@0 1673
michael@0 1674
michael@0 1675 template<typename AddressType, typename EntryType>
michael@0 1676 bool RangeMap<AddressType, EntryType>::StoreRange(const AddressType &base,
michael@0 1677 const AddressType &size,
michael@0 1678 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/stack_frame_symbolizer.cc
michael@0 1679 --- a/src/processor/stack_frame_symbolizer.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1680 +++ b/src/processor/stack_frame_symbolizer.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 1681 @@ -39,17 +39,17 @@
michael@0 1682 #include "common/scoped_ptr.h"
michael@0 1683 #include "google_breakpad/processor/code_module.h"
michael@0 1684 #include "google_breakpad/processor/code_modules.h"
michael@0 1685 #include "google_breakpad/processor/source_line_resolver_interface.h"
michael@0 1686 #include "google_breakpad/processor/stack_frame.h"
michael@0 1687 #include "google_breakpad/processor/symbol_supplier.h"
michael@0 1688 #include "google_breakpad/processor/system_info.h"
michael@0 1689 #include "processor/linked_ptr.h"
michael@0 1690 -#include "processor/logging.h"
michael@0 1691 +#include "common/logging.h"
michael@0 1692
michael@0 1693 namespace google_breakpad {
michael@0 1694
michael@0 1695 StackFrameSymbolizer::StackFrameSymbolizer(
michael@0 1696 SymbolSupplier* supplier,
michael@0 1697 SourceLineResolverInterface* resolver) : supplier_(supplier),
michael@0 1698 resolver_(resolver) { }
michael@0 1699
michael@0 1700 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/stackwalker.cc
michael@0 1701 --- a/src/processor/stackwalker.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1702 +++ b/src/processor/stackwalker.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 1703 @@ -41,17 +41,17 @@
michael@0 1704 #include "google_breakpad/processor/call_stack.h"
michael@0 1705 #include "google_breakpad/processor/code_module.h"
michael@0 1706 #include "google_breakpad/processor/code_modules.h"
michael@0 1707 #include "google_breakpad/processor/minidump.h"
michael@0 1708 #include "google_breakpad/processor/stack_frame.h"
michael@0 1709 #include "google_breakpad/processor/stack_frame_symbolizer.h"
michael@0 1710 #include "google_breakpad/processor/system_info.h"
michael@0 1711 #include "processor/linked_ptr.h"
michael@0 1712 -#include "processor/logging.h"
michael@0 1713 +#include "common/logging.h"
michael@0 1714 #include "processor/stackwalker_ppc.h"
michael@0 1715 #include "processor/stackwalker_sparc.h"
michael@0 1716 #include "processor/stackwalker_x86.h"
michael@0 1717 #include "processor/stackwalker_amd64.h"
michael@0 1718 #include "processor/stackwalker_arm.h"
michael@0 1719
michael@0 1720 namespace google_breakpad {
michael@0 1721
michael@0 1722 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/stackwalker_amd64.cc
michael@0 1723 --- a/src/processor/stackwalker_amd64.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1724 +++ b/src/processor/stackwalker_amd64.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 1725 @@ -36,17 +36,17 @@
michael@0 1726 #include <assert.h>
michael@0 1727
michael@0 1728 #include "common/scoped_ptr.h"
michael@0 1729 #include "google_breakpad/processor/call_stack.h"
michael@0 1730 #include "google_breakpad/processor/memory_region.h"
michael@0 1731 #include "google_breakpad/processor/source_line_resolver_interface.h"
michael@0 1732 #include "google_breakpad/processor/stack_frame_cpu.h"
michael@0 1733 #include "processor/cfi_frame_info.h"
michael@0 1734 -#include "processor/logging.h"
michael@0 1735 +#include "common/logging.h"
michael@0 1736 #include "processor/stackwalker_amd64.h"
michael@0 1737
michael@0 1738 namespace google_breakpad {
michael@0 1739
michael@0 1740
michael@0 1741 const StackwalkerAMD64::CFIWalker::RegisterSet
michael@0 1742 StackwalkerAMD64::cfi_register_map_[] = {
michael@0 1743 // It may seem like $rip and $rsp are callee-saves, because the callee is
michael@0 1744 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/stackwalker_arm.cc
michael@0 1745 --- a/src/processor/stackwalker_arm.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1746 +++ b/src/processor/stackwalker_arm.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 1747 @@ -36,17 +36,17 @@
michael@0 1748 #include <vector>
michael@0 1749
michael@0 1750 #include "common/scoped_ptr.h"
michael@0 1751 #include "google_breakpad/processor/call_stack.h"
michael@0 1752 #include "google_breakpad/processor/memory_region.h"
michael@0 1753 #include "google_breakpad/processor/source_line_resolver_interface.h"
michael@0 1754 #include "google_breakpad/processor/stack_frame_cpu.h"
michael@0 1755 #include "processor/cfi_frame_info.h"
michael@0 1756 -#include "processor/logging.h"
michael@0 1757 +#include "common/logging.h"
michael@0 1758 #include "processor/stackwalker_arm.h"
michael@0 1759
michael@0 1760 namespace google_breakpad {
michael@0 1761
michael@0 1762
michael@0 1763 StackwalkerARM::StackwalkerARM(const SystemInfo* system_info,
michael@0 1764 const MDRawContextARM* context,
michael@0 1765 int fp_register,
michael@0 1766 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/stackwalker_ppc.cc
michael@0 1767 --- a/src/processor/stackwalker_ppc.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1768 +++ b/src/processor/stackwalker_ppc.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 1769 @@ -33,17 +33,17 @@
michael@0 1770 //
michael@0 1771 // Author: Mark Mentovai
michael@0 1772
michael@0 1773
michael@0 1774 #include "processor/stackwalker_ppc.h"
michael@0 1775 #include "google_breakpad/processor/call_stack.h"
michael@0 1776 #include "google_breakpad/processor/memory_region.h"
michael@0 1777 #include "google_breakpad/processor/stack_frame_cpu.h"
michael@0 1778 -#include "processor/logging.h"
michael@0 1779 +#include "common/logging.h"
michael@0 1780
michael@0 1781 namespace google_breakpad {
michael@0 1782
michael@0 1783
michael@0 1784 StackwalkerPPC::StackwalkerPPC(const SystemInfo* system_info,
michael@0 1785 const MDRawContextPPC* context,
michael@0 1786 MemoryRegion* memory,
michael@0 1787 const CodeModules* modules,
michael@0 1788 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/stackwalker_sparc.cc
michael@0 1789 --- a/src/processor/stackwalker_sparc.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1790 +++ b/src/processor/stackwalker_sparc.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 1791 @@ -32,17 +32,17 @@
michael@0 1792 // See stackwalker_sparc.h for documentation.
michael@0 1793 //
michael@0 1794 // Author: Michael Shang
michael@0 1795
michael@0 1796
michael@0 1797 #include "google_breakpad/processor/call_stack.h"
michael@0 1798 #include "google_breakpad/processor/memory_region.h"
michael@0 1799 #include "google_breakpad/processor/stack_frame_cpu.h"
michael@0 1800 -#include "processor/logging.h"
michael@0 1801 +#include "common/logging.h"
michael@0 1802 #include "processor/stackwalker_sparc.h"
michael@0 1803
michael@0 1804 namespace google_breakpad {
michael@0 1805
michael@0 1806
michael@0 1807 StackwalkerSPARC::StackwalkerSPARC(const SystemInfo* system_info,
michael@0 1808 const MDRawContextSPARC* context,
michael@0 1809 MemoryRegion* memory,
michael@0 1810 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/stackwalker_x86.cc
michael@0 1811 --- a/src/processor/stackwalker_x86.cc Thu Mar 28 18:38:05 2013 +0100
michael@0 1812 +++ b/src/processor/stackwalker_x86.cc Thu Mar 28 18:06:39 2013 +0100
michael@0 1813 @@ -37,17 +37,17 @@
michael@0 1814 #include <string>
michael@0 1815
michael@0 1816 #include "common/scoped_ptr.h"
michael@0 1817 #include "google_breakpad/processor/call_stack.h"
michael@0 1818 #include "google_breakpad/processor/code_modules.h"
michael@0 1819 #include "google_breakpad/processor/memory_region.h"
michael@0 1820 #include "google_breakpad/processor/source_line_resolver_interface.h"
michael@0 1821 #include "google_breakpad/processor/stack_frame_cpu.h"
michael@0 1822 -#include "processor/logging.h"
michael@0 1823 +#include "common/logging.h"
michael@0 1824 #include "processor/postfix_evaluator-inl.h"
michael@0 1825 #include "processor/stackwalker_x86.h"
michael@0 1826 #include "processor/windows_frame_info.h"
michael@0 1827 #include "processor/cfi_frame_info.h"
michael@0 1828
michael@0 1829 namespace google_breakpad {
michael@0 1830
michael@0 1831
michael@0 1832 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/static_address_map-inl.h
michael@0 1833 --- a/src/processor/static_address_map-inl.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1834 +++ b/src/processor/static_address_map-inl.h Thu Mar 28 18:06:39 2013 +0100
michael@0 1835 @@ -33,17 +33,17 @@
michael@0 1836 //
michael@0 1837 // Author: Siyang Xie (lambxsy@google.com)
michael@0 1838
michael@0 1839 #ifndef PROCESSOR_STATIC_ADDRESS_MAP_INL_H__
michael@0 1840 #define PROCESSOR_STATIC_ADDRESS_MAP_INL_H__
michael@0 1841
michael@0 1842 #include "processor/static_address_map.h"
michael@0 1843
michael@0 1844 -#include "processor/logging.h"
michael@0 1845 +#include "common/logging.h"
michael@0 1846
michael@0 1847 namespace google_breakpad {
michael@0 1848
michael@0 1849 template<typename AddressType, typename EntryType>
michael@0 1850 bool StaticAddressMap<AddressType, EntryType>::Retrieve(
michael@0 1851 const AddressType &address,
michael@0 1852 const EntryType *&entry, AddressType *entry_address) const {
michael@0 1853
michael@0 1854 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/static_contained_range_map-inl.h
michael@0 1855 --- a/src/processor/static_contained_range_map-inl.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1856 +++ b/src/processor/static_contained_range_map-inl.h Thu Mar 28 18:06:39 2013 +0100
michael@0 1857 @@ -33,17 +33,17 @@
michael@0 1858 // See static_contained_range_map.h for documentation.
michael@0 1859 //
michael@0 1860 // Author: Siyang Xie (lambxsy@google.com)
michael@0 1861
michael@0 1862 #ifndef PROCESSOR_STATIC_CONTAINED_RANGE_MAP_INL_H__
michael@0 1863 #define PROCESSOR_STATIC_CONTAINED_RANGE_MAP_INL_H__
michael@0 1864
michael@0 1865 #include "processor/static_contained_range_map.h"
michael@0 1866 -#include "processor/logging.h"
michael@0 1867 +#include "common/logging.h"
michael@0 1868
michael@0 1869 namespace google_breakpad {
michael@0 1870
michael@0 1871 template<typename AddressType, typename EntryType>
michael@0 1872 StaticContainedRangeMap<AddressType, EntryType>::StaticContainedRangeMap(
michael@0 1873 const char *base)
michael@0 1874 : base_(*(reinterpret_cast<const AddressType*>(base))),
michael@0 1875 entry_size_(*(reinterpret_cast<const uint32_t*>(base + sizeof(base_)))),
michael@0 1876 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/static_map-inl.h
michael@0 1877 --- a/src/processor/static_map-inl.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1878 +++ b/src/processor/static_map-inl.h Thu Mar 28 18:06:39 2013 +0100
michael@0 1879 @@ -33,17 +33,17 @@
michael@0 1880 // Author: Siyang Xie (lambxsy@google.com)
michael@0 1881
michael@0 1882
michael@0 1883 #ifndef PROCESSOR_STATIC_MAP_INL_H__
michael@0 1884 #define PROCESSOR_STATIC_MAP_INL_H__
michael@0 1885
michael@0 1886 #include "processor/static_map.h"
michael@0 1887 #include "processor/static_map_iterator-inl.h"
michael@0 1888 -#include "processor/logging.h"
michael@0 1889 +#include "common/logging.h"
michael@0 1890
michael@0 1891 namespace google_breakpad {
michael@0 1892
michael@0 1893 template<typename Key, typename Value, typename Compare>
michael@0 1894 StaticMap<Key, Value, Compare>::StaticMap(const char* raw_data)
michael@0 1895 : raw_data_(raw_data),
michael@0 1896 compare_() {
michael@0 1897 // First 4 Bytes store the number of nodes.
michael@0 1898 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/static_map_iterator-inl.h
michael@0 1899 --- a/src/processor/static_map_iterator-inl.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1900 +++ b/src/processor/static_map_iterator-inl.h Thu Mar 28 18:06:39 2013 +0100
michael@0 1901 @@ -32,17 +32,17 @@
michael@0 1902 //
michael@0 1903 // Author: Siyang Xie (lambxsy@google.com)
michael@0 1904
michael@0 1905 #ifndef PROCESSOR_STATIC_MAP_ITERATOR_INL_H__
michael@0 1906 #define PROCESSOR_STATIC_MAP_ITERATOR_INL_H__
michael@0 1907
michael@0 1908 #include "processor/static_map_iterator.h"
michael@0 1909
michael@0 1910 -#include "processor/logging.h"
michael@0 1911 +#include "common/logging.h"
michael@0 1912
michael@0 1913 namespace google_breakpad {
michael@0 1914
michael@0 1915 template<typename Key, typename Value, typename Compare>
michael@0 1916 StaticMapIterator<Key, Value, Compare>::StaticMapIterator(const char* base,
michael@0 1917 const int &index):
michael@0 1918 index_(index), base_(base) {
michael@0 1919 // See static_map.h for documentation on
michael@0 1920 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/static_range_map-inl.h
michael@0 1921 --- a/src/processor/static_range_map-inl.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1922 +++ b/src/processor/static_range_map-inl.h Thu Mar 28 18:06:39 2013 +0100
michael@0 1923 @@ -32,17 +32,17 @@
michael@0 1924 // See static_range_map.h for documentation.
michael@0 1925 //
michael@0 1926 // Author: Siyang Xie (lambxsy@google.com)
michael@0 1927
michael@0 1928 #ifndef PROCESSOR_STATIC_RANGE_MAP_INL_H__
michael@0 1929 #define PROCESSOR_STATIC_RANGE_MAP_INL_H__
michael@0 1930
michael@0 1931 #include "processor/static_range_map.h"
michael@0 1932 -#include "processor/logging.h"
michael@0 1933 +#include "common/logging.h"
michael@0 1934
michael@0 1935 namespace google_breakpad {
michael@0 1936
michael@0 1937 template<typename AddressType, typename EntryType>
michael@0 1938 bool StaticRangeMap<AddressType, EntryType>::RetrieveRange(
michael@0 1939 const AddressType &address, const EntryType *&entry,
michael@0 1940 AddressType *entry_base, AddressType *entry_size) const {
michael@0 1941 MapConstIterator iterator = map_.lower_bound(address);
michael@0 1942 diff --git -r 85dd7094b78d -r 636cfcab9682 src/processor/windows_frame_info.h
michael@0 1943 --- a/src/processor/windows_frame_info.h Thu Mar 28 18:38:05 2013 +0100
michael@0 1944 +++ b/src/processor/windows_frame_info.h Thu Mar 28 18:06:39 2013 +0100
michael@0 1945 @@ -41,17 +41,17 @@
michael@0 1946 #include <string.h>
michael@0 1947 #include <stdlib.h>
michael@0 1948
michael@0 1949 #include <string>
michael@0 1950 #include <vector>
michael@0 1951
michael@0 1952 #include "common/using_std_string.h"
michael@0 1953 #include "google_breakpad/common/breakpad_types.h"
michael@0 1954 -#include "processor/logging.h"
michael@0 1955 +#include "common/logging.h"
michael@0 1956 #include "processor/tokenize.h"
michael@0 1957
michael@0 1958 namespace google_breakpad {
michael@0 1959
michael@0 1960 #ifdef _WIN32
michael@0 1961 #define strtoull _strtoui64
michael@0 1962 #endif
michael@0 1963

mercurial