0

I open a new thread cause I reply on an existing one who is doing exactly what I want... But I just can't optain the same result...

Here is the topic : gdb debugging process after exec call

I only want be able to debug an "execled" application with gdb.

Here is what my C program looks like :

if( !fork() ) 
   execl("./exec/nuitretard","nuitretard","S","1000","000","N",ZZTOP);
else wait(&status);
Recup();

When I'm on the line :

97          if( !fork() )

I do in gdb :

(gdb) set follow-fork-mode child                                                
(gdb) break main
Breakpoint 2 at 0x40198c: main. (2 locations)                                   
(gdb) n
[New process 9034]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[Switching to Thread 0x7ffff7eb3780 (LWP 9034)]
98        execl("./exec/nuitretard","nuitretard","S","1000","000","N",ZZTOP);

I put with my gdb "break main" command an breakpoint on all main function isn't it ? So if I press next line I should go in nuitretard's main no ? But when I do, I got this :

(gdb) n
100     Recup();

So I didn't stopped at my "nuitretard" program :/

What have I not done correctly ? Thanks for your help.

Edit : I obviously compiled two programs with -g to debug. I'm on Linux ubuntu.

Community
  • 1
  • 1
Manov
  • 69
  • 6
  • The only reason the child would ever get to the `Recup` statement is if the `execl` call fails. Can you store the return value from `execl` in a variable and print it? – Mark Plotnick Aug 03 '16 at 16:14
  • You are right ! My initial program was lauched directly by the exec folder and I should launch it from the parent one for that works ! Thanks – Manov Aug 05 '16 at 06:32

0 Answers0