Remote debugging on Blackberry devices: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
=Remote debugging on BlackBerry devices=
[[Category:BlackBerry]]
 
= Remote debugging on BlackBerry devices =


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 [http://www.gnu.org/software/gdb/documentation/ the <span class="caps">GDB</span> manual] ''[gnu.org]'' to learn how to use <span class="caps">GDB</span>, the command-line debugger.
Please do not miss the &quot;the GDB manual&amp;quot;:http://www.gnu.org/software/gdb/documentation/ 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 <span class="caps">IDE</span>.
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.


==Pre-requisites==
== Pre-requisites ==


* Allow <span class="caps">SSH</span> connections to your BlackBerry device. See the [[BlackBerry Hints n Tips|BlackBerry Hints and Tips]] article for more details about this.
* Allow SSH connections to your BlackBerry device. See the [[BlackBerry_Hints_n_Tips | BlackBerry Hints and Tips]] article for more details about this.
* Compile your app in the debug mode
* Compile your app in the debug mode


==Deploying the application==
== Deploying the application ==


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:


For PlayBook, see the steps described [[Building and Deploying Qt Applications to the Playbook|here]] ''[qt.io]''
<code><br />&gt; blackberry-nativepackager -devMode -package myapp.bar bar-descriptor.xml<br /></code>
 
For PlayBook, see the steps described &quot;here&amp;quot;:http://wiki.qt.io/Building_and_Deploying_Qt_Applications_to_the_Playbook
 
== Launching the application ==


==Launching the application==
As next, you should launch the app on the device and stop it for debugging. &lt;code&amp;gt;blackberry-deploy&amp;lt;code&amp;gt; will do this for you:


As next, you should launch the app on the device and stop it for debugging. <code>blackberry-deploy<code> will do this for you:</code></code>
<code><br />&gt; blackberry-deploy -debugNative -device &lt;device_ip&amp;gt; -password &lt;device_password&amp;gt; -launchApp myapp.bar<br /></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 <span class="caps">PID</span> is in the output from blackberry-deploy listed as result::&lt;pid&gt;. You will need this &lt;pid&gt; below to attach to the process.
The PID is in the output from blackberry-deploy listed as result::&lt;pid&amp;gt;. You will need this &lt;pid&amp;gt; below to attach to the process.


==Attach and setup the debugger==
== Attach and setup the debugger ==


Execute
Execute


In the <span class="caps">GDB</span> shell, run
<code><br />&gt; ntoarm-gdb<br /></code>
 
In the GDB shell, run
 
<code><br />(gdb) target qnx &lt;device_IP_address&amp;gt;:8000<br />(gdb) attach &lt;pid&amp;gt;<br />(gdb) file /path/to/app/executable/on/the/host<br />(gdb) set solib-search-path $HOST_QTDIR/lib:$HOST_QTDIR/plugins/xyz/:$BBNDK/target_&lt;version&amp;gt;/qnx6/armle-v7/lib/:$BBNDK/target_&lt;version&amp;gt;/qnx6/armle-v7/usr/lib<br />(gdb) attach &lt;pid&amp;gt;<br />(gdb) b main<br />(gdb) c<br /></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: <code>$HOST_QTDIR<code> is a path on the development host machine pointing to the root folder of the Qt build for the <span class="caps">ARM</span> target, and '''not''' on the device. <code>$BBNDK<code> refers to the folder where the BlackBerry <span class="caps">NDK</span> is installed. It can contain multiple versions of target and host files. This is why you have to replace &lt;version&gt; with a value which is valid for your environment.</code></code></code></code>
Note: &lt;code&amp;gt;$HOST_QTDIR&amp;lt;code&amp;gt; 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. &lt;code&amp;gt;$BBNDK&amp;lt;code&amp;gt; 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 &lt;version&amp;gt; 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… ==


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><br />(gdb) info sharedlibrary<br /></code>


You can enforce reloading of the shared libraries by:
You can enforce reloading of the shared libraries by:


<span class="caps">TBD</span>: add information how to download a runtime matching the device libraries.
<code><br />(gdb) sharedlibrary<br /></code>
 
==References==
 
* See the [http://www.qnx.com/developers/docs/6.5.0/index.jsp?topic=/com.qnx.doc.neutrino_prog/using_gdb.html Using <span class="caps">GDB</span>] ''[qnx.com]'' article in the <span class="caps">QNX</span> documentation


===Categories:===
TBD: add information how to download a runtime matching the device libraries.


* [[:Category:BlackBerry|BlackBerry]]
== References ==

Revision as of 09:58, 24 February 2015


Remote debugging on BlackBerry devices

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&quot;:http://www.gnu.org/software/gdb/documentation/ 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:

<br />&gt; blackberry-nativepackager -devMode -package myapp.bar bar-descriptor.xml<br />

For PlayBook, see the steps described "here&quot;:http://wiki.qt.io/Building_and_Deploying_Qt_Applications_to_the_Playbook

Launching the application

As next, you should launch the app on the device and stop it for debugging. <code&gt;blackberry-deploy&lt;code&gt; will do this for you:

<br />&gt; blackberry-deploy -debugNative -device &lt;device_ip&amp;gt; -password &lt;device_password&amp;gt; -launchApp myapp.bar<br />

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&gt;. You will need this <pid&gt; below to attach to the process.

Attach and setup the debugger

Execute

<br />&gt; ntoarm-gdb<br />

In the GDB shell, run

<br />(gdb) target qnx &lt;device_IP_address&amp;gt;:8000<br />(gdb) attach &lt;pid&amp;gt;<br />(gdb) file /path/to/app/executable/on/the/host<br />(gdb) set solib-search-path $HOST_QTDIR/lib:$HOST_QTDIR/plugins/xyz/:$BBNDK/target_&lt;version&amp;gt;/qnx6/armle-v7/lib/:$BBNDK/target_&lt;version&amp;gt;/qnx6/armle-v7/usr/lib<br />(gdb) attach &lt;pid&amp;gt;<br />(gdb) b main<br />(gdb) c<br />

With the last command from the above block, the app should stop in in the first call in main().

Note: <code&gt;$HOST_QTDIR&lt;code&gt; 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. <code&gt;$BBNDK&lt;code&gt; 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&gt; with a value which is valid for your environment.

Reading symbols from shared libraries might be unreliable…

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

<br />(gdb) info sharedlibrary<br />

You can enforce reloading of the shared libraries by:

<br />(gdb) sharedlibrary<br />

TBD: add information how to download a runtime matching the device libraries.

References