pstack icon indicating copy to clipboard operation
pstack copied to clipboard

python3 support

Open xman1979 opened this issue 8 months ago • 1 comments

I made a small change to compile this with python 3.10, e.g:

diff --git a/python.tcc b/python.tcc
index 809f00c..d9064aa 100644
--- a/python.tcc
+++ b/python.tcc
@@ -10,10 +10,10 @@ namespace pstack {
 template<int PyV> int
 getLine(const Reader &proc, const PyCodeObject *code, const PyFrameObject *frame)
 {
-    auto lnotab = readPyObj<PyV, PyVarObject>(proc, Elf::Addr(code->co_lnotab));
+    auto lnotab = readPyObj<PyV, PyVarObject>(proc, Elf::Addr(code->co_linetable));
 
     unsigned char linedata[lnotab.ob_size];
-    proc.readObj(Elf::Addr(code->co_lnotab) + offsetof(PyBytesObject, ob_sval),
+    proc.readObj(Elf::Addr(code->co_linetable) + offsetof(PyBytesObject, ob_sval),
             &linedata[0], lnotab.ob_size);
     int line = code->co_firstlineno;
     int addr = 0;

however, I could not get -p working, I hit error with:

./pstack -pal 2528902
trace of 2528902 failed: Couldn't find a Python interpreter

may I know what is wrong here? up to which python version pstack supports?

xman1979 avatar May 22 '25 05:05 xman1979