2428 Commits

Author SHA1 Message Date
Robert Sesek
f0b9dcba25 Add a tri-state enum to return the result of Xattr operations.
R=mark@chromium.org
TEST=util_test --gtest_filter=Xattr\*

Review URL: https://codereview.chromium.org/842223003
2015-01-09 13:04:36 -05:00
Scott Graham
a277e14c9e Fix function name in error message of scoped_temp_dir_test
After https://codereview.chromium.org/826003003/.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/836833003
2015-01-08 11:08:32 -08:00
Scott Graham
f9c487b1e1 win: port multiprocess_exec_test_child.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/808493003
2015-01-08 11:08:11 -08:00
Scott Graham
c6bcbfb042 win: port semaphore test
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/840933004
2015-01-08 09:32:12 -08:00
Scott Graham
b1d2beb724 win: Disable Clock tests that require SleepNanoseconds
As it was left unimplemented on Windows per previous discussion.

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

Review URL: https://codereview.chromium.org/838833004
2015-01-07 21:04:52 -08:00
Scott Graham
b0545c2627 win: porting for scoped_temp_dir_test
Uses the posix-y CRT functions rather than Win32 API for consistency/similarity
to the POSIX code path as it's localized test code anyway.

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

Review URL: https://codereview.chromium.org/826003003
2015-01-07 16:16:18 -08:00
Scott Graham
7b161de65c win: FILE_PATH_LITERAL in executable_path_test.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/838023002
2015-01-07 15:08:37 -08:00
Scott Graham
9b05b910d4 win: FILE_PATH_LITERALs in http_multipart_builder_test.cc
clang-format wanted to rewrap this way.

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

Review URL: https://codereview.chromium.org/814683003
2015-01-07 15:07:40 -08:00
Scott Graham
119c4fdd93 win: various porting for http_body_test.cc
- Wrap constants in FILE_PATH_LITERAL for L"".
- dynamic allocation, as VS otherwise complains about lack of constant
expression:

d:\src\crashpad\crashpad\util\net\http_body_test.cc(182) : error C2057: expected constant expression
d:\src\crashpad\crashpad\util\net\http_body_test.cc(182) : error C2466: cannot allocate an array of constant size 0
d:\src\crashpad\crashpad\util\net\http_body_test.cc(182) : error C2133: 'buf' : unknown size
d:\src\crashpad\crashpad\util\net\http_body_test.cc(183) : error C2070: 'uint8_t []': illegal sizeof operand
d:\src\crashpad\crashpad\util\net\http_body_test.cc(196) : error C2070: 'uint8_t []': illegal sizeof operand

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

Review URL: https://codereview.chromium.org/837293002
2015-01-07 15:05:38 -08:00
Scott Graham
4ec5405135 win: avoid warning in StringFileWriter.SeekInvalid test
d:\src\crashpad\crashpad\util\file\string_file_writer_test.cc(367) : warning C4244: 'initializing' : conversion from 'const uint64_t' to 'const off_t', possible loss of data

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

Review URL: https://codereview.chromium.org/836413004
2015-01-07 14:42:52 -08:00
Scott Graham
cd4a2f83e6 Roll mini_chromium to 836497baf21c5fbb7876573dc1dadef4c023a87d
Includes:
836497baf21c5fbb7876573dc1dadef4c023a87d win: Default to /SUBSYSTEM:CONSOLE

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/844443003
2015-01-06 17:01:07 -08:00
Robert Sesek
c75dc46b17 Add UUID::InitializeFromString().
R=mark@chromium.org
TEST=util_test --gtest_filter=UUID.FromString

Review URL: https://codereview.chromium.org/820783004
2015-01-02 18:46:10 -05:00
Robert Sesek
1cdb7c1d04 Create ScopedTempDir, implement it on POSIX, and use it where appropriate.
R=mark@chromium.org
TEST=util_test --gtest_filter=ScopedTempDir.*

Review URL: https://codereview.chromium.org/834693002
2015-01-02 13:51:47 -05:00
Robert Sesek
8e98c9251a Add wrappers around getxattr() and setxattr().
R=mark@chromium.org
TEST=util_test --gtest_filter=Xattr.*

Review URL: https://codereview.chromium.org/791493009
2014-12-30 17:39:27 -05:00
Mark Mentovai
3ee6566051 generate_dump, exception_port_tool: set SecTaskAccess allowed.
This adds an Info.plist to these two tools that use task_for_pid().
Since they’re flat unbundled executables, the Info.plist must be placed
as a __TEXT,__info_plist section.

By setting SecTaskAccess to allowed and signing these tools with a
certificate trusted by the system, they will be allowed to use
task_for_pid() without requiring the invoking user to be root. This
provides an alternative to installing these tools as setuid root.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/822533002
2014-12-30 14:27:58 -05:00
Mark Mentovai
f4ec7ba590 Add the run_with_crashpad tool.
run_with_crashpad runs a program with a Crashpad exception handler. It
allows a Crashpad exception-handling server to be started and to direct
crashes to it from programs that are not themselves clients of the
Crashpad client library.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/810423004
2014-12-30 14:25:58 -05:00
Mark Mentovai
2602e9d5d0 Add CrashpadClient.
CrashpadClient is the primary interface for an application to have
Crashpad monitor it for crashes. It contains StartHandler(), which
starts a Crashpad handler process, and UseHandler(), which configures
the process to direct its crashes to a handler process.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/785233011
2014-12-30 14:24:52 -05:00
Mark Mentovai
588d7dba1c Add the crashpad_handler executable.
crashpad_handler is Crashpad’s exception handler server.

Currently, it runs a loop to receive exceptions, and exits when it no
longer has any clients. In the future, this will be extended to write
and potentially upload dumps.

The handler is expected to be started by its initial client via the
CrashpadClient interface.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/789693005
2014-12-30 14:23:47 -05:00
Mark Mentovai
b0e8f3e3e4 tools: Restore Resources, Copyright, and License to man pages.
This updates moved man pages to reference man_footer.ad by a proper
relative path following 39f69c862af6.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/820803003
2014-12-19 18:44:35 -05:00
Scott Graham
47c7c03f9e clang-format: don't bin pack arguments
Prefer

  function(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa,
           bbbbbbbbbbbbb,
           ccccccccccccccccccccccccccccccccccccccccccc);

over

  function(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbbbbbb,
           ccccccccccccccccccccccccccccccccccccccccccc);

R=mark@chromium.org

Review URL: https://codereview.chromium.org/805333006
2014-12-19 15:44:05 -08:00
Scott Graham
6865865773 Change 'bool world_readable' to an enum
More clear at callsites, and relatively important not to accidentally choose the wrong one.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/821483002
2014-12-19 15:35:30 -08:00
Scott Graham
9cfd2c515e Make http_body cross-platform
'util' builds on Windows after this.

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

Review URL: https://codereview.chromium.org/791493007
2014-12-19 15:21:19 -08:00
Scott Graham
4e8a78c182 Roll mini_chromium to 4d84318dbcdf46b543ab4556736cf8a9ae3ced18
Includes:
4d84318dbcdf46b543ab4556736cf8a9ae3ced18 win: Disable C4201, nameless struct/union warning
864f44f98bb8e6869b1243de9b2ebd3f50a03a21 Exclude _test suffixed files too

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/817093002
2014-12-19 15:02:54 -08:00
Scott Graham
8d7681752d win: Avoid signed/unsigned warning
d:\src\crashpad\crashpad\snapshot\cpu_context.cc(96) : warning C4245: 'return' : conversion from 'int' to 'uint64_t', signed/unsigned mismatch

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

Review URL: https://codereview.chromium.org/819703002
2014-12-19 14:53:23 -08:00
Mark Mentovai
110eafe9a1 CloseMultipleNowOrOnExec(): promote out of test.
This function will be useful in upcoming non-test code. Because the
first Crashpad client that wants a Crashpad handler will now be
responsible for starting the handler process, this will prevent file
descriptors from leaking to the handler process.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/819483002
2014-12-19 16:42:34 -05:00
Scott Graham
5f5e342584 Switch [String]FileWriter to use new file_io.h functions/types
Also add ScopedFileHandle as cross-platform version of ScopedFD/ScopedFileHANDLE.

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

Review URL: https://codereview.chromium.org/815053004
2014-12-19 13:33:01 -08:00
Mark Mentovai
25c3afaac5 Add CloseStdinAndStdout().
There will be no reason to leave the handler process connected to its
invoker’s stdin or stdout.

On the other hand, I’m currently leaving it connected to the original
and stderr, as these may be useful for diagnostics.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/818573002
2014-12-19 14:20:20 -05:00
Scott Graham
384497475a Add LoggingSeekFile
As the whence values are "helpfully" available in windows.h as well
( http://msdn.microsoft.com/en-us/library/windows/desktop/dd757336(v=vs.85).aspx )
don't bother inventing a new enum. Add implementations for POSIX and Win32.

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

Review URL: https://codereview.chromium.org/812593005
2014-12-19 10:45:22 -08:00
Scott Graham
4034d30023 Add LoggingOpenFileFor{Read|Write}
I started (https://codereview.chromium.org/812403002/) emulating oflag values
on Windows in FileWriter, but it seemed awkward. On the assumption that we're
only likely to need "read a file" and "write a file" this seemed simpler, and
sufficient (but I don't know if that's necessarily true).

Users of open are not yet switched.

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

Review URL: https://codereview.chromium.org/818433002
2014-12-18 16:29:33 -08:00
Scott Graham
4a9b858fbd win: Add Scoped...Handle
Intended for future use to implement util/file/file_writer.

There's a similar class in base:
https://code.google.com/p/chromium/codesearch#chromium/src/base/win/scoped_handle.h&l=28

However (perhaps for historical reasons) it does not distinguish between
the possible types of HANDLEs which have different invalid values,
resulting in a need to copy a bunch of code rather than simply using
ScopedGeneric.

Instead, distinguish between the types so the caller can use the
correct one.

Refs:
http://blogs.msdn.com/b/oldnewthing/archive/2004/03/02/82639.aspx
http://msdn.microsoft.com/en-us/magazine/cc302328.aspx (Figure 2)

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

Review URL: https://codereview.chromium.org/813873004
2014-12-18 09:51:20 -08:00
Scott Graham
26c6f19927 Roll mini_chromium to 43b7cd397e5f239e59700831430b703d9a4a3b4f
Includes:
43b7cd397e5f239e59700831430b703d9a4a3b4f win: Fix for logging.h ERROR, again
a83f160101c6b054bdcfe81dea62340c7d933778 win: implement sys_byteorder.h

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/817443002
2014-12-18 09:29:46 -08:00
Scott Graham
d1fdcf99e0 win: implement Semaphore
Ref:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686946%28v=vs.85%29.aspx

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

Review URL: https://codereview.chromium.org/797173003
2014-12-18 09:08:57 -08:00
Scott Graham
ec38bf152d win: Add static_cast to AssignIfInRange
Otherwise, when assigning to a smaller type, MSVC warns e.g.

d:\src\crashpad\crashpad\util\numeric\safe_assignment.h(38) : error C2220: warning treated as error - no 'object' file generated
        d:\src\crashpad\crashpad\util\file\string_file_writer.cc(127) : see reference to function template instantiation 'bool crashpad::AssignIfInRange<size_t,FileOffset>(Destination *,Source)' being compiled
        with
        [
            Destination=size_t
,            Source=FileOffset
        ]
d:\src\crashpad\crashpad\util\numeric\safe_assignment.h(38) : warning C4244: '=' : conversion from 'FileOffset' to 'size_t', possible loss of data

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

Review URL: https://codereview.chromium.org/809303003
2014-12-18 08:42:26 -08:00
Scott Graham
10165ce449 Cross platform low level file IO wrappers
Rename fd_io to file_io, and ReadFD to ReadFile, etc.

file_io.cc is the higher level versions that call the basic ReadFile/WriteFile
and then file_io_posix.cc and file_io_win.cc are the implementations of
those functions.

The Windows path is as yet untested, lacking the ability to link the test binary.

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

Review URL: https://codereview.chromium.org/811823003
2014-12-17 14:35:18 -08:00
Mark Mentovai
3d84a738d0 Update GYP to svn r2015 (32ca1cd8e010).
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/813873002
2014-12-17 16:03:58 -05:00
Mark Mentovai
9d2c1cffa2 Update mini_chromium to 222feaf3d302.
This picks up:

222feaf3d302 Update README
e38cddb83571 Lock: don’t require NativeThreadType to be a pointer type
8c599712d10c Include What You Use: <string.h> for memmove() and memcpy()
ef991f44ed63 Linux: always build in C++11 mode

BUG=crashpad:6
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/812133002
2014-12-17 16:01:35 -05:00
Mark Mentovai
39f69c862a tools: Move Mac-specific tools to tools/mac.
R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/804913003
2014-12-17 15:26:23 -05:00
Mark Mentovai
a02f721637 Add NewMachPort() and its test, and switch call sites to use it.
There were many call sites that wasted a few lines on
mach_port_allocate() and sticking the result into a scoper. I was about
to add three more, so I took the opportunity to simplify things.

TEST=util_test
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/809103002
2014-12-17 15:10:38 -05:00
Mark Mentovai
439532bd0b MachMessageServer::Run(): correct documentation.
The comment referred to the old form of the |persistent| argument, which
was a bool.

R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/806953004
2014-12-17 15:09:22 -05:00
Scott Graham
3eeae10ebe win: avoid warning on return of base::RandGenerator
Else,

d:\src\crashpad\crashpad\util\net\http_multipart_builder.cc(50) : warning C4244: 'initializing' : conversion from 'uint64_t' to 'int', possible loss of data

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

Review URL: https://codereview.chromium.org/796643006
2014-12-17 10:50:05 -08:00
Scott Graham
db6492e154 win: clock implementation
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/807973002
2014-12-17 10:45:43 -08:00
Mark Mentovai
86cf286350 Update mini_chromium to 158694255c7a.
This picks up:

158694255c7a win: undef ERROR, causing failing LOGs
3a981db6e6df MSVC: Disable “warning C4702: unreachable code”.
e87cd9d4dff5 Tidy string16.h after
             https://codereview.chromium.org/809563003/

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/812683002
2014-12-16 17:12:30 -05:00
Scott Graham
4a5d21528e DCHECK_LE for cr_ngroups vs arraysize(cr_groups)
This DCHECK fails for me locally as

[----------] 3 tests from ProcessInfo
[ RUN      ] ProcessInfo.Self
[70989:10546846:20141216,112509.948519:FATAL process_info_mac.cc:114] Check failed: static_cast<size_t>(ngroups) < (sizeof(ArraySizeHelper(kern_proc_info_.kp_eproc.e_ucred.cr_groups))) (16 vs. 16).
Abort trap: 6

It doesn't seem to happen on the waterfall, so maybe I'm building against
an incorrect header? I don't particularly understand the code, but assuming
it's normal 0-based array, perhaps it should be a DCHECK_LE in any case.

R=mark@chromium.org

Review URL: https://codereview.chromium.org/813473002
2014-12-16 12:18:32 -08:00
Mark Mentovai
5adfa5039e string_number_conversions: only check CXX_LIBRARY_HAS_CONSTEXPR.
CXX_LIBRARY_VERSION is irrelevant, because the only C++11 library
feature of any concern is whether numeric_limits’ min() and max() are
declared constexpr.

Crashpad is C++11-only as far as the language is concerned, and the
comment doesn’t need to call it out explicitly because static_assert()
is always available.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/809833002
2014-12-16 14:55:28 -05:00
Mark Mentovai
d78b003ef1 Add NotifyServer and its test.
TEST=util_test NotifyServerTest.*
R=rsesek@chromium.org

Review URL: https://codereview.chromium.org/804633002
2014-12-16 14:10:16 -05:00
Scott Graham
4263334db8 win: avoid warnings in string_number_conversion_test.cc
R=mark@chromium.org
BUG=crashpad:1

Review URL: https://codereview.chromium.org/807463004
2014-12-16 11:00:20 -08:00
Scott Graham
b0cf01978d win: Get client/crashpad_info.cc to compile
Just avoid the Mac-specific __attribute__ tagging for now. There will need
to be some Windows-specific pragmas added here once the reader has been
written.

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

Review URL: https://codereview.chromium.org/808623002
2014-12-16 10:22:41 -08:00
Scott Graham
086714261a Roll mini_chromium to 2ef83a609517f284096f7e8296b0915d634c3ca7
Pick up build fix.

TBR=mark@chromium.org

Review URL: https://codereview.chromium.org/804853004
2014-12-15 16:46:46 -08:00
Scott Graham
7941e7f955 Roll mini_chromium to 463f840...
To pull in string16 changes.

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

Review URL: https://codereview.chromium.org/811613002
2014-12-15 16:31:15 -08:00
Scott Graham
9d38069f13 win: static_cast to uint64_t rather than implicit_cast, to avoid warnings
e.g.

FAILED: ninja -t msvc -e environment.x86 -- "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\amd64_x86\cl.exe" /nologo /showIncludes /FC @obj\util\misc\util_test.clock_test.obj.rsp /c ..\..\util\misc\clock_test.cc /Foobj\util\misc\util_test.clock_test.obj /Fdobj\util\util_test.cc.pdb
d:\src\crashpad\crashpad\third_party\mini_chromium\mini_chromium\base\basictypes.h(49) : error C2220: warning treated as error - no 'object' file generated
        d:\src\crashpad\crashpad\util\misc\clock_test.cc(72) : see reference to function template instantiation 'To implicit_cast<uint64_t,double>(const From &)' being compiled
        with
        [
            To=uint64_t
,            From=double
        ]
d:\src\crashpad\crashpad\third_party\mini_chromium\mini_chromium\base\basictypes.h(49) : warning C4244: 'return' : conversion from 'const double' to 'uint64_t', possible loss of data

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

Review URL: https://codereview.chromium.org/807653002
2014-12-15 16:21:12 -08:00