Recent

Author Topic: Cannot debug on Linux  (Read 31156 times)

Anonymous

  • Guest
Cannot debug on Linux
« on: November 15, 2005, 10:30:39 pm »
Hello to all
my Linux box is a Slackware 10.1 and I have installed Lazarus 0.9.10.
When I try to run a project from the IDE, the debugger enter the error state.
My settings are : use gdb (ver. 6.3) with /usr/bin/gdb as the path; the file /etc/fpc.cfg has the option -g enabled.
After the error I look at the debugger window and the last lines are :

(gdb)
<-exec-run>
^running
(gdb)
&"Cannot exec : No such file or directory.\n"
&"You can't do that without a process to debug.\n"
^error,msg="You can't do that without a process to debug."
(gdb)
<info program>
&"info program\n"
~"The program being debugged is not being run.\n"
^done,reason="exited",exit-code="0177"
(gdb)

Please note that the executable file works correctly if launched from the shell. Also note that the previous Lazarus 0.9.8 worked fine on the same Linux box.

Any idea about what I'm doing wrong ?[/quote][/code]

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
RE: Cannot debug on Linux
« Reply #1 on: November 16, 2005, 10:49:30 am »
In the same debugger window, do you see some lines where the filename is set ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

VitFer

  • New Member
  • *
  • Posts: 11
Cannot debug on Linux
« Reply #2 on: November 16, 2005, 12:29:14 pm »
I'm not in front of my Linux box now but I don't remember such a line.
 :cry:

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Cannot debug on Linux
« Reply #3 on: November 17, 2005, 11:16:10 am »
Strange.
Did you try it with an empty new app (single form) saved on a path without spaces, with an unit and project name with a short lowercase name, only using lower ascii ? (just to exclude some possible problems)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

VitFer

  • New Member
  • *
  • Posts: 11
Cannot debug on Linux
« Reply #4 on: November 17, 2005, 10:16:57 pm »
Hi Marc
sorry for the late reply.
I've created a simple project, with an empty form and only the default code inside the unit.
The problem is still the same so I've pasted the entire message in the debugger window. I hope this can help.


<-gdb-set env PWD=/home/vitfer>
^done
(gdb)
<-gdb-set env QTDIR=/usr/lib/qt>
^done
(gdb)
<-gdb-set env SHELL=>
~"Setting environment variable \"SHELL\" to null value.\n"
^done
(gdb)
<-gdb-set env SHLVL=1>
^done
(gdb)
<-gdb-set env T1LIB_CONFIG=/usr/share/t1lib/t1lib.config>
^done
(gdb)
<-gdb-set env TERM=dumb>
^done
(gdb)
<-gdb-set env USER=vitfer>
^done
(gdb)
<-gdb-set env WINDOW_MANAGER=metacity>
^done
(gdb)
<-file-exec-and-symbols "/home/vitfer/test/project1">
~"Using host libthread_db library \"/lib/libthread_db.so.1\".\n"
^done
(gdb)
<-environment-cd "/home/vitfer/test/">
^done
(gdb)
<-data-evaluate-expression FPC_THREADVAR_RELOCATE_PROC>
&"No symbol \"FPC_THREADVAR_RELOCATE_PROC\" in current context.\n"
^error,msg="No symbol \"FPC_THREADVAR_RELOCATE_PROC\" in current context."
(gdb)
<info functions FPC_CPUINIT>
&"info functions FPC_CPUINIT\n"
~"All functions matching regular expression \"FPC_CPUINIT\":\n"
~"\n"
~"Non-debugging symbols:\n"
~"0x0805368c  SYSTEM_FPC_CPUINIT\n"
^done
(gdb)
<-gdb-set language pascal>
^done
(gdb)
<-break-insert -t main>
^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x080535b0",func="main",file="project1.lpr",line="11",times="0"}
(gdb)
<-break-insert FPC_RAISEEXCEPTION>
^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0805ce72",at="<fpc_raiseexception+6>",times="0"}
(gdb)
<-break-insert FPC_BREAK_ERROR>
^done,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr="0x0805f4c2",at="<SYSTEM_HANDLEERRORADDRFRAME$LONGINT$POINTER$POINTER+6>",times="0"}
(gdb)
<-break-insert FPC_RUNERROR>
^done,bkpt={number="4",type="breakpoint",disp="keep",enabled="y",addr="0x0805f592",at="<SYSTEM_RUNERROR$WORD+6>",times="0"}
(gdb)
<info file>
&"info file\n"
~"Symbols from \"/home/vitfer/test/project1\".\n"
~"Local exec file:\n"
~"\t`/home/vitfer/test/project1', file type elf32-i386.\n"
~"\tEntry point: 0x8053490\n"
~"\t0x080480f4 - 0x08048107 is .interp\n"
~"\t0x08048108 - 0x08049368 is .hash\n"
~"\t0x08049368 - 0x0804bc38 is .dynsym\n"
~"\t0x0804bc38 - 0x0804f318 is .dynstr\n"
~"\t0x0804f318 - 0x0804f832 is .gnu.version\n"
~"\t0x0804f834 - 0x0804f884 is .gnu.version_r\n"
~"\t0x0804f884 - 0x0804f8c4 is .rel.dyn\n"
~"\t0x0804f8c4 - 0x08050ca4 is .rel.plt\n"
~"\t0x08050ca4 - 0x08050cbe is .init\n"
~"\t0x08050cc0 - 0x08053490 is .plt\n"
~"\t0x08053490 - 0x081a8700 is .text\n"
~"\t0x081a8700 - 0x081a871e is .fini\n"
~"\t0x081a8720 - 0x081a8724 is .eh_frame\n"
~"\t0x081a9000 - 0x081a9008 is .ctors\n"
~"\t0x081a9008 - 0x081a9010 is .dtors\n"
~"\t0x081a9010 - 0x081a9014 is .jcr\n"
~"\t0x081a9014 - 0x081a9124 is .dynamic\n"
~"\t0x081a9124 - 0x081a9128 is .got\n"
~"\t0x081a9128 - 0x081a9b24 is .got.plt\n"
~"\t0x081a9b24 - 0x0823d850 is .data\n"
~"\t0x0823d850 - 0x08253e48 is .bss\n"
^done
(gdb)
<-exec-run>
^running
(gdb)
&"Cannot exec : No such file or directory.\n"
&"You can't do that without a process to debug.\n"
^error,msg="You can't do that without a process to debug."
(gdb)
<info program>
&"info program\n"
~"The program being debugged is not being run.\n"
^done,reason="exited",exit-code="0177"
(gdb)

What do you think about the message
"No symbol \"FPC_THREADVAR_RELOCATE_PROC\" in current context.\n" ?

Thank you very much for your help

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Cannot debug on Linux
« Reply #5 on: November 18, 2005, 11:37:01 am »
I am puzzeled. Here a breakdown:

Quote

<-gdb-set env PWD=/home/vitfer>
^done
(gdb)
<-gdb-set env QTDIR=/usr/lib/qt>
^done
(gdb)
<-gdb-set env SHELL=>
~"Setting environment variable \"SHELL\" to null value.\n"
^done
(gdb)
<-gdb-set env SHLVL=1>
^done
(gdb)
<-gdb-set env T1LIB_CONFIG=/usr/share/t1lib/t1lib.config>
^done
(gdb)
<-gdb-set env TERM=dumb>
^done
(gdb)
<-gdb-set env USER=vitfer>
^done
(gdb)
<-gdb-set env WINDOW_MANAGER=metacity>
^done
(gdb)

Set some environmentvars: OK

Quote

<-file-exec-and-symbols "/home/vitfer/test/project1">
~"Using host libthread_db library \"/lib/libthread_db.so.1\".\n"
^done
(gdb)

Set the exe name: it loads, mit is recognized as exe, OK

Quote

<-environment-cd "/home/vitfer/test/">
^done
(gdb)

Set working dir: OK

Quote

<-data-evaluate-expression FPC_THREADVAR_RELOCATE_PROC>
&"No symbol \"FPC_THREADVAR_RELOCATE_PROC\" in current context.\n"
^error,msg="No symbol \"FPC_THREADVAR_RELOCATE_PROC\" in current context."
(gdb)
<info functions FPC_CPUINIT>
&"info functions FPC_CPUINIT\n"
~"All functions matching regular expression \"FPC_CPUINIT\":\n"
~"\n"
~"Non-debugging symbols:\n"
~"0x0805368c  SYSTEM_FPC_CPUINIT\n"
^done
(gdb)

Try to find out what version of FPC this exe was build with (does it pass parameters by regs): OK

Quote

<-gdb-set language pascal>
^done
(gdb)

We're talking pascal: OK

Quote

<-break-insert -t main>
^done,bkpt={number="1",type="breakpoint",disp="del",enabled="y",addr="0x080535b0",func="main",file="project1.lpr",line="11",times="0"}
(gdb)
<-break-insert FPC_RAISEEXCEPTION>
^done,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x0805ce72",at="<fpc_raiseexception+6>",times="0"}
(gdb)
<-break-insert FPC_BREAK_ERROR>
^done,bkpt={number="3",type="breakpoint",disp="keep",enabled="y",addr="0x0805f4c2",at="<SYSTEM_HANDLEERRORADDRFRAME$LONGINT$POINTER$POINTER+6>",times="0"}
(gdb)
<-break-insert FPC_RUNERROR>
^done,bkpt={number="4",type="breakpoint",disp="keep",enabled="y",addr="0x0805f592",at="<SYSTEM_RUNERROR$WORD+6>",times="0"}
(gdb)

Set some internal breakpoints to catch exceptions, runtime errors etc. They are found, so we have some debug symbols: OK

Quote

<info file>
&"info file\n"
~"Symbols from \"/home/vitfer/test/project1\".\n"
~"Local exec file:\n"
~"\t`/home/vitfer/test/project1', file type elf32-i386.\n"
~"\tEntry point: 0x8053490\n"

I Only need these two lines: OK

Quote

<-exec-run>
^running
(gdb)
&"Cannot exec : No such file or directory.\n"
&"You can't do that without a process to debug.\n"
^error,msg="You can't do that without a process to debug."
(gdb)

Eeehhh !?!?!?!?
It successfully loads, but it cannot run.
Did you try to run the exe itself from a command shell?
And can you try to run the exe in gdb itself:
Code: [Select]
gdb /home/vitfer/test/project1
run


Quote

<info program>
&"info program\n"
~"The program being debugged is not being run.\n"
^done,reason="exited",exit-code="0177"
(gdb)

It somehow exited before it hit the main entry point.


Quote

What do you think about the message
"No symbol \"FPC_THREADVAR_RELOCATE_PROC\" in current context.\n" ?


It is a way to detect what version of FPC is used to build the exe, so it is possible that it can't be found (but afair fpc 2.0 should have it, I need to check my checks)
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

VitFer

  • New Member
  • *
  • Posts: 11
Cannot debug on Linux
« Reply #6 on: November 18, 2005, 11:58:06 am »
Hi Marc
yes I've tried the exe itself and it runs ok.
I'll try to run it using gdb from the shell asap.
Bye for now

VitFer

  • New Member
  • *
  • Posts: 11
Cannot debug on Linux
« Reply #7 on: November 18, 2005, 01:47:42 pm »
Tried to run the exe from gdb : it print on screen the same error message.
It seems gdb cannot run any exe build with Lazarus, neither 0.9.8 nor 0.9.10.
The stange thing is that 0.9.8 did work well with the debugger.
I want to reinstall 0.9.8 and check again.
Bye

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Cannot debug on Linux
« Reply #8 on: November 21, 2005, 11:25:40 am »
I don't think reinstalling fpc will help.

Does gdb give any error or warning ?

and does gdb work on another exe (like /bin/ls) ?
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

VitFer

  • New Member
  • *
  • Posts: 11
Cannot debug on Linux
« Reply #9 on: November 21, 2005, 02:07:00 pm »
Hi Marc
you're right : nothing is changed with a new installation of 0.9.8.
I tried to run the executable using gdb from the shell and it didn't work (it always returned the same error).
I'll try to run other executables asap.
Bye

SergKam

  • New Member
  • *
  • Posts: 29
Cannot debug on Linux
« Reply #10 on: November 21, 2005, 05:16:40 pm »
fpc 2.1.0 genereate erorr debug info for gdb. try FPC 2.0.
Excuse for my English

VitFer

  • New Member
  • *
  • Posts: 11
Cannot debug on Linux
« Reply #11 on: November 21, 2005, 06:47:27 pm »
I'm using fpc 2.0.0 .
I've never upgraded it.

VitFer

  • New Member
  • *
  • Posts: 11
Cannot debug on Linux
« Reply #12 on: November 22, 2005, 07:58:15 am »
What do you think about gdb 6.3 ?
I guess I used Lazarus 0.9.8 with Slackware 10.0 that installed gdb 6.1.1.
Now I'm not able to use gdb at all, with any kind of executable. The error is always the same :
No such file or directory and error code 0177.
Any idea ?

VitFer

  • New Member
  • *
  • Posts: 11
Cannot debug on Linux
« Reply #13 on: November 28, 2005, 09:24:17 pm »
OK guys, the problem is fixed now.
My environment variable $SHELL was empty  :roll:
I've modified my .profile adding the line
export SHELL=/bin/sh
That's all
Bye

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2584
Cannot debug on Linux
« Reply #14 on: November 29, 2005, 11:53:29 am »
Wierd  :?:

Anyhow, glad that it works
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

 

TinyPortal © 2005-2018