Skip to content

Instantly share code, notes, and snippets.

@dmpots
dmpots / gist:4acf46e109f8948ecc19fb5f46158f80
Created July 17, 2025 19:09
callstack for call to amd_dbgapi_insert_breakpoint_callback
(lldb) bt
thread backtrace
* thread #1, name = 'lldb-server', stop reason = signal SIGSTOP
frame #0: 0x00007ff87d8973dc libc.so.6`futex_wait(private=0, expected=2, futex_word=0x000055bdf46a0b28) at futex-internal.h:146:13
frame #1: 0x00007ff87d8973c6 libc.so.6`__GI___lll_lock_wait(futex=0x000055bdf46a0b28, private=0) at lowlevellock.c:50:7
frame #2: 0x00007ff87d89dff1 libc.so.6`lll_mutex_lock_optimized(mutex=0x000055bdf46a0b28) at pthread_mutex_lock.c:49:5
frame #3: 0x00007ff87d89dfe8 libc.so.6`___pthread_mutex_lock(mutex=0x000055bdf46a0b28) at pthread_mutex_lock.c:89:7
frame #4: 0x000055bdefe1df3f lldb-server`__gthread_mutex_lock(__mutex=0x000055bdf46a0b28) at gthr-default.h:749:12
frame #5: 0x000055bdefe1fe55 lldb-server`std::mutex::lock(this=0x000055bdf46a0b28) at std_mutex.h:100:17
frame #6: 0x000055bdefe1fd93 lldb-server`std::lock_guard<std::mutex>::lock_guard(this=0x00007ffc3f2d9660, __m=0x000055bdf46a0b28) at std_mutex.h:229:19
@dmpots
dmpots / gen_plugin_code.py
Created June 12, 2025 20:59
Python script to generate code to support plugin list/enable/disable
#!/usr/bin/env python3
import os
import argparse
import re
NAMESPACES = [
'ABI',
'Architecture',
'Disassembler',
'DynamicLoader',
@dmpots
dmpots / TestDAP_exception_cpp.md
Created May 1, 2025 17:20
Notes on debugging flaky TestDAP_exception_cpp.py

Debugging a non-deterministic failure of TestDAP_exception_cpp.py

I am debugging a non-deterministic failure of the TestDAP_exception_cpp.py test. The tested binary throws an uncaught exception, which causes the C++ runtime to call std::terminate. That eventually calls abort, which then raises SIGABRT, which is caught by lldb-dap.

The test then makes a DAP request to get the information about the exception. The test will randomly fail sometimes because the returned info is missing the “details” part of the record.

self.assertIsNotNone(exceptionInfo["details"])
@dmpots
dmpots / gist:f8f7715899a738d40301946a40ae216c
Created December 17, 2024 15:47
disassembly of _int_free_merge_chunk and unlink_chunk
(gdb) disassemble _int_free_merge_chunk
Dump of assembler code for function _int_free_merge_chunk:
0x00007f9e2e34ff80 <+0>: push %rbp
0x00007f9e2e34ff81 <+1>: mov %rsp,%rbp
0x00007f9e2e34ff84 <+4>: push %r15
0x00007f9e2e34ff86 <+6>: push %r14
0x00007f9e2e34ff88 <+8>: push %r13
0x00007f9e2e34ff8a <+10>: lea (%rsi,%rdx,1),%r13
0x00007f9e2e34ff8e <+14>: push %r12
0x00007f9e2e34ff90 <+16>: push %rbx
Thread 1 "zig2" received signal SIGILL, Illegal instruction.
_int_free_merge_chunk (av=0x7f9e2e4a8ac0 <main_arena>, p=0x55cad7ad4320, size=928)
at ./malloc/malloc.c:4700
warning: 4700 ./malloc/malloc.c: No such file or directory
(gdb) bt
#0 _int_free_merge_chunk (av=0x7f9e2e4a8ac0 <main_arena>, p=0x55cad7ad4320, size=928)
at ./malloc/malloc.c:4700
#1 0x00007f9e2e35042a in _int_free (av=0x7f9e2e4a8ac0 <main_arena>, p=<optimized out>,
have_lock=<optimized out>) at ./malloc/malloc.c:4646
#2 0x00007f9e2e352d9e in __GI___libc_free (mem=0x55cad7ad4500) at ./malloc/malloc.c:3398
error: the following command terminated unexpectedly:
/home/dmpots/zig/build/zig2 build-exe -fallow-so-scripts --stack 33554432 /home/dmpots/zig/build/zigcpp/libzigcpp.a /home/dmpots/local/llvm19-assert/lib/libclangFrontendTool.a /home/dmpots/local/llvm19-assert/lib/libclangCodeGen.a /home/dmpots/local/llvm19-assert/lib/libclangFrontend.a /home/dmpots/local/llvm19-assert/lib/libclangDriver.a /home/dmpots/local/llvm19-assert/lib/libclangSerialization.a /home/dmpots/local/llvm19-assert/lib/libclangSema.a /home/dmpots/local/llvm19-assert/lib/libclangStaticAnalyzerFrontend.a /home/dmpots/local/llvm19-assert/lib/libclangStaticAnalyzerCheckers.a /home/dmpots/local/llvm19-assert/lib/libclangStaticAnalyzerCore.a /home/dmpots/local/llvm19-assert/lib/libclangAnalysis.a /home/dmpots/local/llvm19-assert/lib/libclangASTMatchers.a /home/dmpots/local/llvm19-assert/lib/libclangAST.a /home/dmpots/local/llvm19-assert/lib/libclangParse.a /home/dmpots/local/llvm19-assert/lib/libclangSema.a /home/dmpots/local/llvm19-assert/lib/li
@dmpots
dmpots / gist:1374144
Created November 17, 2011 19:18
llvm.annotation.i32 intrinsic error
$ cat test.ll
@.str = private unnamed_addr constant [6 x i8] c"Hello\00"
declare i32 @llvm.annotation.i32(i32, i8* , i8*, i32)
define i32 @main(i32 %argc, i8** %argv) nounwind ssp {
%1 = call i32 @llvm.annotation.i32(
i32 0,
i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0),
i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0),
i32 0