Recent

Author Topic: Is it possible to simultaneously debug a parent and child process ?  (Read 2867 times)

440bx

  • Hero Member
  • *****
  • Posts: 4029
Hello,

Note: this is for Windows 7, 64bit.

Two programs, both written in FPC, both same bitness, both with Debugging symbols. From the Lazarus IDE, ProgramA is run under the debugger (GDB) and uses a process creation API to spawn ProcessB (CreateProccess, ShellExecute, etc).

I'd like to have the debugger break at the entry point of ProcessB.  Is this possible ?, if the answer is yes, I'd love to know how that's accomplished.

Thank you for your help.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Is it possible to simultaneously debug a parent and child process ?
« Reply #1 on: March 02, 2019, 01:11:48 pm »
Well, some work is going on, but as this link says: mostly dead. https://sourceware.org/gdb/wiki/MultiTarget
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

440bx

  • Hero Member
  • *****
  • Posts: 4029
Re: Is it possible to simultaneously debug a parent and child process ?
« Reply #2 on: March 02, 2019, 02:18:50 pm »
Well, some work is going on, but as this link says: mostly dead. https://sourceware.org/gdb/wiki/MultiTarget
Thank you Thaddy.  I guess, it may be time to visit writeln country.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Is it possible to simultaneously debug a parent and child process ?
« Reply #3 on: March 02, 2019, 03:05:42 pm »
or add
Code: Pascal  [Select][+][-]
  1. asm int 3 end;
on top of the second?
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

440bx

  • Hero Member
  • *****
  • Posts: 4029
Re: Is it possible to simultaneously debug a parent and child process ?
« Reply #4 on: March 02, 2019, 03:12:53 pm »
or add
Code: Pascal  [Select][+][-]
  1. asm int 3 end;
on top of the second?
I tried, got no joy out of it.   Got an exception ($03) as a consolation prize... chuckle.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9867
  • Debugger - SynEdit - and more
    • wiki
Re: Is it possible to simultaneously debug a parent and child process ?
« Reply #5 on: March 02, 2019, 03:23:37 pm »
Afaik Gdb can only debug one process at a time.

IIRC, gdb could interrupt when the new process get started, and maybe even let you choose one of the two (not sure, from very distant memory).
In any case the IDE does not support this.

If you do not need to intercept immediately, you can attach a 2nd IDE to the forked process. But obviously you can only do that, once it is running. So you do not get it at its entry point.

440bx

  • Hero Member
  • *****
  • Posts: 4029
Re: Is it possible to simultaneously debug a parent and child process ?
« Reply #6 on: March 02, 2019, 03:43:19 pm »
If you do not need to intercept immediately, you can attach a 2nd IDE to the forked process. But obviously you can only do that, once it is running. So you do not get it at its entry point.
That's where the problem is.  I need to start debugging at the entry point. 

Thank you, I appreciate the suggestion and additional information you provided.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018