code: def _GetGdbThreadMapping(self, position):
      
  
      if len(gdb.selected_inferior().threads()) == 1:
        # gdb's output for info threads changes and only displays PID. We cheat.
        return {position[1]: 1}
      # example:
      #   8    Thread 0x7f0a637fe700 (LWP 11894) "test.py" 0x00007f0a69563e63 in
      #   select () from /usr/lib64/libc.so.6
      thread_line_regexp = r'\s*\**\s*([0-9]+)\s+[a-zA-Z]+\s+([x0-9a-fA-F]+)\s.*'
      output = gdb.execute('info threads', to_string=True)
      matches = [re.match(thread_line_regexp, line) for line
                 in output.split('\n')[1:]]
      return {int(match.group(2), 16): int(match.group(1))
              for match in matches if match}
docs: Gets a mapping from python tid to gdb thread num.
  
      There's no way to get the thread ident from a gdb thread.  We only get the
      "ID of the thread, as assigned by GDB", which is completely useless for
      everything except talking to gdb.  So in order to translate between these
      two, we have to execute 'info threads' and parse its output. Note that this
      may only work on linux, and only when python was compiled to use pthreads.
      It may work elsewhere, but we won't guarantee it.
  
      Args:
        position: array of pid, tid, framedepth specifying the requested position.
      Returns:
        A dictionary of the form {python_tid: gdb_threadnum}.