15ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// Copyright (c) 2006, Google Inc.
25ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// All rights reserved.
35ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis//
45ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// Redistribution and use in source and binary forms, with or without
55ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// modification, are permitted provided that the following conditions are
65ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// met:
75ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis//
85ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis//     * Redistributions of source code must retain the above copyright
95ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// notice, this list of conditions and the following disclaimer.
105ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis//     * Redistributions in binary form must reproduce the above
115ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// copyright notice, this list of conditions and the following disclaimer
125ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// in the documentation and/or other materials provided with the
135ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// distribution.
145ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis//     * Neither the name of Google Inc. nor the names of its
155ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// contributors may be used to endorse or promote products derived from
165ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// this software without specific prior written permission.
175ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis//
185ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
195ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
205ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
215ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
225ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
235ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
245ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
255ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
265ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
275ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
285ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
295ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
305ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// minidump_generator.h:  Create a minidump of the current MacOS process.
315ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
325ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#ifndef CLIENT_MAC_GENERATOR_MINIDUMP_GENERATOR_H__
335ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#define CLIENT_MAC_GENERATOR_MINIDUMP_GENERATOR_H__
345ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
355ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#include <mach/mach.h>
36f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#include <TargetConditionals.h>
375ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
385ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#include <string>
395ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
40a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org#include "client/mac/handler/ucontext_compat.h"
415ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#include "client/minidump_file_writer.h"
424621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek#include "common/memory.h"
439be806efde6c55fbd7e9443d2700255835019a03ted.mielczarek#include "common/mac/macho_utilities.h"
444621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek#include "google_breakpad/common/minidump_format.h"
455ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
46de2fd15db9a480c807ba337690669538a97756a4ladderbreaker#include "dynamic_images.h"
4734f57bcf6a1bf45c1052813f384fc18bd15ca159qsr@chromium.org#include "mach_vm_compat.h"
48de2fd15db9a480c807ba337690669538a97756a4ladderbreaker
49b0dc7d9189dbc90258dca778e64565d7f86a7aadqsr@chromium.org#if !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7)
50d01a9f8bc4be2c54027b66fc41f566d41d3c030ated.mielczarek@gmail.com  #define HAS_PPC_SUPPORT
51d01a9f8bc4be2c54027b66fc41f566d41d3c030ated.mielczarek@gmail.com#endif
52f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#if defined(__arm__)
53a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org#define HAS_ARM_SUPPORT
545c2892d9dec0a26b6e86d16fbc0c0a4d1a88410cmark@chromium.org#elif defined(__aarch64__)
55a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org#define HAS_ARM64_SUPPORT
56f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#elif defined(__i386__) || defined(__x86_64__)
57f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org  #define HAS_X86_SUPPORT
58f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#endif
59d01a9f8bc4be2c54027b66fc41f566d41d3c030ated.mielczarek@gmail.com
60e5dc60822e5938fea2ae892ccddb906641ba174emmentovainamespace google_breakpad {
615ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
625ac2b9a569890f165478f91670dcdd553ce2d10ewaylonisusing std::string;
635ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
64a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid// Use the REGISTER_FROM_THREADSTATE to access a register name from the
65a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid// breakpad_thread_state_t structure.
66f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#if __DARWIN_UNIX03 || TARGET_CPU_X86_64 || TARGET_CPU_PPC64 || TARGET_CPU_ARM
67a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid// In The 10.5 SDK Headers Apple prepended __ to the variable names in the
68a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid// i386_thread_state_t structure.  There's no good way to tell what version of
69a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid// the SDK we're compiling against so we just toggle on the same preprocessor
70a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid// symbol Apple's headers use.
71a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid#define REGISTER_FROM_THREADSTATE(a, b) ((a)->__ ## b)
72a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid#else
73a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid#define REGISTER_FROM_THREADSTATE(a, b) (a->b)
74a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid#endif
75a0a0de39a8b25bea9ae18d98c4eb4c052c1a9864nealsid
765ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// Creates a minidump file of the current process.  If there is exception data,
775ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// use SetExceptionInformation() to add this to the minidump.  The minidump
785ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// file is generated by the Write() function.
795ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// Usage:
805ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// MinidumpGenerator minidump();
815ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis// minidump.Write("/tmp/minidump");
825ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis//
835ac2b9a569890f165478f91670dcdd553ce2d10ewaylonisclass MinidumpGenerator {
845ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis public:
855ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  MinidumpGenerator();
86de2fd15db9a480c807ba337690669538a97756a4ladderbreaker  MinidumpGenerator(mach_port_t crashing_task, mach_port_t handler_thread);
87de2fd15db9a480c807ba337690669538a97756a4ladderbreaker
88d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org  virtual ~MinidumpGenerator();
895ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
905ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Return <dir>/<unique_name>.dmp
915ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Sets |unique_name| (if requested) to the unique name for the minidump
925ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  static string UniqueNameInDirectory(const string &dir, string *unique_name);
935ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
945ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Write out the minidump into |path|
955ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // All of the components of |path| must exist and be writable
965ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Return true if successful, false otherwise
975ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  bool Write(const char *path);
985ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
995ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Specify some exception information, if applicable
10061e88c7ad7eb072977b4d4d26bcf8929b75af2d4ted.mielczarek  void SetExceptionInformation(int type, int code, int subcode,
10161e88c7ad7eb072977b4d4d26bcf8929b75af2d4ted.mielczarek                               mach_port_t thread_name) {
1025ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis    exception_type_ = type;
1035ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis    exception_code_ = code;
10461e88c7ad7eb072977b4d4d26bcf8929b75af2d4ted.mielczarek    exception_subcode_ = subcode;
1055ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis    exception_thread_ = thread_name;
1065ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  }
1075ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
10860a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org  // Specify the task context. If |task_context| is not NULL, it will be used
10960a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org  // to retrieve the context of the current thread, instead of using
11060a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org  // |thread_get_state|.
111a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org  void SetTaskContext(breakpad_ucontext_t *task_context);
11260a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org
1135ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Gather system information.  This should be call at least once before using
1145ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // the MinidumpGenerator class.
1155ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  static void GatherSystemInformation();
1165ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
117d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org protected:
118d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org  // Overridable Stream writers
119d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org  virtual bool WriteExceptionStream(MDRawDirectory *exception_stream);
120d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org
121d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org  // Overridable Helper
122d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org  virtual bool WriteThreadStream(mach_port_t thread_id, MDRawThread *thread);
123d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org
1245ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis private:
125d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org  typedef bool (MinidumpGenerator::*WriteStreamFN)(MDRawDirectory *);
1265ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
1275ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Stream writers
1285ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  bool WriteThreadListStream(MDRawDirectory *thread_list_stream);
1294621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek  bool WriteMemoryListStream(MDRawDirectory *memory_list_stream);
1305ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  bool WriteSystemInfoStream(MDRawDirectory *system_info_stream);
1315ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  bool WriteModuleListStream(MDRawDirectory *module_list_stream);
1325ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  bool WriteMiscInfoStream(MDRawDirectory *misc_info_stream);
133e5dc60822e5938fea2ae892ccddb906641ba174emmentovai  bool WriteBreakpadInfoStream(MDRawDirectory *breakpad_info_stream);
1345ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
1355ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Helpers
1366162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com  uint64_t CurrentPCForStack(breakpad_thread_state_data_t state);
1370344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  bool GetThreadState(thread_act_t target_thread, thread_state_t state,
1380344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com                      mach_msg_type_number_t *count);
139867df1c65264c657ed71d68c3d266401686edcadnealsid  bool WriteStackFromStartAddress(mach_vm_address_t start_addr,
1405ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis                                  MDMemoryDescriptor *stack_location);
141255bbe93ed7aef5418000339b6cdb5677bf9e4d6ted.mielczarek  bool WriteStack(breakpad_thread_state_data_t state,
1425ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis                  MDMemoryDescriptor *stack_location);
143255bbe93ed7aef5418000339b6cdb5677bf9e4d6ted.mielczarek  bool WriteContext(breakpad_thread_state_data_t state,
1445ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis                    MDLocationDescriptor *register_location);
1458fac6df2a0dfbfe7512c3f6616cda4cbac4f0d9dqsr@chromium.org  bool WriteCVRecord(MDRawModule *module, int cpu_type,
1468fac6df2a0dfbfe7512c3f6616cda4cbac4f0d9dqsr@chromium.org                     const char *module_path, bool in_memory);
1475ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  bool WriteModuleStream(unsigned int index, MDRawModule *module);
148867df1c65264c657ed71d68c3d266401686edcadnealsid  size_t CalculateStackSize(mach_vm_address_t start_addr);
149de2fd15db9a480c807ba337690669538a97756a4ladderbreaker  int  FindExecutableModule();
1505ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
1510344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  // Per-CPU implementations of these methods
152f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#ifdef HAS_ARM_SUPPORT
153f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org  bool WriteStackARM(breakpad_thread_state_data_t state,
154f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org                     MDMemoryDescriptor *stack_location);
155f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org  bool WriteContextARM(breakpad_thread_state_data_t state,
156f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org                       MDLocationDescriptor *register_location);
1576162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com  uint64_t CurrentPCForStackARM(breakpad_thread_state_data_t state);
158f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#endif
159a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org#ifdef HAS_ARM64_SUPPORT
160a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org  bool WriteStackARM64(breakpad_thread_state_data_t state,
161a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org                       MDMemoryDescriptor *stack_location);
162a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org  bool WriteContextARM64(breakpad_thread_state_data_t state,
163a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org                         MDLocationDescriptor *register_location);
164a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org  uint64_t CurrentPCForStackARM64(breakpad_thread_state_data_t state);
165a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org#endif
166d01a9f8bc4be2c54027b66fc41f566d41d3c030ated.mielczarek@gmail.com#ifdef HAS_PPC_SUPPORT
1670344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  bool WriteStackPPC(breakpad_thread_state_data_t state,
1680344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com                     MDMemoryDescriptor *stack_location);
1690344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  bool WriteContextPPC(breakpad_thread_state_data_t state,
1700344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com                       MDLocationDescriptor *register_location);
1716162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com  uint64_t CurrentPCForStackPPC(breakpad_thread_state_data_t state);
1720344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  bool WriteStackPPC64(breakpad_thread_state_data_t state,
1730344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com                       MDMemoryDescriptor *stack_location);
1740344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  bool WriteContextPPC64(breakpad_thread_state_data_t state,
1750344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com                       MDLocationDescriptor *register_location);
1766162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com  uint64_t CurrentPCForStackPPC64(breakpad_thread_state_data_t state);
177d01a9f8bc4be2c54027b66fc41f566d41d3c030ated.mielczarek@gmail.com#endif
178f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#ifdef HAS_X86_SUPPORT
1790344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  bool WriteStackX86(breakpad_thread_state_data_t state,
1800344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com                       MDMemoryDescriptor *stack_location);
1810344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  bool WriteContextX86(breakpad_thread_state_data_t state,
1820344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com                       MDLocationDescriptor *register_location);
1836162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com  uint64_t CurrentPCForStackX86(breakpad_thread_state_data_t state);
1840344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  bool WriteStackX86_64(breakpad_thread_state_data_t state,
1850344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com                        MDMemoryDescriptor *stack_location);
1860344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  bool WriteContextX86_64(breakpad_thread_state_data_t state,
1870344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com                          MDLocationDescriptor *register_location);
1886162aed3c3fcfc53373c963ac375d39a5dfa5a25ted.mielczarek@gmail.com  uint64_t CurrentPCForStackX86_64(breakpad_thread_state_data_t state);
189f7b0f838d6a35ce130c41447e6da032447b5af05qsr@chromium.org#endif
1900344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com
1915ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // disallow copy ctor and operator=
1925ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  explicit MinidumpGenerator(const MinidumpGenerator &);
1935ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  void operator=(const MinidumpGenerator &);
1945ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
195d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org protected:
1965ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Use this writer to put the data to disk
1975ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  MinidumpFileWriter writer_;
1985ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
199d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org private:
2005ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // Exception information
2015ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  int exception_type_;
2025ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  int exception_code_;
20361e88c7ad7eb072977b4d4d26bcf8929b75af2d4ted.mielczarek  int exception_subcode_;
2045ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  mach_port_t exception_thread_;
205de2fd15db9a480c807ba337690669538a97756a4ladderbreaker  mach_port_t crashing_task_;
206de2fd15db9a480c807ba337690669538a97756a4ladderbreaker  mach_port_t handler_thread_;
2070344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com
2080344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  // CPU type of the task being dumped.
2090344a368deac6abaa280a298bcea9bb00a90df3fted.mielczarek@gmail.com  cpu_type_t cpu_type_;
2105c2892d9dec0a26b6e86d16fbc0c0a4d1a88410cmark@chromium.org
2115ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  // System information
2125ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  static char build_string_[16];
2135ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  static int os_major_version_;
2145ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  static int os_minor_version_;
2155ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis  static int os_build_number_;
21660a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org
21760a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org  // Context of the task to dump.
218a157c99f9fdfc5f5072db05a5075ae23fce43c88mark@chromium.org  breakpad_ucontext_t *task_context_;
21960a69eecd7cf717a1819a1f75b4ef21a6b51c457qsr@chromium.org
220de2fd15db9a480c807ba337690669538a97756a4ladderbreaker  // Information about dynamically loaded code
221de2fd15db9a480c807ba337690669538a97756a4ladderbreaker  DynamicImages *dynamic_images_;
2224621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek
2234621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek  // PageAllocator makes it possible to allocate memory
2244621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek  // directly from the system, even while handling an exception.
2254621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek  mutable PageAllocator allocator_;
2264621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek
227d4b7d35a8a3908e94e0913c9e1deec7c8fdb03acqsr@chromium.org protected:
2284621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek  // Blocks of memory written to the dump. These are all currently
2294621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek  // written while writing the thread list stream, but saved here
2304621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek  // so a memory list stream can be written afterwards.
2314621ee06914b2ebe963c93ea78fabf982cf670dfted.mielczarek  wasteful_vector<MDMemoryDescriptor> memory_blocks_;
2325ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis};
2335ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
234e5dc60822e5938fea2ae892ccddb906641ba174emmentovai}  // namespace google_breakpad
2355ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis
2365ac2b9a569890f165478f91670dcdd553ce2d10ewaylonis#endif  // CLIENT_MAC_GENERATOR_MINIDUMP_GENERATOR_H__
237