Commit graph

1853 commits

Author SHA1 Message Date
Nelson Billing
315ab8a927 Fix common_windows.gyp.
- Rename two files from '.cpp' to '.cc' and insert missing comma in
  between lines in source files list.

Change-Id: I169a738b565f52292cb0292b34c4397e9dc05370
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1666351
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2019-06-18 23:11:27 +00:00
Nelson Billing
92032389a6 Move Windows Symbol Converter to breakpad
- First step, this is just enough to get it generating a msbuild
  project with GYP, which in turn can build the executable.
- Tests need to be redesigned because there isn't an available server.

Change-Id: I45440fd32b3ede29666c127703bcd441f0e4288e
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1661134
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2019-06-18 21:58:05 +00:00
Mark Mentovai
a7d686086c Mac upload_system_symbols: make dump of /Library/QuickTime optional
/Library/QuickTime is gone in 10.15b2 19A487l.

Change-Id: I927350a9cb383b93e8b18aef5f36c77bb67fede1
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1663996
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2019-06-18 15:01:25 +00:00
Mark Mentovai
9575315d8b Mac upload_system_symbols: use log.Fatalf where formatting is desired
Change-Id: I5623da3109feeb4b80137fa67501b8fd7aa5c8ec
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1663995
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2019-06-18 14:48:57 +00:00
Nelson Billing
87bc402210 Enable PE-only metadata dumping for 64bit (aka. PE32+ format) PEs files.
- Implement in common_windows_lib-- added class "PESourceLineWriter".
    - Add command-line switch to tell dump_syms to use PESourceLineWriter.
      Symbol data created this way will contain information to correlate the
      module with ones found in minidumps, along with frame info that allows
      much higher quality stack-walking in those minidumps.
    - Significant refactor of PDBSourceLineWriter-- all code concerned with
      extracting metadata from PE files has been moved into utility
      functions. This is to allow sharing of this functionality with newly-
      added PESourceLineWriter.
    - Added a unit test to dump_syms for the PE-only scenario.

Change-Id: If0855f05d424d32d23f484995be5f34232179a37
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1525325
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2019-06-12 21:20:27 +00:00
Nelson Billing
548ca6e382 Port new symbol upload API to Windows symupload tool.
- CL for Linux change, including new documentation for API, at:
  https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1422400/3

Change-Id: I579744fec74c64757b8bc31de63d7a07ef9a0f1f
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1487982
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2019-06-12 20:56:37 +00:00
Joshua Peraza
756daa536a Removed unused includes/declarations
Change-Id: I2ada9f96efe97c25c885eef561af725418a46bec
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1652667
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-06-11 23:36:23 +00:00
Joshua Peraza
d7676cd696 fix build failures
Change-Id: I9e745d2a4b3f780941ba286bbafa5d4169d172f7
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1653863
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-06-11 22:27:59 +00:00
Joshua Peraza
c2467077b9 Enable truncation of module ranges
ELF modules are loaded in memory in several, possibly discontiguous,
segments. If the holes between segments are large enough, other things,
possibly other ELF modules may be mapped in that space. Crashpad
records the range of modules as the base address of the lowest mapped
segment to the high address of the highest mapped segment. This means
that when one module is mapped into a hole in another, it appears to
the Breakpad processor as overlapping modules. Module ranges are
relevant to the Breakpad processor during stackwalking for identifying
which module a particular program counter belongs to (i.e. mapping the
address to a module's text segment). This patch addresses this issue of
overlapping modules by truncating the range of the module with the
lower base address. A typical module's text segment is the first loaded
segment which would leave the text segment range unaffected. Module
producers can restrict the size of holes in their ELF modules with the
flag "-Wl,-z,max-page-size=4096", preventing other modules from being
mapped in their address range.

Properly contemplating ELF module address ranges would require
extensions to the minidump format to encode any holes.
crbug.com/crashpad/298

This patch also renames the concept of "shrinking down" (which
truncated the upper of two overlapping ranges) to "truncate upper".

Change-Id: I4599201f1e43918db036c390961f8b39e3af1849
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1646932
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-06-11 19:04:02 +00:00
Joshua Peraza
6f287a5f57 linux: fix broken tests
Fixes errors for comparisons between signed and unsigned ints.

Change-Id: I7ef151ba84a48a0c8cc449cfaf12b9fef775d5a7
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1642361
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-06-04 00:19:16 +00:00
Ivan Penkov
e436b07330 Fix a build break with SDK 10.14.
* Updated the minimal target version from 10.5 to 10.7.
* Reference for the similar issue:
  https://github.com/uglide/RedisDesktopManager/issues/4284

Fix provided by Hiroyuki Komatsu.

Change-Id: Ie08f8f6084e66d439d8b6282f1f4734b2dfe778f
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1633390
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-05-29 16:53:09 +00:00
John Z Wu
d930308bbb Fix orphaned crash reports.
The path NSCachesDirectory may change across app updates and sometimes
even across app launches. As a result, the Config-XXX files may end up
with an outdated path to the associated minidump file.

Change-Id: I0befde26b2ac406c154ce7c7e9be0063ee99892d
Bug:850379
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1592561
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-05-15 03:47:37 +00:00
John Z Wu
b2831dbed1 Increase timeout of HTTPMultipartUpload from 10s to 60s.
This, hopefully, will reduce occurrences of UnfinishedReportUploads. It
will not eliminate it completely because uploads are never retried if
they fail.

60s is actually the default value. Before iOS6, 240s was the default and
minimum applied to requests with a body. Reference:
https://developer.apple.com/documentation/foundation/nsmutableurlrequest/1414063-timeoutinterval?language=objc

Bug:850379
Change-Id: I2f16fda7d7e8cbb8b8a6fc917111d9f646fbdad0
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1609876
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-05-13 20:24:15 +00:00
Mark Mentovai
21b48a72aa Linux breakpad_unittests: fix ThreadSanitizer problems
Some tests were failing because they had expectations about the number
of threads in a process, but TSan, and in some cases, ASan, introduce
their own threads. Where a sanitizer affects this, the expectations are
now used as minimum thread counts, not exact thread counts. See
https://www.brooklinen.com/blogs/brookliving/best-thread-count-for-sheets.

These problems were detected by ThreadSanitizer at
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8915151099544583616/+/steps/breakpad_unittests__with_patch_/0/stdout

Bug: chromium:949098
Change-Id: Ie40f1766bea27e9bcb112bf9e0b8b846fb343012
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1585948
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2019-04-26 18:44:54 +00:00
Mark Mentovai
9f90ceb904 Linux MinidumpWriter: fix stack-use-after-scope violation
One form of google_breakpad::WriteMinidump() passed MappingList and
AppMemoryList objects by reference to a MinidumpWriter object,
instantiating them directly as constructor parameters. The
MinidumpWriter stored these objects internally as references, and the
underlying objects went out of scope after MinidumpWriter construction.
The MinidumpWriter outlived them, causing a violation on any attempt to
access them following construction.

This bug was detected by AddressSanitizer at
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket.appspot.com/8915150848087289472/+/steps/breakpad_unittests__with_patch_/0/stdout

Bug: chromium:949098
Change-Id: I072ea9f1b64e1eae3e89d4a2b158764ff7970db5
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1585946
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2019-04-26 18:44:49 +00:00
Olivier Robin
1fc9cc0d0e [Breakpad iOS] Add a callback on report upload completion.
This CL adds a result callback on report upload completion.
On failure, Breakpad deletes the configuration file and does retry to
upload a report.
Using this callback, the client will be able to log some metrics and to
act on upload failure.

Bug: 954175
Change-Id: I95a3264b65d4c06ba5d8dde8377440d23f1e2081
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1572661
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-23 13:07:06 +00:00
Mark Mentovai
8c70c504b2 Make breakpad_unittests work with Chrome's test runner instead of gtest's
Chrome's test runner on Linux installs its own StackDumpSignalHandler
which swallows signals and doesn't re-raise them. This is sloppy, but
apparently there are reasons (https://crbug.com/551681). For
breakpad_unittests, it causes problems where a test process expects (via
waitpid()) to observe a child crash.  Deal with those cases by
explicitly restoring the default signal handler.

In another case, Chrome's test runner seems to have been arriving at the
conclusion that it was to expect output from a child. Transitioning from
exit() to _exit() fixes this problem, and it's not necessarily a bad
idea to do this in post-fork() children without an execve() anyway.

Bug: chromium:949098
Change-Id: I5a6af0c2a09cd8eac9998358f6d5ea665288236f
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1575670
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-19 21:42:27 +00:00
John Z Wu
ebab5970b0 Use correct c++ standard library in Xcode project.
This makes it build again for Xcode 10.

Change-Id: Ia28b8c0b131ac2862a8c17e223d1d7b1f0f59134
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1574177
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-19 14:19:05 +00:00
Mark Mentovai
232c45abee linux_core_dumper: add missing newline to Android test-disabled message
The [       OK ] LinuxCoreDumperTest.VerifyExceptionDetails line does
not appear at the beginning of a line, hiding it from Chromium’s test
infrastructure. This causes the test to have an unknown result, which is
treated as a failure.

https://ci.chromium.org/p/chromium/builders/try/android-kitkat-arm-rel/233129

Bug: google-breakpad:791
Change-Id: I0eb646a219fa40347db884fd28ace647328c5e49
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1558893
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2019-04-09 00:09:28 +00:00
Mike Frysinger
4d550cceca linux_core_dumper: partially disable test on Android
Running this test on android-kitkat-arm-rel fails for some reason:
[ RUN      ] LinuxCoreDumperTest.VerifyExceptionDetails
linux_core_dumper_unittest.cc:170: Failure
Expected: (0U) != (dumper.crash_address()), actual: 0 vs 0
linux_core_dumper_unittest.cc:178: Failure
Expected equality of these values:
  2U
    Which is: 2
  info.size()
    Which is: 0
[  FAILED  ] LinuxCoreDumperTest.VerifyExceptionDetails (7 ms)

Disable it for now on Android until someone can look into it.

Bug: google-breakpad:791
Change-Id: I40a5e3dbeeb44e5eb0df187e61d55e07d8ad3613
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1546778
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-07 14:08:29 +00:00
Mike Frysinger
9e9e236c82 mac dump_syms: remove unused vars to fix -Werror build failures
Bug: chromium:940823, chromium:946404
Change-Id: Ib8af7f0845b0488f36cd1b91326aba11bf283b0a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1546779
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-04-05 00:25:48 +00:00
Mike Frysinger
e2b3b80e43 linux_core_dumper: add explicit casts for exception fields
Some of the fields we save might have signed types depending on the
system (e.g. `typedef int pid_t`).  Depending on the toolchain, we
can trip -Werror=narrowing failures like:
src/client/linux/minidump_writer/linux_core_dumper.cc:248:66: error:
  narrowing conversion of ‘(__pid_t)info->siginfo_t::_sifields.siginfo_t::<anonymous union>::_kill.siginfo_t::<anonymous union>::<anonymous struct>::si_pid’
  from ‘__pid_t {aka int}’ to ‘long unsigned int’ inside { } [-Werror=narrowing]
             set_crash_exception_info({info->si_pid, info->si_uid});
                                             ^^^^^^
src/client/linux/minidump_writer/linux_core_dumper.cc:252:71: error:
  narrowing conversion of ‘(int)info->siginfo_t::_sifields.siginfo_t::<anonymous union>::_sigsys.siginfo_t::<anonymous union>::<anonymous struct>::_syscall’
  from ‘int’ to ‘long unsigned int’ inside { } [-Werror=narrowing]
             set_crash_exception_info({info->si_syscall, info->si_arch});
                                             ^^^^^^^^^^

Since the exception info fields are all uint64_t which should be large
enough to handle all the fields in the siginfo_t structure, add casts
for all the assignments to avoid these errors.  We have implicit casts
even without them, so we aren't changing behavior.

Bug: google-breakpad:791
Bug: chromium:945653
Change-Id: Ib04e015998f08b857159ac13e9a065a66d228d49
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1544862
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-03-30 03:52:15 +00:00
Mark Mentovai
b4a0eb2d06 mac dump_syms: Support .dSYMs > 4GB (partially)
Even 64-bit Mach-O (MH_MAGIC_64 = 0xfeedfacf) is not a fully 64-bit file
format. File offsets in sections are stored in 32-bit fields, with
Mach-O writers typically truncating offsets too large to fit to just
their low 32 bits. When a section begins at a file offset >= 4GB,
dump_syms would produce an error such as:

Google Chrome Framework.dSYM/Contents/Resources/DWARF/Google Chrome Framework: the section '__apple_names' in segment '__DWARF' claims its contents lie outside the segment's contents

As a workaround, this implements the strategy I first described in
https://crbug.com/940823#c22.

Segment file offsets are stored in 64-bit fields. Because segments
contain sections and must load contiguously, it’s possible to infer a
section’s actual offset by computing its load address relative to its
containing segment’s load address, and treating this as an offset into
the containing segment’s file offset. For safety, this is only done for
64-bit segments (LC_SEGMENT_64) where the 32-bit section offset stored
in the Mach-O file is equal to the low (truncated) 32 bits of the
section offset recomputed per the above strategy.

Beware that this does not provide full “large file” support for 64-bit
Mach-O files. There are other file offsets within Mach-O files aside
from section file offsets that are stored in 32-bit fields even in the
64-bit format, including offsets to symbol table data (LC_SYMTAB and
LC_DYSYMTAB). No attempt is made to recover correct file offsets for
such data because, at present, such data is always stored by dsymutil
near the beginning of .dSYM files, within the first 4GB. If it becomes
necessary to address these other offsets, it should be possible to
recover these offsets by reference to the __LINKEDIT segment that
normally contains them, provided that __LINKEDIT doesn’t span more than
4GB, according to the strategy discussed at the bottom of
https://crbug.com/940823#c22.

Although this is sufficient to allow dump_syms to interpret Chromium
.dSYM files that exceed 4GB, be warned that these Mach-O files are still
technically malformed, and most other tools that consume Mach-O files
will continue to have difficulties interpreting these large files.

As further warning, note that should any individual DWARF section exceed
4GB, internal section offsets will be truncated irrecoverably, unless
and until the toolchain implements support for DWARF64.
https://bugs.llvm.org/show_bug.cgi?id=14969

With this change, dump_syms is able to correctly recover file offsets
from and continue processing a .dSYM file with length 4530593528
(4321MB), whose largest section (__DWARF,__debug_info = .debug_info) has
size 0x8d64c0b8 (2262MB), and which contains four sections (starting
with __DWARF,__apple_names) beginning at file offsets >= 4GB.

Bug: chromium:940823, chromium:946404
Change-Id: I23f5f3b07773fa2f010204d5bb53b6fb1d4926f7
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1541830
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2019-03-28 20:43:54 +00:00
Nelson Billing
a86aedb515 Fix dump_syms unit tests on Windows.
- Baselines appeared to be stale. dump_syms now prints FUNC entries
  with the full function signature, whereas the baselines only
  contained the function name. The current state of the symbol file
  docs
  (https://chromium.googlesource.com/breakpad/breakpad/+/refs/heads/master/docs/symbol_files.md)
  seem to agree with the new FUNC entries rather than the old ones.
  Example of a name given in current docs:
  "nsQueryInterfaceWithError::operator()(nsID const&, void**) const".

Change-Id: I9e01354cd82b7184b7cba31d132603e949a657ac
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1529133
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2019-03-18 23:08:12 +00:00
Mike Frysinger
8547289da5 linux_core_dumper: handle missing SIGSYS support
If the kernel/C library headers are old, they might not have the
fields needed for SIGSYS decoding.  Add ifdef checks for that and
skip the logic entirely.  Easier than adding arch-specific siginfo
structs to the codebase.

Bug: google-breakpad:791
Change-Id: Ia473e3ffa61fce4c42cf4c1e73a9df044599bc5c
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1524447
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-03-14 21:53:16 +00:00
Mike Frysinger
3ee9a0b274 linux_core_dumper: support setting exception_information
Many signals in Linux support additional metadata on a per-signal
basis.  We can extract that from NT_SIGINFO and pass it through
in the exception_information fields.

The current core dumper logic doesn't set exception_information
at all, so this is an improvement.

Bug: google-breakpad:791
Change-Id: I38b78d6494e9bc682441750d98ac9be5b0656f5a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1497662
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-03-12 05:02:27 +00:00
Mike Frysinger
57f420bf7c linux_core_dumper: add a fallback definition for NT_SIGINFO
When building on an old system with outdated headers, this define
might not be available.  Add a fallback to our existing elf header.

Bug: google-breakpad:790
Change-Id: I4dfe7a5cebd414cca3582a1a9cfc983503d5a779
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1507073
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-03-07 05:58:16 +00:00
Mike Frysinger
7864f2edaa core2md: write error message with perror
The current failure message omits the underlying errno.  This can
make diagnosing failures a bit difficult unless you run everything
through strace.  For example:
 $ core2md core /proc/self md
 $ core2md core /proc/self md
 Unable to generate minidump

Now we get the errno details:
 Unable to generate minidump: File exists

Change-Id: I67f30879868ce4a726d5d888ee8c0a4a316b5186
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1497660
Reviewed-by: Ted Mielczarek <ted.mielczarek@gmail.com>
2019-03-04 16:45:16 +00:00
Mike Frysinger
59d89be2d6 linux_core_dumper: support NT_SIGINFO for reading crashing address
The current core dumper only parses NT_PRSTATUS notes.  With signal
details, this note only includes three fields: signo, code, and errno.
We set exception_code to signo and exception_flag to code.  The errno
value isn't set by the kernel, so there's no need to save it.

However, we never fill in exception_address which means all converted
crashes look like they happen at address 0.  This implies a NULL jump
which is usually not the case, so it's just confusing.  The prstatus
structure doesn't offer anything directly that tracks this.

Starting with linux-3.7, the kernel writes out the full siginfo
structure in the NT_SIGINFO note.  So lets support that to pull out
si_addr which, for a bunch of common signals, is the value we want in
exception_address.

The size of the siginfo_t structure should be locked to 128 bytes at
build time for all architectures, so this should hopefully be stable.

Bug: google-breakpad:790
Change-Id: I458bad4787b1a8b73fad8fe068e9f23bec957599
Reviewed-on: https://chromium-review.googlesource.com/c/1497661
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-03-03 17:39:36 +00:00
Lei Zhang
19a8433a60 Replace TYPED_TEST_CASE with TYPED_TEST_SUITE.
TYPED_TEST_CASE is deprecated in modern googletest.

BUG=chromium:936654

Change-Id: I08004ffbb26089ebe17302934ed6d3268220d151
Reviewed-on: https://chromium-review.googlesource.com/c/1493423
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-02-28 03:09:44 +00:00
Nico Weber
2853d21e20 breakpad: Remove semicolons, iOS edition.
Bug: chromium:926235
Change-Id: I237e7b7d89e5746beea80754675a232c881f25f6
Reviewed-on: https://chromium-review.googlesource.com/c/1487336
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-02-25 21:43:47 +00:00
Nico Weber
30153b4eb5 breakpad: Remove semicolons, mac edition.
Bug: chromium:926235
Change-Id: I473a7727c1831717b92a582c50d98256ea41d854
Reviewed-on: https://chromium-review.googlesource.com/c/1482716
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-02-22 16:53:33 +00:00
Nico Weber
37a60998ca breakpad: Remove semicolons.
Bug: chromium:926235
Change-Id: I7f0795ebd651303b6f7fb6981c2f639e17a536bb
Reviewed-on: https://chromium-review.googlesource.com/c/1481232
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-02-21 15:43:19 +00:00
Andreas Haas
a0e078365d Delete deprecated SetFirstChanceExceptionHandler function
This CL removes the code I marked as deprecated in
https://crrev.com/c/1411776. I could not delete the code in that CL
before I removed all uses in Chrome in https://crrev.com/c/1411643.

The tracking bug contains more information.

R=mark@chromium.org

Bug: chromium:921971
Change-Id: I77597826ef6e69a13ece529a5d24702bc72aa436
Reviewed-on: https://chromium-review.googlesource.com/c/1412353
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-02-19 22:12:01 +00:00
Gabriele Svelto
44384d80b3 Always emit a 32-bit crash address for 32-bit architectures
Certain minidumps for 32-bit crashes have the upper 32-bit of the crash
address (which is a 64-bit value) set to non-zero values. This caused a
crash address with more than 32-bits to be printed out for minidumps of
32-bit architectures. This patch masks out those bits when reading the
raw minidump data to ensure this doesn't happen anymore.

Bug: google-breakpad:783

Change-Id: Ieef6dff759fd0ee2efc47c4c4a3cf863a48f0659
Reviewed-on: https://chromium-review.googlesource.com/c/1427819
Reviewed-by: Ted Mielczarek <ted.mielczarek@gmail.com>
2019-01-30 16:21:52 +00:00
Gabriele Svelto
13b234ce24 Make the minidump processor correctly populate the CPU information string for Microsoft-style ARM64 minidumps
This affects the output of tools like minidump_stackwalk which currently
print out the hexadecimal representation of the architecture instead of
the "arm64" string.

BUG=780

Change-Id: Id1d9d65fa5f3509c8c6580e2e3042f7d682b52be
Reviewed-on: https://chromium-review.googlesource.com/c/1412004
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2019-01-30 16:20:00 +00:00
Andreas Haas
9b06049ed9 Introduce SetFirstChanceHandler with more strict signature
Eventually, I want to remove the current version of
SetFirstChanceHandler. That is why I changed the name of the current
callback type to FirstChanceHandlerDeprecated.

I also made sure that it is not possible to have two different
FirstChanceHandlers set at the same time.

This is the first of a set of CLs to clean up the API between Chrome,
BreakPad, and V8. See more information in the tracking bug.

R=mark@chromium.org

Bug: chromium:921971
Change-Id: Ia8c2fd9bd875c36dd7ae8bb4a02e538556bc67a1
Reviewed-on: https://chromium-review.googlesource.com/c/1411776
Reviewed-by: Mark Mentovai <mark@chromium.org>
2019-01-15 15:14:20 +00:00
Tom Tan
b988fa74ec Extract intruction pointer correctly for Windows ARM64
Bug: 893460
Change-Id: Ibbdf734e72c29c4779b6a701dceec1626056a9ba
Reviewed-on: https://chromium-review.googlesource.com/c/1393763
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2019-01-03 00:10:28 +00:00
Joshua Peraza
3bc301d4f9 Conditionally define BPLOG_LAZY_STREAM
This allows BPLOG_LAZY_STREAM to be overridden by BP_LOGGING_INCLUDE

Change-Id: I5c9ec19b619ad5db9e97f3a1813b0f965a357b38
Reviewed-on: https://chromium-review.googlesource.com/c/1351361
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2018-11-27 16:12:23 +00:00
Joshua Peraza
e42f2456b7 Add mac dump_syms support for arm64e
Change-Id: I6a25b47d4fc5e42ff9fa30107b563dcf1d51c0d1
Reviewed-on: https://chromium-review.googlesource.com/c/1351352
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-11-26 18:29:35 +00:00
Joshua Peraza
5cbd3c69e0 fix dump_syms xcode project
dwarf_range_list_handler.{cc,h} were added in 16e08520.

Default to building with c++11.

Change-Id: Iceb29ab665260a9e71a30920fdfb5623d10a9cfa
Reviewed-on: https://chromium-review.googlesource.com/c/1351351
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-11-26 18:29:16 +00:00
Ludovic Guegan
12ecff373a Skip empty DWARF code range when mapping lines
BUG=777

Change-Id: Ic6d05eee3ff4660b6d087999a8cea04a1ee3e92b
Reviewed-on: https://chromium-review.googlesource.com/c/1333507
Reviewed-by: Ted Mielczarek <ted.mielczarek@gmail.com>
2018-11-21 15:38:37 +00:00
Joshua Peraza
66571f4838 Conditionally define BPLOG_IF
This allows BPLOG_IF to be overriden by defines in BP_LOGGING_INCLUDE.

Change-Id: Ic6e8373476cc4d1f73d55e13a23686a2c8309fdc
Reviewed-on: https://chromium-review.googlesource.com/c/1278104
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2018-10-12 17:49:54 +00:00
Evan Bernstein
315d1368a7 Adds method to get the date of the most recent iOS crash report.
Also adds method to determine if breakpad is started.

Change-Id: I272765e7ac6bbc07d77ca2d8dcc34d51c205116e
Reviewed-on: https://chromium-review.googlesource.com/c/1260625
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-10-08 16:40:19 +00:00
Lei Zhang
54fa71efbe Swap MDCVInfoELF::cv_signature if needed.
BUG=chromium:877888

Change-Id: Ie4437228dfc32619ce5feb1769ba1644a4ea8ca2
Reviewed-on: https://chromium-review.googlesource.com/1192963
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-08-28 17:41:06 +00:00
Joshua Peraza
ee6f67d3b0 win: fix formatting after 21c98747
Change-Id: If50c3563fec7a8a9edf05c22f7d157201184df38
Reviewed-on: https://chromium-review.googlesource.com/1191671
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2018-08-27 20:58:44 +00:00
Joshua Peraza
21c9874722 win: replace a while loop with a for loop
This is the recommended resolution to warning C4127.
https://msdn.microsoft.com/en-us/library/6t66728h.aspx

Change-Id: Ifcffe68e21d9a6383bb9aef07503cbb034caca19
Reviewed-on: https://chromium-review.googlesource.com/1191661
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2018-08-27 19:44:50 +00:00
Joshua Peraza
1459e5df74 Fix debug build after 16e0852
Also remove ranges_handler_ which is unused.

Change-Id: I771bf4b5fc4410f0406bf26e1e405905b55389ab
Reviewed-on: https://chromium-review.googlesource.com/1180587
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-08-18 01:46:46 +00:00
Joshua Peraza
47b4a1c105 Make a parameter a const reference
Change-Id: I7d232dd9be3a03b5bd9f1d46c307d080fadf9116
Reviewed-on: https://chromium-review.googlesource.com/1179978
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-08-17 17:02:52 +00:00
Joshua Peraza
6ee298a346 Treat high_pc as an address for DW_FORM_GNU_addr_index
The high_pc is an address and has already been read from .debug_addr
before being passed into FuncHandler::ProcessAttributeUnsigned.

Bug:870908
Change-Id: I950098e360b5193f26bf767b8fa0a5f9d59e66ce
Reviewed-on: https://chromium-review.googlesource.com/1178760
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-08-17 04:26:39 +00:00
Mark Mentovai
acf983292a Fix Windows client_tests GYP build after 88d8114fda
Bug: google-breakpad:770
Change-Id: I5539cda6053c39a11c354fba7f3e689ae02d3019
Reviewed-on: https://chromium-review.googlesource.com/1176126
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2018-08-15 18:25:08 +00:00
Gabriele Svelto
658a77e532 Fixed a typo introduced in revision 16e08520e6
BUG=769

Change-Id: I1e118fe31b4a4031275b8b49c4c1eb98745ce21a
Reviewed-on: https://chromium-review.googlesource.com/1174571
Reviewed-by: Ted Mielczarek <ted.mielczarek@gmail.com>
2018-08-14 14:12:51 +00:00
Gabriele Svelto
16e08520e6 Add support for parsing the DW_AT_ranges attributes
This enables the DWARF reader to properly parse DW_AT_ranges attributes
in compilation units and functions. Code covered by a function is now
represented by a vector of ranges instead of a single contiguous range
and DW_AT_ranges entries are used to populate it. All the code and tests
that assumed functions to be contiguous entities has been updated to
reflect the change. DW_AT_ranges attributes found in compilation units
are parsed but no data is generated for them as it is not currently needed.

BUG=754

Change-Id: I310391b525aaba0dd329f1e3187486f2e0c6d442
Reviewed-on: https://chromium-review.googlesource.com/1124721
Reviewed-by: Ted Mielczarek <ted.mielczarek@gmail.com>
2018-08-13 19:12:00 +00:00
Joshua Peraza
7b98edabb6 Set new ARM64 context flags
Change-Id: I4749459ec37b076b226fa734824380a7254f1064
Reviewed-on: https://chromium-review.googlesource.com/1163826
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-08-06 18:02:41 +00:00
Joshua Peraza
f12b689789 processor: Fix memory leak after 88d8114f
This was mistakenly deleted in
https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1155938/12

Change-Id: I95e5d84b36e2f89a7a364ee278ccb128b7d34b50
Reviewed-on: https://chromium-review.googlesource.com/1159525
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-08-02 00:02:10 +00:00
Joshua Peraza
88d8114fda Define and use a a new MDRawContextARM64
This struct matches the layout defined by Microsoft and replaces
Breakpad's MDRawContextARM64_Old. This CL updates the processor to
understand either the old or new structs, but clients continue to write
the old structs.

Change-Id: I8dedd9ddb2ec083b802723b9ac87beb18d98edbd
Reviewed-on: https://chromium-review.googlesource.com/1155938
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-08-01 19:27:25 +00:00
Joshua Peraza
627ef0cb9c Rename MDRawContextARM64 and its context flags
This makes way for the addition of a struct matching Microsoft's layout
for ARM64.

Change-Id: I115f25290863e7438852691d1ec3c9324a42f7a5
Reviewed-on: https://chromium-review.googlesource.com/1152158
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2018-08-01 19:26:38 +00:00
Joshua Peraza
948ce04ed7 mac: Fix broken xcode projects
Change-Id: I1cd8f0b0224c9b629dda720c11f6c081b175f8bd
Reviewed-on: https://chromium-review.googlesource.com/1157121
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-07-31 18:52:20 +00:00
Ivan Penkov
9fecc95c72 Add path_helper.cc and path_helper.h to dump_syms.xcodeproj.
Fixes a build break of dump_syms with Xcode.

Patch provided by Hiroyuki Komatsu.

Change-Id: I3bd3772060afee9f78dc99c75cd94f96a56c7617
Reviewed-on: https://chromium-review.googlesource.com/1144604
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-07-24 17:12:32 +00:00
Joshua Peraza
c79e349bec ios: Fix build of exception_handler_no_mach
Change-Id: I2a9f85e78f6d3189f018824ad98e39af30d2ecf8
Reviewed-on: https://chromium-review.googlesource.com/1129465
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2018-07-09 19:25:39 +00:00
Joshua Peraza
5dc88243a6 Use hash_map and hash_set from __gnu_cxx
Change-Id: Ia8521e5cfd8424c5dec247503532454eb8806c48
Reviewed-on: https://chromium-review.googlesource.com/1129203
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2018-07-09 19:25:18 +00:00
Joshua Peraza
89e7a8615f iOS: disable using CFI in stackwalking
dump_syms produces incomplete CFI info on iOS because it doesn't support
converting compact unwind to Breakpad symbols. Attempting to use
incomplete CFI can result in infinte stack traces.

Bug: google-breakpad:764
Change-Id: Id042aa515d17928cb5503a79038607d95c56238d
Reviewed-on: https://chromium-review.googlesource.com/1128252
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2018-07-06 21:22:45 +00:00
Lei Zhang
79ba6a494f Ignore duplicate module list entries.
BUG=chromium:838322

Change-Id: Ie19c1a39e49332b650a618758f925b127026bddf
Reviewed-on: https://chromium-review.googlesource.com/1115437
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-06-28 00:20:21 +00:00
Lei Zhang
fac0e886c8 Only do Android-specific adjustments for Android minidumps.
Change-Id: I33b1f988766f79b473127c4b56b1c81021b89631
Reviewed-on: https://chromium-review.googlesource.com/1115436
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-06-28 00:20:01 +00:00
Lei Zhang
d531e1b2ba Refactor code out of MinidumpModuleList::Read().
Add a StoreRange() helper method and an IsDevAshmem() helper function.

Change-Id: Iaec9dee1e08bd0155f1c33cfe9af722b0dcaef31
Reviewed-on: https://chromium-review.googlesource.com/1114188
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2018-06-28 00:19:24 +00:00
Lei Zhang
d0241bb91c Add an anonymous namespace in minidump.cc.
Change-Id: I1b064013b5d6253fe887245ebda7a861688d3cd6
Reviewed-on: https://chromium-review.googlesource.com/1114089
Reviewed-by: Will Harris <wfh@chromium.org>
2018-06-28 00:18:51 +00:00
Mike Hommey
69c2c51dd8 Fall back to the raw symbol name from DW_AT_MIPS_linkage_name when there is nothing else
When DW_AT_MIPS_linkage_name doesn't demangle, breakpad currently throws
the symbol completely, but in some cases, there is no DW_AT_name or
DW_AT_abstract_origin to figure out a name, and the raw value from
DW_AT_MIPS_linkage_name is still better than nothing. Fall back to that
in when there is nothing else.

R=ted@mielczarek.org

Change-Id: I5cc7580244f2b99f5f1f279d09b904031cae1a37
Reviewed-on: https://chromium-review.googlesource.com/1082176
Reviewed-by: Ted Mielczarek <ted.mielczarek@gmail.com>
2018-06-19 10:44:10 +00:00
Aaron Dierking
7b3afa9258 Avoid endl when writing symbol files
endl flushes output after each line. Using "\n" instead significantly improves
I/O efficiency.

Change-Id: If6a5549fc3613ca3a7c9a71838ec36c5b7a20580
Reviewed-on: https://chromium-review.googlesource.com/1077626
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-05-30 19:05:54 +00:00
Max Moroz
27c001192b Add SEVERITY_CRITICAL to logging, that would help to suppress logs from the fuzz target.
Follow-up CL will be https://chromium-review.googlesource.com/c/chromium/src/+/1073395

Bug: 846721
Change-Id: Ie9e6dc5c5ef6b035c414fbdc4f711f995b52f4d7
Reviewed-on: https://chromium-review.googlesource.com/1073394
Reviewed-by: Will Harris <wfh@chromium.org>
2018-05-29 19:24:32 +00:00
Lei Zhang
9eac2058b7 Read Linux si_code in minidump_processor.
For common signals: SIGILL, SIGFPE, SIGSEGV, and SIGBUS.

Change-Id: I80048f70445c3fa6accd548704c5700b3bed12a4
Reviewed-on: https://chromium-review.googlesource.com/1012589
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2018-04-13 18:59:09 +00:00
Sergey Abbakumov
c83fcf6470 Initialize variables for MSAN
The variables in the CL are not initialized. Even if it's safe not to
initialize them here, MSAN doesn't know that.

Bug: 394028
Change-Id: I597a7d76aa19d5789decd0f85150fa31c9655269
Reviewed-on: https://chromium-review.googlesource.com/1001573
Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-04-10 17:13:20 +00:00
Lei Zhang
adcc90ddb8 Linux: Write out si_code for SIGBUS exceptions.
Store the information in the exception record's exception_information
field.

Change-Id: Ie215cae2f070fdab63c3d05cc1bc4fb4b7b095fa
Reviewed-on: https://chromium-review.googlesource.com/990799
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-04-03 16:35:14 +00:00
Takuto Ikuta
e93f852a3c Add missing header for free function
Change-Id: I8ff2dcb546849493f2883777895341e043e44fb3
Reviewed-on: https://chromium-review.googlesource.com/981965
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-03-27 14:57:55 +00:00
Ted Mielczarek
2d80611fed Allow minidump_dump to print module lists that would normally be rejected
for being too long.

We've seen some minidumps that fail to process because they contain
a ridiculous number of modules (usually due to something leaking shm
mappings, it looks like). They're annoying to investigate because even
minidump_dump fails to load and print the module list. This patch makes
minidump_dump effectively remove the limit on the number of modules it
will load, so inspecting the dump by hand is possible.

R=vapier@chromium.org

Change-Id: I7a55387ca4aaad8664cd4d2651052da989366027
Reviewed-on: https://chromium-review.googlesource.com/957130
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2018-03-12 09:59:33 +00:00
Daniel Bratell
88e9a460de Fixing incorrect include guard (missing #define)
Noticed while adding an include guard presubmit check in
Chromium.

Change-Id: I9e677412d881b32a58d695208045b575bb8f8be6
Reviewed-on: https://chromium-review.googlesource.com/934448
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-23 14:30:08 +00:00
Adam Harrison
6bb6c9b26a Fix crash when an NSException is thrown.
old_handlers is zeroish whenever an NSException is thrown. This caused PROT_WRITE to never be set and resulted in an EXC_BAD_ACCESS when trying to set the handler to NULL.

Change-Id: Ibb7da448204431c7602b1001f3a5216303c4c9d1
Reviewed-on: https://chromium-review.googlesource.com/899907
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-02-02 20:18:46 +00:00
Lars Volker
ac4a549e29 Extend ifdef to include helper functions
The previous change to fix compiling on Android < N forgot to include a
helper in the ifdef, thus not fixing the problem. This change extends
the ifdef to include all helpers used by the test.

Change-Id: Ibb3030f54a81b5609a0b55ccef387a3cba22d088
Reviewed-on: https://chromium-review.googlesource.com/895240
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2018-01-31 21:02:06 +00:00
Lars Volker
242327485d Remove barrier to fix Android build.
The unittest for #752 made use of pthread_barrier_t, which is not
supported on Android. This change replaces the barrier code with a
simple sleep, which proved sufficient to trigger the race. It only
affects the test and does not affect the original fix for #752.

Change-Id: I82c32cf00899176fa09089e716ed85850b8711e6
Reviewed-on: https://chromium-review.googlesource.com/895168
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2018-01-31 20:09:18 +00:00
Nico Weber
fd99ff473c Make breakpad build with -Wimplicit-fallthrough (on linux)
Fixes a bug where MD_EXCEPTION_CODE_MAC_PPC_ALTIVEC_ASSIST
would unintentionally get two reason strings appended.

Bug: 177475
Change-Id: I4957268328a242c7c75bbff8add98e9a48ba83ad
Reviewed-on: https://chromium-review.googlesource.com/895705
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-31 16:39:12 +00:00
Peter Collingbourne
6d001e7159 Do not use non-standard stdext::checked_array_iterator with libc++.
Bug: chromium:801780
Change-Id: Id1b0b2330d7d609bda62869bcda5bb2f6fde12bd
Reviewed-on: https://chromium-review.googlesource.com/872458
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-18 14:55:11 +00:00
Lars Volker
97a9883676 Only restore the signal handler if sigaction has not changed
Restoring the signal handler in ExceptionHandler::SignalHandler() can
lead to a race in scenarios where multiple threads crash within a short
time. This can cause threads to alternately try to write a minidump
without ever terminating the process.

The first thread to write a minidump will reset the signal handler to
the SIG_DFL using signal() in InstallDefaultHandler(). The next thread
to execute SignalHandler() will detect this and will reset the signal
handler to SignalHandler(). If the first thread takes too long to write
its minidump (e.g. when there are many threads), the chances increase
that the second thread will enter SignalHandler() before the first one
leaves the critical section.

After resetting the signal handler, the second thread will fail to write
a minidump (since the file already exists) and will try to reset the
signal handler to the default by calling RestoreHandlersLocked().
However, in the meantime the first thread will have entered
SignalHandler() again and will overwrite it one more time.

After that, no further attempts will be made to restore the default
signal handler and both threads will continue to re-raise the signal and
attempt to write minidump files.

This change adds a check to make sure that cur_handler.sa_sigaction is
still pointing to SignalHandler() before re-installing the handler.

To test this we start a large number of sleeping threads and two threads
that will crash simultaneously. Without the fix, this would reproducibly
lead to a loop between the two crashing threads.

Bug: 752
Change-Id: I784328cfff17ddc7476d6668354570ab867ba405
Reviewed-on: https://chromium-review.googlesource.com/855137
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2018-01-09 16:22:07 +00:00
Syed Nisar Ul Haq
ceef4a517d Fixed file extention for minidump_upload in tools_linux.gypi
Bug:
Change-Id: I02ceca2ff7cb87bb2b8f0cf02d31f9ab6d46a8da
src/tools/linux/tools_linux.gypi was using 'symupload/minidump_upload.m' whereas it should have been 'symupload/minidump_upload.cc' for linux. '.m' is for mac.
Reviewed-on: https://chromium-review.googlesource.com/840622
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2018-01-04 08:43:43 +00:00
bsheedy
4a02ec0303 Add asm and machine headers
Adds asm/ and machine/ directories to src/common/android/include. This
is necessary because some required files for MIPS were removed in newer
Android NDK versions, which broke Breakpad compilation.

Bug: 771171
Change-Id: Ie6a079b6b8130b549ebc6d0bc4aef0e47e7bd6c2
Reviewed-on: https://chromium-review.googlesource.com/835282
Reviewed-by: Mark Mentovai <mark@chromium.org>
2018-01-03 21:22:16 +00:00
Mike Frysinger
9bcfabcaa7 android: drop sgidefs.h hack for LSS
Breakpad shouldn't be hacking up headers for LSS.  This was eventually
fixed in LSS directly in https://codereview.chromium.org/1248033002, so
we can drop this hack on our side.

Change-Id: Iff29efe7f6af40835e0aab1f6ac3fd8d167045ef
Reviewed-on: https://chromium-review.googlesource.com/843124
Reviewed-by: Mark Seaborn <mseaborn@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-23 13:21:00 +00:00
Yunlian Jiang
4af3e83b10 Fix minidump on ChromeOS
Chrome somehow changed the memory mapping with hugepage enabled.
This makes the hack in CrOSPostProcessMappings more general.

BUG=chromium:793452
TEST=with this patch on Chromium,
         minidump_dump *dmp shows the right information on chrome

Change-Id: Iff58bf1a712a6e66cbd2d813422db7549a3080a5
Reviewed-on: https://chromium-review.googlesource.com/837963
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-20 23:46:35 +00:00
Robert Sesek
c283630201 Reconcile -[BreakpadController withBreakpadRef:] with its documentation.
The header states that if the controller is not -start:'ed that it will call
the block with a NULL BreakpadRef. As previously implemented, it asserted if
it was not started.

Change-Id: I3a329a773c0484dc1b74013717b68426758ea2cd
Reviewed-on: https://chromium-review.googlesource.com/829834
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-15 16:50:42 +00:00
Mike Wittman
aebee55695 Update binaries with dump_syms changes to write new field
Incorporates the changes in
897a12cd26

Bug: google-breakpad:751
Change-Id: I8c6de8c0477c0b1e6d7a65551ecb116c95e1a696
Reviewed-on: https://chromium-review.googlesource.com/820567
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-12 03:49:04 +00:00
Mike Wittman
897a12cd26 Write field indicating multiple symbols at an address in dump_syms
Updates dump_syms to write the optional 'm' first field in FUNCTION and
PUBLIC records to indicate that the address corresponds to more than one
symbol.

Bug: google-breakpad:751
Change-Id: I850b0122324ed5f9ec747aa92ba354a3126a7ef9
Reviewed-on: https://chromium-review.googlesource.com/820711
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-11 22:36:40 +00:00
Adam Harrison
23ad65d54a Remove duplicate import.
The mac exception_handler is included in a conditional below.
Change-Id: I505fad7ef6731706a39b7aaacc9a948800fc3069
Reviewed-on: https://chromium-review.googlesource.com/809306
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-05 19:18:39 +00:00
Mike Wittman
a61afe7a3e Make iterator string types match map container string types
Fixes a compilation error when ::string != std::string.

Bug:
Change-Id: Ifa782da65dd08973de1fc4215f658c798ae5160b
Reviewed-on: https://chromium-review.googlesource.com/802324
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-12-01 18:57:52 +00:00
Mike Wittman
b1226959a2 Add optional field indicating multiple symbols at an address
Adds an optional 'm' as the first field in FUNCTION and PUBLIC records
to indicate that the address corresponds to more than one symbol.
Controls this by a command line flag for now to give symbol file users
a chance to update.

Also reduces the number of IDiaSymbols retained in memory to one per
address. This reduces memory consumption by 8% when processing
chrome.dll.pdb.

Updates the processor to parse the new optional field.

Bug: google-breakpad:751
Change-Id: I6503edaf057312d21a1d63d9c84e5a4fa019dc46
Reviewed-on: https://chromium-review.googlesource.com/773418
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-29 21:33:23 +00:00
Mike Wittman
4eeb384f3e Update test data for identical-code-folded symbol changes
Bug: google-breakpad:749
Change-Id: I2e56c8414c98c95372bd73811581cf1e98efe88e
Reviewed-on: https://chromium-review.googlesource.com/791914
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-28 04:01:03 +00:00
Mike Wittman
70914b2d38 Make identical-code-folded symbol output more consistent between runs
Consistently output the "least" symbol by decorated name when
multiple symbols share an address.

Testing with chrome.dll.pdb the diffs between the new and old output
look sensible, and this is actually ~20% faster than the existing
implementation.

Bug: 749
Change-Id: Ie638559b63f0eb2dcb80b1ebb579228d62c63bb2
Reviewed-on: https://chromium-review.googlesource.com/758885
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-14 14:31:22 +00:00
Tomas Popela
615ad2b6f4 List missing 64-bit arches in the bundled curl
Currently the bundled curl fails to build on ppc64/ppc64le or s390x, because
it has an incomplete list of 64-bit arches (where long is 64-bit).

Similar version is currently used as a downstream patch in Fedora
https://src.fedoraproject.org/rpms/firefox/blob/master/f/build-ppc64-s390x-curl.patch
Change-Id: Id27bfe1ca048340c45926f5435336941c080f132
Reviewed-on: https://chromium-review.googlesource.com/765453
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-11-13 19:50:29 +00:00
Robert Sesek
8a0edac9ab Add index-based set functionality to NonAllocatingMap.
This enables repeatedly setting a value based on index, which avoids a
linear scan of the entry table after the first SetKeyValue().

Bug: chromium:598854
Change-Id: I9964670a09dcd8ff76180d031a373f20990bf4d8
Reviewed-on: https://chromium-review.googlesource.com/757579
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-07 23:24:48 +00:00
Peter Collingbourne
3bbf3fb0db dump_symbols: Stop rejecting files with Android packed relocation sections.
The lld linker has native support for creating packed relocation
sections, and as a result we can expect files with these sections to
have symbols.

Bug: chromium:742655
Change-Id: I48a50bff041146f51b3a8b730d7a778f832787f6
Reviewed-on: https://chromium-review.googlesource.com/754239
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-07 14:56:36 +00:00
Yi Wang
8e9080bc53 Create LongStringDictionary and replace SimpleStringDictionary on iOS
This relands fd0a0d2b7a which was reverted
in 5dad29423e, with a fix for guarding
kMaxSuffixLength which only used in assert()s with macros which breaks
chromium.mac/ios-device.

Change-Id: I5ee21b7f290517d6e7a0ef90b693b97f92392549
Reviewed-on: https://chromium-review.googlesource.com/751922
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-03 17:06:05 +00:00
Adam Harrison
550c6227bb Don’t set exit_after_write to false for tvOS.
On tvOS, the app fails to shutdown after write.
Allow exit_after_write to be false for tvOS in order to force an exit() after write.

Change-Id: Ib2e1e1d03264a2972f5607b3070f4a6287aa0a98
Reviewed-on: https://chromium-review.googlesource.com/752071
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-03 02:53:56 +00:00
Mark Mentovai
5dad29423e Revert "Create LongStringDictionary and replace SimpleStringDictionary usages in client/ios/Breakpad.mm."
This reverts commit fd0a0d2b7a.

Reason for revert: Build failures reported at https://chromium-review.googlesource.com/c/chromium/src/+/750591#message-cc4f7dd486fa1da7373ad5d83d56f550d607d429

Failed build on chromium.mac/ios-device: https://build.chromium.org/p/chromium.mac/builders/ios-device/builds/73163, https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.mac%2Fios-device%2F73163%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout

[637/3593] CXX obj/third_party/breakpad/client/long_string_dictionary.o
FAILED: obj/third_party/breakpad/client/long_string_dictionary.o 
[…]
../../third_party/breakpad/breakpad/src/common/long_string_dictionary.cc:46:16: error: unused variable 'kMaxSuffixLength' [-Werror,-Wunused-const-variable]
  const size_t kMaxSuffixLength = 4;
               ^
1 error generated.
[…]
[641/3593] CXX ios_clang_arm64/obj/third_party/breakpad/client/long_string_dictionary.o
FAILED: ios_clang_arm64/obj/third_party/breakpad/client/long_string_dictionary.o 
../../third_party/breakpad/breakpad/src/common/long_string_dictionary.cc:46:16: error: unused variable 'kMaxSuffixLength' [-Werror,-Wunused-const-variable]
  const size_t kMaxSuffixLength = 4;
               ^
1 error generated.

Change-Id: I285eaac6abfcb7d173a0d1e4998b92d5c8dd6ecb
Reviewed-on: https://chromium-review.googlesource.com/751723
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-02 17:56:17 +00:00
Peter Collingbourne
2d85d492ae Rename an argument named "register" to "reg".
This silences a warning in newer versions of clang that complains
about "register" being a deprecated keyword.

Bug: chromium:780692
Change-Id: If354b9b18421e3e910849b385c44207e0ce02590
Reviewed-on: https://chromium-review.googlesource.com/750362
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-11-02 02:40:39 +00:00
Nicholas Baldwin
7e3c165000 Fix double declaration of tgkill when using Android NDK Headers.
As of Android API level 16 tgkill is declared in the NDK version of
signal.h, which conflicts with the static definition found in
src/client/linux/handler/exception_handler.cc. This change removes
the static tgkill definition and replaces its use with sys_tgkill
from the linux syscall support library.

Bug:
Change-Id: Ic70addd8a064cfa36345d86b7e36409e2089e909
Reviewed-on: https://chromium-review.googlesource.com/738912
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-10-30 17:23:56 +00:00
Yi Wang
fd0a0d2b7a Create LongStringDictionary and replace SimpleStringDictionary usages in client/ios/Breakpad.mm.
Bug:
Change-Id: I401028f5d90417d79fb109b510aaa9660a039b44
Reviewed-on: https://chromium-review.googlesource.com/688301
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-27 17:47:03 +00:00
Bruce Dawson
73d2773f9f Avoid skipping an initializer with a goto
C++ doesn't allow skipping initialization with a goto. This means that
this code is illegal:

  void func(bool b) {
    if(b) goto END;
    int value = 0; //error C2362 with /permissive-
    //... value used here
  END:
    return;
  }

Adding an extra scope makes the code legal. This problem is only
detected with /permissive- but now that compiling with this
switch is practical we might as well stay /permissive- clean:
https://blogs.msdn.microsoft.com/vcblog/2016/11/16/permissive-switch/

Note that compiling /permissive- clean only works with the 10.0.16299.0
SDK which currently has other issues...

Bug: 773476
Change-Id: I54e64aaef46d70a817cf7da272f76d9ae5f6a6f7
Reviewed-on: https://chromium-review.googlesource.com/740287
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-26 22:25:57 +00:00
Tobias Sargeant
072f86ca83 Provide helper wrappers for basename(3) and dirname(3)
This hides the need to provide mutable C strings, and unifies
existing basename calls and variations in a single location.

Change-Id: Idfb449c47b1421f1a751efc3d7404f15f8b369ca
Reviewed-on: https://chromium-review.googlesource.com/725731
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-10-18 15:44:59 +00:00
Peter Collingbourne
9b23ca3a7c Move main executable handling out of procmaps parser loop.
If the mapping for the main executable needed to be merged (for
example, if it was linked with lld and therefore contains an r mapping
followed by an r/x mapping), we would never reach the code that makes
it the first module. Handle that situation by moving that code into
a separate loop.

This fixes an issue where breakpad_unittests fails on Android devices
when linked with lld. It appears that the glibc dynamic loader
happens to always load executables (or at least the executables that
we create) at a lower address than DSOs, so we never hit this bug on
desktop Linux.

Testing: "make check" with both gold and lld as linker. Also
breakpad_unittests when patched into Chromium on Linux (lld) and
Android (gold and lld).

Bug: chromium:469376
Change-Id: I6329e4afd2f1bf44c25a6c3e684495e21dba83a6
Reviewed-on: https://chromium-review.googlesource.com/722286
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-17 20:19:03 +00:00
Ted Mielczarek
8bb3d55af7 Rename src/common/memory.h to memory_allocator.h.
memory.h shadows a system header which normally isn't a problem
because of the include paths in Breakpad, but the Firefox build
system winds up with src/common in the include path so we've had
a workaround for this for years. Renaming the file lets us get
rid of that workaround and shouldn't hurt anything.

Change-Id: I3b7c4239dc77f3b2b7cf2b572a0cad88cd7e8522
Reviewed-on: https://chromium-review.googlesource.com/723261
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-17 14:02:43 +00:00
Tobias Sargeant
3d6076efc2 Add -s flag to microdump_stackwalk for dumping stack contents.
Note that the current MicrodumpProcessor::Process implementation has a
bug due to the fact that it creates a local Microdump instance, and then
holds onto a pointer to the object returned by microdump.GetMemory()
which is destroyed when microdump goes out of scope. This CL fixes the
crash by making Microdump outlive MicrodumpProcessor, which is the same
pattern that Minidump/MinidumpProcessor uses.

Bug: google-breakpad:748
Change-Id: I554b46d309649cf404523722bd9ee39e17a10139
Reviewed-on: https://chromium-review.googlesource.com/720809
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-10-17 10:22:46 +00:00
Tobias Sargeant
623c4a0f42 Convert {mini|micro}dump_stackwalk argument parsing to getopt.
Bug: google-breakpad:748
Change-Id: I70b16ba6456df0be038d6c7170eb22b093fdc65d
Reviewed-on: https://chromium-review.googlesource.com/718756
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-10-16 09:13:02 +00:00
Adam Harrison
bc8fb88648 ios: Adds a no-Mach exception handler
This exception_handler_no_mach does not use Mach for exception handling
so that clients such as tvOS and watchOS that do not support mach
messages can handle POSIX signals.

Change-Id: I4a4574e58834bc590e110e6ecd1825f8af1437a2
Reviewed-on: https://chromium-review.googlesource.com/714276
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-12 00:21:31 +00:00
Joshua Peraza
1c3f8d1002 Android: Use sys/types.h instead of stdint.h for sys/user.h
When using traditional headers, sys/types.h is needed to define __u64
for sys/user.h. Previously, we thought this would be provided by
stdint.h, but it is not.

Change-Id: I0e648712f4ef1e303104a5264d3d2d0b218f5d45
Reviewed-on: https://chromium-review.googlesource.com/705267
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-10-06 18:19:40 +00:00
Mark Mentovai
0bdf616c7e Fix minidump_dump_test after 6d0287851f
Change-Id: I9957f27cd134f862b9831e4b1d90f8a014eb37b6
Reviewed-on: https://chromium-review.googlesource.com/701740
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-10-05 15:18:12 +00:00
Mark Mentovai
6d0287851f Dump Crashpad extension structures in minidump_dump
This is currently mostly useful to expose the annotations that Crashpad
stores in minidumps.

Example output:

MDRawCrashpadInfo
  version = 1
  report_id = 01234567-89ab-cdef-0123-456789abcdef
  client_id = fedcba98-7654-3210-fedc-ba9876543210
  simple_annotations["channel"] = canary
  simple_annotations["plat"] = OS X
  simple_annotations["prod"] = Chrome_Mac
  simple_annotations["ver"] = 59.0.3069.0
  module_list[0].minidump_module_list_index = 0
  module_list[0].version = 1
  module_list[0].simple_annotations["ptype"] = crashpad-handler
  module_list[1].minidump_module_list_index = 28
  module_list[1].version = 1
  module_list[1].list_annotations[0] = abort() called

Change-Id: I00ba291f93ea3a37fc3754c651b3ccc542e5b8b2
Reviewed-on: https://chromium-review.googlesource.com/688416
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-09-27 21:27:17 +00:00
Orgad Shaneh
09df67311f Fix MSVC build on 64-bit
Mostly int<->size_t implicit conversions.

Warning 4366 (The result of the unary '&' operator may be unaligned)
appears in minidump.cc:907, but I don't know why. It looks aligned to me.

Change-Id: I641942adc324f8f9832b20662083dc83498688a8
Reviewed-on: https://chromium-review.googlesource.com/637390
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-09-25 07:10:11 +00:00
Orgad Shaneh
005f41eb8c Refresh refresh_binaries.bat
Change-Id: I15687f35e560eb1e25bb4d7483c8f6fe5fdf210e
Reviewed-on: https://chromium-review.googlesource.com/637391
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-09-24 23:23:20 +00:00
Mark Mentovai
1c6d161396 Restore missing #include <stdint.h> to Android <sys/user.h>
This was lost in afa9c52715, but it turns out that it’s still
necessary.

Bug: google-breakpad:733
Change-Id: I4e0e4e4d2e80c22df1ff6b82e471905773c940a3
Reviewed-on: https://chromium-review.googlesource.com/675732
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-09-20 19:34:39 +00:00
Mark Mentovai
bddcc58860 Replace remaining references to 'struct ucontext' with 'ucontext_t'
This relands
e3035bc406,
which was accidentally committed to breakpad/breakpad/src, the read-only
mirror of src in breakpad/breakpad. (Well, it should have been
read-only.) See https://crbug.com/766164.

This fixes issues with glibc-2.26.

See https://bugs.gentoo.org/show_bug.cgi?id=628782 ,
https://sourceware.org/git/?p=glibc.git;h=251287734e89a52da3db682a8241eb6bccc050c9 , and
https://sourceware.org/ml/libc-alpha/2017-08/msg00010.html for context.
Change-Id: Id66f474d636dd2afa450bab925c5514a800fdd6f
Reviewed-on: https://chromium-review.googlesource.com/674304
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-09-20 11:50:04 +00:00
Mark Mentovai
491f174949 Fix googletest/googlemock build
1. testing.gyp is a gyp file, not a gypi file. It is only referenced in
“dependencies” sections. The gypi extension is used for files that are
included by an “includes” section.

2. Update paths in testing.gyp to reflect the real locations of
googletest and googlemock following their merge into a single
repository.

Change-Id: If9c356d93aa5ffda54af46fbed648baa2274dac6
Reviewed-on: https://chromium-review.googlesource.com/673404
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-09-19 20:51:42 +00:00
Mark Mentovai
afa9c52715 android: Don’t compete with NDK API >= 21 over NDK structures
Chrome uses API 16 for 32-bit builds and API 21 for 64-bit builds. The
NDK’s <link.h> provides r_debug and link_map structure definitions only
at API 21 and above. Breakpad used a custom <link.h> to define these
structures only during 64-bit builds, which worked for Chrome’s
purposes. However, other consumers may wish to build Breakpad at
arbitrary API levels without regard to bitness. This alters Breakpad’s
custom <link.h> to correctly check the NDK API level rather than target
CPU bitness.

Likewise for <sys/user.h> on 32-bit x86, which provided a typedef for
user_fpxregs_struct to user_fxsr_struct. API 21 and above, as well as
the unified headers at any API level, always name the structure
user_fpxregs_struct.

Definitions for 64-bit ARM’s user_regs_struct and user_fpsimd_struct
have been removed from Breakpad’s copy of <sys/user.h>. The header
claims that these fallback definitions are only necessary with NDK r10,
which should no longer be in use even by Chromium, which now uses NDK
r12b. This removes the Chromium-specific ANDROID_NDK_MAJOR_VERSION macro
from use entirely.

Fixes https://stackoverflow.com/questions/44141159/ and b/65630828.

Bug: google-breakpad:733
Change-Id: I5841906297cd15b15ce48b73fd8332fd40afc9a0
Reviewed-on: https://chromium-review.googlesource.com/665740
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-09-18 14:00:44 +00:00
Mike Frysinger
6a4976483b drop bundled gflags from the checkout
The only code using gflags is google_crash_report_sender, and nothing
builds or tests that code currently.  Switch it over to using system
versions of gflags so we can drop the local prebuilts.  Tested local
builds by hand of the tool.

Bug: google-breakpad:360
Change-Id: I75d79b176468c948773079a54d87e70709feaf87
Reviewed-on: https://chromium-review.googlesource.com/665799
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-09-13 23:38:29 +00:00
Mike Frysinger
d8c6101124 drop glog from the checkout
Nothing appears to be using this anymore, so stop bundling it.

Bug: google-breakpad:360
Change-Id: Id95b36994379da92f8ef2a81754b3da5f1f79cae
Reviewed-on: https://chromium-review.googlesource.com/665503
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-09-13 21:35:17 +00:00
Mark Mentovai
7c409af709 Parse DWARF 4 line tables correctly
Breakpad’s DWARF line table reader only understood line tables at the
level of DWARF 2. This wasn’t a problem because LLVM only produced line
tables at this level, even when generating DWARF 4. But LLVM would like
to output DWARF 4 line tables when generating DWARF 4, and Breakpad
needs to understand this format. (Meanwhile, it seems that GCC has used
DWARF 4 line tables with DWARF 4 output since 4.5.0, 2010-04-14.)

DWARF 3 line tables are fully compatible with DWARF 2 (assuming that
nothing needs “prologue end,” “epilogue begin,” or “isa”, and opcodes
related to these fields are properly skipped). DWARF 4 changes the line
number program header slightly to include a “maximum operations per
instruction” field. This field must be recognized, but can safely be
ignored (and assumed to be always 1) if VLIW architectures are not
supported (they aren’t). DWARF 4 also introduces a “discriminator”,
whose opcode can also be skipped if these values are not needed (they
shouldn’t be).

This recognizes the “maximum operations per instruction” field when
processing DWARF 4 line tables, but asserts that its value is 1 and
otherwise ignores it.

This is not compatible with VLIW architectures that set this field to a
value other than 1. Such architectures are irrelevant to Breakpad, and
mainline GCC and the proposed LLVM patch always set this field to 1.
There are other things that could be extracted from DWARF 3 and 4 line
tables that aren’t currently extracted (although these are currently
irrelevant to Breakpad too).

Bug: google-breakpad:745
Change-Id: I5bf9c0b1aa654849c9cce64e60682447d10be8ba
Reviewed-on: https://chromium-review.googlesource.com/663441
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-09-13 19:50:52 +00:00
Tobias Sargeant
a1dbcdcb43 Increase the maximum number of modules allowed in minidumps.
Bug: google-breakpad:743
Change-Id: I2e40b5cc36c012c18a1c4637634fb139b0d8e14d
Reviewed-on: https://chromium-review.googlesource.com/647886
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-09-01 14:49:17 +00:00
Tobias Sargeant
c4335f0435 Fix memory leak in ppc64 stackwalker
BUG=757166

Change-Id: I967a6903332b9c3d16b583f7fa4d3c9c44c2f729
Reviewed-on: https://chromium-review.googlesource.com/643267
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-08-30 17:28:54 +00:00
Tobias Sargeant
2b3be5179e Add crash reason extraction to microdump processor
BUG=754715

Change-Id: I00fe62ed06dbbab4c8f6c416d56e2d444be11571
Reviewed-on: https://chromium-review.googlesource.com/621307
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-08-21 10:19:07 +00:00
Tobias Sargeant
b1e7ec065d Fix memory leak in ppc stackwalker
BUG=756317

Change-Id: Id096372e5a0d1e7c70e95304b1f0c181f57d3882
Reviewed-on: https://chromium-review.googlesource.com/619126
Reviewed-by: Leonard Mosescu <mosescu@chromium.org>
2017-08-18 10:24:52 +00:00
Tobias Sargeant
38cbbfed71 Add crash reason and address to microdumps.
This will allow us to provide the right information for webview renderer
crashes. At the moment the crash information for the browser process is
captured (from the debuggerd output) instead.

BUG=754715

Change-Id: I409546311b6e38fe1cf804097c18d7bb2a015d83
Reviewed-on: https://chromium-review.googlesource.com/612381
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-08-14 09:49:51 +00:00
Lars Volker
1b704857f1 Increase maximum number of regions for minidump_stackwalk.
Change I361d8812df7b2977fe2630289059d31c3c9a4cc3 increased the maximum
number of threads for minidump_stackwalk. This change also increases the
maximum number of regions.

Change-Id: I61efd4453df8809bd9cd657546d1d6727cd10281
Reviewed-on: https://chromium-review.googlesource.com/588384
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-07-28 22:28:15 +00:00
Leonard Mosescu
01431c2f61 Handle very large stack traces
The main motivation for this change is to handle very large stack
traces, normally the result of infinite recursion. This part is
actually fairly simple, relaxing a few self-imposed limits on how
many frames we can unwind and the max size for stack memory.

Relaxing these limits requires stricter and more consistent checks for
stack unwinding. There are a number of unwinding invariants that apply
to all the platforms:

1. stack pointer (and frame pointer) must be within the stack memory
   (frame pointer, if preset, must point to the right frame too)
2. unwinding must monotonically increase SP
   (except for the first frame unwind, this must be a strict increase)
3. Instruction pointer (return address) must point to a valid location
4. stack pointer (and frame pointer) must be appropriately aligned

This change is focused on 2), which is enough to guarantee that the
unwinding doesn't get stuck in an infinite loop.

1) is implicitly validated part of accessing the stack memory
   (explicit checks might be nice though).
4) is ABI specific and while it may be valuable in catching suspicious
   frames is not in the scope of this change.
3) is also an interesting check but thanks to just-in-time compilation
   it's more complex than just calling 
   StackWalker::InstructionAddressSeemsValid() 
   and we don't want to drop parts of the callstack due to an overly
   conservative check.

Bug: chromium:735989

Change-Id: I9aaba77c7fd028942d77c87d51b5e6f94e136ddd
Reviewed-on: https://chromium-review.googlesource.com/563771
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-07-12 17:53:15 +00:00
Leonard Mosescu
5f112cb174 A couple of minor fixes
1. Fixing ExceptionHandlerTest.FirstChanceHandlerRuns:
   exit() is not an async-signal-safe function (http://man7.org/linux/man-pages/man7/signal-safety.7.html)

2. Fixing entry point signature in minidump_dump
  Changed "const char* argv[]" to "char* argv[]" to match the standard entry point signature

3. Updating .gitignore to exclude unit test artifacts

Change-Id: I9662898d0bd97769621fb6476a720105821c60f0
Reviewed-on: https://chromium-review.googlesource.com/562356
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-07-11 17:24:47 +00:00
Eric Holk
66856d617b Fix asan builds
When rolling this into Chrome, we got compile failures due to
DoNullPointerDereference being undefined but the new FirstChanceHandlerRuns
tests depends on this and was still defined.

The fix is to only enable the FirstChanceHandlerRuns test on non-asan builds.

Bug:
Change-Id: I5a3da0a21e2d0dd663ffc01137496d16905293a6
Reviewed-on: https://chromium-review.googlesource.com/544186
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-06-22 17:17:43 +00:00
Eric Holk
1628d99f7b Add first chance exception handler API
This change adds the option for Breakpad hosts to register a callback
that gets the first chance to handle an exception. The handler will 
return true if it handled the exception and false otherwise.

The primary use case is V8's trap-based bounds checking support for
WebAssembly.

Bug:
Change-Id: I5aa5b87d1229f1cef905a00404fa2027ee86be56
Reviewed-on: https://chromium-review.googlesource.com/509994
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-06-19 18:23:41 +00:00
Peter Collingbourne
94b6309aec Merge exec and non-exec segments while merging executable bit.
The bfd and gold linkers create segments like this: r/x, r/w where
the r/x segment covers the start of the ELF file.

lld's segments look like this: r, r/x, r/w where the r segment covers
the start of the ELF file.

So we cannot rely on the location of the r/x to tell where the start
of the ELF is. But we can still rely on the r and r/x mappings being
adjacent. So what we do is when we see an r segment followed by an r/x,
merge the r into the r/x and claim that it is executable. This way,
the minidump writer will continue to see a single executable segment
covering the entire executable.

Testing: "make check" passes when breakpad is compiled with
lld compiled from trunk (requires bug fix from LLVM r303689).

Also patched change into chromium and tested these builds:

$ cat args.gn
is_chrome_branded = true
is_debug = false
is_official_build = true
use_lld = true
allow_posix_link_time_opt = false
is_cfi = false

$ cat args.gn
target_os = "android"
target_cpu = "arm"
is_debug = false
is_official_build = true
is_chrome_branded = true

With both builds breakpad_unittests passes and
chrome/chrome_modern_public_apk create good minidumps after navigating
to chrome://inducebrowsercrashforrealz (checked that minidump contains
stack trace entry for content::HandleDebugURL).

Bug: chromium:716484
Change-Id: Ib6ed3a8420b83acf4a5962843930fb006734cb95
Reviewed-on: https://chromium-review.googlesource.com/513610
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2017-05-26 16:51:46 +00:00
Peter Collingbourne
08bea455d4 Teach the ELF parser to handle multiple PT_NOTE phdrs.
It is legal for an ELF to contain multiple PT_NOTEs, and that is in
fact what lld's output looks like.

Testing: "make check" and breakpad_unittests when patched into
chromium.

Bug: chromium:716484
Change-Id: I01d3f8679961e2cb7e789d4007de8914c6af357d
Reviewed-on: https://chromium-review.googlesource.com/513512
Reviewed-by: Primiano Tucci <primiano@chromium.org>
Reviewed-by: Ted Mielczarek <ted@mielczarek.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-05-26 16:43:47 +00:00
Markus Stange
8880afb762 Make the cross-compilation glue for dump_syms Mac handle x86_64h.
x86_64h has a different cpusubtype from x86_64. The h is for Haswell.

BUG=

Change-Id: Icf884e5699fe120c12d13aa57cd62db5b69a2ce6
Reviewed-on: https://chromium-review.googlesource.com/457171
Reviewed-by: Ted Mielczarek <ted@mielczarek.org>
2017-05-26 16:03:39 +00:00
John Budorick
dc3ba60f0f Don't attempt to use PTRACE_GETREGS if it isn't defined.
Follow up to https://chromium-review.googlesource.com/c/484479/, which
does not compile on arm64.

Bug: chromium:725754
Change-Id: Iaa6fbc332564909a10e2602a1026c14fb25625f4
Reviewed-on: https://chromium-review.googlesource.com/515044
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-05-25 14:44:22 +00:00
Peter Collingbourne
fbfd41af5f Simplify ELF parser code.
The layout of Elf32_Nhdr and Elf64_Nhdr is the same, so remove
templating and code that extracts the elfclass from the ELF file.

Testing: "make check" and breakpad_unittests when patched into
chromium.

Bug: chromium:716484
Change-Id: I41442cfff48afc6ae1a5b604d22b67550a910376
Reviewed-on: https://chromium-review.googlesource.com/514450
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-05-25 00:14:08 +00:00
John Budorick
77305c3ae6 Wrap config.h include in HAVE_CONFIG_H.
Bug: breakpad:730
Change-Id: I5a24b96258e1114378061512239d3e18f3f753f0
Reviewed-on: https://chromium-review.googlesource.com/514283
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-05-24 20:44:03 +00:00
John Budorick
16f5b5f512 Use __NR_exit_group in MinidumpWriterTest.MinidumpStacksSkippedIfRequested.
Also adds waits for all child processes spawned in MinidumpWriterTest.

Bug: 725754
Change-Id: I3248925993dede2c113ab1989b322a9d9c8f24bd
Reviewed-on: https://chromium-review.googlesource.com/513480
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-05-24 16:05:24 +00:00
Lars Volker
ffe3e47865 Only use O_CLOEXEC on platforms that support it
Change a9fca58 made use of the O_CLOEXEC flag, which is not supported on
older Linux kernels. This change makes the use contingent on kernel
support.

Testing: I manually compiled breakpad on CentOS 5.8 running kernel
2.6.18-308.8.2.el5.centos.plusxen.

Bug: 730
Change-Id: I21dff928cfba3c156a56708913f65a0c7b5396a6
Reviewed-on: https://chromium-review.googlesource.com/498528
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-05-10 21:32:37 +00:00
Lars Volker
54a54702a1 Fix race in ExceptionHandler::GenerateDump()
When writing a minidump on Linux, we called clone() in
linux/handler/exception_handler.cc with the CLONE_FILES flag. If the
parent process died while the child waited for the continuation signal,
the write side of the pipe 'fdes' stayed open in the child. The child
would not receive a SIGPIPE and would wait forever.

To fix this, we clone without CLONE_FILES and then close the
read-side of fdes in the master before the ptrace call. That way, if the
master dies, the child will receive a SIGPIPE and will die, too.

To test this I added a sleep() call before SendContinueSignalToChild()
and then killed the master, manually observing that the child would die,
too.

Bug: 728
Change-Id: Ifd72de835a34e7d9852ae1a362e707fdc6c96c7e
Reviewed-on: https://chromium-review.googlesource.com/464708
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-05-10 18:02:37 +00:00
Andrew Ermakovich
67649c6185 Fixing breakpad on old linux kernel
Try to read the trace's registers by PTRACE_GETREGS if kernel doesn't support PTRACE_GETREGSET.

Bug:

Change-Id: I881f3a868789747ca217f22a93370c6914881f9a
Reviewed-on: https://chromium-review.googlesource.com/484479
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-04-21 17:28:03 +00:00
Gabriele Svelto
a9fca58305 Make minidump name generation on Linux as random as possible
This patch ensures that two crashes taken within the same second have
different minidump names. The random characters used in the minidump
filename are now read from /dev/urandom where possible or generated via
arc4random(). If neither is available we fall back to regular rand() but
mixing the address of an object to the current time when generating the
random seed to make it slightly less predictable.

BUG=681

Change-Id: I2e97454859ed386e199b2628d6b7e87e16481b75
Reviewed-on: https://chromium-review.googlesource.com/445784
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-04-12 18:51:24 +00:00
Robert Sesek
aa7115cfde Dump MH_DYLINKER images in upload_system_symbols.
Change-Id: I18291efe211f88ae0607a9055d027b520ef13291
Reviewed-on: https://chromium-review.googlesource.com/462676
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-03-30 03:31:20 +00:00
Tobias Sargeant
846b6335c5 Treat the process stack as the top of memory for free space histograms.
Because we can't determine the top of userspace mappable memory
directly, we rely on the fact that the process stack is allocated at the
top of the address space (minus some randomization). Anything after that
should not count as free space.

BUG=695382

Change-Id: I68453aac9732c2bd4b87236b234518068dec6640
Reviewed-on: https://chromium-review.googlesource.com/446100
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2017-03-29 10:42:31 +00:00
Lars Volker
219d0b15c4 Increase maximum number of threads for minidump_stackwalk.
BUG=

Change-Id: I361d8812df7b2977fe2630289059d31c3c9a4cc3
Reviewed-on: https://chromium-review.googlesource.com/459010
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-03-28 19:41:00 +00:00
Mike Frysinger
7a8374fc4c minidump_dump: fix up init paths
Fix some build & test failures in the previous minidump_dump code.

BUG=chromium:598947

Change-Id: Ia8fce453265167368de96747a8a92af930e78245
Reviewed-on: https://chromium-review.googlesource.com/458881
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-03-25 01:37:18 +00:00
Mike Frysinger
e1b3620ec7 minidump_dump: dump stack memory like hexdump
The current stack output is one line byte string which is not easy for
humans to parse.  Extend the print mode to support a hexdump-like view
and switch to that by default.  Now we get something like:
Stack
00000000  20 67 7b 53 94 7f 00 00  01 00 00 00 00 00 00 00  | g{S...........|
00000010  00 70 c4 44 9a 25 00 00  08 65 7a 53 94 7f 00 00  |.p.D.%...ezS...|

BUG=chromium:598947

Change-Id: I868e1cf4faa435a14c5f1c35f94a5db4a49b6a6d
Reviewed-on: https://chromium-review.googlesource.com/404008
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-03-24 16:22:21 +00:00
Mike Frysinger
117aa25107 minidump_dump: add proper cli processing
In preparation for adding more flexibility to this tool, add a
proper parser for the command line flags.  This uses the style
as seen in other breakpad tools.

BUG=chromium:598947

Change-Id: I95495e6ca7093be34d0d426f98a6c22880ff24a3
Reviewed-on: https://chromium-review.googlesource.com/457019
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-03-24 16:21:48 +00:00
Gordana Cmiljanovic
eb6c296472 Remove unused typedef
This removes unused typedef left in change:
https://chromium-review.googlesource.com/c/447697/
and fixes error:
dump_symbols.cc:613:35: error: unused typedef 'Word' [-Werror,-Wunused-local-typedef]

Change-Id: Ib5a82cd8af9a58ebf173b0f338fa9ad341819ef3
Reviewed-on: https://chromium-review.googlesource.com/459518
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-03-24 14:02:02 +00:00
Tobias Sargeant
0b7c2ea698 Fix ASSERT_EQUAL that should have been ASSERT_EQ.
BUG=703599

Change-Id: I5623705edc41644495aa4f2389056d255e22da8e
Reviewed-on: https://chromium-review.googlesource.com/459617
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2017-03-24 12:05:43 +00:00
Tobias Sargeant
97483928cc Don't generate minidump if crash thread doesn't ref principal mapping.
If the crashing thread doesn't reference the principal mapping we can
assume that not only is that thread uninteresting from a debugging
perspective, the whole crash is uninteresting. In that case we should
not generate a minidump at all.

BUG=703599

Change-Id: Ia25bbb8adb79d04dcaf3992c3d2474f3b9b1f796
Reviewed-on: https://chromium-review.googlesource.com/457338
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-03-23 15:16:01 +00:00
Joshua Peraza
6cfdde4b91 Sanity check frame pointer while stackwalking
BUG=

Change-Id: Ib9b0fd5ba7f829f8be8cf856ab371c6540279ee5
Reviewed-on: https://chromium-review.googlesource.com/458526
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-03-22 23:23:25 +00:00
Joshua Peraza
124035f4fb Use string instead of std::string
BUG=

Change-Id: I06d1a836f8ff59a6abb7e420cd35fe52610ce091
Reviewed-on: https://chromium-review.googlesource.com/457872
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-03-22 23:22:40 +00:00
Gordana Cmiljanovic
77411db895 [MIPS] Get (ptrace) value of $pc for a thread
This change is fixing LinuxPtraceDumperTest.SanitizeStackCopy
test case.

Change-Id: I1eb3becfd4b3660bc5529b5d2a5e35db0b6eb6e0
Reviewed-on: https://chromium-review.googlesource.com/458277
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-03-22 12:47:06 +00:00
Mike Frysinger
0a57d7a32b dump_context: arm: name the registers in the dump output
The current ARM minidump_dump output makes people remember or look up
how registers are mapped in the ISA.  Let's use human friendly names
instead so they don't have to.

Currently it looks like:
MDRawContextARM
  context_flags       = 0x40000006
  iregs[ 0]            = 0x3c48b000
  iregs[ 1]            = 0x3
  iregs[ 2]            = 0x20
  iregs[ 3]            = 0x0
  iregs[ 4]            = 0x1c
  iregs[ 5]            = 0x3c48b000
  iregs[ 6]            = 0x20
  iregs[ 7]            = 0x3c48b04c
  iregs[ 8]            = 0x39100611
  iregs[ 9]            = 0x1c
  iregs[10]            = 0x0
  iregs[11]            = 0xbe61c200
  iregs[12]            = 0xfb9c1fec
  iregs[13]            = 0xbe61bd28
  iregs[14]            = 0x39e19b1c
  iregs[15]            = 0x357dd74c
  cpsr                = 0x680b0010
  float_save.fpscr     = 0x0

Now it looks like:
MDRawContextARM
  context_flags        = 0x40000006
  r0                   = 0x3c48b000
  r1                   = 0x3
  r2                   = 0x20
  r3                   = 0x0
  r4                   = 0x1c
  r5                   = 0x3c48b000
  r6                   = 0x20
  r7                   = 0x3c48b04c
  r8                   = 0x39100611
  r9                   = 0x1c
  r10                  = 0x0
  r11                  = 0xbe61c200
  r12                  = 0xfb9c1fec
  sp                   = 0xbe61bd28
  lr                   = 0x39e19b1c
  pc                   = 0x357dd74c
  cpsr                 = 0x680b0010
  float_save.fpscr     = 0x0

BUG=chromium:665083

Change-Id: I46d87c4ff7303a7efcd60da1d0b67ae7a5465c8f
Reviewed-on: https://chromium-review.googlesource.com/457197
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-03-18 03:04:26 +00:00
Jon Turney
0c3b559653 Fix sporadic failure of InstructionPointerMemory test on Windows
If another memory region of interest (e.g. a thread stack) randomly happens
to lie immediately before the page allocated by this test, the memory
regions can be coalesced in the minidump generated.  Relax this test so it
correctly handles the case where the expected 256 bytes around the IP aren't
at the start of the minidump memory region.

Alternatively, that could be avoided by reserving the page before the page
used for this test, in which case this test is degenerate with
InstructionPointerMemoryMinBound and can be removed.

BUG=

Change-Id: Ib1bfb242b2c0acaa090df68334a02ac434ad880c
Reviewed-on: https://chromium-review.googlesource.com/456702
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-03-17 19:15:06 +00:00
Jon Turney
4bb0cd4743 Fix issues with Windows dump_syms_unittest
* Turn DumpSymsRegressionTest into a parameterized test so it's easier to
see which test file is failing

* Convert dump_syms_regtest.sym to DOS line endings, being careful to
preserve the required spaces at the end of 'STACK WIN' lines

* In test #4 (omap_reorder_bbs), since the .exe corresponding to the .pdb is
not present, no INFO line is generated in the .sym file.  Update .sym file.

* Stop collecting stderr from dump_syms.  Future work: perhaps it's worth
collecting stderr to compare with a different file to verify that "Couldn't
locate EXE or DLL file" is output when expected?

* Regenerate testdata for test #5 (dump_syms_regtest64), which currently
does not pass, seemingly due a mis-match in the PDB age between the .pdb
file and the .sym file.  Also add the .exe corresponding to the .pdb
present, to provide CFI

BUG=

Change-Id: I54fab866437c9e1bad3a5534cef4fe4b6ae47cd2
Reviewed-on: https://chromium-review.googlesource.com/453178
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-03-17 17:49:55 +00:00
Dragan Mladjenovic
796a6c9baf [MIPS]: Don't terminate stackwalk when $sp value doesn't change between frames
Currently on MIPS we accidentally terminate stackwalk if $sp value doesn't change between frames 
which results in incomplete callchain terminated at the point of first tailcall encountered.

Change-Id: I8f1ed1df958d8f0a9eb11fd7800062184d8f1ee2
Reviewed-on: https://chromium-review.googlesource.com/449755
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-03-16 15:59:05 +00:00
Jon Turney
7ec3caf6c7 Fix Windows client ExceptionHandlerTest tests
ExceptionHandlerTest.InvalidParameterMiniDumpTest and
ExceptionHandlerTest.PureVirtualCallMiniDumpTest both also exercise a
feature that if the MiniDumpWithFullMemory MINIDUMP_TYPE is used, both
UUID.dmp and UUID-full.dmp files are written.

This is currently broken, and requesting a minidump with
MiniDumpWithFullMemory MINIDUMP_TYPE fails, as the file handle for the full
dump is not set.

Call GenerateFullDumpFile() if MiniDumpWithFullMemory is requested, to
generate a filename for the full dump file and set the file handle.

Currently GenerateFullDumpFile() also generates another UUID for the full
dump filename, so also make the private method
MinidumpGenerator::GenerateDumpFilePath() idempotent (so the same UUID is
reused)

(Note that calling Generate(|Full)DumpFile() more than once is not
permitted, so there's no behaviour where this changed the UUID to preserve)

BUG=

Change-Id: I74304f38b398f53da1c24f368dedfba8463da9e5
Reviewed-on: https://chromium-review.googlesource.com/452978
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-03-11 20:58:29 +00:00
Roman Margold
dac2223398 iOS client identifies itself via URL params
For iOS apps, product and version information is 
now automatically provided as part of the crash 
report upload URL to allow for early rejections.

Change-Id: Ia19c490c38023f9e23ec8a537f7a203ff1e642d7
Reviewed-on: https://chromium-review.googlesource.com/436164
Reviewed-by: Roman Margold <rmargold@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-03-10 18:30:14 +00:00
George Kola
a784e84497 Use NSURLSession if the min version we support is iOS 7+.
Because many apps still support iOS 8, they were defaulting to
deprecated NSURLConnection even if the code ran on iOS 10.
NSURLConnection requires a run loop and hence the code did not
always upload if the queue ran on a thread without a Run Loop.
This should improve break pad uploads

BUG=

Change-Id: I7bff80ea977fd1ab13c8812ed933ef842dab417f
Reviewed-on: https://chromium-review.googlesource.com/451880
Reviewed-by: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-03-09 16:11:07 +00:00
Joshua Peraza
5dbd93a0f8 Fix segfault when interpreting bad debug_file
BUG=chromium:661037

Change-Id: Ia4da0bd9787c232a6a199cfdfccfbed60c2515c2
Reviewed-on: https://chromium-review.googlesource.com/450090
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-03-08 21:31:16 +00:00
Dragan Mladjenovic
32a9e03835 [MIPS]: Relax dwarf section loading to accept both PROGBITS and MIPS_DWARF section types
Change-Id: I0862d930d92687dee47daa8d4dc3a21524c1c893
Reviewed-on: https://chromium-review.googlesource.com/447697
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-03-07 16:09:40 +00:00
Maciej Pawlowski
d61d49b385 Fix dump_syms clang compilation on Windows
Clang complains about bad format strings (DWORD is an unsigned long, not
unsigned int) and signed/unsigned comparison.
This change is necessary for https://codereview.chromium.org/2712423002/

BUG=245456

Change-Id: I58da92d43d90ac535c165fca346ee6866dfce22e
Reviewed-on: https://chromium-review.googlesource.com/448037
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-03-02 13:32:02 +00:00
Scott Graham
88e5b2c880 win: Set LargeAddressAware on symupload
This was set manually on Chrome's built binary before
https://codereview.chromium.org/2173533002 but wasn't added to the build
file.

After this change:

c:\src\breakpad\src\src>dumpbin /headers tools\windows\symupload\Release\symupload.exe | grep large
                   Application can handle large (>2GB) addresses

This change only affects x86 builds.

R=mark@chromium.org
BUG=chromium:696911

Change-Id: I8f1bd5535af242edde51e70c60cf33b6170855ea
Reviewed-on: https://chromium-review.googlesource.com/447780
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-02-28 19:27:24 +00:00
Tobias Sargeant
ccf03c13eb Improve stack sanitization unittests.
Rather than relying on the process stack having all the things that
should/shouldn't be sanitized, create synthetic stacks to test all of
the important cases.

BUG=664460

Change-Id: I959266390e94d6fb83ca8ef11ac19fac89e68c31
Reviewed-on: https://chromium-review.googlesource.com/446108
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-02-24 19:59:03 +00:00
Scott Graham
19af23e3c0 Handle ntdll only emitting PUBLIC at func entry
This handles a case encountered in ntdll.dll symbols for Windows 7,
where a PUBLIC would be emitted only for the entry point to the
function. The body of the function, however, is split in a PGO-ish
fashion to another remote location in the binary. Because of this, there
were large gaps in the RVA space that would be attributed to the "last"
function that happened to have an entry point before the gap. In
practice, something like this:

0x100 Func1
0x110 Func2
0x120 Func3
0x130 Func4
...
0x800 LaterFuncs

The bodies of Func1/2/3 tend to be implemented as a fast-path check,
followed by a jmp to somewhere in the range between 0x130 and 0x800.
Because no symbols are emitted for this range, everything is attributed
to Func4, causing crash misattribution.

In this CL, the change is: after emitting the entry point symbol, also
walk in the original OMAP entries through the untranslated binary, and
for each block until we resolve to a new symbol (via the same mechanism
as we found the entry point) emit another PUBLIC indicating that there's
another block that belongs to that symbol. This effectively breaks up
the "0x130 - 0x800" range above.

R=mark@chromium.org
BUG=chromium:678874

Change-Id: Ib3741abab2e7158c81e3e34bca4340ce4d3153a1
Reviewed-on: https://chromium-review.googlesource.com/446717
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-02-23 18:28:02 +00:00
Tobias Sargeant
4a7e088a27 Make stack sanitization elide pointers to non-executable mappings.
The address space of every Android Java process is approximately 50%
mapped, which means that sanitization tends to be ineffective because
most string fragments are plausibly pointers into some mapping.

For example, the zygote on 32 bit devices has the following mappings
made by dalvik and this covers all 4 byte strings starting with a
character between 0x13 and 0x52 (which includes all uppercase characters
up to and including 'R').

12c00000-12d16000
12d16000-32c00000
32c00000-32c01000
32c01000-52c00000

In order to perform stack unwinding we only need pointers into the stack
of the thread in question, and pointers to executable mappings. If we
reduce the set of considered mappings to those mappings alone, then only
~2% of the address space is left unelided.

BUG=664460

Change-Id: I1cc27821659acfb91d658f42a83a24c176505a88
Reviewed-on: https://chromium-review.googlesource.com/446500
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-02-23 17:47:47 +00:00
Tobias Sargeant
4af8174278 Use the correct PC when determining whether to skip storing a stack.
This addresses a bug in commit 049a1532 that meant that the PC of the
crashing thread was always used to determine whether to include a stack,
instead of using the PC of the thread in question.

BUG=664460

Change-Id: Idcbd5db751e5c00941a1be28607389961c0c75d7
Reviewed-on: https://chromium-review.googlesource.com/446499
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-02-23 17:47:07 +00:00
Mike Frysinger
4e82b6fa11 minidump: mark Read as override in derived classes
The base class here declares Read as virtual, so make sure it's
marked as override in the derived classes.  This fixes some build
errors with clang.

src/google_breakpad/processor/minidump.h:853:8: error:
  'Read' overrides a member function but is not marked 'override'
  [-Werror,-Winconsistent-missing-override]
  bool Read(uint32_t expected_size_);
       ^
src/google_breakpad/processor/minidump.h:153:16: note:
  overridden virtual function is here
  virtual bool Read(uint32_t expected_size) = 0;
               ^

Change-Id: Ie4e5fec097b7f37739433a9deb39e7ed60471461
Reviewed-on: https://chromium-review.googlesource.com/444385
Reviewed-by: Tobias Sargeant <tobiasjs@chromium.org>
2017-02-20 18:03:14 +00:00
Tobias Sargeant
fd28a5bbe9 Fix compile errors arising from compiling breakpad with clang.
These compile errors occur when building the check target with:
CXX=clang++-3.8
CXXFLAGS="-Werror -Wconstant-conversion -g -O2 -std=c++11"

src/processor/stackwalker_mips.cc:60:9: error: comparison of constant
  18446744073709551615 with expression of type 'bool' is always false
  [Werror,-Wtautological-constant-out-of-range-compare]
        > 0xffffffffffffffff) {
        ^ ~~~~~~~~~~~~~~~~~~
src/processor/stackwalker_mips.cc:68:66: error: comparison of constant
  4294967295 with expression of type 'bool' is always false
  [-Werror,-Wtautological-constant-out-of-range-compare]
    if ((memory_ && memory_->GetBase() + memory_->GetSize() - 1) > 0xffffffff) {
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~

Change-Id: I29eed8f4a67b9feeb274aa1fc6c79a019135e8d6
Reviewed-on: https://chromium-review.googlesource.com/438445
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-02-17 03:18:05 +00:00
Mike Frysinger
8ba59492ab libdisasm: add upstream/license details
The license file comes from the upstream libdisasm tarball/repo.

Change-Id: I04a4002db72f778dd67dbcd71d3b5d1205a8c21d
Reviewed-on: https://chromium-review.googlesource.com/441884
Reviewed-by: Ted Mielczarek <ted@mielczarek.org>
2017-02-14 11:07:42 +00:00
George Kola
96b79e9bf8 There is no need to use the main queue just for perform selector.
We were using the main queue to queue up a perform selector and then the code
[self sendStoredCrashReports] was immediately doing a dispatch_async.
This unnecessary thread switching is not needed.

We simplify the above logic and use dispatch_after to queue the block on
the
internal queue after a delay

Note that main queue is typically more loaded and it is better for
non-UI code
to not use the main queue. This may also help improve crash log upload.

This change also switches from @synchronized to dispatch_once as that is
faster
Reference:
http://googlemac.blogspot.com/2006/10/synchronized-swimming.html

BUG=

Change-Id: I81035149cbbf13a3058ca3a11e6efd23980f19ad
Reviewed-on: https://chromium-review.googlesource.com/441364
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2017-02-13 21:45:42 +00:00
Jon Turney
d4676b89a0 Appveyor CI for Windows MSVS build
Add a .gyp file for building all windows tools, and add hook to run gyp
to create corresponding .sln files.

This doesn't try to build for platform:x64.  This fails due to various
errors caused by the assumption that size_t can be converted to an unsigned
int without loss of information, which is not true on Windows x64 (LLP64),
where size_t is 64 bits, but int is only 32 bits.

There are test failures.  client_tests failures are as described in [1].
dump_syms_unittest are as discussed in the description of [2].

[1] https://bugs.chromium.org/p/google-breakpad/issues/detail?id=520
[2] https://codereview.chromium.org/1782453003

BUG=

Change-Id: I965244eb3746f87f30160fd0577e1cc9eb7a8b08
Reviewed-on: https://chromium-review.googlesource.com/441026
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2017-02-13 17:57:15 +00:00
Mike Frysinger
cc1deb4452 processor: drop set-but-unused variable
Change-Id: Idf3fe363c76734caa3e6a6cc20a53fd1d661188d
Reviewed-on: https://chromium-review.googlesource.com/438564
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-02-12 18:51:56 +00:00
Mike Frysinger
0e45a1268a macho_reader_unittest: use EXPECT_FALSE
This avoids compile time errors:
In file included from ./src/testing/googletest/include/gtest/gtest.h:1874:0,
                 from ./src/breakpad_googletest_includes.h:33,
                 from src/common/mac/macho_reader_unittest.cc:39:
src/common/mac/macho_reader_unittest.cc: In member function 'virtual void LoadCommand_SegmentBE32_Test::TestBody()':
./src/testing/googletest/include/gtest/internal/gtest-internal.h:133:55: error:
  converting 'false' to pointer type for argument 1 of 'char testing::internal::IsNullLiteralHelper(testing::internal::Secret*)' [-Werror=conversion-null]
     (sizeof(::testing::internal::IsNullLiteralHelper(x)) == 1)
                                                       ^
...
src/common/mac/macho_reader_unittest.cc:1117:3: note: in expansion of macro 'EXPECT_EQ'
   EXPECT_EQ(false,                        actual_segment.bits_64);

Change-Id: I0cf88160dbe17b0feebed3c91ad65491b81023fd
Reviewed-on: https://chromium-review.googlesource.com/439004
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-02-12 18:51:38 +00:00
Mike Frysinger
2b7724245b windows: fix build on pre-Win10 systems
The use of DBG_PRINTEXCEPTION_WIDE_C was added for Win10 support,
but that define doesn't exist in older versions which means we fail
to build.  Put it behind an ifdef check to work everywhere.

Change-Id: Ibab8bddd5c19b4b50e356f59edeb3873c3104569
Reviewed-on: https://chromium-review.googlesource.com/441525
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-02-11 22:36:18 +00:00
Mike Frysinger
12f8ca4855 windows: update gtest/gmock paths
The Windows build has rotted a bit with the gtest/gmock updates.
Update all of the paths to fix things up again.

Change-Id: Id67ce76abfd331c0543aa4bd1138e9cc13a18c75
Reviewed-on: https://chromium-review.googlesource.com/441584
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-02-11 18:03:31 +00:00
Mike Frysinger
8b0a1053e2 fix write() unused-result warning
src/client/linux/microdump_writer/microdump_writer_unittest.cc:98:47: error:
  ignoring return value of 'ssize_t write(int, const void*, size_t)',
  declared with attribute warn_unused_result [-Werror=unused-result]
   write(STDOUT_FILENO, identifiable_string, 0);

Change-Id: I3f2305fbec0dbd1464de9aeff051e7cba2ee69a2
Reviewed-on: https://chromium-review.googlesource.com/438545
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-02-08 05:50:30 +00:00
Joshua Peraza
64c2eda38a Fixed leak of unloaded module lists.
BUG=

Change-Id: I6d03820082f793a2eac3c3c2abd184b4acf66aa4
Reviewed-on: https://chromium-review.googlesource.com/438755
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-02-07 22:41:43 +00:00
Tobias Sargeant
7ba80c7284 Address post-submit review comments related to CL #430050
See: https://chromium-review.googlesource.com/c/430050/

BUG=664460

Change-Id: I3cbfbd5b00725bd501f06427eebd976267c4f617
Reviewed-on: https://chromium-review.googlesource.com/438444
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2017-02-07 16:34:17 +00:00
Mike Frysinger
6c78460419 md5: fix strict aliasing warnings
Change-Id: I64f4570610c625b1325249fd5fa1b9edc3a89ae4
Reviewed-on: https://chromium-review.googlesource.com/438864
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-02-07 01:10:12 +00:00
Tobias Sargeant
cff58cdd0a Remove debugging fprintf in unittest code that prevents rolling breakpad
BUG=664460

Change-Id: I40d8567c659e97415db65cb308c0d39391c44353
Reviewed-on: https://chromium-review.googlesource.com/438364
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2017-02-06 15:27:19 +00:00
Tobias Sargeant
049a1532e5 Wire up stack sanitization and skipping to WriteMinidump
This makes the parameters stored in the MinidumpDescriptor structure
functional for minidumps, analogously to how they are applied to
microdumps.

BUG=664460

Change-Id: I7578e7a1638cea8f0445b18d4bbdaf5e0a32d808
Reviewed-on: https://chromium-review.googlesource.com/435380
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-02-03 10:01:12 +00:00
Roman Margold
24c359d329 Revert "Several fixes for broken Mac build"
This reverts commit 5c521532fc.
2017-02-01 16:26:39 -08:00
Roman Margold
2c4c039118 Revert "iOS client identifies itself via URL params"
This reverts commit 262a3f50fe.
2017-02-01 16:26:29 -08:00
Roman Margold
262a3f50fe iOS client identifies itself via URL params
Recently, Crash started applying quotas for crash report uploads to protect the service and its client products from misbehaving product or product version. For the protection to be effective, products need to identify themselves during report upload via URL parameters. This new code makes iOS apps using Breakpad provide the parameters automatically.
2017-02-01 09:06:31 -08:00
Roman Margold
5c521532fc Several fixes for broken Mac build 2017-02-01 08:33:44 -08:00
Tobias Sargeant
7c2799f3ba Sanitize dumped stacks to remove data that may be identifiable.
In order to sanitize the stack contents we erase any pointer-aligned
word that could not be interpreted as a pointer into one of the
processes' memory mappings, or a small integer (+/-4096).

This still retains enough information to unwind stack frames, and also
to recover some register values.

BUG=682278

Change-Id: I541a13b2e92a9d1aea2c06a50bd769a9e25601d3
Reviewed-on: https://chromium-review.googlesource.com/430050
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-01-31 14:13:48 +00:00
Joshua Peraza
cb94b71d28 Fixed a bug where cv record size was not correctly checked.
BUG=

Change-Id: I6c1d78cfe344c7b90a03f6df35193d67623bfd89
Reviewed-on: https://chromium-review.googlesource.com/434094
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-01-30 21:07:24 +00:00
Bruce Dawson
76a48f4aa9 Change symbol upload message to include 'breakpad'
The breakpad symbol uploader prints messages of this form:

    Uploaded symbols for windows-x86/eventlog_provider.dll.pdb/...

This is confusing because many people see this message and assume that
symbols are being uploaded to a symbol server. This changes the message
to clarify what is happening.

BUG=677226

Change-Id: Id6fdd8497d0cb97be43c4af010058aab9d84375c
Reviewed-on: https://chromium-review.googlesource.com/434187
Reviewed-by: Mark Mentovai <mark@chromium.org>
2017-01-28 03:11:17 +00:00
Joshua Peraza
0924d424e4 Populate stack frames with unloaded module info.
This CL hits lots of source files because:
 1. An update to the CodeModule virtual class. I added an is_loaded
  method to specify whether the module is loaded. There were several
  mocks/test classes that needed to be updated with an implementation.
  An alternative to this route would be to modify
  MinidumpUnloadedModule::code_file to prepend "Unloaded_" to the
  module name.

 2. Added an unloaded_modules parameter to
  StackFrameSymbolizer::FillSourceLineInfo.

BUG=

Change-Id: Ic9c7f7c7b7e932a154a5d4ccf292c1527d8da09f
Reviewed-on: https://chromium-review.googlesource.com/430241
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2017-01-19 19:33:56 +00:00
Tobias Sargeant
e7dfafc16e Add API to skip dump if crashing thread doesn't reference a given module (2)
Follow-up CL to add relevant code to the copy constructor and assignment
operator for MinidumpDescriptor

BUG=664460

Change-Id: I71c0ad01d8686a9215a718cebc9d11a215ea342c
Reviewed-on: https://chromium-review.googlesource.com/430711
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2017-01-19 16:33:00 +00:00
Tobias Sargeant
833cadc0a1 Add API to skip dump if crashing thread doesn't reference a given module
This CL makes it possible to skip a dump if the crashing thread doesn't
have any pointers to a given module. The concrete use case is WebView
where we would like to skip generating microdump output when webview
is unreferenced by the stack and thus cannot be responsible for the
crash in a way that would be debuggable.

The range of interesting addresses is chosen by examining the process
mappings to find the one that contains a pointer that is known to be in
the right shared object (i.e. an appropriately chosen function pointer)
passed from the client.

If the extracted stack does not contain a pointer in this range, then we
do not generate a microdump. If the stack extraction fails, we still
generate a microdump (without a stack).

BUG=664460

Change-Id: If19406a13168264f7751245fc39591bd6cdbf5df
Reviewed-on: https://chromium-review.googlesource.com/419476
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2017-01-18 15:41:07 +00:00
Joshua Peraza
c2d969cb10 Added classes to support reading unloaded module lists in minidumps.
The implementations of Module/UnloadedModule and
ModuleList/UnloadedModuleList are very similar. They have been made
separate classes because they operate on different structs, complicating
factoring code into a base class and have sufficiently different
implementation that templates would not be suitable.

When unloaded modules have partially overlapping ranges, the module
shrink down feature is used to move the start of the higher range to the
end of the lower range. If two unloaded modules overlap identically, the
second module will not be added to the range map and the failure
ignored.

Places where MinidumpUnloadedModule differs from MinidumpModule:
  code_identifier: the android/linux case is deleted since cv_records
    never exist.
  debug_file/debug_identifier/version: always return empty strings.
  Read: an expected size is provided as opposed to MD_MODULE_SIZE. A
    seek is used if there are extra, unused bytes.

Places where MinidumpUnloadedModuleList differs from
  MinidumpModuleList:
  Read: entry and header size is provided in the header in
    addition to count. This changes the checks and handling of padding.
    Failures from StoreRange are ignored.
  GetMainModule: always returns NULL.

BUG=

Change-Id: I52e93d3ccc38483f50a6418fede8b506ec879aaa
Reviewed-on: https://chromium-review.googlesource.com/421566
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2016-12-16 20:15:04 +00:00
Tobias Sargeant
f78d953511 Fix unit tests expecting no output when a microdump is suppressed.
BUG=

Change-Id: Ie4d190c68ecbd8709874a3f1ceb872b94b36914f
Reviewed-on: https://chromium-review.googlesource.com/419036
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2016-12-12 16:16:22 +00:00
Mike Percy
5c42d7288a Fix sign-compare compiler warning in MicrodumpWriterTest
Commit 7a8980997d introduced additional
tests into MicrodumpWriterTest, two of which throw warnings which break
"make check" under default settings on Linux, because the Makefiles are
configured with -Werror=sign-compare.

This patch just makes the signedness of the assertion arguments match.

Change-Id: Ib522f44205c84f91bc9b93276fad60ebbf005f60
Reviewed-on: https://chromium-review.googlesource.com/418938
Reviewed-by: Tobias Sargeant <tobiasjs@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2016-12-10 17:53:36 +00:00
Mike Frysinger
c13d6fa467 crash_generation: fix bad call to close
If signal_fd is -1 still, we end up calling close(-1).  Not generally
a problem, but it's bad form, and coverity is upset by it.

Change-Id: I46f9c7ca4be7b43af5b609dd8e3f03a0700af418
Reviewed-on: https://chromium-review.googlesource.com/414544
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2016-12-09 15:56:26 +00:00
Tobias Sargeant
596fbb61bc Log a message when microdump output is suppressed.
Change-Id: I11542ea9b702055e8f0b99c26cad2fea8681bce0
Reviewed-on: https://chromium-review.googlesource.com/417824
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2016-12-07 21:44:22 +00:00
Orgad Shaneh
87e444e17d Remove comparison of this with nullptr
GCC6 optimizes it out, leading to crash.

Change-Id: I8425d456c1364929d135ce3860121b8098bab1f7
Reviewed-on: https://chromium-review.googlesource.com/413120
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2016-12-06 13:58:40 +00:00
Tobias Sargeant
7a8980997d Do not generate a microdump if there are no webview pointers on the stack.
The stack interest range is passed in MicrodumpExtraInfo from the client.
If the extracted stack does not contain a pointer in this range, then we
assume that this is not a WebView crash, and do not generate a microdump.
If the stack extraction fails, we still generate a microdump (without a
stack).

BUG=664460

Change-Id: Ic762497f76f074a3621c7ec88a8c20ed768b9211
Reviewed-on: https://chromium-review.googlesource.com/412781
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2016-12-01 17:22:27 +00:00
Orgad Shaneh
e6ef06f13d Comment out an unused function argument
Change-Id: I09c90d496edc67d4cad3e2b99f4347dc04713bdb
Reviewed-on: https://chromium-review.googlesource.com/414357
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2016-11-29 21:04:21 +00:00
Mike Frysinger
7515ab1376 microdump_stackwalk_test: fix bashism in test
These are /bin/sh scripts, and `source` is a bash-specific command.
Switch to the portable `.` command instead.

Change-Id: I51d8253b26aa61c130bb5fdc4789f8d623c6d9db
Reviewed-on: https://chromium-review.googlesource.com/414524
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2016-11-25 04:53:01 +00:00
Orgad Shaneh
11d7510c08 Update links
code.google.com is obsolete.

Fix all broken markdown links while at it.

Change-Id: I6a337bf4b84eacd5f5c749a4ee61331553279009
Reviewed-on: https://chromium-review.googlesource.com/411800
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2016-11-18 17:24:37 +00:00
Pierre-Antoine Manzagol
4eb76cbc9e Add a crash reason string for the simulated crashpad exception code
BUG=

Change-Id: I19a1abf1d00f208943db1c362cc426ca8bd2068e
Reviewed-on: https://chromium-review.googlesource.com/409632
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-11-10 14:46:53 +00:00
Ivan Penkov
2f6cb866d6 Allow compiling the google-breakpad code using a global ::string class instead of std::string.
For more details take a look at common/using_std_string.h

BUG=

Change-Id: Ifebfc57f691ef3a3bef8cfed7106c567985edffc
Reviewed-on: https://chromium-review.googlesource.com/399738
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-11-08 01:29:06 +00:00
Scott Graham
1f574b52c6 Basic handling of CIE version 4 in dwarf reading
CIE looks like it's been emitted by clang since ~May 2015 [1]. This
means that we didn't have any CFI because this parse aborted, which
meant that all stack walks reverted to stack scanning. Allow expected
values for address size and segment descriptor size through so that
dump_syms can generate at least somewhat reasonable data.

[1]: http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150518/277292.html

R=mark@chromium.org
BUG=chromium:627529

Change-Id: I6dc92f51c4afd25c2adff92c09ccb8bb03bf9112
Reviewed-on: https://chromium-review.googlesource.com/406012
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-11-02 02:52:37 +00:00
Mike Frysinger
7df62a96eb minidump-2-core: add more control over filenames
The code has been rewriting the location of the shared lib lookup
completely which breaks normal sysroot usage with gdb.  Split out
the behavior into dedicated flags so people can opt into it.  You
can see examples of -i/-f in the usage() text.

We also change the -S behavior so that it's no longer enabled by
default -- if people want /var/lib/breakpad/, they can pass the -S
flag explicitly.

BUG=chromium:598947

Change-Id: Ic81726c27b4ad6c271c70696f2ac62798f07ccfb
Reviewed-on: https://chromium-review.googlesource.com/402909
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-11-01 03:48:58 +00:00
Hans Wennborg
26ed3386af Fix pointer arithmetic in UTF8ToUTF16Char
Found by PVS-Studio!

BUG=chromium:660198

Change-Id: I2605de2b1499f85c6e01d19e87e9eeb6af8486f3
Reviewed-on: https://chromium-review.googlesource.com/404552
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2016-10-27 23:27:56 +00:00
Mike Wittman
325120efbd Generate reason for bad function table exception
This exception is being seen in Chrome during stack unwinding.

BUG=

Change-Id: Ica3f721ca605dff835ffc3814c60bab9f6f9b192
Reviewed-on: https://chromium-review.googlesource.com/404332
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-27 21:40:12 +00:00
Mike Frysinger
54b524be13 minidump-2-core: add an -o flag for controlling core output
Always writing to stdout makes it hard to debug, and hard to use in
some script environments.  Add an explicit -o flag to make it easier.

BUG=chromium:598947

Change-Id: I79667d033c8bdc8412d3a44fe3557d65f704968f
Reviewed-on: https://chromium-review.googlesource.com/403988
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-26 18:44:42 +00:00
Mike Frysinger
ed7dcced19 minidump-2-core: rewrite argument processing
This uses the same general framework as other minidump tools by using
getopt to parse command line options, and then passing the parsed state
around as a struct rather than via globals.

This does change the --sobasedir flag to -S because we don't support
getopt_long anywhere in the tree.  Unfortunate, but better to match
all the other breakpad tools which only accept short options.

BUG=chromium:598947

Change-Id: I473081a29a8e3ef07a370848343f1a9e6681fd4e
Reviewed-on: https://chromium-review.googlesource.com/402908
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-26 17:57:43 +00:00
Ted Mielczarek
2ecb2baba8 Don't demangle Rust symbols by default, but allow linking to rust-demangle.
The Rust compiler uses GCC C++ name mangling, but it has another layer of
encoding so abi::cxa_demangle doesn't produce great results. This patch
changes dump_syms to dump unmangled names by default so that consumers can
demangle them after-the-fact.

It also adds a tiny bit of support for linking against a Rust library I wrote
that can demangle Rust symbols nicely:
https://github.com/luser/rust-demangle-capi

BUG=

Change-Id: I63a425035ebb7ac516f067fed2aa782849ea9604
Reviewed-on: https://chromium-review.googlesource.com/402308
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-25 10:43:00 +00:00
Gabriele Svelto
e6d1c032ba Fix iterating over the MDXStateFeature entries on 32-bit hosts
On 32-bit hosts the new code for dumping version 5 of the MDRawMiscInfo
structure uses a 32-bit left shift to select flags corresponding to the
entries in the MDXStateFeature array. Since the array is made of 64
element this automatically skipped half of it.

Change-Id: Ic4e3beaf6c56083524b33da9a396c14eec0d2bd2
Reviewed-on: https://chromium-review.googlesource.com/396107
Reviewed-by: Ted Mielczarek <ted@mielczarek.org>
2016-10-18 19:37:33 +00:00
Tim Angus
6b2f69dd10 Also treat DBG_PRINTEXCEPTION* as debug exceptions
Windows 10 now raises an exception when OutputDebugString* are called:
(https://ntquery.wordpress.com/2015/09/07/windows-10-new-anti-debug-outputdebugstringw/)
This change ignores these exception types such that they're not falsely
identified as a crash.

BUG=

Change-Id: I1326212662d46e16407681d5ea6377f63ee188ce
Reviewed-on: https://chromium-review.googlesource.com/398998
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-18 18:08:24 +00:00
Scott Graham
48a13da168 Provide initial EBX value to FPO frame data evaluator
EBX is sometimes used in "WIN FRAME 4" programs. Not providing the
initial value was causing the evaluation in some frames of ntdll,
resulting in a fallback to scanning and a failed stack walk.

R=mark@chromium.org
BUG=chromium:651453

Change-Id: I94a8184e1eed72b0d0e3212fe323fbdd10d56da5
Reviewed-on: https://chromium-review.googlesource.com/398059
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-14 17:51:32 +00:00
Justin Cohen
36d613ef59 Don't call _exit() on iOS.
Calling _exit() is something iOS inherited from Mac OS X Breakpad, and isn't
necessary on iOS.  This is necessary because recently iOS has started
re-launching the application if breakpad catches a startup crash and calls exit
during startup.

BUG=chromium:645146

Change-Id: Ibb5a681282a886259424655aa8506a80a1fd4f4c
Reviewed-on: https://chromium-review.googlesource.com/397058
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-10-13 04:34:00 +00:00
Mark Mentovai
98b6a6309f Fix dump_syms for C++ after 7398ce15b7
Change-Id: Ifb56d41d8c5c6e766dee459157e1345553088e2a
Reviewed-on: https://chromium-review.googlesource.com/389411
Reviewed-by: Ted Mielczarek <ted@mielczarek.org>
2016-09-26 14:13:13 +00:00
Mark Mentovai
7398ce15b7 Initial support for dumping DWARF corresponding to Swift code
The DWARF data for Swift code has a top-level DW_TAG_module DIE as the
child of the DW_TAG_compile_unit DIE and the parent of the
DW_TAG_subprogram DIEs that dump_syms uses to locate functions.
dump_syms needs to process DW_TAG_module DIEs as introducing nested
scopes to make it work with Swift.

This also reworks demangling to be language-specific, so that the C++
demangler isn't invoked when processing Swift code. The DWARF data for
Swift code presents its mangled names in the same form as used for C++
(DW_AT_MIPS_linkage_name or DW_AT_linkage_name) but the mangling is
Swift-specific (beginning with _T instead of _Z). There is no
programmatic interface to a Swift name demangler as an analogue to C++'s
__cxa_demangle(), so mangled Swift names are exposed as-is. Xcode's
"xcrun swift-demangle" can be used to post-process these mangled Swift
names on macOS.

Support for mangled names presented in a DW_AT_linkage_name attribute,
as used by DWARF 4, is added. This supersedes the earlier use of
DW_AT_MIPS_linkage_name.

BUG=google-breakpad:702,google-breakpad:715
R=ted.mielczarek@gmail.com

Review URL: https://codereview.chromium.org/2147523005 .
2016-09-23 14:22:42 -04:00
Mike Frysinger
138886803c generate a repo manifest from the DEPS file
This allows people to use repo to manage the checkout instead of gclient.
This helps when you're used to the standard repo+gerrit workflow that the
Android & Chromium OS projects use.

Change-Id: I8b720e7995af2a1a8c9ce2ee9aa6c2638441b4a1
Reviewed-on: https://chromium-review.googlesource.com/379736
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-21 20:01:47 +00:00
Ted Mielczarek
d3b9631f81 Fix a win32 build error by moving a #include out of an #ifndef _WIN32 2016-09-20 12:12:56 -04:00
Ivan Penkov
b857dfec2b Fixing the Xcode project for the Breakpad Mac crash reporter.
Added new files elf_reader and corrected the references to dump_syms. Also some corrections to be able to build using a newer Xcode and SDK version (tested with Xcode 7.3, SDK 10.11).

Patch provided by Thomas Schweitzer.

BUG=

Change-Id: I18bd3f8ce0c1d0ceb737aee2fa8305adfcc83139
Reviewed-on: https://chromium-review.googlesource.com/377746
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-02 21:50:30 +00:00
Ivan Penkov
8cb66bcef7 Corrected some old references to mm files, which were renamed to cc files a while ago.
Patch provided by Thomas Schweitzer.

BUG=

Change-Id: I1721db8cab7774b433ff6703a0ddc1eab6620c0b
Reviewed-on: https://chromium-review.googlesource.com/379898
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-09-01 17:43:04 +00:00
Ivan Penkov
704f41ec90 This change allows compiling the google-breakpad code using a global ::string class instead of std::string.
For more details take a look at common/using_std_string.h

BUG=

Change-Id: I11f1ce697be23e13f12ea8f0468bbe02fa63c967
Reviewed-on: https://chromium-review.googlesource.com/378159
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-08-30 23:31:43 +00:00
Ivan Penkov
3fef603b65 Fixing some casts in order to be able to build with new Xcode and SDK versions (tested with Xcode 7.3, SDK 10.11).
Patch provided by Thomas Schweitzer.

BUG=

Change-Id: Ib35cdf766e73e4936e66f75474d83c2602f8ceb4
Reviewed-on: https://chromium-review.googlesource.com/378059
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-08-30 20:59:37 +00:00
Ben Scarlato
968c388922 Updating ExploitabilityLinux to check memory mapping names against a prefix
instead of a specific name.

This will prevent false positives on systems which use a format such as
“[stack:69616]” for stack memory mapping names.

Change-Id: I51aeda2fe856c1f37f0d18ac06cce69fec2fffa2
Reviewed-on: https://chromium-review.googlesource.com/377086
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2016-08-29 18:39:01 +00:00
Rafal Chlodnicki
a2196179cc Fix breakpad compilation issue with clang on Windows
Fix unused variable error. Code that uses the kWaitForHandlerThreadMs
constant is inside and ifdef so in some compile configurations constant
was unused. Move it where it's used.

And do the same with other constants as requested during review.

BUG=

Change-Id: I4f4c8f36c982092d53438ed6d2a0a97772402d69
Reviewed-on: https://chromium-review.googlesource.com/374378
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-08-25 21:43:05 +00:00
Gabriele Svelto
c9f80bf1a8 Update MDRawMiscInfo to support version 5 of the MINIDUMP_MISC_INFO_N structure.
The routines used to read from the structure were also modified to accomodate for unknown future versions by skipping over the unsupported part instead of failing.

R=ted.mielczarek@gmail.com

Review URL: https://codereview.chromium.org/2109063004/ .
2016-08-19 13:29:36 -04:00
Sylvain Defresne
13c634f6a1 Revert "Don't define |r_debug| and |link_map| on Android releases 21 and later"
This reverts commit 0fc6d0c8df because it
does not compile in Chromium due to the following error:

In file included from ../../breakpad/src/client/linux/minidump_writer/linux_dumper.h:43:0,
                 from ../../breakpad/src/client/linux/minidump_writer/minidump_writer.h:41,
                 from ../../breakpad/src/client/linux/handler/exception_handler.h:42,
                 from ../../components/crash/content/app/breakpad_linux.cc:44:
../../breakpad/src/common/android/include/link.h:46:9: error: multi-line comment [-Werror=comment]
 #endif  // !defined(__aarch64__) && !defined(__x86_64__) && \
         ^

> Don't define |r_debug| and |link_map| on Android releases 21 and later
>
> NDKs for Android 21 and later have the data structures |r_debug| and
> |link_map| defined in their header files. Defining them multiple times
> generates a compiler error.
>
> This patch protects both data structures from definition on Android 21
> and later.
>
> BUG=629088
> R=rmcilroy@chromium.org
>
> Review URL: https://codereview.chromium.org/2156173002 .
>
> Patch from Thomas Zimmermann <tzimmermann@mozilla.com>.
>
> Committed: 0ebdc4a10a

BUG=629088

Change-Id: Ia8d7d0eff060d661113e544d732813820bcb69e0
Reviewed-on: https://chromium-review.googlesource.com/367717
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-08-10 22:01:39 +00:00
Sylvain Defresne
600ec35c5b Fail with a proper error message if input file is not found.
Previously, if the input file was missing, the symupload tool on Mac
would happily process, try to parse it (calling a method on nil) and
fail when trying to create the payload to send to the server as one
of the method raised a NSInvalidArgumentException when receiving a
nil value.

Change to code to instead check the file for existence which makes it
easier to understand what is happening when part of the build system
is misconfigured and invoke symupload without first creating the symbol
file.

BUG=449348

Change-Id: Icc0f08958114da4be0cbbd7a7c2aeef905bc0db1
Reviewed-on: https://chromium-review.googlesource.com/367260
Reviewed-by: Mark Mentovai <mark@chromium.org>
2016-08-09 23:13:07 +00:00
Thomas Zimmermann
0fc6d0c8df Don't define |r_debug| and |link_map| on Android releases 21 and later
NDKs for Android 21 and later have the data structures |r_debug| and
|link_map| defined in their header files. Defining them multiple times
generates a compiler error.

This patch protects both data structures from definition on Android 21
and later.

BUG=629088
R=rmcilroy@chromium.org

Review URL: https://codereview.chromium.org/2156173002 .

Patch from Thomas Zimmermann <tzimmermann@mozilla.com>.

Committed: 0ebdc4a10a
2016-08-03 15:28:43 +01:00
Mark Mentovai
5f638d5323 Remove DISALLOW_COPY_AND_ASSIGN from MinidumpStreamInfo
DISALLOW_COPY_AND_ASSIGN was inadvertently added to
Minidump::MinidumpStreamInfo in f04a010f71f6, but this class is used as
the value side of the Minidump::stream_map_ map and must be copyable
(with an old enough C++ library).

This broke:

https://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_chromeos_rel_ng/builds/247141/steps/compile%20%28with%20patch%29/logs/stdio

TBR=ivanpe@chromium.org

Review URL: https://codereview.chromium.org/2158423003 .
2016-07-20 10:08:14 -04:00
Ross McIlroy
b5200a97b7 Revert "Don't define |r_debug| and |link_map| on Android releases 21 and later"
This reverts commit 0fc10739232ac803f7304d01522db6051c7454ff.

Reason: breaks 64bit Android architectures.

BUG=629088
R=primiano@chromium.org

Review URL: https://codereview.chromium.org/2163923002 .
2016-07-20 11:27:11 +01:00
Will Harris
c99d374dde Add new exception code for OOM generated from Chromium.
See also https://codereview.chromium.org/2130293003/ for Chromium-side change and go/internal_cl_for_2130293003 for internal change.

BUG=chromium:614440
R=mark@chromium.org

Review URL: https://codereview.chromium.org/2160373002 .
2016-07-19 14:41:53 -07:00
Primiano Tucci
5adeef6117 Add process type to MicroDumpExtraInfo
BUG=616774
R=primiano@chromium.org, torne@chromium.org

Review URL: https://codereview.chromium.org/2087413002 .
2016-07-19 17:44:10 +01:00
Thomas Zimmermann
0ebdc4a10a Don't define |r_debug| and |link_map| on Android releases 21 and later
NDKs for Android 21 and later have the data structures |r_debug| and
|link_map| defined in their header files. Defining them multiple times
generates a compiler error.

This patch protects both data structures from definition on Android 21
and later.

BUG=629088
R=rmcilroy@chromium.org

Review URL: https://codereview.chromium.org/2156173002 .

Patch from Thomas Zimmermann <tzimmermann@mozilla.com>.
2016-07-19 17:00:51 +01:00
Ting-Yuan (Leo) Huang
41b91d064e Recover memory mappings before writing dump on ChromeOS
On Linux, breakpad relies on /proc/[pid]/maps to associate symbols from
addresses. ChromeOS' hugepage implementation replaces some segments
with anonymous private pages, which is a restriction of current
implementation in Linux kernel at the time of writing. Thus, breakpad
can no longer symbolize addresses from those text segments replaced by
hugepages.

This patch tries to recover the mappings. Because hugepages are always
inserted in between some .text sections, it tries to infer the names and
offsets of the segments, by looking at segments immediately precede and
succeed them.

For example, a text segment before hugepage optimization
  02001000-03002000 r-xp /opt/google/chrome/chrome

can be broken into
  02001000-02200000 r-xp /opt/google/chrome/chrome
  02200000-03000000 r-xp
  03000000-03002000 r-xp /opt/google/chrome/chrome

BUG=crbug.com/628040
R=mark@chromium.org

Review URL: https://codereview.chromium.org/2161713002 .

Patch from Ting-Yuan (Leo) Huang <laszio@chromium.org>.
2016-07-18 20:11:07 -04:00
John Budorick
965424f183 [Android] Guard some NDK workarounds by major version.
BUG=599327
R=mark@chromium.org

Review URL: https://codereview.chromium.org/2152153003 .
2016-07-15 12:49:44 -07:00
Ting-Yu Chou
dfd2da7979 Add a new argument to specify the minidump type to write on Windows.
R=ted.mielczarek@gmail.com
BUG=https://bugzilla.mozilla.org/show_bug.cgi?id=1267329

Review URL: https://codereview.chromium.org/2107083002/ .
2016-06-29 06:48:26 -04:00
Ivan Penkov
24f5931c5e Server-side workaround to handle overlapping modules.
This change is resolving an issue that was caused by the combination of:
 - Android system libraries being relro packed in N+.
 - Breakpad dealing with relro packed libraries in a hack way.

This is a fix for http://crbug/611824.

I also found an use-after-free issue (bug in Minidump::SeekToStreamType).  I disallowed the MinidumpStreamInfo copy and assign constructors and the compiler detected another similar issue in Minidump::Print.  Then I disabled the copy and assign constructors for most classes in minidump.h (just in case).  There are a couple of classes where I couldn't disallow them (since assign is used).  This will require a small refactor so I left it out of this CL.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/2060663002 .
2016-06-20 11:14:47 -07:00
Mike Frysinger
67f738b7ad linux-syscall-support: pull in latest version
The sys_mmap/sys_mmap2 weirdness has been cleaned up in lss now and there
is only one API now for everyone -- sys_mmap.

R=mseaborn@chromium.org

Review URL: https://codereview.chromium.org/2065493006 .
2016-06-14 14:17:56 -04:00
Ted Mielczarek
c44217f646 Dump INFO CODE_ID containing Build ID in Linux dump_syms
I'd like to have the Build ID available for our symbol server
uploading, and this will make it easy.

Most of this change is me rewriting dump_symbols_unittest to be
typed tests so I could add a new test there.

R=mark@chromium.org
BUG=

Review URL: https://codereview.chromium.org/2052263002 .
2016-06-10 13:23:29 -04:00
Nicholas Nethercote
7fc25b8962 Fix a trivial parsing bug caught by static analysis
R=ted
2016-06-10 09:51:14 -04:00
Ralph Giles
c65ed6573e Update symbol file documentation links.
These locations have changed since the move from Google Code.

R=ted.mielczarek@gmail.com
BUG=https://bugzilla.mozilla.org/show_bug.cgi?id=1275630
2016-06-10 06:29:06 -04:00
Primiano Tucci
a34c929f6f linux/android: add SIGTRAP to the list of signals handled by the client
__builtin_trap() causes a SIGTRAP on arm64 (at least with GCC 4.9).
SIGTRAP is not handled by breakpad, causing crashes induced by
__builtin_trap() to be missed.
Note that on x86 and arm, instead, __builtin_trap() raises a SIGILL,
which is already handled by breakapd.

BUG=chromium:614865
R=vapier@chromium.org

Review URL: https://codereview.chromium.org/2042853002 .
2016-06-08 17:04:49 +01:00
Primiano Tucci
72e94c4ddb [Android] Roll back to r10e.
BUG=599327
R=primiano@chromium.org
TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/2042873003 .
2016-06-06 20:43:36 +01:00
Primiano Tucci
7933830cb7 [Android] Revert x86 workaround changes for NDK r11c.
BUG=599327
R=primiano@chromium.org
TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/2035343002 .
2016-06-06 14:35:51 +01:00
Ivan Penkov
240ed57ee1 Adding support for overlapping ranges to RangeMap.
When enabled, adding of a new range that overlaps with an existing one can be a successful operation.  The range which ends at the higher address will be shrunk down by moving its start position to a higher address so that it does not overlap anymore.

This change is required to fix http://crbug/611824.  The actual fix will come in a separate CL.

R=mmandlis@chromium.org

Review URL: https://codereview.chromium.org/2029953003 .
2016-06-05 22:41:10 -07:00
Primiano Tucci
d269bd0f29 [Android] Update breakpad to NDK r11c.
BUG=599327
R=mark@chromium.org, primiano@chromium.org

Review URL: https://codereview.chromium.org/2025923003 .
2016-06-02 17:07:07 +01:00
Mike Frysinger
bad9e55ea5 fix signed warning errors in unittests
A bunch of gtest assert statements fail due to signed warnings as
unadorned constants are treated as signed integers.  Mark them all
unsigned to avoid that.

One example (focus on the "[with ...]" blocks that show the types):
In file included from src/breakpad_googletest_includes.h:33:0,
                 from src/common/memory_unittest.cc:30:
src/testing/gtest/include/gtest/gtest.h: In instantiation of 'testing::AssertionResult testing::internal::CmpHelperEQ(const char*, const char*, const T1&, const T2&) [with T1 = int; T2 = long unsigned int]':
src/testing/gtest/include/gtest/gtest.h:1524:23: required from 'static testing::AssertionResult testing::internal::EqHelper<true>::Compare(const char*, const char*, const T1&, const T2&, typename testing::internal::EnableIf<(! testing::internal::is_pointer<T2>::value)>::type*) [with T1 = int; T2 = long unsigned int; typename testing::internal::EnableIf<(! testing::internal::is_pointer<T2>::value)>::type = void]'
src/common/memory_unittest.cc:41:246: required from here
src/testing/gtest/include/gtest/gtest.h:1448:16: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare]
   if (expected == actual) {
                ^
cc1plus: some warnings being treated as errors
Makefile:5180: recipe for target 'src/common/src_client_linux_linux_client_unittest_shlib-memory_unittest.o' failed
make[2]: *** [src/common/src_client_linux_linux_client_unittest_shlib-memory_unittest.o] Error 1

R=ted.mielczarek@gmail.com

Review URL: https://codereview.chromium.org/2013893003 .
2016-05-26 10:09:46 -04:00