117 Commits

Author SHA1 Message Date
Mark Mentovai
79b4434c81 Add a ReceiveLarge parameter to MachMessageServer::Run().
Previously, MachMessageServer::Run() only provided two strategies for
dealing with large messages, indicated by mach_msg() returning
MACH_RCV_TOO_LARGE: the receive buffer could be reallocated and the
message received, or the entire function could return MACH_RCV_TOO_LARGE
to the caller. There are situations where an intermediate behavior might
be desirable. This intermediate behavior would allow the function to
continue waiting for another message without returning an error to the
caller or attempting to receive the large message. This is desirable
when dealing with fixed-sized messages and a receiver that might be sent
messages by unknown, possibly-malicious callers. This can happen when
the corresponding send right is published with the bootstrap server, for
example.

Existing users continue to request their existing behavior, typically
receiving an error when encountering a large message.
catch_exception_tool will use the new “ignore” behavior when running in
persistent mode.

TEST=util_test MachMessageServer.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/756803002
2014-11-25 14:48:44 -05:00
Mark Mentovai
09d3a6c695 Add the generate_dump tool.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/727983002
2014-11-14 19:21:43 -05:00
Mark Mentovai
49d7fdba9a Add DropPrivileges().
DropPrivileges() is used in exception_port_tool, so that when it is
installed as a setuid executable, it only uses elevated privileges to
obtain a task port for its -p option, and then relinquishes those
privileges.

It is difficult to provide a test for this function, because it must be
running setuid or setgid in order to do anything interesting. However,
the function contains its own CHECKs to verify that it behaves properly.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/727053002
2014-11-14 18:44:19 -05:00
Mark Mentovai
de3c46c6b3 Add TaskForPID().
This also transitions exception_port_tool to use TaskForPID(), so that
it can be safely used as a setuid executable without giving permission
to operate on any process on the system.

It is difficult to provide a test for this function, because it must be
running setuid root in order to do anything interesting.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/728973002
2014-11-14 17:56:17 -05:00
Mark Mentovai
f59e3e6b78 Add tool man pages in asciidoc format.
nroff mandoc-format man pages can be generated by running:

a2x --format manpage \
    --attribute 'mansource=Crashpad' \
    --attribute 'manversion=0.6.0' \
    --attribute 'manmanual=Crashpad Manual' \
    --attribute 'revdate=October 2014' \
    manpage.ad

For HTML output, use --format xhtml.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/664553004
2014-10-17 11:01:48 -04:00
Mark Mentovai
5d74f120fc Convert NULL to nullptr.
This change was generated mechanically by running:

  find . \( -name \*.cc -or -name \*.mm -or -name \*.h \) \
      -and -not -path ./third_party/\* -and -not -path ./out/\* \
      -exec sed -i '' -E -e 's/(^|[^_])NULL/\1nullptr/g' {} +

Further manual fix-ups were applied to remove casts of nullptr to other
pointer types where possible, to preserve the intentional use of NULL
(as a short form of MACH_PORT_NULL) in exception_port_tool, and to fix
80-column violations.

https://groups.google.com/a/chromium.org/d/topic/chromium-dev/4mijeJHzxLg/discussion

TEST=*_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/656703002
2014-10-14 11:10:45 -04:00
Mark Mentovai
8c7872e9e0 Use the correct null constants for Mach threads, tasks, and hosts.
This uses THREAD_NULL, TASK_NULL, and HOST_NULL in preference to
MACH_PORT_NULL and kMachPortNull. These constants are correctly-typed
(thread_t, task_t, and host_t) and result in more readable source code,
especially where thread and task parameters appear together as they do
in exc_*_variants.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/649713002
2014-10-13 12:59:21 -04:00
Mark Mentovai
40602fab1f Don’t use using directives (“using namespace”) in tools.
The contents of tools are moved into the namespace
crashpad::(anonymous namespace).

https://google-styleguide.googlecode.com/svn/trunk/cppguide.html#Namespaces

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/627273004
2014-10-07 17:30:09 -04:00
Scott Graham
7dda7b3228 Superficial gyp changes to not immediately error out on Windows
Just guarding the usage of $SDKROOT so that ninja doesn't error out
on invalid $ escape on parsing.

R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/620553004
2014-09-30 13:11:04 -07:00
Mark Mentovai
0d8f67c1f5 Specify system framework dependencies properly in .gyp files.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/588073004
2014-09-22 14:06:06 -04:00
Mark Mentovai
12b67422f9 catch_exception_tool: Show the thread ID, state flavor, and state count.
For identity-carrying exceptions, the system-wide thread ID is shown.

For state-carrying exceptions, the flavor and old_state_count are shown.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/581153002
2014-09-18 13:55:03 -04:00
Mark Mentovai
4d35ffa80e Use more-specific typedefs for send rights to task, thread, and
exception handler ports.

task_t, thread_t, and exception_handler_t are typedefs for mach_port_t.
They are more descriptive than mach_port_t, and are already in use in
exc_server_variants.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/577293002
2014-09-18 13:53:43 -04:00
Mark Mentovai
1b61c90e7c Add exception_port_tool.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/575033004
2014-09-18 12:09:00 -04:00
Mark Mentovai
021c93c2e0 Use a more specific type, mach_exception_code_t, when possible.
mach_exception_data_type_t is more generic and is used for any element
of a codes[] array. For individual elements, the typedefs
mach_exception_code_t and mach_exception_subcode_t are available. Using
mach_exception_code_t when possible gives slightly more descriptive
code.

No functional change.

TEST=util_test ExcServerVariants.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/585473003
2014-09-18 11:56:03 -04:00
Mark Mentovai
b4fe6dfae0 Refactor EXC_CRASH code[0] processing into a new function,
ExcCrashRecoverOriginalException(), and use it where sensible.

TEST=util_test ExcVariantsTest.ExcCrashRecoverOriginalException …
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/566693003
2014-09-17 17:59:35 -04:00
Mark Mentovai
f764db270f Add catch_exception_tool.
catch_exception_tool catches Mach exceptions. Currenlty, it simply
prints a message with some information about each exception it handles.
In the future, it will be tied to the minidump generator as well.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/579443005
2014-09-17 15:40:09 -04:00
Mark Mentovai
0b7f86a650 Add on_demand_service_tool.
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/477353002
2014-08-20 15:18:55 -04:00