%% Colin Burgess <cburgess@qnx.com> writes:
cb> Paul D. Smith <pausmith@nortelnetworks.com> wrote:
I have to say I’m pretty bummed with QSSI’s support of PPC so far. I
can’t believe they don’t even have a native debugger.
cb> Right now we only support a native development environment on our
cb> x86 platform. However, we do make the source code to our GNU
cb> tools available for download if you wish to do your own thing with
cb> it (see developers.qnx.com)
I don’t really care about a complete development environment; I probably
wouldn’t want to build code on my embedded system anyway. But to me, a
native GDB is really critical! I can’t run my code on an x86 to debug
it; my hardware is a custom embedded system.
Remote GDB is only a marginal substitute, especially when getting it
going and using it is as labor-intensive as this is!
Personally I think it’s really not too much to ask that there be a
native debugger for a supposedly supported platform. And, it’s not like
you need to write it from scratch: you are using GDB, which you’ve
already ported to QNX (on Intel), and which already runs on many other
OSs on PowerPC… how hard could it be for an engineer at QSSI who knows
this stuff to get a port to QNX on PowerPC?
I also need a make (because our unit test suite, which must run natively
of course) is driven with make. But, I already ported GNU make to QNX
PPC using the Solaris cross-compiler so that’s OK.
And I’d really like a bash–the shell on the PPC is just different
enough to make me nuts.
There’s a bug in the gawk that they ship: it will not run unless you set
LD_LIBRARY_PATH to /lib. If you don’t it fails with an error about
/lib/libm.so.2 not found (but it’s right there!) I even tried using the
cross-compiler to build my own gawk and it has the identical problem.
cb> What do you have LD_LIBRARY_PATH set to when it fails?
Nothing, it’s not set at all:
No home directory.
Logging in with home = “/”.
sh: /etc/profile[23]: tty: not found
Sun Jan 25 04:20:34 1970 on
Welcome to the QNX Realtime Platform!!
Last login: Sat Jan 24 23:12:07 1970 on
$ echo $LD_LIBRARY_PATH
$ /usr/bin/gawk
Could not find library libm.so.2
$ printf “%2.5f\n” 0.034
0.03400
$ export LD_LIBRARY_PATH=/lib
$ /usr/bin/gawk --version
GNU Awk 3.0.6
Copyright (C) 1989, 1991-2000 Free Software Foundation.
…
I can’t use -rpath to set an automatic place to look for shared libs;
this works on every other platform I build on except for QNX (both intel
and PPC). It’s documented to work but it doesn’t (QNX 6.1.0A).
cb> This was broken in 6.1 - it has been fixed in 6.2
This is a pretty serious problem: any chance we can get a patch or some
kind of fix for this in 6.1?
I still can’t get the remote debugger to work with my shared libraries
on PPC; I’ve had to switch back to static libraries.
cb> Here’s some tips
cb> Set the LD_LIBRARY_PATH required for your app before starting pdebug.
I do this. I tried using the documented “set qnx…” in GDB methods for
handling environment variables, but all combinations of this failed as
well.
cb> Note that gdb cannot load them symbol information about shared libraries
cb> before they are loaded into memory by the application,
I’m setting a breakpoint at a symbol in the shared lib, then when the
breakpoint is hit I get an error from gdb saying it can’t find my shared
library. If I try to step or continue I get a SIGILL.
Once I hit a breakpoint, the shared lib should be loaded…?
Also, if I’m in main() and I come to a function call that’s in a shared
lib, even if I "s"tep it runs the entire function call as if I’d hit
"n"ext rather than stepping into the function.
cb> and that the shared libraries should have a SONAME set (with the
cb> -Wl,–soname=name option)
I definitely do this, on all my platforms:
[…]
qcc -V gcc_ntoppcbe -g -O2 -Wall -Werror -fPIC […] -o …/…/_rmc_QNX_6.1.0_ppcbe/src/cunit/example_test.o -c example_test.c
qcc -V gcc_ntoppcbe -shared -Wl,-soname,libcunit.so.1 -o …/…/_rmc_QNX_6.1.0_ppcbe/lib/libcunit.so.1.0.0 [… .o’s …]
ln -s libcunit.so.1.0.0 …/…/_rmc_QNX_6.1.0_ppcbe/lib/libcunit.so.1
ln -s libcunit.so.1.0.0 …/…/_rmc_QNX_6.1.0_ppcbe/lib/libcunit.so
qcc -V gcc_ntoppcbe -Wl,-rpath,/…/_rmc_QNX_6.1.0_ppcbe/lib -o …/…/_rmc_QNX_6.1.0_ppcbe/bin/example … -L/…/_rmc_QNX_6.1.0_ppcbe/lib -lcunit -lsocket
cb> In gdb, set the solib-search-path variable to be a colon separated
cb> list of paths pointing to the host side location of your shared
cb> libraries.
Hm. This isn’t in the docs. I’ll try it…
OK, setting this variable works a lot better. I don’t get the “can’t
find libfoo.so” error any more. Shared library symbols are still not
loaded for me when the shared library is loaded, as they are on the
other platforms on which I use GDB.
cb> Once your shared libraries are in memory, you can view them with
cb> ‘info sharedlibrary’, and load the symbols with ‘sharedlibrary’
Ouch. It’s a pain that you have to do this by hand. But doing it this
way does work… somewhat.
Also, whenever I re-run the program it disables all my breakpoints and I
have to use “enable” to re-enable them. Again, this is very different
than the other platforms GDB runs on.
Also, the process is kind of dodgy still. Watch:
(gdb) target qnx pair4:8000
Remote debugging using pair4:8000
(gdb) set solib-search-path /…/_rmc_QNX_6.1.0_ppcbe/lib:/lib:/usr/lib
(gdb) run
Starting program: /…/_rmc_QNX_6.1.0_ppcbe/bin/example
Set a breakpoint in a shared library:
(gdb) br cUnit_register_test
Breakpoint 1 at 0x48041c5c
(gdb) c
Continuing.
Breakpoint 1, 0x48041c5c in cUnit_register_test ()
Good, we stopped. Now we look around, and realize no symbols are lodaded:
(gdb) bt
#0 0x48041c5c in cUnit_register_test ()
#1 0x48040898 in register_tests () at example_test.c:132
#2 0xfe365130 in ?? ()
from /…/_rmc_QNX_6.1.0_ppcbe/lib/libcunit.so.1
OK, let’s load the symbols:
(gdb) info share
From To Syms Read Shared Object Library
0xfe363000 0xfe3679d0 No /…/_rmc_QNX_6.1.0_ppcbe/lib/libcunit.so.1
0xfe368000 0xfe380ccc No /lib/libsocket.so
0xfe300000 0xfe3bd848 No /lib/libc.so
(gdb) share /…/_rmc_QNX_6.1.0_ppcbe/lib/libcunit.so.1
Reading symbols from /…/_rmc_QNX_6.1.0_ppcbe/lib/libcunit.so.1…done.
Breakpoint 1 at 0xfe364684: file cUnit.c, line 155.
Fine. Let’s go on…
(gdb) s
Program received signal SIGILL, Illegal instruction.
0x48041c5c in cUnit_register_test () at cUnit.c:151
151 {
Gack! I’ve tried loading the shared library symbols in other orders as
well, but so far the only thing that seems to work is to set a
breakpoint on main() and after it stops there I can load the symbol
table stuff.
(gdb) n
Program exited normally.
Ugh. And it didn’t really exit normally, it stopped at the SIGILL. OK,
well, let’s try running it again:
(gdb) run
Starting program:
/…/_rmc_QNX_6.1.0_ppcbe/bin/example
(gdb) c
Continuing.
warning: Cannot insert breakpoint 1:
warning: Temporarily disabling shared library breakpoints:
warning: breakpoint #1
cUnit: 2 tests of 2 passed.
Program exited normally.
Well, no SIGILL but it disabled my breakpoints!! I have to set a
breakpoint on main() so it stops at the beginning and I can re-enable my
shared library breakpoints. Phooey.
–
Paul D. Smith <pausmith@nortelnetworks.com> HASMAT–HA Software Mthds & Tools
“Please remain calm…I may be mad, but I am a professional.” --Mad Scientist
These are my opinions—Nortel Networks takes no responsibility for them.