godzie44 / BugStalker

Rust debugger for Linux x86-64
MIT License
554 stars 15 forks source link

debug c code #37

Closed TornaxO7 closed 2 months ago

TornaxO7 commented 2 months ago

Hi! I've got a little question regarding debugging c with bugstalker instead of gdb. Assuming we've got the following file: /tmp/main.c

#include <stdio.h>

int main() {
    puts("Hello there!");
    return 0;
}

and if I execute the following commands:

cd /tmp
gcc main.c
bs a.out

now if I do b main I'm getting:

Add deferred breakpoint for future shared library load?

is that expected? Do you have an suggestion how to fix this so that I can debug c code?

godzie44 commented 2 months ago

Hi! You can try to build you program with -g flag (this will force compiler to add debug information), this works for me:

gcc -g main.c
bs ./a.out
BugStalker greets

(bs) b main.c:4
New breakpoint 1 at 0x00000000001151: /home/kd/main.c:4 
(bs) r
Hit breakpoint 1 at 0x00555555555151: /home/kd/main.c:4
   4     puts("Hello there!");

Also looks like there is some sort of a bug, when i set b main bs set breakpoint at line 6 instead of line 4, i will fix this in next releases (if there is no conflicts with rust debugging process)

TornaxO7 commented 2 months ago

Oh right.... I need to apply -g for C. Thanks!