Пример #1
0
  def _get_binary_path_from_link_map(self):
    name = gdb_script_util.get_arg('char*', 0)
    if not name:
      return None
    # This will be like: 0x357bc "libc.so"
    matched = re.match(r'.*"(.*)"', name)
    if not matched:
      print('Failed to retrieve the name of the shared object: "%s"' % name)
      return None

    path = matched.group(1)
    # Check if this is the main binary before the check for
    # "lib" to handle tests which start from lib such as libndk_test
    # properly.
    if path == os.path.basename(self._main_binary) or path == 'main.nexe':
      path = self._main_binary
    else:
      # Some files are in a subdirectory. So search files in the _library_path.
      for dirpath, _, filenames in os.walk(self._library_path):
        if path in filenames:
          path = os.path.join(dirpath, path)
          break

    if not os.path.exists(path):
      # TODO(crbug.com/354290): In theory, we should be able to
      # extract the APK and tell GDB the path to the NDK shared
      # object.
      print('%s does not exist! Maybe NDK in APK?' % path)
      return None

    return path
Пример #2
0
    def _get_binary_path_from_link_map(self):
        name = gdb_script_util.get_arg('char*', 0)
        if not name:
            return None
        # This will be like: 0x357bc "libc.so"
        matched = re.match(r'.*"(.*)"', name)
        if not matched:
            print('Failed to retrieve the name of the shared object: "%s"' %
                  name)
            return None

        path = matched.group(1)
        # Check if this is the main binary before the check for
        # "lib" to handle tests which start from lib such as libndk_test
        # properly.
        if path == os.path.basename(self._main_binary) or path == 'main.nexe':
            path = self._main_binary
        else:
            # Some files are in a subdirectory. So search files in the _library_path.
            for dirpath, _, filenames in os.walk(self._library_path):
                if path in filenames:
                    path = os.path.join(dirpath, path)
                    break

        if not os.path.exists(path):
            # TODO(crbug.com/354290): In theory, we should be able to
            # extract the APK and tell GDB the path to the NDK shared
            # object.
            print('%s does not exist! Maybe NDK in APK?' % path)
            return None

        return path
Пример #3
0
    def stop(self):
        prot = int(gdb_script_util.get_arg('int', 2))
        # Wait until the first PROT_READ|PROT_EXEC mmap.
        if prot != 5:
            return False

        # We do not use return_value of FinishBreakpoint because it
        # requires debug information. As of March 2015, nonsfi_loader has
        # debug information, but NaCl team may strip it in future.
        addr = int(gdb_script_util.get_arg('unsigned int', 0))
        assert addr
        # self.delete() should work according to the document, but it
        # finishes the debugger for some reason. Instead, just disable
        # this breakpoint.
        self.enabled = False
        MmapFinishBreakpoint(self._main_binary, self._library_path,
                             self._runnable_ld_path, addr)
  def stop(self):
    prot = int(gdb_script_util.get_arg('int', 2))
    # Wait until the first PROT_READ|PROT_EXEC mmap.
    if prot != 5:
      return False

    # We do not use return_value of FinishBreakpoint because it
    # requires debug information. As of March 2015, nonsfi_loader has
    # debug information, but NaCl team may strip it in future.
    addr = int(gdb_script_util.get_arg('unsigned int', 0))
    assert addr
    # self.delete() should work according to the document, but it
    # finishes the debugger for some reason. Instead, just disable
    # this breakpoint.
    self.enabled = False
    MmapFinishBreakpoint(
        self._main_binary, self._library_path,
        self._runnable_ld_path, addr)
Пример #5
0
 def _get_text_section_address_from_link_map(self, path):
   base_addr_str = gdb_script_util.get_arg('unsigned int', 1)
   if not base_addr_str:
     return None
   try:
     base_addr = int(base_addr_str)
   except ValueError:
     print('Failed to retrieve the address of the shared object: ' +
           base_addr_str)
     return None
   file_off = gdb_script_util.get_text_section_file_offset(path)
   if file_off is None:
     return None
   return file_off + base_addr
Пример #6
0
 def _get_text_section_address_from_link_map(self, path):
     base_addr_str = gdb_script_util.get_arg('unsigned int', 1)
     if not base_addr_str:
         return None
     try:
         base_addr = int(base_addr_str)
     except ValueError:
         print('Failed to retrieve the address of the shared object: ' +
               base_addr_str)
         return None
     file_off = gdb_script_util.get_text_section_file_offset(path)
     if file_off is None:
         return None
     return file_off + base_addr