Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - gdb on QNX 6.3.2: Page 1 of 2 (30 Items)
   
gdb on QNX 6.3.2  
Hello,

I have a problem running gdb on a QNX machine, even for the most simple C 
program (just a loop from 0 to 9, which prints the counter value)
The executable name is test, so in the terminal window i write:

$gdb test

I get the debugger prompt, and try to actually run, after setting a 
breakpoint on "main"

(gdb) b main
Breakpoint 1 at 0x8048452: file test.c, line 7.
(gdb)r
Starting program: /home/qa/Yael/profiles/test/test

The gdb prompt is displayed again, and i don't reach the breakpoint:

(gdb) where
#0 0xb0334792 in ?? ()

I try to continue:

(gdb) c
Continuing

And nothing happens. I can't stop the execution with ctrl+C, and the 
application doesn't print it's outputs. The only way out is to kill the 
process from another window.

What am i doing wrong?

Thanks,
Yael Frommer
Software Development
Modeling Solutions Product Division
Telelogic, An IBM Company
2 Pekeris St. Tamar Park
Rehovot 76100
Israel
Phone: 972-8-9484688
Fax: 972-8-9471313
Re: gdb on QNX 6.3.2  
Are you using gdb shipped with 6.3.2?

Could you post what is printed when you start gdb (it should 
print information about how it was configured, this is just 
for me to confirm which gdb it is)?

Is your 'test' application running correctly without the 
debugger?

Thanks,

Aleksandar
Re: gdb on QNX 6.3.2  
Yes, i'm using the gdb shipped with 6.3.2.
The test application runs correctly without the debugger.
The message printed when i start gdb is:

$ gdb ./test
GNU gdb 5.2.1qnx-nto
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "ntox86"...
Re: gdb on QNX 6.3.2  
It is supposed to work.

What gcc version are you using?

Could you try a "Hello World" application? Does it work?

If the sample code you mentioned is not something 
proprietary, could you attach the project? I would like to 
try to reproduce.

Thanks,

Aleksandar
Re: gdb on QNX 6.3.2  
The test application i'm running is basically a "Hello World" application.
The code is :

#include <stdio.h>

void main()
{
  int i;

  for (i=0; i<10; i++) 
    printf("Value of counter is %d\n", i);
}

About the gcc version - I'll answer you tomorrow, when i get to the 
office.
Does the gdb configuration look ok?

thanks for your help,
Yael



From:
Aleksandar Ristovski <community-noreply@qnx.com>
To:
general-toolchain <post16379@community.qnx.com>
Date:
11/11/2008 04:50 PM
Subject:
Re: gdb on QNX 6.3.2



It is supposed to work.

What gcc version are you using?

Could you try a "Hello World" application? Does it work?

If the sample code you mentioned is not something 
proprietary, could you attach the project? I would like to 
try to reproduce.

Thanks,

Aleksandar

_______________________________________________
General
http://community.qnx.com/sf/go/post16379



Re: gdb on QNX 6.3.2  


Yael Frommer wrote:
> Does the gdb configuration look ok?

Yes, I just wanted to make sure that is the gdb that comes 
with 6.3.2.
Re: gdb on QNX 6.3.2  
Yael Frommer wrote:
> The test application i'm running is basically a "Hello World" application.
> The code is :
> 
> #include <stdio.h>
> 
> void main()
> {
>   int i;
> 
>   for (i=0; i<10; i++) 
>     printf("Value of counter is %d\n", i);
> }
> 
> About the gcc version - I'll answer you tomorrow, when i get to the 
> office.

If you are using just 6.3.2 target, gcc is probably 2.93.3.

I just tried and it worked for me.

Below is my debugging session using the code above. Note 
that after starting the program, gdb will stop on a shared 
library event. It is not supposed to stop here, but it 
stops. In any case, if you just continue at that point that 
will take you to the breakpoint set in main.

I think what was happening in your case is that you were 
trying to use gdb when it is stopped due to shared library 
event; gdb 5.2.1 does not behave well at that early stage of 
program loading, but continuing on that breakpoint should 
take you to more friendly debugging session.

Note also that I compiled the program using -g compiler 
option and turning off all optimizations (-O0). It is very 
difficult to debug program without debug information; 
therefore, use -g whenever you need to debug your 
application. Optimizations do not have to be turned off, but 
expect odd behaviour: you may be stepping line by line and 
see that gdb is "jumping" all over the place. Optimizations 
will do that. Use the lowest optimization level you can 
under given circumstances.

Finally, I would encourage you to use the newer gdb-6.7 
which you can download from here:
http://community.qnx.com/sf/frs/do/listReleases/projects.toolchain/frs.gdb

Try the latest update, it should work just fine on 6.3.2.


----------------------- session -------------------------
# gcc -v
Reading specs from 
/usr/qnx632/host/qnx6/x86/usr/lib/gcc-lib/ntox86/2.95.3/specs
gcc version 2.95.3
# gcc -o test -O0 -g test.c
test.c: In function `main':
test.c:4: warning: return type of `main' is not `int'
# gdb ./test
GNU gdb 5.2.1qnx-nto
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public 
License, and you are
welcome to change it and/or distribute copies of it under 
certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show 
warranty" for details.
This GDB was configured as "ntox86"...
(gdb) b main
Breakpoint 1 at 0x8048452: file test.c, line 6.
(gdb) r
Starting program: /tmp/test
(gdb) c
Continuing.
[Switching to process 1212460]

Breakpoint 1, main () at test.c:6
6         for (i=0; i<10; i++)
(gdb) step
7           printf("Value of counter is %d\n", i);
(gdb) step
Value of counter is 0
6         for (i=0; i<10; i++)
(gdb)
7           printf("Value of counter is %d\n", i);
(gdb)
Value of counter is 1
6         for (i=0; i<10; i++)
(gdb)
7           printf("Value of counter is %d\n", i);
(gdb)
Value of counter is 2
6         for (i=0; i<10; i++)
(gdb)
7           printf("Value of counter is %d\n", i);
(gdb)
Value of counter is 3
6         for (i=0; i<10; i++)
(gdb) c
Continuing.
Value of counter is 4
Value of counter is 5
Value of counter is 6
Value of counter is 7
Value of counter is 8
Value of counter is 9

Program exited normally.
(gdb) q
--------------------- session end ------------------
Re: gdb on QNX 6.3.2  
The gcc version i have is 2.95.3.
I recompiled my code as you suggested, with -g and -O0, but the results 
were the same:
My debugging session behaves just like yours up to the point where you 
press 'c' (continue). When i press 'c' i wait and wait and wait and 
nothing happens... Only if i kill the gdb process (from another terminal) 
the "block" is released and the application runs to completion:

(gdb) c
Continuing.
                       <---- here i wait and wait and nothing..
Value of counter is 0  <----- These are printed after i kill the gdb
Value of counter is 1
Value of counter is 2
Value of counter is 3
Value of counter is 4
Value of counter is 5
Value of counter is 6
Value of counter is 7
Value of counter is 8
Value of counter is 9
Terminated
$

I will check the possibilty to download a newer gdb version, but other 
than that - any ideas what could be the problem? or what more i can do to 
help identify the problem? could it be a problem with a shared library 
used by gdb?

thanks,
Yael



From:
Aleksandar Ristovski <community-noreply@qnx.com>
To:
general-toolchain <post16394@community.qnx.com>
Date:
11/11/2008 05:51 PM
Subject:
Re: gdb on QNX 6.3.2



Yael Frommer wrote:
> The test application i'm running is basically a "Hello World" 
application.
> The code is :
> 
> #include <stdio.h>
> 
> void main()
> {
>   int i;
> 
>   for (i=0; i<10; i++) 
>     printf("Value of counter is %d\n", i);
> }
> 
> About the gcc version - I'll answer you tomorrow, when i get to the 
> office.

If you are using just 6.3.2 target, gcc is probably 2.93.3.

I just tried and it worked for me.

Below is my debugging session using the code above. Note 
that after starting the program, gdb will stop on a shared 
library event. It is not supposed to stop here, but it 
stops. In any case, if you just continue at that point that 
will take you to the breakpoint set in main.

I think what was happening in your case is that you were 
trying to use gdb when it is stopped due to shared library 
event; gdb 5.2.1 does not behave well at that early stage of 
program loading, but continuing on that breakpoint should 
take you to more friendly debugging session.

Note also that I compiled the program using -g compiler 
option and turning off all optimizations (-O0). It is very 
difficult to debug program without debug information; 
therefore, use -g whenever you need to debug your 
application. Optimizations do not have to be turned off, but 
expect odd behaviour: you may be stepping line by line and 
see that gdb is "jumping" all over the place. Optimizations 
will do that. Use the lowest optimization level you can 
under given circumstances.

Finally, I would encourage you to use the newer gdb-6.7 
which you can download from here:
http://community.qnx.com/sf/frs/do/listReleases/projects.toolchain/frs.gdb

Try the latest update, it should work just fine on 6.3.2.


----------------------- session -------------------------
# gcc -v
Reading specs from 
/usr/qnx632/host/qnx6/x86/usr/lib/gcc-lib/ntox86/2.95.3/specs
gcc version 2.95.3
# gcc -o test -O0 -g test.c
test.c: In function `main':
test.c:4: warning: return type of `main' is not `int'
# gdb ./test
GNU gdb 5.2.1qnx-nto
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public 
License, and you are
welcome to change it and/or distribute copies of it under 
certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show 
warranty" for details.
This GDB was configured as "ntox86"...
(gdb) b main
Breakpoint 1 at 0x8048452: file test.c, line 6.
(gdb) r
Starting program: /tmp/test
(gdb) c
Continuing.
[Switching to process 1212460]

Breakpoint 1, main () at test.c:6
6         for (i=0; i<10; i++)
(gdb) step
7  ...
View Full Message
Re: gdb on QNX 6.3.2  
Yael Frommer wrote:
> The gcc version i have is 2.95.3.
> I recompiled my code as you suggested, with -g and -O0, but the results 
> were the same:
> My debugging session behaves just like yours up to the point where you 
> press 'c' (continue). When i press 'c' i wait and wait and wait and 
> nothing happens... Only if i kill the gdb process (from another terminal) 
> the "block" is released and the application runs to completion:
> 
> (gdb) c
> Continuing.
>                        <---- here i wait and wait and nothing..

Could you at this point (where you wait) use pidin in 
another terminal and post the output here?

Re: gdb on QNX 6.3.2  
BTW can you try to debug using IDE? It is straightforward to create a simple program in IDE and run remote debugging.

Aleksandar Ristovski wrote:
> Yael Frommer wrote:
>> The gcc version i have is 2.95.3.
>> I recompiled my code as you suggested, with -g and -O0, but the results 
>> were the same:
>> My debugging session behaves just like yours up to the point where you 
>> press 'c' (continue). When i press 'c' i wait and wait and wait and 
>> nothing happens... Only if i kill the gdb process (from another terminal) 
>> the "block" is released and the application runs to completion:
>>
>> (gdb) c
>> Continuing.
>>                        <---- here i wait and wait and nothing..
> 
> Could you at this point (where you wait) use pidin in 
> another terminal and post the output here?
> 
> 
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post16462
> 
Re: gdb on QNX 6.3.2  
This is the output of pidin :

$ pidin
     pid tid name               prio STATE       Blocked
       1   1 procnto              0f READY
       1   2 procnto             10r RECEIVE     1
       1   3 procnto             10r RECEIVE     1
       1   4 procnto             10r RECEIVE     1
       1   5 procnto             10r RECEIVE     1
       1   6 procnto             10r RECEIVE     1
       1   7 procnto             10r RUNNING
       1   8 procnto             10r RECEIVE     1
       1   9 procnto             10r RECEIVE     1
       1  10 procnto             10r RECEIVE     1
       1  11 procnto             10r RECEIVE     1
       2   1 sbin/tinit          10o REPLY       1
    4099   1 proc/boot/pci-bios  12o RECEIVE     1
    4100   1 proc/boot/slogger   10o RECEIVE     1
    4101   1 proc/boot/io-usb    10o SIGWAITINFO
    4101   2 proc/boot/io-usb    21r RECEIVE     4
    4101   3 proc/boot/io-usb    21r RECEIVE     1
    4101   4 proc/boot/io-usb    10o RECEIVE     7
    4101   5 proc/boot/io-usb    10r NANOSLEEP
    4101   6 proc/boot/io-usb    10o RECEIVE     7
    4102   1 proc/boot/io-hid    10o SIGWAITINFO
    4102   2 proc/boot/io-hid    10o RECEIVE     4
    4102   3 proc/boot/io-hid    10o RECEIVE     4
    4102   4 proc/boot/io-hid    10r REPLY       4101
    4102   5 proc/boot/io-hid    15r RECEIVE     12
    4102   6 proc/boot/io-hid     9r RECEIVE     16
    4103   1 /boot/devc-con-hid  20o RECEIVE     1
    4103   2 /boot/devc-con-hid  10o REPLY       4102
    8200   1 roc/boot/devb-eide  10o SIGWAITINFO
    8200   2 roc/boot/devb-eide  21r RECEIVE     1
    8200   3 roc/boot/devb-eide  21r RECEIVE     4
    8200   4 roc/boot/devb-eide  10o RECEIVE     10
    8200   5 roc/boot/devb-eide  10o RECEIVE     7
    8200   6 roc/boot/devb-eide  10o RECEIVE     7
    8200   7 roc/boot/devb-eide  10o RECEIVE     7
    8200  11 roc/boot/devb-eide  10o RECEIVE     7
    8201   1 oc/boot/umass-enum  10o SIGWAITINFO
    8201   2 oc/boot/umass-enum  10r REPLY       4101
   16394   1 sbin/pipe           10o SIGWAITINFO
   16394   2 sbin/pipe           10o RECEIVE     1
   16394   3 sbin/pipe           10o RECEIVE     1
   16394   4 sbin/pipe            9o RECEIVE     1
   16394   6 sbin/pipe           10o RECEIVE     1
   20491   1 sbin/mqueue         10o RECEIVE     1
   77837   1 sbin/io-audio       10o SIGWAITINFO
   77837   2 sbin/io-audio       10o RECEIVE     1
   77837   3 sbin/io-audio       10o RECEIVE     1
   77837   4 sbin/io-audio       10o RECEIVE     1
   77837   5 sbin/io-audio       50r INTR
   94223   1 sbin/devc-ser8250   24o RECEIVE     1
   94226   1 sbin/devc-par       10o RECEIVE     1
   94226   2 sbin/devc-par        9r CONDVAR     8053e00
   94228   1 sbin/io-net         10o SIGWAITINFO
   94228   2 sbin/io-net         10o RECEIVE     5
   94228   3 sbin/io-net         10o RECEIVE     1
   94228   4 sbin/io-net         10o RECEIVE     1
   94228   5 sbin/io-net         10o RECEIVE     1
   94228   6 sbin/io-net         21r RECEIVE     19
  110614   1 usr/sbin/spooler    10o NANOSLEEP
  131086   1 sbin/devb-fdc       10o SIGWAITINFO
  131086   2 sbin/devb-fdc       21r RECEIVE     1
  131086   3 sbin/devb-fdc       10o RECEIVE     7
  131086   4 sbin/devb-fdc       10o RECEIVE     4
  131086   5 sbin/devb-fdc       10o RECEIVE     4
    131086   6 sbin/devb-fdc       10o RECEIVE     4
  139276   1 sbin/devc-pty       10o RECEIVE     1
  143376   1 usr/sbin/random     10o SIGWAITINFO
  143376   2 usr/sbin/random     10o RECEIVE     1
  143376   3 usr/sbin/random     10o NANOSLEEP
  155665   1 usr/sbin/dumper     10o RECEIVE     1
  163861   1 usr/sbin/inetd      10o SIGWAITINFO
  167955   1 usr/sbin/qconn      10o SIGWAITINFO
  167955   2 usr/sbin/qconn      15o RECEIVE     1
  167955   3 usr/sbin/qconn      10o CONDVAR     805dfc8
  167955   4 usr/sbin/qconn      10o RECEIVE     4
  184343   1 bin/login        ...
View Full Message
Re: gdb on QNX 6.3.2  
Apparently the problem i have with gdb has something to do specifically 
with the host from which i connect (through phindows) to the target qnx 
machine.
I found that if i work directly on the target (not through phindows), gdb 
runs ok.
I also found that when connecting through phindows to the target from 
another host (not my PC), gdb also runs Ok.
So what can be the problem with my host (maybe keyboard or mouse 
settings?) that causes this?
Re: gdb on QNX 6.3.2  

Yael Frommer wrote:
> Apparently the problem i have with gdb has something to do specifically 
> with the host from which i connect (through phindows) to the target qnx 
> machine.
> I found that if i work directly on the target (not through phindows), gdb 
> runs ok.
> I also found that when connecting through phindows to the target from 
> another host (not my PC), gdb also runs Ok.
> So what can be the problem with my host (maybe keyboard or mouse 
> settings?) that causes this?
> 

Ok, now I think I know what the problem is; there is a PR on 
this (PR24823). Gdb inherits sigmask from the phindows and 
it shouldn't.

You do, however, have alternatives:

1) use telnet to connect to your target.
2) use host-side momentics and debug your program remotely 
from command line or using IDE

Re: gdb on QNX 6.3.2  
The telnet option works, but not the host-side momentics.
Trying to debug the application through momentics crashes immediately, 
before i even reach main, and this is what i see in the IDE debug window:



I'm not sure this is the same sigmask problem, but other host machines 
don't have this problem.
Is there a way to control the sigmask setting in momentics or phindows ?
Re: gdb on QNX 6.3.2  
Yael Frommer wrote:
> The telnet option works, but not the host-side momentics.
> Trying to debug the application through momentics crashes immediately, 
> before i even reach main, and this is what i see in the IDE debug window:
> 

Could you repeat what do you see in the IDE debug window? It 
shouldn't be related to the phindows issue. Maybe it's 
something else.
Re: gdb on QNX 6.3.2  
I hope you can see the attached bitmap - a snapshot of the momentics IDE 
debug window.
If i connect through telenet to the qnx target machine, i can debug this 
exe with no problem, but through momentics it crashes even before it 
starts.



Attachment: Text momentics_dbg.bmp 1.04 MB
Re: gdb on QNX 6.3.2  
Yael Frommer wrote:
> I hope you can see the attached bitmap - a snapshot of the momentics IDE 
> debug window.
> If i connect through telenet to the qnx target machine, i can debug this 
> exe with no problem, but through momentics it crashes even before it 
> starts.
> 
> 

Yes, I can see the bitmap. It is very strange there are no 
symbols.


I have to ask more questions:

1) what version of momentics did you install on your host side?

2) Please attach complete build-log after rebuilding your 
project.

3) Please attach complete debugger log for the failing session.
Re: gdb on QNX 6.3.2  
Momentics version on the host: 6.3.0 Service Pack 3.
Complete build-log and debug-log are attached, as well as the host's "
Help->About QNX Momentics IDE" window



Attachment: Text host_momentics_ver.bmp 580.18 KB Text build_log.bmp 3.14 MB Text debug_log.bmp 3.27 MB
Re: gdb on QNX 6.3.2  
So you host is 6.3.0 SP3 and your target is 6.3.2? That is where library mismatch is coming from.

Yael Frommer wrote:
> Momentics version on the host: 6.3.0 Service Pack 3.
> Complete build-log and debug-log are attached, as well as the host's "
> Help->About QNX Momentics IDE" window
> 
> 
> 
> 
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post16759
Re: gdb on QNX 6.3.2  
Elena Laskavaia wrote:
 > So you host is 6.3.0 SP3 and your target is 6.3.2? That 
is where library mismatch is coming from.


Yes, if they do not match you will definitely have problems 
debugging your applications. Gdb on your host side uses 
libraries on the host which are different than the ones on 
the target (this, in general case, makes debugging session 
unusable even if it doesn't fail like yours does).

You may still be able to run the application built with 
6.3.0 momentics - try running instead of debugging the 
application, or copy your binary to the target and run it 
usinig telnet; but that wouldn't make any difference with 
regards to debugging it from your host.


In any case, you will want matching momentics for your 
development. Note that after you get the matching momentics, 
you can upgrade GDB with the updates posted on the foundry.

Re: gdb on QNX 6.3.2  
Indeed this was a host/target compatibility issue, problem solved now.
Thanks you very much!
Re: gdb on QNX 6.3.2  
This is not IDE from 6.3.2 btw.


from FAQ:

  Q: I am trying to debug simple program and it SIGSEGV before entering main. It runs fine without debugger. What can I 
do?

This is usually a symptom of a library host/target mismatch.
For example when you run Momentics 6.3.2 on the target and Momentics 6.4.0 on the host.
When using gdb version 6.7 or greater (available from Foundry 27, independent of Momentics)
it will print a warning about a library mismatch to the console.
This can also happen if you applied libc patch on the host and not on the target (and vice versa).
Re: gdb on QNX 6.3.2  
Is there an editor (like emacs on Unix) for qnx, where i can run gdb in?
Re: gdb on QNX 6.3.2  
I think someone got emacs going, but also checkout cgdb - it's an easy port

Yael Frommer wrote:
> Is there an editor (like emacs on Unix) for qnx, where i can run gdb in?
> 
> 
> _______________________________________________
> General
> http://community.qnx.com/sf/go/post16511
> 

-- 
cburgess@qnx.com
Re: gdb on QNX 6.3.2  
You can also use your linux host and use gdb in a remote 
session. You would need momentics installed on the host and 
qconn running on the target.


Colin Burgess wrote:
> I think someone got emacs going, but also checkout cgdb - it's an easy port
> 
> Yael Frommer wrote:
>> Is there an editor (like emacs on Unix) for qnx, where i can run gdb in?
>>
>>
>> _______________________________________________
>> General
>> http://community.qnx.com/sf/go/post16511
>>
>