Project Home
Project Home
Trackers
Trackers
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Qnx IDE: Tip of the Day #10: Remote debugging with shared library: (2 Items)
   
Qnx IDE: Tip of the Day #10: Remote debugging with shared library  
Remote debugging is not an easy thing, and remove debugging with shared libraries is more complected.
To do successful debugging with shared library (i.e. to set breakpoints in libraries and view sources) you need the 
following things:
- create launch configuration for debugging
- have set of binary and all libraries available on target. Library name should be SONAME, i.e. name that binary 
required, not the name of the file. Usually they different by .so postfix. I.e. compiler would create libaaa.so and 
actual name is libaaa.so.1. Loader needs second name. Linker needs first. If you using IDE to upload (Upload tab of 
launch configuration) it will rename all libraries appropriately. If not - you have to take care of it yourself. Also 
you need to set LD_LIBRARY_PATH variable in Environment tab if libraries are not in standard path (path is on target).
- set of binary and libraries with debug info available on the host. Debugger has to know where they are.
Set binary in the Main tan and Library paths in the Debugger tab - Shared Libraries. Library name MUST be SOMENAME on 
the host, i.e. libaaa.so.1, otherwise debugger would not find it. If you using IDE upload it will also take care of 
renaming host libraries, if not you have to make sure they are renamed. The better approach for debugging would be 
actually not to use soname at all when you building the library for debugging (controlled by linker option).
- sources for binary and library available on host. If it was compiled on different host you also need to set Path 
mapping in the Source tab.

Happy debugging!
RE: Qnx IDE: Tip of the Day #10: Remote debugging with shared library  
Just to add my 'tip' to point#3:

On the host (Linux) we create a 'debug' directory and use a shell script
to create sym links to all our libraries and append the needed so.#
postfix. Then from within the Debug Tab in the IDE we just point to this
one directory as the repository for all our libraries. Typically we only
need to run the script once after the first build and only need to
re-run it if we add a new library. Here is the script. Note that the
version number for our libraries is always '1'.

#!/bin/sh

if [ ! "$1" ]; then
  echo "no directory supplied (expect module directory)"
  exit 1
fi
reldir=$1
trgdir=debug
echo "$1"

# 2. Find the SO lib and copy it to the current directory

for i in `find $reldir -name '*.so' -print`
do
#  (echo $i; cp $i $trgdir/`basename $i`.1; echo copying $i)
  (echo $i; ln -sf ../$i $trgdir/`basename $i`.1; echo copying $i)
done

Cheers
Robert

-----Original Message-----
From: Elena Laskavaia [mailto:community-noreply@qnx.com] 
Sent: Thursday, April 02, 2009 11:32 AM
To: tips-ide
Subject: Qnx IDE: Tip of the Day #10: Remote debugging with shared
library

Remote debugging is not an easy thing, and remove debugging with shared
libraries is more complected.
To do successful debugging with shared library (i.e. to set breakpoints
in libraries and view sources) you need the following things:
- create launch configuration for debugging
- have set of binary and all libraries available on target. Library name
should be SONAME, i.e. name that binary required, not the name of the
file. Usually they different by .so postfix. I.e. compiler would create
libaaa.so and actual name is libaaa.so.1. Loader needs second name.
Linker needs first. If you using IDE to upload (Upload tab of launch
configuration) it will rename all libraries appropriately. If not - you
have to take care of it yourself. Also you need to set LD_LIBRARY_PATH
variable in Environment tab if libraries are not in standard path (path
is on target).
- set of binary and libraries with debug info available on the host.
Debugger has to know where they are.
Set binary in the Main tan and Library paths in the Debugger tab -
Shared Libraries. Library name MUST be SOMENAME on the host, i.e.
libaaa.so.1, otherwise debugger would not find it. If you using IDE
upload it will also take care of renaming host libraries, if not you
have to make sure they are renamed. The better approach for debugging
would be actually not to use soname at all when you building the library
for debugging (controlled by linker option).
- sources for binary and library available on host. If it was compiled
on different host you also need to set Path mapping in the Source tab.

Happy debugging!

_______________________________________________
Tip of the Day
http://community.qnx.com/sf/go/post25863