Commit graph

1963 commits

Author SHA1 Message Date
George Burgess IV
0c816d2d12 module_unittest: fix use-after-free
`Construct.FunctionsWithSameAddress` started failing at ff5892c5. It
looks like the cause of this is in the calls to
`generate_duplicate_function`:

```
generate_duplicate_function("_without_form");
generate_duplicate_function("_and_void");
```

`generate_duplicate_function` directly calls `new
Module::Function(...);`, which stores the `StringView` it's given.
`generate_duplicate_function` currently takes a `const
string &`; in the above statements, these strings get `free()`d at the
`;`.

Making the parameter a `StringView` means the `Module::Function` will
store pointers to the string literal, which lives for the whole program.

All calls to `generate_duplicate_function` are given literals.

Bug: b:235999011
Change-Id: Ied04c1307a2467b9816a83f0c4d84d47779ec610
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3726855
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2022-06-27 20:59:02 +00:00
George Burgess IV
a8e8a69591 elf_core_dump_unittest: skip test if setrlimit will fail
Some systems have constrained rlimits for core files (the CrOS chroot is
an example of this). Fail gracefully in this case, rather than breaking
the user's tests.

Bug: b:235999011
Change-Id: I5649b42d3e6fd9b4f9b11e1fd9d0d4a1083d300f
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3722724
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2022-06-24 20:05:22 +00:00
George Burgess IV
ad8a43f367 dwarf_cu_to_module_unittest: fix tests
https://crrev.com/7933ec0a69bac134b7cee4b60a5dc80743b2b1a9
removed warnings about unknown abstract origins, which caused these
tests to fail on ChromeOS. Update these tests to reflect the code
changes in said CL.

Bug: b:235999011
Change-Id: Ifa450d33080d955d33b3aadb951c2e75c0aa1c85
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3723686
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2022-06-24 19:46:57 +00:00
Dangyi Liu
467ac5701f Ignore failure in recovering optional registers
Evaluating CFI rules may fail due to e.g. the unavailability of the
memory or some register values. Failures in recovering registers other
than CFA or return address can be ignored because they are optional.

Bug: fuchsia:102034
Change-Id: Ia1d8bdb12766e32b5445b49d353fc71c63ab73e7
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3701260
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-06-14 21:39:43 +00:00
Iryna Shakhova
c4c43b80ea Reland "Support PE modules in core files when running core2md"
This is a reland of commit 0808030bee

Original change's description:
> Support PE modules in core files when running core2md
>
> Core files generated from `wine` contain both ELF and PE modules. Module
> format can be guessed by checking the file contents. If the module
> corresponds to PE-file conditions (has specific fields set up as
> described in https://code.google.com/archive/p/corkami/wikis/PE.wiki)
> we'll create a MDCVInfoPDB70 record in the minidump for it, but if
> the file cannot be opened, is too short or is not a PE file, we'll
> fall back to ELF procedure.
>
> Added /src/client/linux/minidump_writer/pe_file.{cc,h} to
> src_client_linux_libbreakpad_client_a_SOURCES and
> src_client_linux_linux_client_unittest_shlib_SOURCES.
> Makefile.in and aclocal.m4 were generated by running 'aclocal && automake'.
>
> Test: build core2md and use it to convert a core file into dmp, validate
> that the generated dmp file can be opened. Ran './configure & make'.
>
> Change-Id: I225ffeea3f582deed40ecdfe7ab77f5754e90cbe
> Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3629189
> Reviewed-by: Joshua Peraza <jperaza@chromium.org>

Change-Id: I09dd067a39a95f81f48656595e811c263561ebf2
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3695863
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-06-08 19:59:24 +00:00
Justin Cohen
82b16055af Remove usage of sprintf in dwarf_cfi_to_module.
sprintf is marked as deprecated with Xcode 14.

Bug: 1331345
Change-Id: Ic301134ec0c5e7b9ee9d590ab1423491aad5ccf7
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3692036
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2022-06-08 18:11:56 +00:00
Justin Cohen
0f1f43edd2 Revert "Support PE modules in core files when running core2md"
This reverts commit 0808030bee.

Reason for revert: Breaks Android Compile

ld.lld: error: undefined symbol: google_breakpad::PEFile::TryGetDebugInfo(char const*, google_breakpad::_RSDS_DEBUG_FORMAT*)
>>> referenced by minidump_writer.cc
>>>               client/minidump_writer.o:((anonymous namespace)::MinidumpWriter::FillRawModule(google_breakpad::MappingInfo const&, bool, unsigned int, MDRawModule*, unsigned char const*)) in archive obj/third_party/breakpad/libclient.a


https://ci.chromium.org/ui/p/chromium/builders/try/android-marshmallow-arm64-rel/1188618/overview

Original change's description:
> Support PE modules in core files when running core2md
>
> Core files generated from `wine` contain both ELF and PE modules. Module
> format can be guessed by checking the file contents. If the module
> corresponds to PE-file conditions (has specific fields set up as
> described in https://code.google.com/archive/p/corkami/wikis/PE.wiki)
> we'll create a MDCVInfoPDB70 record in the minidump for it, but if
> the file cannot be opened, is too short or is not a PE file, we'll
> fall back to ELF procedure.
>
> Added /src/client/linux/minidump_writer/pe_file.{cc,h} to
> src_client_linux_libbreakpad_client_a_SOURCES and
> src_client_linux_linux_client_unittest_shlib_SOURCES.
> Makefile.in and aclocal.m4 were generated by running 'aclocal && automake'.
>
> Test: build core2md and use it to convert a core file into dmp, validate
> that the generated dmp file can be opened. Ran './configure & make'.
>
> Change-Id: I225ffeea3f582deed40ecdfe7ab77f5754e90cbe
> Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3629189
> Reviewed-by: Joshua Peraza <jperaza@chromium.org>

Change-Id: I7105ed615a338263f112243bd8dc9e86b906fcb1
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3695862
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-06-08 18:11:47 +00:00
Ben Hamilton
4d85225467 [breakpad] Add MINIDUMP_THREAD_NAME_LIST support
Change-Id: I84205358ae48e757fa3b836747eadc32c2671756
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3690389
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-06-07 18:42:06 +00:00
Nelson Billing
737e2cd338 Look for http redirection errors from SymSrv in google_converter.
Change-Id: Ic793f2a5baceb342154c995c43bf60b6f57612a5
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3689705
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-06-06 19:47:33 +00:00
Nelson Billing
41a11409d6 Upload native symbols from google_converter.
Change-Id: I4b636ccb1dc536ad63b0995994057fe1874f4ee6
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3681980
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-06-03 20:12:57 +00:00
Nelson Billing
678d69cd78 Add symbol type option to SymUploadV2ProtocolSend.
Change-Id: Ia2eadae56c7f879ddb2212e4018024a5c04634aa
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3670054
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-05-31 21:13:35 +00:00
Nelson Billing
bee636cea4 Migrate google_converter to v2 upload API.
Change-Id: If045809cfa3a3601b93725b6b2b45089e7558eb3
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3657059
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-05-20 22:08:43 +00:00
Nelson Billing
c34fc86972 Make sym-upload-v2 windows code shareable.
Change-Id: I228c93655203977b27052a85705c42bafef1e1ef
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3656055
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-05-19 22:17:08 +00:00
Iryna Shakhova
0808030bee Support PE modules in core files when running core2md
Core files generated from `wine` contain both ELF and PE modules. Module
format can be guessed by checking the file contents. If the module
corresponds to PE-file conditions (has specific fields set up as
described in https://code.google.com/archive/p/corkami/wikis/PE.wiki)
we'll create a MDCVInfoPDB70 record in the minidump for it, but if
the file cannot be opened, is too short or is not a PE file, we'll
fall back to ELF procedure.

Added /src/client/linux/minidump_writer/pe_file.{cc,h} to
src_client_linux_libbreakpad_client_a_SOURCES and
src_client_linux_linux_client_unittest_shlib_SOURCES.
Makefile.in and aclocal.m4 were generated by running 'aclocal && automake'.

Test: build core2md and use it to convert a core file into dmp, validate
that the generated dmp file can be opened. Ran './configure & make'.

Change-Id: I225ffeea3f582deed40ecdfe7ab77f5754e90cbe
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3629189
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-05-12 18:24:10 +00:00
Adam Duke
c85eb4a59b avoid dump_syms crashing if selected arch is not found
https://crrev.com/c/3327644 introduced the ability for dump_syms to
operate on in memory data, which has the consequence of not going
through the same input validation as the dump_syms cli tool. In certain
cases, it is possible that architecture info can't be reliably
determined, e.g. new architectures that breakpad is unware of. In that
case, dump_syms should avoid crashing when calling ReadSymbolData and
return false instead.

Change-Id: Ie9acdf811300084f1d5916f4778754f8abca10e0
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3572251
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-04-15 19:07:25 +00:00
Zequan Wu
8b68c72a3f [dump_syms] Fix DW_AT_specification warning on Mac.
1. Visit DW_TAG_class_type when it's inside DW_TAG_subprogram.
2. Only warn when we can't get the name for the DIE and it has DW_AT_specification that is not in the specification map.

Bug: 1078932
Change-Id: Id3126aec305658f8f65c01675a8e9e3ea03f3651
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3579855
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-04-12 17:33:22 +00:00
Yuly Novikov
e09741c609 Fix build with Windows 10 20348 SDK
Bug: chromium:1292528
Change-Id: Iaee784fe3992725086636dddb5f73d7e1373e7d7
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3558794
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-03-29 23:51:59 +00:00
Nelson Billing
fd72a6c232 Set use_async_processing in windows symupload.
Change-Id: If9cc629a44b8c05e4be55d765800c239c47e076c
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3554917
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-03-29 23:47:37 +00:00
Nelson Billing
dccd242781 Set use_async_processing in mac symupload.
Change-Id: I9192aed92cc3ee85c6fdce54cbf51414338d7b99
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3558027
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-03-29 23:46:40 +00:00
Ivan Penkov
c685fe1153 Better identification of context frames.
Since the introduction of inlined frames, it is not sufficient to check
the stack trace length (== 1) in order to identify context frames.
Updating all location that were depending on this assumption to check
for frame trust level instead.

Change-Id: I98f966889367c2270c268b8e78b67418c89c50f1
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3499020
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-03-01 21:11:40 +00:00
Ivan Penkov
622a582fa6 Support for leaf functions which don't touch any callee-saved registers
for Windows x64 stacks.

According to https://reviews.llvm.org/D2474, LLVM does't generate unwind info for leaf function which doesn't touch any callee-saved
registers. According to MSDN, leaf functions can be unwound simply by
simulating a return.

Change-Id: Ic0503e2aca90b0ba5799133ea8439f1b5f2eefda
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3489332
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-02-24 22:51:59 +00:00
Ivan Penkov
88f5fc451e Never use frame pointer unwinding on a Windows x64 stack.
MSVC never generates code that works with frame pointer chasing, and LLVM does the same.

Change-Id: I9943160d200509c079fb91394c1a5d789dc188e5
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3486523
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-02-24 19:17:11 +00:00
Ivan Penkov
fc1b9d3203 Populating is_multiple in google_breakpad::StackFrame from symbol files.
This is needed in order to properly detect and highlight frames that
correspond to multiple functions, for example as the result of identical
code folding by the linker.

Bug: google-breakpad:751
Change-Id: I2ee7c147fcff6493c2454383ad5422b38269759a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3471034
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-02-19 22:51:15 +00:00
Sunbreak
34af6bcff1 Fix missing <memory> header for Windows dump_syms
Change-Id: Ia58efa4ec5b30f644f8114eab85ef589271291dd
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3271972
Reviewed-by: Nelson Billing <nbilling@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-02-13 15:06:00 +00:00
Nathan Scoglio
7685201906 Add support for product_name in Mac sym_upload v2
Change-Id: I6fab9f62434fd19eb7aea4a66f0dd809af57e595
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3436859
Reviewed-by: Nelson Billing <nbilling@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-02-04 22:41:30 +00:00
Takuto Ikuta
3123f102ff include memory header when using unique_ptr
This is to fix build error on Windows.

Bug: chromium:1294084
Change-Id: I8e6a2e46d53d6f5b02343b81cfaa078580a8326d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3438886
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-02-04 18:21:24 +00:00
Ivan Penkov
8205b6edb8 The X86 stack walker was doing an illegal down cast from base-class (StackFrame) to derived-class (StackFrameX86).
Inline frames are always of the base-class type (StackFrame). Treating them as derived-class and accessing members was causing heap buffer overflows.

Change-Id: Id4122ab6a31f016933038a1cb63d45d5c38481f5
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3425445
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-02-02 19:32:58 +00:00
Zequan Wu
08bd844599 Fix corner cases on Windows dump_syms
- don't do iter decrement when the map empty.
- add dummy file with id equals to 0 to represent unknown file.

Change-Id: I3fe55a459c9fa835bbe0c4272e4ac12b1150c034
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3425732
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-01-29 00:51:00 +00:00
Zequan Wu
d55a5f3dca Make symupload v2 api respect --timeout flag
Change-Id: I763f45aa395a56e9c3285544e7755a1e5a85dbe4
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3422007
Reviewed-by: Nelson Billing <nbilling@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-01-28 17:45:39 +00:00
Adam Duke
f6974b15ef namespace implementations of FileID
In trying to create a backend service that can process both ELF and
Mach-O binaries, I found that symbol collisions occur when trying to
link different implementations of FileID. This change puts the
different implementations into separate namespaces to avoid the
collision.

Change-Id: I15aabb222803f2ffbda15ed13e66793bae32ddce
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3421417
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-01-28 17:11:22 +00:00
Adam Duke
772cfc1db6 allow dump_syms to operate on contents in memory
dump_syms assumes it is operating on a file and can access a compliant
file system. This change allows dump_syms to operate on the contents of
a file that has already been read into memory. This is useful in a
server context where the file does not exist on the local file system.

Change-Id: Id63f115c2df287083d548dadd5ac487f97bde057
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3327644
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-01-25 22:18:42 +00:00
Zequan Wu
92a20b6504 Fix reading DW_AT_ranges in dwarf 5
Bug: chromium:1285381
Change-Id: I8be6b0920e4d137a5d62283ce622669fa56bc417
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3389983
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-01-14 23:26:59 +00:00
danakj
862dc68dbc Match the return type of getopt().
getopt() returns an int, not a char.

Bug: chromium:1287175
Change-Id: I9866112f7420b39ea470d9f04435ca328ab37ce0
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3387609
Reviewed-by: Mark Mentovai <mark@chromium.org>
2022-01-13 19:35:52 +00:00
Zequan Wu
bbf740148d Fix symupload build failure on Windows.
- Make handle_inline default to false in PDBSourceLineWriter constructor.
- Add --i flag for symupload to generate inline information.

Change-Id: I3149173ee635a503b9508a12ef572f8b6e5c5dfe
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3364804
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2022-01-05 21:43:13 +00:00
Zequan Wu
10afee3916 Add INLINE and INLINE_ORIGIN records on Windows dump_syms
This adds INLINE and INLINE_ORIGIN records on Window dump_syms. It also
adds more LINE records that represents the inner most callsite line info
inside a function.

Bug: chromium:1190878
Change-Id: I15c2044709f8ca831b03a453910d036f749452c6
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3133606
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2022-01-05 00:28:26 +00:00
Mark Mentovai
634a7b3fad mac: add go.mod for upload_system_symbols
This was created by running “go mod init upload_system_symbols”. This is
necessary for “go build” to work in recent versions of golang.
Previously, errors such as this were produced:

go: cannot find main module, but found .git/config in …/breakpad/src
	to create a module there, run:
	cd ../../../.. && go mod init

Change-Id: Ia88834aec2eb8ee01db452889c525a5f6ebefa25
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3345400
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2021-12-16 21:39:50 +00:00
David Faure
605c51ed96 Fix for non-constant SIGSTKSZ
On glibc > 2.33, `SIGSTKSZ` might not be constant (in which case
it expands to a call to `sysconf` which returns a `long int`); see
https://sourceware.org/pipermail/libc-alpha/2020-October/118513.html

Pass unsigned explicitly to std::max, to avoid relying on template
argument deduction. This works both with the old-style constant
`SIGSTKSZ` and the new configurable one.

Initially based on https://chromium-review.googlesource.com/c/2776379

Change-Id: I9fc95337f973e871b84735ce822b5e11ba73ea8c
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3340721
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-12-15 22:00:51 +00:00
Zequan Wu
3846f6d297 Add <call_site_file_id> to INLINE and remove <file_id> from INLINE_ORIGIN
This is the dump_syms side change on
https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3232838/.
This fixes incorrect source file names when a inlined function's source
file name is different from its parent's.

Change-Id: I25683912d206c6a8db44e322eca5f7383ea8c47e
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3248438
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-12-14 23:19:21 +00:00
Zequan Wu
b6510f998a Fix RegisterValidFlag
Return CONTEXT_VALID_NONE if register num is greater than 15 or negative.

Change-Id: I7203d9d51f54e5d589f9ea6fd62bbbaa71de3a4d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3336256
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-12-13 22:43:30 +00:00
Ivan Penkov
64b25d6653 Fixing issues in the Breakpad symbol file serialization code.
- FastSourceLineResolver::Module::LoadMapFromMemory now rejects an older version of the serialization format.
- Cleaned up several unneeded usages of scoped_ptr::get.
- Fixed the serialization of bool. The serialization code was using 255 for 'true' while the deserialization code was expecting to see 1.
- Serialization for PublicSymbol.is_multiple was missing. Deserialization was expecting it
- Added some logging to processor/source_line_resolver_base.cc

Change-Id: Iadc7d8ee23bf3a07e4ea280d5d4c3f25f6278b69
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3324395
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-12-09 05:03:53 +00:00
Zequan Wu
647aa17a7a Fix corrupted symbol file due to malformed INLINE/INLINE_ORIGIN records
- Ignore DW_TAG_inlined_subroutine with empty range.
- Don't stop parsing after parsing malformed INLINE/INLINE_ORIGIN
records, because reports can still be generated without them but won't
have inlined frames.

Bug: 1190878
Change-Id: I445105ad06b9146268f7d064e85b0d162c3f2a39
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3321166
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-12-07 20:40:40 +00:00
Zequan Wu
0ae29c99d1 Add serialization of inlines and inline origins for FastSourceLineResolver so that it can construct inlined frames later.
Bug: 1190878
Change-Id: Ie3b0f2f44e04e790501ea54680fe223974c750ab
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3294126
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-12-01 00:31:39 +00:00
Zequan Wu
c472afe064 Change Inlines in Function to be ContainedRangeMap that is easier to serialize.
Change-Id: I565d41f7d629d7ea9b66cec6760686ca201994b3
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3294125
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-11-30 23:24:59 +00:00
Zequan Wu
4458a5965a Extend ContainedRangeMap and StaticContainedRangeMap
This adds a new mode in ContainedRangeMap which allows existance of
equal ranges. Among those equal ranges, the most recently added range is
the innermost range.

This also adds a function to ContainedRangeMap and
StaticContainedRangeMap to allow users get a vector of entries that
contains given address from innermost to outermost ranges.

Change-Id: I84c1f2e49ffcaf8238df60e41498730103d1ead6
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3291137
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-11-30 23:24:46 +00:00
Zequan Wu
4ee9854be5 Limit Tokenize max_tokens to 512 when parsing INLINE record.
This is a more practical reserved capacity than
std::numeric_limits<int>::max() for the vector.

Change-Id: Ic8d4e812c3804e4f15cc51650f7a91bae7313415
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3301419
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
2021-11-29 21:48:50 +00:00
Sunbreak
2dce3fe73e Add missing config for encoding_util.h/m in iOS client project
Change-Id: I448bc3d20e8b9bc091577e9c11bcb1603bff2588
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3236246
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Nelson Billing <nbilling@google.com>
2021-11-22 18:47:26 +00:00
Alex Pankhurst
38ee0be4d1 Update Rust demangling to use rustc-demangle
The rust-demangle-capi crate hasn't been updated since 2016 and
out-of-date. Instead, Breakpad needs to use C API offered by the
rustc-demangle to demangle Rust symbols.

*** TESTING ***

1) Set up rustc-demangle

> git clone https://github.com/rust-lang/rustc-demangle.git
> cd rustc-demangle
> cargo build -p rustc-demangle-capi --release

2) Breakpad

> ./configure --with-rustc-demangle=<path to rustc-demangle>
> make check src/common/dward_cu_to_module

Change-Id: Ib68b62ef329f1397bc379a1d04c632781e4b2069
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3273324
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-11-11 02:02:49 +00:00
Alex Gough
fe35cd43f2 Allow breakpad to read extended amd64 contexts
Minidumps can contain extended, and compacted extended, contexts to
include xstate data such as the state of the cet registers cetumsr
and cetussp. Previously breakpad would reject dumps with contexts
larger than expected. With this chage, breakpad now accepts and reads
these minidumps. This change does not yet add processing for this
extra data, but will allow any minidumps to be passed on to other
processing tools, or be available for manual inspection.

See chromium-review.googlesource.com/c/crashpad/crashpad/+/2575920
for motivation.

Bug: 1250098
Change-Id: Id67649738ef1c7fb6308e05e6cd8fde790771cb2
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3256483
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2021-11-02 20:17:21 +00:00
Zequan Wu
ee2ad61263 Make processor compatible with both old and new format INLINE/INLINE_ORIGIN
This is similar to the processor part of
https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3232838/,
but added compatibility to process both old and new format of
INLINE/INLINE_ORIGIN records in symbol file.

Old INLINE format:
INLINE <inline_nest_level> <call_site_line> <origin_id>
[<address> <size>]+
New INLINE format:
INLINE <inline_nest_level> <call_site_line> <call_site_file_id>
<origin_id> [<address> <size>]+
Old INLINE_ORIGIN format:
INLINE_ORIGIN <origin_id> <file_id> <name>
New INLINE_ORIGIN format:
INLINE_ORIGIN <origin_id> <name>

Change-Id: I555d9747bfd44a1a95113b9946dcd509b7710876
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3248433
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-10-29 23:23:38 +00:00
Mark Mentovai
dfcb7b6799 Revert "Fix incorrect source file name for inlined frames"
This reverts commit 54d878abcb.

54d878abcb changed the dump_syms format incompatibly. This must be
redone in a multi-step process: the processor must be made to understand
the old and new formats simultaneously and the processor service must be
rebuilt and run with that update before dump_syms output can change to
use the new format.

Bug: chromium:1263390
Change-Id: I5b6f8aff8ea2916b2c07ac6a74b569fa27db51b9
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3244775
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-10-26 17:23:46 +00:00
André Kempe
076073c96b Enable PA and BTI for breakpad
Introduces Arm's Pointer Authentication and Branch Target Identification
to breakpad.

The changes are similar to changes for PA/BTI to Marl, see
https://github.com/google/marl/pull/204

Bug: 1145581
Change-Id: I6a770316ad333bfcfad2ce7f3c1ff78afb35c010
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3226471
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2021-10-25 13:47:48 +00:00
Zequan Wu
54d878abcb Fix incorrect source file name for inlined frames
Processor shows incorrect source file name if a frame have an inlined
frame and their source files are different.
Consider this example:
FILE 0 /tmp/a.h
FILE 1 /tmp/a.cpp
INLINE_ORIGIN 0 0 foo()
FUNC 1110 a 0 main
INLINE 0 22 0 1110 7
1110 7 3 0
1117 3 23 1

When querying the address 0x1110, we know this line 0x1110 corresponds
to /tmp/a.h line 3 and it's inside a inlined function foo() which is
defined at /tmp/a.h and called at line 22. But we don't know at which
file it's being called at line 22. So, we will get stacks like this:
void foo() /tmp/a.h:3
int main() /tmp/a.h:22

The correct stacks should be this:
void foo() /tmp/a.h:3
int main() /tmp/a.cpp:22

In this change:
1. Remove file_id field for INLINE_ORIGIN record.
2. Add call_site_file_id for INLINE record to represents the file where
this call being inlined.

After adding call_site_file_id to it (as third field), it looks like
this:
FILE 0 /tmp/a.h
FILE 1 /tmp/a.cpp
INLINE_ORIGIN 0 foo()
FUNC 1110 a 0 main
INLINE 0 22 1 0 1110 7
1110 7 3 0
1117 3 23 1

Bug: 1190878
Change-Id: Ibbb697d2f7e1b6ac3208cac6fae4353c8743198d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3232838
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-10-20 21:15:06 +00:00
Peter Kasting
71387fc200 Fix an instance of -Wshadow.
Bug: chromium:794619
Change-Id: I7edb70a915ffb3c6f945dce77b0bd913e32e85eb
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3229392
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-10-20 13:21:51 +00:00
Zequan Wu
6b66d136ca Fix building unittests failure caused by the introduction of StringView at https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3189410
Change-Id: I258863e5de6201bc24b53dbe50b4d2515d29e338
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3221513
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2021-10-14 19:28:10 +00:00
Justin Cohen
db97ea1fd0 Fix errors in minidump_exception_mac and dwarf_cu_to_module_unittest
Change-Id: I468f19048f6b48b230913e911d0da7a20d96cae8
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3222826
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Nelson Billing <nbilling@google.com>
2021-10-14 18:54:17 +00:00
Justin Cohen
d93f6b9393 ios/mac: Add exception code for Crashpad uncaught exceptions.
Change-Id: I4c6a6fb353cacb09710c579e59332d70d1e801a8
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3093129
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-10-14 17:11:21 +00:00
Marvin Scholz
0c04944727 Fix StringView build
After ff5892c5da added the new StringView,
building fails with GCC 6 due to it apparently failing to properly find
the type for nullptr_t resulting in the following error:

In file included from ../src/common/module.h:49:0,
                 from ../src/common/dwarf_cfi_to_module.h:49,
                 from ../src/common/linux/dump_symbols.cc:59:
../src/common/string_view.h:55:27: error: field 'nullptr_t' has incomplete type 'google_breakpad::StringView'
   StringView(nullptr_t) = delete;
                           ^~~~~~
../src/common/string_view.h:42:7: note: definition of 'class google_breakpad::StringView' is not complete until the closing brace
 class StringView {
       ^~~~~~~~~~

This can be fixed by adding the std:: namespace to nullptr_t.

Change-Id: I00a090d307ebe21d1143eac4a605ff319ce27048
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3201997
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-10-04 19:42:45 +00:00
Marvin Scholz
cf6246e2ba Fix warnings in http_upload.cc with GCC
The context arguments are of type DWORD_PTR which is actually a
integer type, not a pointer, so using NULL here causes a type
missmatch warning:

  error: passing NULL to non-pointer argument 8 [...]
Change-Id: Ia52f51fd0cd33af3b139f0427dec6c59c2455d0a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3168663
Reviewed-by: Primiano Tucci <primiano@chromium.org>
2021-10-04 13:26:20 +00:00
Zequan Wu
ff5892c5da Add a string pool to store functions names
- Added StringView which is used as a reference to a string, but
doesn't own the string.
- Removed the old string pool in DwarfCUToModule::FilePrivate, since
it's doing string copy.
- Added a string pool in Module to store functions/inline origins'
names (mangled and demangled).
- The peak memory usage drops from 20.6 GB to 12.5 GB when disabling
inline records and drops from 36 GB to 20.3 GB when enabling inline records.

Bug: chromium:1246974, chromium:1250351
Change-Id: Ie7e9740ea10c1930a0fc58c6becaae2d718b83b8
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3189410
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-09-30 22:10:13 +00:00
Zequan Wu
d4bf038be7 Add missing const in AssignFilesToInlineOrigins method
Change-Id: I3904d52e946158439899f4c5aaa92d1d15160745
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3183519
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2021-09-24 22:48:11 +00:00
Zequan Wu
1816ae7f35 Fix dump_syms memory leak
It moves InlineOriginMap to module.h. Let Module keeps the global InlineOriginMap to easily get all referenced InlineOrigin when emitting. And release allocated memory inside its destructor.

Verified that the symbol file with inline records for chrome is the same before and after this change.

Change-Id: I7541aa05d3d2df0b9d52d670cab58241baecf20d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3171638
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-09-24 20:39:31 +00:00
Zequan Wu
1147c2fcf0 Fix an uninitialized member variable in previous commit
Change-Id: I83a2d026f1cef1771d28b420d76de17f0cf296ec
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3166678
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-09-17 17:18:26 +00:00
Zequan Wu
30020c0d47 Use -d flag enable procecessing DW_TAG_inlined_subroutine
This change makes sure dump_syms process DW_TAG_inlined_subroutine only when -d flag is given, which save memory and time when -d is not given. Before this, it always processes DW_TAG_inlined_subroutine and -d determines whether or not to emit INLINE records.

Bug: chromium:1250351, chromium:1246974
Change-Id: I54725ba1e513cafe17268ca389ff8acc9c11b25e
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3166674
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-09-16 22:52:27 +00:00
Zyan Wu
94c4208821 fix: minidump-2-core doesn't work for new arm64 dumps
The app will check if process_architecture is ARM64_OLD which is 0x8003
but newman is a new arch which is ARM64 (0x12)
We can fix the issue by checking both values

Test: "/google/src/cloud/zyanwu/latest/google3/blaze-bin/chrome/dongle/platform/tools/minidump --crash_report_id=49ed111b84c0736e --crash_server=crash --build_number=265669 --build_branch=1.56 --product=newman-user --eureka_root=/usr/local/google/home/zyanwu/eureka --symbol_cache_dir=/usr/local/google/home/zyanwu/android/debug/symbols --debug" can work and it can convert the minidump to core dump then load gdb.
Bug: 199144156
Change-Id: I1590a5b617e55ae8347aad426ba5b636ff6dcdfb
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3146740
Reviewed-by: Sterling Augustine <saugustine@google.com>
Reviewed-by: Nelson Billing <nbilling@google.com>
2021-09-09 00:15:11 +00:00
Brian Sheedy
1e093103ca Workaround Mac arch issue
Temporarily works around an issue on Mac where the system version of
NXGetLocalArchInfo is returning x86 information on x86_64 devices,
which results in dump_syms failing on said devices. Instead, the
Breakpad implementation of NXGetLocalArchInfo, which is meant for
dump_syms_mac on Linux, will be used until the system version is fixed.

Bug: 1242776
Change-Id: Id398338e580eb9c67c61f9f01670d2e7dbe86bea
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3143524
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-09-07 20:52:52 +00:00
Lei Zhang
4722484bf6 Fix compiler errors found with -Wunreachable-code-aggressive.
Break statements immediately following returns are unreachable.

Bug: chromium:1246232
Change-Id: I0892a66617f7b27b5e317a7d9741f5fcd19249f2
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3140192
Reviewed-by: Robert Sesek <rsesek@chromium.org>
2021-09-03 13:36:45 +00:00
Zequan Wu
e87bb1b3b4 Make INLINE_ORIGIN positions not important in symbol file
This allows INLINE_ORIGIN records appears in after FUNC records.

Change-Id: I69b8b5948ed91453e15c7f4c3888dfbe38e7bc5c
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3132381
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-08-31 21:59:32 +00:00
Lei Zhang
5645ad8275 Modernize MinidumpCrashpadInfo::Print().
Use range-based for-loops where appropriate.

Change-Id: I2fffd270d434c90850e8151ee40e5adf0736ce55
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3120666
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-08-27 17:56:58 +00:00
Zequan Wu
7933ec0a69 Remove warning about unknown abstract origin
Dwarf generated by Clang -g1 will not have DW_AT_inline attribute for some DW_TAG_subprograms even if they are inlined. This warning recently increased a lot (~ 3 million) due to DW_TAG_inlined_subroutine also complains about unknown abstract origin. It caused infra failure in building bots.

Bug: 1241579
Change-Id: I9b5135925b71aa915760c140bcf73fc603bb77d3
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3111782
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-08-23 17:16:47 +00:00
Zequan Wu
4959def222 Remove usages of make_unique
Building fails for some people because configure requires c++11 but make_unique is a c++14 feature.

Change-Id: I23ce689fc92e9e90a95e7643ff29602f6b32ccbb
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3107784
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-08-19 18:59:48 +00:00
Mark Mentovai
524a6249f0 mac dump_syms: fix -d option
This is a follow-up to 3c70e0145e to make -d work.

Bug: chromium:1190878,chromium:1238693
Change-Id: Ie0c6c663c98491462fca1aa992503037f19cefa9
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3103526
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-08-18 18:08:29 +00:00
Joshua Peraza
3c70e0145e mac: conditionally generate inlines
Change-Id: I35d7a5e50537bd6f20bcb5a91d386ffee9325b18
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3098093
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-08-16 19:05:42 +00:00
Joshua Peraza
bc7ddae234 Don't count str_offsets_table header size before DWARF 5
The header is not present in earlier versions of split dwarf.

Change-Id: I8fde233268230cea157b2b3276f3cf05190962f2
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3083253
Reviewed-by: Sterling Augustine <saugustine@google.com>
2021-08-09 23:24:12 +00:00
Zequan Wu
4f5b814790 Add INLINE and INLINE_ORIGIN records to symbol file.
The size of symbol file for chrome binary increased from 577 MB to
1205 MB. There are 7,453,748 INLINE records and 1,268,493 INLINE_ORIGIN
records.

Bug: 1190878
Change-Id: I802ec1b4574c14f74ff80d0f69daf3c81085778a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2915828
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-08-03 22:05:47 +00:00
Peter Kasting
0d9416d3bf Fix some instances of -Wunreachable-code-aggressive.
Bug: chromium:1066980
Change-Id: Ie95754402ce30bbd4bfcfc0c0150f07d2e3008f6
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3055796
Reviewed-by: Nelson Billing <nbilling@google.com>
2021-07-29 15:56:57 +00:00
Peter Kasting
4c27c15b84 Fix an instance of -Wunused-but-set-variable.
Bug: chromium:1203071
Change-Id: I749fcfe30f9d634acb314a43f9c9ffcdbb26195c
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3053832
Reviewed-by: Sterling Augustine <saugustine@google.com>
2021-07-26 16:01:35 +00:00
Zequan Wu
f080350795 Add support to process INLINE records in symbol files
This adds the support to process INLINE and INLINE_ORIGIN records in
symbol files and to generate inlined frames using those records if
possible.

Bug: 1190878
Change-Id: Ia0b6d56c9de37cf818d9bb6842d58c9b68f235b2
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3024690
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-07-22 19:09:50 +00:00
Peter Kasting
32096a2dc8 Fix more instances of -Wunreachable-code-aggressive.
Bug: chromium:1066980
Change-Id: Id4bc2b08180963bc6ef61df6548341c8198d4c5e
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3036985
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-07-19 15:52:17 +00:00
Joshua Peraza
415b54ab8c Account for string offsets table header size
Section 7.26 of the DWARF 5 spec describes a header of
either 8 or 16 bytes before the offsets begin.

Bug: b/187205051
Change-Id: I1ba01008dcd7a533f59d3865762ca09b9d43032b
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/3016609
Reviewed-by: Sterling Augustine <saugustine@google.com>
2021-07-08 23:22:17 +00:00
Zequan Wu
68735f74e7 NFC: use enum SymbolData as flags
To make it easier to add flags when adding new options in SymbolData.

Example:
I want to add a flag to disable inline record for https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2915828.
Change-Id: Ifc5da27c01efa0b0bc21cfcf769d4e6d604a63c6
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2984198
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-07-07 18:29:13 +00:00
Peter Kasting
04a9ffbe59 Fix -Wunreachable-code-aggressive.
Bug: chromium:1066980
Change-Id: Iddd276bb884076591399433c6191425b3a131d0d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2995406
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2021-07-02 01:25:51 +00:00
Peter Kasting
b95c4868b1 Fix a -Wdeprecated-copy warning.
Bug: chromium:1221591
Change-Id: I52968a535f126b854f8e860b9632ffe00c55b6be
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2973213
Reviewed-by: Lei Zhang <thestig@chromium.org>
2021-06-18 17:48:13 +00:00
Darren Mo
7ba29f4a36 Mitigate upload failure when app is backgrounded.
iOS closes an app’s network connections when the app is backgrounded. This can cause an in-progress upload request to fail. We can mitigate this by requesting additional background execution time using the `UIApplication` background task APIs.

BUG=b:130302235

Change-Id: Ifd8e14ca82c736ad7dd60dcdd0d4bbcabb76f5ad
Signed-off-by: Darren Mo <darrenmo@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2251020
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-06-16 22:10:20 +00:00
Zequan Wu
dbbdf05740 Load .symtab and .strtab sections before .debug_info to deduplicate
PUBLIC records.

For chrome, the symbol file size dropped from 661 MB to 577 MB.
The number of PUBLIC records dropped from 559416 to 91930.

Change-Id: I7f703d619f2acc7c83f002e6f588f6a6569e5c87
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2916731
Reviewed-by: Lei Zhang <thestig@chromium.org>
2021-06-11 23:07:32 +00:00
Zequan Wu
a524a1e24b Fix dangling pointer in forward_ref_die_to_func
Bug: google-breakpad:843
Change-Id: I14358b239604e1faeb5a8c4c4734102571dbed09
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2951787
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2021-06-11 17:25:51 +00:00
Mike Frysinger
e21ebdacfa refresh minidump test output
When I extended the output for these fields, I missed updating the
test baselines.

Change-Id: Ic793dbc9f42771e6fafff343ee2563bb37272c3f
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2945147
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-06-07 16:00:01 +00:00
Tyrel Russell
472541827e Fix Clang Tidy error and fix ambiguous use of Endianess
Bug: b/189249305
Change-Id: I2b2e891dae5d632d965869c916c386cf3cd3c678
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2920513
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-05-26 20:14:52 +00:00
Tyrel Russell
a83110d6ba Remove last remaining use of dwarf2reader.
Bug: b/189249305
Change-Id: Id417a853928d7b17dc14dfc175c4dd236882f874
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2920512
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-05-26 19:22:38 +00:00
Tyrel Russell
0622f68827 Move the dwarf2reader objects into google_breakpad namespace to make it consistent with cfi_assembler.cc
Bug: b/189249305
Change-Id: I3433ff5c41d2f66ab292fbecb969f2cd08d24b29
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2920506
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-05-26 17:46:49 +00:00
Chingjun Lau
f7428bc397 Fix macos_dump_syms when __eh_frame is included in the dSYM file.
macho_reader assumes that every section in a segment exists, or none of the
sections exist in the file (for dSYM files).

https://reviews.llvm.org/D94460?id=315965 added __eh_frame section to the
__TEXT segments in dSYM files. All the other sections are removed, but still
have non-zero size in the header. macho_reader only looks at `fileoff` and
`filesize` fields to determine the size of the segment, but it looks at `addr`
and `size` to determine the size of the section, therefore it determines that
the sections would not fit in the segment and refused to parse the file.

In this case the removed sections all have offset == 0. Ignore such cases.

Change-Id: Ife771f7b302c1bc81c673b1103492c41321b5e3e
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2911204
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-05-21 18:56:41 +00:00
Joshua Peraza
b7ce678aec fix includes and remove tr1::unordered_map
_LIBCPP_VERSION doesn't reliably detect c++11.

Change-Id: I1adb4303269885e4a08648f049e14b244a2fde50
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2911693
Reviewed-by: Nelson Billing <nbilling@google.com>
2021-05-20 22:47:28 +00:00
Joshua Peraza
0e86eebc5a mac: fix xcode project
Change-Id: Ia8d1a6a7249cdadfd6790da34194376b3f6dbd51
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2466325
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2021-05-19 21:03:25 +00:00
Zequan Wu
275e6d46a4 Make forward reference DIEs cross compilation units.
Before this change, forward_ref_die_to_func is always empty.
Because forward reference DIEs could cross compilation units,
forward_ref_die_to_func is moved into FilePrivate.
By using "grep "name omitted" sym | wc -l", the number of functions
with no name is reduced from 26951 to 203 if forward reference only is
allowed within CU. It's reduced from 203 to 6 if crossing compilation
units is allowed.

Change-Id: Ie2a457abfc0c4d8e68fe0fa595a27ea4abf33a76
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2904093
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2021-05-18 22:17:51 +00:00
Zequan Wu
6842fa5aa8 Set addr_base_ before parsing attributes.
If there is an address index reference to .debug_addr section before
DW_AT_addr_base, addr_base_ will be 0. It will retrieve wrong address.
An example could be DW_AT_loc_pc occurs before DW_AT_addr_base.

Change-Id: Id2b337f5235470cc9beaf05a62efebbde797dacf
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2900806
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-05-17 23:03:02 +00:00
Zequan Wu
13ba5a1549 Fix parsing .debug_rnglists section
Change-Id: I1bab1517c04684b8251984498eb0d43e1505fd30
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2888265
Reviewed-by: Sterling Augustine <saugustine@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-05-13 21:05:04 +00:00
Kristofer Spinka
5c4b5d89e4 Support building with C++20
std::allocator<T>::pointer and related are removed in C++20, so moving to
std::allocator_traits which is available since C++11.
Change-Id: Ie67b5c24b27e59edf5595a3575f2794748c3817f
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2894004
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2021-05-13 15:08:00 +00:00
Lei Zhang
c484031f1f Consistently call BaseName() in various Usage() functions.
Make various tools print just their names as part of the usage
instructions, rather than the full path. Also fix a missing space in the
dump_syms usage output.

Change-Id: I2b796678cd47e7dbabcc03df2b57cdc3420c008c
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2787678
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2021-04-07 20:37:52 +00:00
Michael Bai
3bea2815bf Add option to dump crash thread only
Add minidump_stackwalk option to dump the crash thread only

Bug: 1129202

Change-Id: I1370b4dc972f76ba1d57fca083da7d486774e65a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2762072
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-04-01 17:42:21 +00:00
Brian Sheedy
dff7d5afd5 Revert "arm: Allow the first function to use linked register as return pc"
This reverts commit f2b3ab5e0a.

Reason for revert: Causes symbolization errors on ARM ChromeOS
devices crbug.com/1182948.

Original change's description:
> arm: Allow the first function to use linked register as return pc
>
> For a crash at the function entry with corrupted PC, the caller's PC
> could be lying in the link register. Using the PC from link register
> would be more effective than blindly scanning the stack immediately.
>
> Change-Id: I51673b7298e70faeeab2bfa97075e3c4793f94bc
> Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2678992
> Reviewed-by: Mike Frysinger <vapier@chromium.org>
> Reviewed-by: Joshua Peraza <jperaza@chromium.org>

Bug: 1182948
Change-Id: I2818b35ab1fb99012919cccc0fb80368e456ca15
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2765164
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-03-16 18:00:35 +00:00
Mike Frysinger
8b22babdf8 minidump-2-core: check platform_id for Linux
We have an enum for the OS, so check that instead.

Change-Id: I4bb38145553e3f5a2aa9baab330d588fef09a07e
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2757679
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-03-13 00:16:24 +00:00
Mike Frysinger
344b0ebf57 minidump_dump: decode cpu & os fields
We already have helper functions for this, so use them.

Change-Id: I6f77c9e138c461837cfb93adafce639ed8b836bb
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2753492
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-03-12 03:10:37 +00:00
Hans Wennborg
d6a6f52606 Strip LLVM-generated symbol suffixes when demangling Windows symbols
LLVM, especially in ThinLTO builds, sometimes puts a suffix on symbols
to give them a unique name. For example:

   ?foo@@YAXXZ$5520c83448162c04f2b239db4b5a2c61
   ?foo@@YAXXZ.llvm.1304071520971994875

Strip such suffixes in order to demangle the names.

Bug: chromium:1179132
Change-Id: Ibc8da0c605b95c6b9fc51802a56b89f6e7cfb7e1
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2739612
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2021-03-08 20:26:34 +00:00
Justin Cohen
7279404aea Correct native symbol upload and UUID.
The auto-detection of the UUID was missing the extra "0" added for
compatibility reasons.  The native upload also was sending malformed
HTTP.

Change-Id: I8c261fc525f0f0086f269f2dee02941dd55488cb
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2739320
Reviewed-by: Nelson Billing <nbilling@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-03-08 17:38:32 +00:00
Justin Cohen
46f4b593ee Automatically capture debugID in Mac OS symupload tool.
There's no need to pass in debug ID to symupload for native symbol
uploads, as breakpad can extra the ID itself for dsym and macho types.

Change-Id: Ib0b7703eac85bc84fe1f095e678d75b347bd872a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2724731
Reviewed-by: Nelson Billing <nbilling@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-03-02 19:22:16 +00:00
Mike Frysinger
778bd12f22 switch repo manifest to track the main branch
Change-Id: Ibb74f3c06e821ba386dd286e730fce4f9344ac75
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2718528
Reviewed-by: Ian Barkley-Yeung <iby@chromium.org>
2021-02-25 01:23:04 +00:00
Mike Frysinger
fe5025b7f1 restore gtest updates
The recent dwarf5 work in here incorrectly reverted the gtest macros.

Change-Id: I8eca7c1c85e26f5ad6ff461e4ef26d2859c08625
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2691092
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-02-11 21:12:39 +00:00
Sim Sun
f2b3ab5e0a arm: Allow the first function to use linked register as return pc
For a crash at the function entry with corrupted PC, the caller's PC
could be lying in the link register. Using the PC from link register
would be more effective than blindly scanning the stack immediately.

Change-Id: I51673b7298e70faeeab2bfa97075e3c4793f94bc
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2678992
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-02-09 01:00:32 +00:00
Caroline Tice
558bfc31e1 breakpad: Fix typo in unit test.
'uint64' -> 'unit64_t'

Change-Id: I49071328366d7a4f90dea84985ad9744de9ec46a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2643078
Reviewed-by: Sterling Augustine <saugustine@google.com>
2021-01-21 16:59:08 +00:00
Caroline Tice
3b3469e9ed breakpad: Eliminate 'unused variable' warnings.
When built with -Werror, dwar2reader.cc fails to build with three
-Wunused-variable warnings.  This CL fixes that.

Change-Id: I10487644377d623d850acc258a94bbacb368ffae
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2638927
Reviewed-by: Sterling Augustine <saugustine@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2021-01-20 20:33:59 +00:00
Caroline Tice
f794d083dc Dwarf5 fixes [5 of 5]: Recognize dwp version 5.
Fifth of 5 small patches to fix various breakpad issues found
while testing dump_syms of DWARF v5 in ChromeOS.

DWARF v5 introduces a new dwp version, version 5. The current
dwp reader only recognizes versions 1 & 2 as valid dwp versions. This
CL fixes that.

Change-Id: I5ac43b318b59e406ca1f6749232709aaef59a67b
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2634550
Reviewed-by: Sterling Augustine <saugustine@google.com>
2021-01-19 20:21:24 +00:00
Caroline Tice
3c528da94c Dwarf5 fixes [4 of 5]: Skip processing Dwarf5 type units.
Fourth of 5 small patches to fix various breakpad issues found
while testing dump_syms on DWARF v5 in ChromeOS.

Dwarfv5 adds many new Type Unit sections to debug information. Since
these only contain type information, they are of no interest to
dump_syms.  This CL gets dump_syms to skip trying to process the
type unit sections.  Without this CL, dump_syms takes ~ 3 hours to
process the DWARF v5 Chrome binary.  With this CL, dump_syms takes
~ 8 minutes to process the DWARF v5 Chrome binary (about the same
time as it takes for DWARF v4).

This CL also adds a test case to verify that type units are being
skipped.

Change-Id: Ie0bb2d675718f7041b8e9b3186ed44f80a3ad39c
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2634549
Reviewed-by: Sterling Augustine <saugustine@google.com>
2021-01-19 20:20:49 +00:00
Caroline Tice
646f0f4920 Dwarf5 fixes [3 of 5]: Fix bugs reading .debug_line_str.
Third of 5 small patches to fix various breakpad issues found
while testing dump_syms on DWARF v5 in ChromeOS.

The offset into the line table was being incorrectly added to the
.debug_string and debug_line_str sections in the code for reading
the line table.  It was also skipping trying to read the line table
if the .debug_line_str section was present.  This CL fixes these
issues.

Change-Id: If14543731016bcee201b8c33dca53e9520007222
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2634548
Reviewed-by: Sterling Augustine <saugustine@google.com>
2021-01-19 20:20:04 +00:00
Caroline Tice
ac9712d9b4 Dwarf5 fixes [2 of 5]: Handle .debug_str_offsets properly.
Second of 5 small patches to fix various breakpad issues found
while testing dump_syms on DWARF v5 in ChromeOS.

This patch adds code to properly find & parse the
DW_AT_str_offsets_base attribute, and use it to handle strings
of the forms DW_FORM_strx, DW_FORM_strx1..DW_FORM_strx4 This is the
largest of the DWARF5 fixes.  It also includes a unittest to test
using a string offset.

Change-Id: I5d1def862d9d91cae4b2853578441e04ea85449d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2634547
Reviewed-by: Sterling Augustine <saugustine@google.com>
2021-01-19 20:18:42 +00:00
Caroline Tice
f4115fad24 Dwarf5 fixes [1 of 5]: Add & use missing enums, fix typo.
First of 5 small patches to fix various breakpad issues found
while testing dump_syms on DWARF v5 in ChromeOS.

This patch adds some missing DWARF enums, and their uses, and fixes
one small typo (was updating 'lineptr' instead of '*lineptr').

Change-Id: Ic674d5db29f29a69a3f6e370d0553eb4139c91de
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2634546
Reviewed-by: Sterling Augustine <saugustine@google.com>
2021-01-19 18:51:06 +00:00
Mike Frysinger
f469cab97b update to newer googletest
This matches the version used in Chromium.

Change-Id: I1b697c7f79a4e628cecf96f6abc3e5dacac0888a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2605357
Reviewed-by: Mark Mentovai <mark@chromium.org>
2021-01-04 22:49:21 +00:00
Eric Astor
86c090b77f Do not build core_handler unless memfd_create is available
Restores build compatibility with glibc < 2.27.

Change-Id: I1e58ab5e15d7691ad076769a52260fa01c9cfd06
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2597562
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2020-12-21 22:07:02 +00:00
Snehasish Kumar
83203748ae Add a test to check debug information for split functions.
With optimizations such as -fsplit-machine-functions (clang) and
-freorder-blocks-and-partition (gcc), the function body may be
discontiguous in the binary. Control flow between the parts are routed
using jumps. This test ensures that breakpad consumes debuginfo
generated by the -fsplit-machine-functions optimization and the line
table for the cold function part is correct.

Change-Id: I44d59704864ee940dd429c5249d5d793fe081d6a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2591951
Reviewed-by: Sterling Augustine <saugustine@google.com>
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2020-12-15 17:14:09 +00:00
Snehasish Kumar
ebc5567370 Fix a typo in lineinfo unittest.cc
When initializing the LineReader, the size passed should be the sizeof
the dwarf4 line program.

Change-Id: I67e6fa404d4fa8851e4958013a35a061fe169156
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2585345
Reviewed-by: Sterling Augustine <saugustine@google.com>
2020-12-10 19:58:43 +00:00
Ludovic Guegan
78f7ae495b pid2md: generate a minidump from a running process
On Linux, this tool generates a minidump for given process. It requires
the permission to trace the process and access its /proc directory. This
is useful when a defective behavior of a process does not lead to a
crash. For example, it can be used by a watchdog or if a process does
not correctly respond to a termination request.

Change-Id: Iab501e42c064a537aea62831c471e395ff697186
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2539920
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2020-11-24 08:18:56 +00:00
Ludovic Guegan
bd4a28c08b core_handler: coredump handler to produce minidump
On Linux, it is possible to register a core handler via
/proc/sys/kernel/core_pattern. Doing so invokes the core handler when
a process crash. The core_handler uses /proc/<pid>/mem to access the
process memory. This way it is not necessary to process the full
coredump which takes time and consumes memory.

In order to profit from this core handler, for example, one can
integrate dump_syms into Yocto and generate an archive with the
breakpad symbols of all the binaries in the rootfs. Minidumps are
especially useful on embedded systems since they are lightweight and
provide contextual information.

Change-Id: I9298d81159029cefb81c915831db54884310ad05
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2536917
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2020-11-23 23:15:15 +00:00
Ludovic Guegan
e3d485f73f Dwarf5ReadRangeList: remove duplicated declaration
Bug: Test Dwarf5ReadRangeList does not compile with GCC 10 because of
Change-Id: Ibeea82084bbf4c1d0e760a7bba14109401cf3639
duplicated declaration.
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2536913
Reviewed-by: Sterling Augustine <saugustine@google.com>
2020-11-13 17:15:14 +00:00
Sterling Augustine
78180df608 Use size_t to fix the build on mac.
Change-Id: Id145bdb711eea9ee33bcd9f258ff3befd6e7e86b
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2465487
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2020-10-12 18:09:01 +00:00
Sterling Augustine
a9afca9c06 Support miscelaneous dwarf5 forms.
Most of this is simple, "Read the form, get the data, then
call ProcessAttribute."

Handling DW_FORM_implcit_const is a little trickier, as it
is the only form that stores its value inline in the abbrev
table itself. Add a test for that.

Print errors for supplementary object files.

Change-Id: I0999b039848bded1891998a866e5059acd538a09
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2446627
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2020-10-09 16:56:59 +00:00
Sterling Augustine
9ecccc5512 Implement dwarf5 range lists.
This is a big change. dwarf5 range lists are quite a bit more complicated
than dwarf 4 range lists, both in the contextual information required, and
in their own representation and interpretation.

The big design choice here is how to pass the CU information all the
way down to the reader. I chose a structure, because otherwise the
parameter list gets very long and error prone (and has to be passed
down several levels). This structure could be made a parto of the CU
context itself, or the range handler, so it wouldn't have to be
separately assembled at range-list read time, but both of those
solutions get even more invasive, and harder to follow.

I've tried to figure out how to break this into smaller changes, but it
affects nearly everything that has to do with a compilation unit's
own addresses and when decisions must be made about how to read them.
Dependency injection will do that to you.

It does add tests for range list reading, which did not exist before.

Change-Id: I923b9a2c3379a0f52609bc05310097de5cbb7227
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2446635
Reviewed-by: Joshua Peraza <jperaza@chromium.org>
2020-10-08 21:59:15 +00:00
Joshua Peraza
5c7535af78 amd64: reject frames with invalid rsp/rip
CFI might compute invalid rsp/rip values if the values in the callee
frame were corrupted, as in stack overflow. Rejecting the frame
computed by CFI allows Breakpad to fall-back to scanning.

Bug: b/169611285
Change-Id: Ifeb08ab5639932c0e23722a161d9d15403738019
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2456037
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-10-07 19:33:38 +00:00
Sterling Augustine
f6669d6df4 Revert "Refactor rangelist handling to prepare for dwarf5 .debug_rngslist"
This reverts commit 2b936b06c1.

After getting deep into the dwarf5 range reader, I realized that this
should be done a somewhat different way. So reverting in favor or
a better design, coming in a few minutes.

Change-Id: Ie0b2846e70b3df1e637831e96ea69fe093f4e712
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2446011
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-10-02 17:55:10 +00:00
Sterling Augustine
2b936b06c1 Refactor rangelist handling to prepare for dwarf5 .debug_rngslist
Dwarf5 introduces a new .debug_rngslist section, to take the place
of the Dwarf4 .debug_ranges. However, the dwarf version is CU-based,
and not file-based, so there can be both sections, and which section
the CU needs isn't known until the dwarf parser encounters either
DW_AT_ranges (dwarf 4 and lower) or DW_AT_rnglists_base (dwarf 5).

This change refactors the code around range lists and range list
readers to defer the decision of what section to parse until
the relevant attribute is found. It moves the range list section
reader from the range-list handler itself (which doesn't know which
section it will use) to the CU context, and then lets the handler
know when it encounters DW_AT_ranges.

I will add a reader for the new dwarf5 section, along with the code to
interpret the new section, and its forms and such in a subsequent patch.

Change-Id: Ie92e4c9daa3f0acb98d7ef74f6b9c2065db849b1
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2433684
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-28 17:56:12 +00:00
Nelson Billing
9c4671f2e3 Change JSON serialization error check.
- Mac OS symupload used to check for errors in JSON serialization by
inspecting the "error" out parameter of the serialization function. Now
it checks the returned data for "nil".
- Similar change for the HTTP request that's made in the same function.

Change-Id: I86f50ef44e60ee119c302e0614b115a8d35e9b5b
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2390753
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-09 22:07:06 +00:00
Mike Frysinger
bdac77a801 file_id_unittest: avoid system()
We have API's for copying files & changing file modes, so there's
no sense in using system() to run programs to do that.

For the strip call, do the minimal spawn+wait dance.  This avoids
weird quoting string issues at least.

Change-Id: Ibda117f243e886c0c7fcf8076fb8602b8d3ba42d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2396558
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-08 00:16:33 +00:00
Mike Frysinger
5640e57f1f CopyFile: add a C++ API
Having to swizzle to C strings all the time is a bit annoying.

Change-Id: I0b80877706e32e873e567685f6b471745da70311
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2396557
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-09-07 23:03:28 +00:00
Sim Sun
c6d49c47a0 linux: Fix leak when the offset of memory_mapped_file is greater than 0
Breakpad should only map the file content after the offset instead of
the whole file. Mapping the whole file while only unmap 'file_len - offset'
would leak 'offset' bytes of mapping in virtual memory.

Change-Id: I10be4f929d969703a6a02c1f709d2a4ca86a6e9e
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2393468
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2020-09-05 02:52:36 +00:00
Nelson Billing
9c38ab7c67 Add native symbol uploads to Mac OS symupload tool.
- sym-upload-v2 protocol only.
- Supports elf, dwp, debug_only, macho, dsym, pe, and pdb (with the classic mode being called 'breakpad').

Change-Id: I68c0065aec3a7ffe29b364dd9e2e1dbdb58e3e5d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2357528
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-08-17 22:31:50 +00:00
Sim Sun
62d9272419 linux: Fix segfault when there is no section header in ELF file
Some vendor library doesn't contain the section header. It causes
segmentation fault in `FindElfClassSection`.

> e_shoff:
> This member holds the section header table's file offset in bytes.
> If the file has no section header table this member holds zero.

Change-Id: Id98d6ff3bd16af4541deb5a55a8fad2fa74eda23
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2354427
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-08-15 05:28:45 +00:00
Joshua Peraza
087795c851 processor: subtract 1 from return pointers while scanning
Each stackwalker subtracts the size of an instruction
from a frame's instruction pointer to determine which
instruction it was executing. This should also be done
for pointers examined while scanning for likely return
addresses to ensure that those pointers don't point
past the end of functions.

Bug: b/118634446
Change-Id: I043e3f1e51a2c0a3d99ed14bf18ea64dc98add44
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2356649
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-08-14 17:26:39 +00:00
Nelson Billing
014e84252c Escape more characters in Mac OS sym-upload-v2 debug_file strings.
- Attempt to escape all characters which must be escaped in a URL or JSON string, for debug_file, since almost all of these are legal filename characters.

Change-Id: Ic7a9c1aef00093d164683be7db84f4f282f45f7a
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2339706
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-08-12 22:12:51 +00:00
Nelson Billing
e3a62dc550 [Mac]Exit with unique status in symupload when file already exists.
- This change should also be made for other platforms.
- This allows users to tell the difference between upload succeeding, failing, and being skipped because the file already exists on server.

Change-Id: I0b404da7aac29e0a16346bbd816ad1c815985bce
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2341373
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-08-06 22:00:38 +00:00
Nelson Billing
3d8daa2c74 Fix sym-upload-v2 whitespace in filenames.
- Checking symbol status would fail for files whose names contained spaces, because the file name was being put in the URL unescaped.
- Now the filename is escaped before being put in URL when checking symbol status.

Change-Id: I3b989d877e0fd9aef57ec13bdbbb6c3dacb6a9e2
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2339782
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2020-08-05 19:42:38 +00:00
Nelson Billing
a6218eb66d Fix v1 symupload protocol in Mac client.
- A printf's arguments got broken in refactor for v2 protocol (my fault).

Change-Id: I8018e25f55b18fd47038d28a4ff0ac3be3d2caae
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2333387
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-31 21:47:18 +00:00
Nelson Billing
a740aa2625 Fix Mac symupload non-XCode builds.
Change-Id: Ic4924032faba83fc14f62feaac9a97bbfd0971ed
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2324311
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-29 23:30:33 +00:00
Sterling Augustine
28d7cbdd42 Check for tombstone as very first entry in the line table.
This is a folow up to
https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2317730

and handles the additional case where there are no entries in the line
table at all.

Change-Id: I100c5d0891e7dc7088d58da11240d7df3a6c48d9
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2321300
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-27 21:13:28 +00:00
Sterling Augustine
7d65240249 Properly handle new tombstone values that now appear as a result of the llvm change described at https://reviews.llvm.org/D81784.
Change-Id: I79dc5a72b651aa057104cd42b4773391df68125b
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2317730
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Nelson Billing <nbilling@google.com>
2020-07-24 21:34:14 +00:00
Nelson Billing
114336881a Port new symbol API to symupload on Mac.
- See documentation in Linux implementation commit: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1422400.

Change-Id: If3ff256e63f2db3ac9c0be78cfc17754d532cb88
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1497653
Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
2020-07-24 00:20:34 +00:00
Mike Frysinger
721108fd54 fix NDEBUG breakage with new dwarf5 code
These fields are only used when NDEBUG is not defined.  We get build
failures with the current code like:
src/common/dwarf/dwarf2reader.h:181:12: error: private field 'string_buffer_length_' is not used [-Werror,-Wunused-private-field]
  uint64_t string_buffer_length_;

Change-Id: I01d6e29d31d50e29ed3736e7197e70455724ae48
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2299022
Reviewed-by: Sterling Augustine <saugustine@google.com>
2020-07-16 03:04:43 +00:00
Mike Frysinger
09b056975d fix pointer style to match the style guide
We do this in a lot of places, but we're inconsistent.
Normalize the code to the Google C++ style guide.

Change-Id: Ic2aceab661ce8f6b993dda21b1cdf5d2198dcbbf
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2262932
Reviewed-by: Sterling Augustine <saugustine@google.com>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-07-15 06:20:02 +00:00
Sterling Augustine
a741027533 Add support for dwarf5 line tables.
Change-Id: I2c0cd0e7163502e52fbf0745b611befb2e219071
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2276193
Reviewed-by: Sterling Augustine <saugustine@google.com>
2020-07-14 00:46:58 +00:00
Sterling Augustine
b6f36dd775 Move GetSectionByName out of CompilationUnit.
For the upcoming Dwarf5 LineInfo changes, we will need to get
several additional sections by name, but without a the Compilation
Unit. This change prepares for that.

Change-Id: I566855abb339a856110a2f7d243d3848fe2b3c18
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2268861
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-26 18:32:51 +00:00
Sterling Augustine
8efe0f1c3b Read dwarf5 compilation unit headers.
Change-Id: Ia85b2fb7b3cb821ad353a0003223d8b8465e792d
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2265259
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-25 21:56:34 +00:00
Sterling Augustine
72c118f4a6 Add and handle various dwarf5 addrx forms.
Given the almost nonexistent direct dwarfreader tests, I think
the best way to test these dwarf5 additions will be to add a full
dwarf5 compilation unit similar to the ones used incidentally in
the other tests. But I can't do that until enough dwarf5 is
correctly implemented.

Change-Id: I3418bda7212ae85c4b67232a2ab8fea9b9ca5d42
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2258838
Reviewed-by: Mark Mentovai <mark@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2020-06-24 20:39:58 +00:00
Sterling Augustine
feb2dca989 Add and handle new dwarf5 string-related forms.
Adding the new forms by type and processing should avoid
the problems with 0c0e24f709,
where new forms weren't handled in switch statements, breaking
the build.

Testing this should follow the testing for DW_FORM_GNU_str_index,
very closely, but there doesn't appear to be any tests for that,
or even DW_FORM_strp.

Change-Id: I609d56b1dc879971bfef1070f063f8457fec6017
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2233839
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
2020-06-22 23:39:36 +00:00
Michael Moss
2757a2c9c8 Make symupload exit with an error code when command-line parsing fails.
This should address the issue where some Chrome builds were failing to
upload symbols due to a bad command-line flag, but there was no
indication of a problem, and no build failure, because symupload was
exiting with a success code.

BUG=1091387
R=nbilling@google.com, wuwang@google.com

Change-Id: I0d7f1a6d689ca5fd37be3abad4c5ebc97f108e50
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2231574
Reviewed-by: Nelson Billing <nbilling@google.com>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
2020-06-05 01:31:45 +00:00