minidump.h.svn-base

来自「SumatraPDF是一款小型开源的pdf阅读工具。虽然玲珑小巧(只有800多K」· SVN-BASE 代码 · 共 885 行 · 第 1/3 页

SVN-BASE
885
字号
class MinidumpException : public MinidumpStream { public:  virtual ~MinidumpException();  const MDRawExceptionStream* exception() const {    return valid_ ? &exception_ : NULL;  }  // The thread ID is used to determine if a thread is the exception thread,  // so a special getter is provided to retrieve this data from the  // MDRawExceptionStream structure.  Returns false if the thread ID cannot  // be determined.  bool GetThreadID(u_int32_t *thread_id) const;  MinidumpContext* GetContext();  // Print a human-readable representation of the object to stdout.  void Print(); private:  friend class Minidump;  static const u_int32_t kStreamType = MD_EXCEPTION_STREAM;  explicit MinidumpException(Minidump* minidump);  bool Read(u_int32_t expected_size);  MDRawExceptionStream exception_;  MinidumpContext*     context_;};// MinidumpSystemInfo wraps MDRawSystemInfo and provides information about// the system on which the minidump was generated.  See also MinidumpMiscInfo.class MinidumpSystemInfo : public MinidumpStream { public:  virtual ~MinidumpSystemInfo();  const MDRawSystemInfo* system_info() const {    return valid_ ? &system_info_ : NULL;  }  // GetOS and GetCPU return textual representations of the operating system  // and CPU that produced the minidump.  Unlike most other Minidump* methods,  // they return string objects, not weak pointers.  Defined values for  // GetOS() are "mac", "windows", and "linux".  Defined values for GetCPU  // are "x86" and "ppc".  These methods return an empty string when their  // values are unknown.  string GetOS();  string GetCPU();  // I don't know what CSD stands for, but this field is documented as  // returning a textual representation of the OS service pack.  On other  // platforms, this provides additional information about an OS version  // level beyond major.minor.micro.  Returns NULL if unknown.  const string* GetCSDVersion();  // If a CPU vendor string can be determined, returns a pointer to it,  // otherwise, returns NULL.  CPU vendor strings can be determined from  // x86 CPUs with CPUID 0.  const string* GetCPUVendor();  // Print a human-readable representation of the object to stdout.  void Print(); private:  friend class Minidump;  static const u_int32_t kStreamType = MD_SYSTEM_INFO_STREAM;  explicit MinidumpSystemInfo(Minidump* minidump);  bool Read(u_int32_t expected_size);  MDRawSystemInfo system_info_;  // Textual representation of the OS service pack, for minidumps produced  // by MiniDumpWriteDump on Windows.  const string* csd_version_;  // A string identifying the CPU vendor, if known.  const string* cpu_vendor_;};// MinidumpMiscInfo wraps MDRawMiscInfo and provides information about// the process that generated the minidump, and optionally additional system// information.  See also MinidumpSystemInfo.class MinidumpMiscInfo : public MinidumpStream { public:  const MDRawMiscInfo* misc_info() const {    return valid_ ? &misc_info_ : NULL;  }  // Print a human-readable representation of the object to stdout.  void Print(); private:  friend class Minidump;  static const u_int32_t kStreamType = MD_MISC_INFO_STREAM;  explicit MinidumpMiscInfo(Minidump* minidump_);  bool Read(u_int32_t expected_size_);  MDRawMiscInfo misc_info_;};// MinidumpBreakpadInfo wraps MDRawBreakpadInfo, which is an optional stream in// a minidump that provides additional information about the process state// at the time the minidump was generated.class MinidumpBreakpadInfo : public MinidumpStream { public:  const MDRawBreakpadInfo* breakpad_info() const {    return valid_ ? &breakpad_info_ : NULL;  }  // These thread IDs are used to determine if threads deserve special  // treatment, so special getters are provided to retrieve this data from  // the MDRawBreakpadInfo structure.  The getters return false if the thread  // IDs cannot be determined.  bool GetDumpThreadID(u_int32_t *thread_id) const;  bool GetRequestingThreadID(u_int32_t *thread_id) const;  // Print a human-readable representation of the object to stdout.  void Print(); private:  friend class Minidump;  static const u_int32_t kStreamType = MD_BREAKPAD_INFO_STREAM;  explicit MinidumpBreakpadInfo(Minidump* minidump_);  bool Read(u_int32_t expected_size_);  MDRawBreakpadInfo breakpad_info_;};// Minidump is the user's interface to a minidump file.  It wraps MDRawHeader// and provides access to the minidump's top-level stream directory.class Minidump { public:  // path is the pathname of a file containing the minidump.  explicit Minidump(const string& path);  ~Minidump();  static void set_max_streams(u_int32_t max_streams) {    max_streams_ = max_streams;  }  static u_int32_t max_streams() { return max_streams_; }  static void set_max_string_length(u_int32_t max_string_length) {    max_string_length_ = max_string_length;  }  static u_int32_t max_string_length() { return max_string_length_; }  const MDRawHeader* header() const { return valid_ ? &header_ : NULL; }  // Reads the minidump file's header and top-level stream directory.  // The minidump is expected to be positioned at the beginning of the  // header.  Read() sets up the stream list and map, and validates the  // Minidump object.  bool Read();  // The next set of methods are stubs that call GetStream.  They exist to  // force code generation of the templatized API within the module, and  // to avoid exposing an ugly API (GetStream needs to accept a garbage  // parameter).  MinidumpThreadList* GetThreadList();  MinidumpModuleList* GetModuleList();  MinidumpMemoryList* GetMemoryList();  MinidumpException* GetException();  MinidumpSystemInfo* GetSystemInfo();  MinidumpMiscInfo* GetMiscInfo();  MinidumpBreakpadInfo* GetBreakpadInfo();  // The next set of methods are provided for users who wish to access  // data in minidump files directly, while leveraging the rest of  // this class and related classes to handle the basic minidump  // structure and known stream types.  unsigned int GetDirectoryEntryCount() const {    return valid_ ? header_.stream_count : 0;  }  const MDRawDirectory* GetDirectoryEntryAtIndex(unsigned int index) const;  // The next 2 methods are lower-level I/O routines.  They use fd_.  // Reads count bytes from the minidump at the current position into  // the storage area pointed to by bytes.  bytes must be of sufficient  // size.  After the read, the file position is advanced by count.  bool ReadBytes(void* bytes, size_t count);  // Sets the position of the minidump file to offset.  bool SeekSet(off_t offset);  // The next 2 methods are medium-level I/O routines.  // ReadString returns a string which is owned by the caller!  offset  // specifies the offset that a length-encoded string is stored at in the  // minidump file.  string* ReadString(off_t offset);  // SeekToStreamType positions the file at the beginning of a stream  // identified by stream_type, and informs the caller of the stream's  // length by setting *stream_length.  Because stream_map maps each stream  // type to only one stream in the file, this might mislead the user into  // thinking that the stream that this seeks to is the only stream with  // type stream_type.  That can't happen for streams that these classes  // deal with directly, because they're only supposed to be present in the  // file singly, and that's verified when stream_map_ is built.  Users who  // are looking for other stream types should be aware of this  // possibility, and consider using GetDirectoryEntryAtIndex (possibly  // with GetDirectoryEntryCount) if expecting multiple streams of the same  // type in a single minidump file.  bool SeekToStreamType(u_int32_t stream_type, u_int32_t* stream_length);  bool swap() const { return valid_ ? swap_ : false; }  // Print a human-readable representation of the object to stdout.  void Print(); private:  // MinidumpStreamInfo is used in the MinidumpStreamMap.  It lets  // the Minidump object locate interesting streams quickly, and  // provides a convenient place to stash MinidumpStream objects.  struct MinidumpStreamInfo {    MinidumpStreamInfo() : stream_index(0), stream(NULL) {}    ~MinidumpStreamInfo() { delete stream; }    // Index into the MinidumpDirectoryEntries vector    unsigned int    stream_index;    // Pointer to the stream if cached, or NULL if not yet populated    MinidumpStream* stream;  };  typedef vector<MDRawDirectory> MinidumpDirectoryEntries;  typedef map<u_int32_t, MinidumpStreamInfo> MinidumpStreamMap;  template<typename T> T* GetStream(T** stream);  // Opens the minidump file, or if already open, seeks to the beginning.  bool Open();  // The largest number of top-level streams that will be read from a minidump.  // Note that streams are only read (and only consume memory) as needed,  // when directed by the caller.  The default is 128.  static u_int32_t max_streams_;  // The maximum length of a UTF-16 string that will be read from a minidump  // in 16-bit words.  The default is 1024.  UTF-16 strings are converted  // to UTF-8 when stored in memory, and each UTF-16 word will be represented  // by as many as 3 bytes in UTF-8.  static unsigned int max_string_length_;  MDRawHeader               header_;  // The list of streams.  MinidumpDirectoryEntries* directory_;  // Access to streams using the stream type as the key.  MinidumpStreamMap*        stream_map_;  // The pathname of the minidump file to process, set in the constructor.  const string              path_;  // The file descriptor for all file I/O.  Used by ReadBytes and SeekSet.  // Set based on the |path_| member by Open, which is called by Read.  int                       fd_;  // swap_ is true if the minidump file should be byte-swapped.  If the  // minidump was produced by a CPU that is other-endian than the CPU  // processing the minidump, this will be true.  If the two CPUs are  // same-endian, this will be false.  bool                      swap_;  // Validity of the Minidump structure, false immediately after  // construction or after a failed Read(); true following a successful  // Read().  bool                      valid_;};}  // namespace google_breakpad#endif  // GOOGLE_BREAKPAD_PROCESSOR_MINIDUMP_H__

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?