import gdb inf = gdb.selected_inferior() pid = inf.pid maps = [] for line in open("/proc/%d/maps" % pid): parts = line.split() try: lo, hi = [int(x, 16) for x in parts[0].split('-')] off = int(parts[2], 16) maps.append((lo, hi, off, parts[5] if len(parts) > 5 else "")) except Exception: pass def resolve(addr): for lo, hi, off, name in maps: if lo <= addr < hi: return "%s+0x%x" % (name.split('/')[-1], off + (addr - lo)) return "?" gdb.execute("set pagination off") print("=== THREADS ===") for t in inf.threads(): try: t.switch() except Exception as e: print("switch err", e) continue pc = int(gdb.parse_and_eval("$pc")) print("TID %s pc=%s" % (t.ptid, resolve(pc))) try: bt = gdb.execute("bt 12", to_string=True) except Exception as e: bt = "bt err %s" % e for ln in bt.splitlines(): ln = ln.strip() if ln.startswith("#"): try: a = int(ln.split()[1], 16) print(" ", ln, "=>", resolve(a)) except Exception: print(" ", ln) else: print(" ", ln) print("DIAG-DONE") gdb.execute("detach") gdb.execute("quit")