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