[Python] LLDB running a Python debugging script. I'm getting error: invalid thread

Discussão em 'Python' iniciado por Stack, Fevereiro 15, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to run a Python debug script in LLDB, but I'm getting invalid thread errors. I'm not sure why.

    Here are my programs:

    main.c:

    #include <stdio.h>
    #include <stdlib.h>

    int addNumbs(int a, int b)
    {
    return a+b;
    }

    int main()
    {
    int a =5;
    int b= 24;

    int total = addNumbs(a,b);

    printf("%d\n", total);

    return 0;
    }


    My python debugging script debugersample.py:

    import lldb

    debugger = lldb.debugger

    debugger.HandleCommand("b main")
    debugger.HandleCommand("r")

    for i in range(0,3): #execute next 3 times
    debugger.HandleCommand("n")

    debugger.HandleCommand("bt")


    Running LLDB:

    clang -g main -o main
    lldb ./main
    (lldb) command script import debugsample.py

    Breakpoint 1: where = main`main + 15 at main.c:11:9, address = 0x0000000100003f0f
    Process 5344 launched: '/Users/xxxx/CLionProjects/C_Practice/main' (x86_64)
    error: invalid thread
    error: invalid thread
    error: invalid thread
    error: invalid thread
    Process 5344 stopped
    * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
    frame #0: 0x0000000100003f0f main`main at main.c:11:9
    8
    9 int main()
    10 {
    -> 11 int a =5;
    12 int b= 24;
    13
    14 int* ptr = (int*)malloc(sizeof(int));
    Target 0: (main) stopped.


    Note: When I run these commands in LLDB Python's interactive interpreter line by line, it works fine.

    Continue reading...

Compartilhe esta Página