Devel tools for PPC?

bridged with qdn.public.qnxrtp.powerpc
Paul D. Smith

Re: Devel tools for PPC?

Post by Paul D. Smith » Mon Apr 08, 2002 4:19 am

%% Colin Burgess <cburgess@qnx.com> writes:

cb> WRT auto loading of shared libs, you can set the gdb
cb> auto-solib-add variable which will load the symbols of shared libs
cb> when they are mapped in.

Hmm. I'll try this. Thanks for the note.

Why is this all necessary here, when it's not necessary anywhere else
(I've been using GDB for over 10 years on _many_ different types of
systems--maybe that's part of my problem; I _know_ how it's supposed to
work after all that time using it :)). I don't understand why the
default behavior of ntoppc-gdb is so different...?

cb> These commands are documented, although in a somewhat peculiar place

cb> set auto-solib-add value

cb> Make the loading of shared library symbols automatic or
cb> manual:
cb> o If value is nonzero, symbols from all shared
cb> object libraries are loaded automatically when
cb> the inferior process (i.e. the one being
cb> debugged) begins execution, or when the dynamic
cb> linker informs GDB that a new library has been
cb> loaded.
cb> o If value is zero, symbols must be loaded
cb> manually with the sharedlibrary command.

Hmm. I saw this variable, but your documentation is not the same as
mine. Mine is for GDB 5.1.1; has this changed since 5.0? Here is what
mine says:

On HP-UX systems, GDB detects the loading of a shared library and
automatically reads in symbols from the newly loaded library, up to a
threshold that is initially set but that you can modify if you wish.

Beyond that threshold, symbols from shared libraries must be
explicitly loaded. To load these symbols, use the command
`sharedlibrary FILENAME'. The base address of the shared library is
determined automatically by GDB and need not be specified.

To display or set the threshold, use the commands:

`set auto-solib-add THRESHOLD'
Set the autoloading size threshold, in megabytes. If THRESHOLD is
nonzero, symbols from all shared object libraries will be loaded
automatically when the inferior begins execution or when the
dynamic linker informs GDB that a new library has been loaded,
until the symbol table of the program and libraries exceeds this
threshold. Otherwise, symbols must be loaded manually, using the
`sharedlibrary' command. The default threshold is 100 megabytes.

First note it sounds like this is only relevant on HP-UX (although maybe
it's just not written clearly), and second note that it says the
_default_ threshold is 100 M... which is more than enough. So I didn't
go much further with this. But, now that I run "show auto-solib-add" in
ntoppc-gdb I can see that the value is 0. Was the default value was
modified between 5.0 and 5.1.1?

Hm. I just invoked my copy of GDB 5.0 I built for native Solaris and I
see this:

(gdb) show auto-solib-add
Autoloading of shared library symbols is 1.

Obviously the exact meaning of this variable has been changed between
5.0 and 5.1.1, from a true/false to a size value. _But_, it seems like
the GDB 5.0 that you provide is using different default values for these
settings than the ones that other targets use? Or does it always build
that way for cross compilers, or for PPC, or something?

--
-------------------------------------------------------------------------------
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.

Paul D. Smith

Re: Devel tools for PPC?

Post by Paul D. Smith » Mon Apr 08, 2002 4:23 am

%% Chris McKillop <cdm@qnx.com> writes:

cm> Can you disclose (even by email) what that milestone date is?

Not exactly (don't know myself, because until it's official we can have
individuals pulled off for "priority interrupts", which pushes out the
schedule--everyone understands that), but it's very soon (like weeks).

cm> Why not just set LD_LIBRARY_PATH in the boot image so it is
cm> global? ie:

Maybe we'll do this for the final system, but (a) we don't have a
special boot image, and (b) we're using many different paths; the shared
libraries are left in workspaces which are NFS-mounted to the target.
So, every workspace has a different path. Setting this in a boot image
is not feasible for our development environment.

--
-------------------------------------------------------------------------------
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.

Colin Burgess

Re: Devel tools for PPC?

Post by Colin Burgess » Mon Apr 08, 2002 11:14 am

Why is this all necessary here, when it's not necessary anywhere else
(I've been using GDB for over 10 years on _many_ different types of
systems--maybe that's part of my problem; I _know_ how it's supposed to
work after all that time using it :)). I don't understand why the
default behavior of ntoppc-gdb is so different...?
What platforms were you using?

The handling of shared libs was ported directly from the svr4 shared lib
code. As such the behaviour is the same, although some of the defaults
are different (for example, automatic loading of shared library symbols).

Hmm. I saw this variable, but your documentation is not the same as
mine. Mine is for GDB 5.1.1; has this changed since 5.0? Here is what
mine says:
Yes, the limit was added after 5.0. In fact, this was the reason for
setting the default to non-automatic - it was exhausting the memory of
our RTP dev systems.

--
cburgess@qnx.com

Paul D. Smith

Re: Devel tools for PPC?

Post by Paul D. Smith » Mon Apr 08, 2002 1:26 pm

%% Colin Burgess <cburgess@qnx.com> writes:

cb> What platforms were you using?

I've used gdb on DG/UX, SunOS, Solaris, HP-UX, AIX, Ultrix, UnixWare,
FreeBSD, NetBSD, Linux, Irix, OSF/1, and maybe a few other oddball
systems I can't recall right now :).

cb> Yes, the limit was added after 5.0. In fact, this was the reason
cb> for setting the default to non-automatic - it was exhausting the
cb> memory of our RTP dev systems.

Ah. OK. I think these kinds of things deserve some special mention in
the QNX docs, though, especially where you've changed the default
behavior of GDB.

Thanks for all your help... I'll be sure to let you know if we run
into more problems ;).

--
-------------------------------------------------------------------------------
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.

Paul D. Smith

Re: Devel tools for PPC?

Post by Paul D. Smith » Thu Apr 11, 2002 4:05 am

As a "thanks" for all the help, here is a little shell script which you
can use to invoke GDB for a remote target, that will set up properly for
shared library support. I've excised our code for determining what the
valid path for the shared libs is, since it's obviously very specific to
your environment.

This is still problematic because there's no way to script the
invocation of the pdebug properly on the target side, and I'd still
really like a native debugger. But, it's better than typing all this by
hand...

-----------------------------------
#!/bin/sh
#
# Invoke GDB to target QNX on the PPC, with setup.
#
# Author:
# Paul D. Smith <pausmith@nortelnetworks.com>
#
# This file is in the public domain.

usage () {
cat <<EOF

usage: $0 <host>:<port> <exe> [...args...]

Where:
<host> is the hostname of the target system
<port> is the port number where the pdebug server is listening
<exe> is the executable to debug (if it's not in the current directory,
the script will try to find it in common locations).

Any remaining arguments are given to the executable when it's invoked.

EOF
exit 1
}

# Grab any GDB options. If you want to be very accurate about this you
# need to do better (especially with option arguments).

opts=
while true; do
case "$1" in
--) shift; break ;;

-*) opts="$opts $1"; shift ;;

*) break ;;
esac
done

# Do we have anything left? We need at least two arguments
case "$2" in
'') usage ;;
esac

target="$1"
program="$2"
shift 2

# Compute SOLIBDIR ... I just left it hardcoded for this example

SOLIBDIR=/usr/local/lib

# If we don't have $QNX_HOST, assume the default
# The user can set PPCGDB to choose a different debugger.

PPCGDB=${PPCGDB:-${QNX_HOST:-/opt/QNXsdk/solaris/sparc}/usr/bin/ntoppc-gdb}


# We will create a temporary script to be given to GDB as an initializer
script=${TMPDIR:-/tmp}/gdb$$

trap "rm $script" 0
trap "exit 1" 1 2 15

# Create the initial setup script
#
# In order to make things work correctly on the remote host with shared
# libraries we have to set solib-search-path properly. Then before we
# can set breakpoints, etc. in shared libraries we have to load their
# symbols; mark that to happen automatically
# Note that using quoted arguments is somewhat problematic here.

cat > $script <<EOF
shell rm $script
target qnx $target
set solib-search-path $SOLIBDIR:/lib:/usr/lib
set auto-solib-add 100
set args $@
EOF

# Run it!!

exec $PPCGDB $opts -r -x $script -- "$program"


--
-------------------------------------------------------------------------------
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.

Post Reply

Return to “qdn.public.qnxrtp.powerpc”