Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / breakpad / src / client / linux / minidump_writer / linux_dumper.h
index ad2af01..40678e9 100644 (file)
 #include <sys/types.h>
 #include <sys/user.h>
 
+#include "client/linux/dump_writer_common/mapping_info.h"
+#include "client/linux/dump_writer_common/thread_info.h"
 #include "common/memory.h"
 #include "google_breakpad/common/minidump_format.h"
 
 namespace google_breakpad {
 
-#if defined(__i386) || defined(__x86_64)
-typedef typeof(((struct user*) 0)->u_debugreg[0]) debugreg_t;
-#endif
-
 // Typedef for our parsing of the auxv variables in /proc/pid/auxv.
 #if defined(__i386) || defined(__ARM_EABI__) || defined(__mips__)
 typedef Elf32_auxv_t elf_aux_entry;
@@ -67,50 +65,6 @@ typedef typeof(((elf_aux_entry*) 0)->a_un.a_val) elf_aux_val_t;
 // This should always be less than NAME_MAX!
 const char kLinuxGateLibraryName[] = "linux-gate.so";
 
-// We produce one of these structures for each thread in the crashed process.
-struct ThreadInfo {
-  pid_t tgid;   // thread group id
-  pid_t ppid;   // parent process
-
-  uintptr_t stack_pointer;  // thread stack pointer
-
-
-#if defined(__i386) || defined(__x86_64)
-  user_regs_struct regs;
-  user_fpregs_struct fpregs;
-  static const unsigned kNumDebugRegisters = 8;
-  debugreg_t dregs[8];
-#if defined(__i386)
-  user_fpxregs_struct fpxregs;
-#endif  // defined(__i386)
-
-#elif defined(__ARM_EABI__)
-  // Mimicking how strace does this(see syscall.c, search for GETREGS)
-  struct user_regs regs;
-  struct user_fpregs fpregs;
-#elif defined(__aarch64__)
-  // Use the structures defined in <asm/ptrace.h>
-  struct user_pt_regs regs;
-  struct user_fpsimd_state fpregs;
-#elif defined(__mips__)
-  user_regs_struct regs;
-  user_fpregs_struct fpregs;
-  uint32_t hi[3];
-  uint32_t lo[3];
-  uint32_t dsp_control;
-#endif
-};
-
-// One of these is produced for each mapping in the process (i.e. line in
-// /proc/$x/maps).
-struct MappingInfo {
-  uintptr_t start_addr;
-  size_t size;
-  size_t offset;  // offset into the backed file.
-  bool exec;  // true if the mapping has the execute bit set.
-  char name[NAME_MAX];
-};
-
 class LinuxDumper {
  public:
   explicit LinuxDumper(pid_t pid);
@@ -157,19 +111,13 @@ class LinuxDumper {
   virtual bool BuildProcPath(char* path, pid_t pid, const char* node) const = 0;
 
   // Generate a File ID from the .text section of a mapped entry.
-  // If not a member, mapping_id is ignored.
+  // If not a member, mapping_id is ignored. This method can also manipulate the
+  // |mapping|.name to truncate "(deleted)" from the file name if necessary.
   bool ElfFileIdentifierForMapping(const MappingInfo& mapping,
                                    bool member,
                                    unsigned int mapping_id,
                                    uint8_t identifier[sizeof(MDGUID)]);
 
-  // Find the shared object name (SONAME) by examining the ELF information
-  // for |mapping|. If the SONAME is found copy it into the passed buffer
-  // |soname| and return true. The size of the buffer is |soname_size|.
-  // The SONAME will be truncated if it is too long to fit in the buffer.
-  static bool ElfFileSoName(
-      const MappingInfo& mapping, char* soname, size_t soname_size);
-
   uintptr_t crash_address() const { return crash_address_; }
   void set_crash_address(uintptr_t crash_address) {
     crash_address_ = crash_address;
@@ -181,6 +129,17 @@ class LinuxDumper {
   pid_t crash_thread() const { return crash_thread_; }
   void set_crash_thread(pid_t crash_thread) { crash_thread_ = crash_thread; }
 
+  // Extracts the effective path and file name of from |mapping|. In most cases
+  // the effective name/path are just the mapping's path and basename. In some
+  // other cases, however, a library can be mapped from an archive (e.g., when
+  // loading .so libs from an apk on Android) and this method is able to
+  // reconstruct the original file name.
+  static void GetMappingEffectiveNameAndPath(const MappingInfo& mapping,
+                                             char* file_path,
+                                             size_t file_path_size,
+                                             char* file_name,
+                                             size_t file_name_size);
+
  protected:
   bool ReadAuxv();