Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-06

How to exec some gdb command on start in lazarus

9 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Petr Kristan

Hallo

I want to send this command to gdb:

handle SIGPIPE nostop noprint pass

to ignore SIGPIPE.
I set it in my ~/.gdbinit, but Lazarus ignores it.

I tried write it to Debugger_Startup_Options, but without success.

Petr

Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401 Czech Republic (Eastern Europe) fax: +420 461101481

Reply by email

martin
to Petr Kristan
Petr Kristan wrote 11 lines
Hallo I want to send this command to gdb: handle SIGPIPE nostop noprint pass to ignore SIGPIPE. I set it in my ~/.gdbinit, but Lazarus ignores it. I tried write it to Debugger_Startup_Options, but without success.

the Debugger_Startup_Options, would be like

--eval-command="handle SIGPIPE nostop noprint pass"

if you are on windows IIRC gdb does not take this option.

Reply by email

martin
to martin
martin wrote 18 lines
On 24/06/13 16:11, Petr Kristan wrote: > Hallo > > I want to send this command to gdb: > > handle SIGPIPE nostop noprint pass > > to ignore SIGPIPE. > I set it in my ~/.gdbinit, but Lazarus ignores it. > > I tried write it to Debugger_Startup_Options, but without success. > the Debugger_Startup_Options, would be like --eval-command="handle SIGPIPE nostop noprint pass" if you are on windows IIRC gdb does not take this option.

that is even if you send it later ....

you can try by changing debugger/gdbmidebugger.pp

function TGDBMIDebuggerCommandStartDebugging.DoExecute: Boolean;
line 4634 after
     ExecuteCommand('-gdb-set language pascal', [cfCheckError]);

insert
ExecuteCommand('handle SIGPIPE nostop noprint pass', [], [cfNoMiCommand, cfIgnoreState, cfExternal]);

see
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#Log_info_for_debug_session for a log that contains all commands send to gdb

Reply by email

Petr Kristan
to martin: the Debugger_Startup_Options, would be like --eval-command="handle SIGPIPE nostop…
martin wrote 18 lines
On 24/06/13 16:11, Petr Kristan wrote: >Hallo > >I want to send this command to gdb: > >handle SIGPIPE nostop noprint pass > >to ignore SIGPIPE. >I set it in my ~/.gdbinit, but Lazarus ignores it. > >I tried write it to Debugger_Startup_Options, but without success. > the Debugger_Startup_Options, would be like --eval-command="handle SIGPIPE nostop noprint pass" if you are on windows IIRC gdb does not take this option.

Thank you for the fast response. I try it, but I get this message: Debugger: Initialization output: &"Undefined command: \"\". Try \"help\".\n

In processes i have
/usr/bin/gdb -silent -i mi -nx --eval-command="handle SIGPIPE nostop noprint pass"

But gdb already stops on SIGPIPE.

If I try run
/usr/bin/gdb -silent -i mi -nx --eval-command="handle SIGPIPE nostop noprint pass" from bash, then it works ok.

Petr

Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401 Czech Republic (Eastern Europe) fax: +420 461101481

Reply by email

martin
to Petr Kristan
Petr Kristan wrote 11 lines
Thank you for the fast response. I try it, but I get this message: Debugger: Initialization output: &"Undefined command: \"\". Try \"help\".\n In processes i have /usr/bin/gdb -silent -i mi -nx --eval-command="handle SIGPIPE nostop noprint pass" But gdb already stops on SIGPIPE. If I try run /usr/bin/gdb -silent -i mi -nx --eval-command="handle SIGPIPE nostop noprint pass" from bash, then it works ok.

Did you try single quotes ?
looks like the parts of the command line are not correctly broken into individual args.

Reply by email

Petr Kristan
to martin
martin wrote 16 lines
On 25/06/13 07:49, Petr Kristan wrote: >Thank you for the fast response. I try it, but I get this message: >Debugger: Initialization output: &"Undefined command: \"\". Try \"help\".\n > >In processes i have >/usr/bin/gdb -silent -i mi -nx --eval-command="handle SIGPIPE nostop noprint pass" > >But gdb already stops on SIGPIPE. > >If I try run >/usr/bin/gdb -silent -i mi -nx --eval-command="handle SIGPIPE nostop noprint pass" >from bash, then it works ok. Did you try single quotes ? looks like the parts of the command line are not correctly broken into individual args.

Yes. With the same result.

I try to debug Debugger_Startup_Options: --eval-command="handle SIGPIPE nostop noprint pass" with strace and here is execve line:

[pid 20053] execve("/usr/bin/gdb", ["/usr/bin/gdb", "-silent", "-i", "mi", "-nx", "--eval-command=\"handle SIGPIPE nostop noprint pass\""], [/* 52 vars */]) = 0

IMHO it looks ok.

Petr

Petr Kristan . EPOS PRO s.r.o., Smilova 333, 530 02 Pardubice tel: +420 461101401 Czech Republic (Eastern Europe) fax: +420 461101481

Reply by email

martin
to Petr Kristan
Petr Kristan wrote 5 lines
I try to debug Debugger_Startup_Options: --eval-command="handle SIGPIPE nostop noprint pass" with strace and here is execve line: [pid 20053] execve("/usr/bin/gdb", ["/usr/bin/gdb", "-silent", "-i", "mi", "-nx", "--eval-command=\"handle SIGPIPE nostop noprint pass\""], [/* 52 vars */]) = 0 IMHO it looks ok.

I don't think it should have the \", if the entire argument is quoted. but I am not sure

afaik/iirc the IDE passes this to TProcess (in fpc) and I do not know what happens there

however TProcess.Commandline is deprecated, afaik because arguments must be parsed... not sure.

In any case, I do not know how to solve, until the IDE stopped using the deprecated method / no time frame on that.

You can try my other suggestion and change the source....

Reply by email

patspiper
to martin
martin wrote 20 lines
On 25/06/13 10:51, Petr Kristan wrote: > I try to debug Debugger_Startup_Options: --eval-command="handle > SIGPIPE nostop noprint pass" with strace and here is execve line: > [pid 20053] execve("/usr/bin/gdb", ["/usr/bin/gdb", "-silent", "-i", > "mi", "-nx", "--eval-command=\"handle SIGPIPE nostop noprint > pass\""], [/* 52 vars */]) = 0 IMHO it looks ok. I don't think it should have the \", if the entire argument is quoted. but I am not sure afaik/iirc the IDE passes this to TProcess (in fpc) and I do not know what happens there however TProcess.Commandline is deprecated, afaik because arguments must be parsed... not sure. In any case, I do not know how to solve, until the IDE stopped using the deprecated method / no time frame on that. You can try my other suggestion and change the source....

Maybe the patch in http://bugs.freepascal.org/view.php?id=22751 can be a starting point?

Stephano

Reply by email

hovercraft
to Petr Kristan: Hallo I want to send this command to gdb: handle SIGPIPE nostop noprint pass to ignore…

It may be a late reply, but for somebody interested: it is possible to achieve this by altering lazarus source file debugger/gdbmidebugger.pp (as previously mentioned by Martin). But line actually should be if (Assigned(FTheDebugger)) then
FTheDebugger.ExecuteCommand('handle SIGPIPE ignore noprint pass', [], [cfNoMiCommand, cfIgnoreState, cfExternal]);
after the "ExecuteCommand('-gdb-set language pascal', [cfCheckError]); " line.
In the Lazarus v1.0.12 this is somewhere near line 4344

Reply by email