Sign in Join

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

Mailing lists / lazarus / 2015-08

GDB strangeness

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

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

Michael Van Canneyt

Hi,

I'm debugging a program, and it just won't debug inside lazarus.

When I look at the debug output in Lazarus, I see:

<-exec-run>
=thread-group-started,id="i1",pid="20658"
=thread-created,id="1",group-id="i1"
^running
*running,thread-id="all"
(gdb)
=thread-exited,id="1",group-id="i1"
=thread-group-exited,id="i1"
^error,msg="During startup program exited with code 1."

The strange thing is that if I use gdb on the command-line, it does start and run the program, and I can debug as I would expect it (albeit very rudimentary).

What could be the cause of this difference in behaviour ? Are there any options I can give through 'Debugger_startup_options' to diagnose more ?

Michael.

Reply by email

Martin Frb
to Michael Van Canneyt
Michael Van Canneyt wrote 17 lines
I'm debugging a program, and it just won't debug inside lazarus. When I look at the debug output in Lazarus, I see: <-exec-run> =thread-group-started,id="i1",pid="20658" =thread-created,id="1",group-id="i1" ^running *running,thread-id="all" (gdb) =thread-exited,id="1",group-id="i1" =thread-group-exited,id="i1" ^error,msg="During startup program exited with code 1." The strange thing is that if I use gdb on the command-line, it does start and run the program, and I can debug as I would expect it (albeit very rudimentary).

lazarus tries to set a break at entrypoint, and once that is reached it will set user breaks.

the last line/error is from the IDE, because that entry point brk was not reached.

2 possible solutions:
- a library interfers with the name "main". there is an option (tools/options/ debugger) to skip loading dll info http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#internal-error:_clear_dangling_display_expressions
- tools/options/ debugger change the InternalStartBreak option

Reply by email

Michael Van Canneyt
to Martin Frb
Martin Frb wrote 29 lines
On 25/08/15 11:06, Michael Van Canneyt wrote: > > I'm debugging a program, and it just won't debug inside lazarus. > > When I look at the debug output in Lazarus, I see: > > <-exec-run> > =thread-group-started,id="i1",pid="20658" > =thread-created,id="1",group-id="i1" > ^running > *running,thread-id="all" > (gdb) =thread-exited,id="1",group-id="i1" > =thread-group-exited,id="i1" > ^error,msg="During startup program exited with code 1." > > The strange thing is that if I use gdb on the command-line, it does start > and run the program, > and I can debug as I would expect it (albeit very rudimentary). lazarus tries to set a break at entrypoint, and once that is reached it will set user breaks. the last line/error is from the IDE, because that entry point brk was not reached. 2 possible solutions: - a library interfers with the name "main". there is an option (tools/options/ debugger) to skip loading dll info http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#internal-error:_clear_dangling_display_expressions - tools/options/ debugger change the InternalStartBreak option

After a lot of testing, I tracked it to the run command-line I was using. It contains ? and other characters in need of escaping.

While I was using the exact same command-line on the console and in lazarus, there was a difference. It has to do with the way gdb parses the arguments. It apparently uses the shell to expand the arguments to a program. Which shell it uses depends on the environment.

I use tcsh as my shell, and apparently lazarus lets gdb use another shell.

Maybe adding an explicit command may help, there seems to be:

set startup-with-shell

For me, I fixed it by properly escaping the run command, and then all went well. It took me quite some time to find out :(

Hopefully people will learn from my experience :)

Michael.

Reply by email