Remote debugging on Blackberry devices: Difference between revisions
No edit summary |
Henri Vikki (talk | contribs) No edit summary |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
[[Category:BlackBerry]] | [[Category:BlackBerry]] | ||
This page is a how-to on how to setup remote debugging for BlackBerry devices with the command-line tools. Currently the instructions are for Linux and Mac, but should be similar on Windows. | This page is a how-to on how to setup remote debugging for BlackBerry devices with the command-line tools. Currently the instructions are for Linux and Mac, but should be similar on Windows. | ||
Please do not miss the | Please do not miss the [http://www.gnu.org/software/gdb/documentation/ the GDB manual] to learn how to use GDB, the command-line debugger. | ||
Note that Qt Creator supports remote debugging for BlackBerry devices as well, see this [[Qt-Creator-with-BlackBerry-10 | article]] for details. Qt Creator uses the same steps as outlined below, just wraps it into its IDE. | Note that Qt Creator supports remote debugging for BlackBerry devices as well, see this [[Qt-Creator-with-BlackBerry-10 | article]] for details. Qt Creator uses the same steps as outlined below, just wraps it into its IDE. | ||
Line 18: | Line 20: | ||
The deployment process is the same as for just testing the application the device: | The deployment process is the same as for just testing the application the device: | ||
<code> | <code> | ||
> blackberry-nativepackager -devMode -package myapp.bar bar-descriptor.xml | |||
</code> | |||
For PlayBook, see the steps described | For PlayBook, see the steps described [http://wiki.qt.io/Building_and_Deploying_Qt_Applications_to_the_Playbook here] | ||
== Launching the application == | == Launching the application == | ||
As next, you should launch the app on the device and stop it for debugging. | As next, you should launch the app on the device and stop it for debugging. '''blackberry-deploy''' will do this for you: | ||
<code> | <code> | ||
> blackberry-deploy -debugNative -device <device_ip> -password <device_password> -launchApp myapp.bar | |||
</code> | |||
This will stop the execution early on (immediately after the process has been spawned) and wait for the debugger to attach and tell it to continue. | This will stop the execution early on (immediately after the process has been spawned) and wait for the debugger to attach and tell it to continue. | ||
The PID is in the output from blackberry-deploy listed as result:: | The PID is in the output from blackberry-deploy listed as result::<pid>. You will need this <pid> below to attach to the process. | ||
== Attach and setup the debugger == | == Attach and setup the debugger == | ||
Line 36: | Line 42: | ||
Execute | Execute | ||
<code> | <code> | ||
> ntoarm-gdb | |||
</code> | |||
In the GDB shell, run | In the GDB shell, run | ||
<code> | <code> | ||
(gdb) target qnx <device_IP_address>:8000 | |||
(gdb) attach <pid> | |||
(gdb) file /path/to/app/executable/on/the/host | |||
(gdb) set solib-search-path $HOST_QTDIR/lib:$HOST_QTDIR/plugins/xyz/:$BBNDK/target_<version>/qnx6/armle-v7/lib/:$BBNDK/target_<version>/qnx6/ | |||
armle-v7/usr/lib | |||
(gdb) attach <pid> | |||
(gdb) b main | |||
(gdb) c | |||
</code> | |||
With the last command from the above block, the app should stop in in the first call in main(). | With the last command from the above block, the app should stop in in the first call in main(). | ||
Note: | Note: '''$HOST_QTDIR''' is a path on the development host machine pointing to the root folder of the Qt build for the ARM target, and '''not''' on the device. '''$BBNDK''' refers to the folder where the BlackBerry NDK is installed. It can contain multiple versions of target and host files. This is why you have to replace <version> with a value which is valid for your environment. | ||
== Reading symbols from shared libraries might be unreliable… == | == Reading symbols from shared libraries might be unreliable… == | ||
Line 50: | Line 67: | ||
If versions of the target libs on the host do not match those on the target, gdb might fail to load symbols from shared libraries. You can check the status of loaded shared libraries by | If versions of the target libs on the host do not match those on the target, gdb might fail to load symbols from shared libraries. You can check the status of loaded shared libraries by | ||
<code> | <code> | ||
(gdb) info sharedlibrary | |||
</code> | |||
You can enforce reloading of the shared libraries by: | You can enforce reloading of the shared libraries by: | ||
<code> | <code> | ||
(gdb) sharedlibrary | |||
</code> | |||
TBD: add information how to download a runtime matching the device libraries. | TBD: add information how to download a runtime matching the device libraries. | ||
== References == | == References == |
Latest revision as of 10:33, 1 April 2015
This page is a how-to on how to setup remote debugging for BlackBerry devices with the command-line tools. Currently the instructions are for Linux and Mac, but should be similar on Windows.
Please do not miss the the GDB manual to learn how to use GDB, the command-line debugger.
Note that Qt Creator supports remote debugging for BlackBerry devices as well, see this article for details. Qt Creator uses the same steps as outlined below, just wraps it into its IDE.
Pre-requisites
- Allow SSH connections to your BlackBerry device. See the BlackBerry Hints and Tips article for more details about this.
- Compile your app in the debug mode
Deploying the application
The deployment process is the same as for just testing the application the device:
> blackberry-nativepackager -devMode -package myapp.bar bar-descriptor.xml
For PlayBook, see the steps described here
Launching the application
As next, you should launch the app on the device and stop it for debugging. blackberry-deploy will do this for you:
> blackberry-deploy -debugNative -device <device_ip> -password <device_password> -launchApp myapp.bar
This will stop the execution early on (immediately after the process has been spawned) and wait for the debugger to attach and tell it to continue.
The PID is in the output from blackberry-deploy listed as result::<pid>. You will need this <pid> below to attach to the process.
Attach and setup the debugger
Execute
> ntoarm-gdb
In the GDB shell, run
(gdb) target qnx <device_IP_address>:8000
(gdb) attach <pid>
(gdb) file /path/to/app/executable/on/the/host
(gdb) set solib-search-path $HOST_QTDIR/lib:$HOST_QTDIR/plugins/xyz/:$BBNDK/target_<version>/qnx6/armle-v7/lib/:$BBNDK/target_<version>/qnx6/
armle-v7/usr/lib
(gdb) attach <pid>
(gdb) b main
(gdb) c
With the last command from the above block, the app should stop in in the first call in main().
Note: $HOST_QTDIR is a path on the development host machine pointing to the root folder of the Qt build for the ARM target, and not on the device. $BBNDK refers to the folder where the BlackBerry NDK is installed. It can contain multiple versions of target and host files. This is why you have to replace <version> with a value which is valid for your environment.
If versions of the target libs on the host do not match those on the target, gdb might fail to load symbols from shared libraries. You can check the status of loaded shared libraries by
(gdb) info sharedlibrary
You can enforce reloading of the shared libraries by:
(gdb) sharedlibrary
TBD: add information how to download a runtime matching the device libraries.