參考資訊:
https://wiki.qt.io/Remote_debugging_on_Blackberry_devices
main.c
#include <stdio.h>
int main(int argc, char** argv)
{
printf("This is a testing for Blackberry 10\n");
return 0;
}
bar-descriptor.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<qnx xmlns="http://www.qnx.com/schemas/application/1.0">
<id>com.Steward.main</id>
<name>main</name>
<filename>main</filename>
<versionNumber>1.0.0</versionNumber>
<buildId>1</buildId>
<description>Testing for Blackberry 10</description>
<author>Steward</author>
<authorId>gYAAgGE4qaHzBnzEAu8JKe4G1OI</authorId>
<asset path="main" entry="true" type="Qnx/Elf">main</asset>
</qnx>
1. 編譯檔案
$ source ~/bbndk/bbndk-*.sh
$ ntoarmv7-gcc -g -o main main.c
$ blackberry-nativepackager -package main.bar bar-descriptor.xml -devMode -debugToken ${HOME}/.rim/debugtoken_q30.bar
2. 透過Chrome安裝main.bar到手機上
3. 建立ssh連線
$ ssh-keygen -b 4096 -f ~/.ssh/id_rsa_4096
$ blackberry-connect xxx.xxx.xxx.xxx -password xxx -sshPublicKey ~/.ssh/id_rsa_4096.pub
Info: Connecting to target xxx.xxx.xxx.xxx:4455
Info: Authenticating with target xxx.xxx.xxx.xxx:4455
Info: Encryption parameters verified
Info: Authenticating with target credentials.
Info: Successfully authenticated with target credentials.
Info: Sending ssh key to target xxx.xxx.xxx.xxx:4455
Info: ssh key successfully transferred.
Info: Successfully connected. This application must remain running in order to use debug tools. Exiting the application will terminate this connection.
4. 開啟另一個Terminal視窗並且Deploy main.bar(result的結果就是PID)
$ blackberry-deploy -debugNative -device xxx.xxx.xxx.xxx -password xxx -launchApp main.bar
Info: Sending request: LAUNCH
Info: Action: Launch
Info: Debug native: on
Info: Launching com.Steward.main.testDev_teward_main13c0fbb4...
result::15708394
Info: done
5. Debug main.bar
$ ntoarm-gdb
(gdb) target qnx xxx.xxx.xxx.xxx:8000
Remote debugging using xxx.xxx.xxx.xxx:8000
MsgNak received - resending
Remote target is little-endian
(gdb) attach 15708394
Attaching to pid 15708394
[New pid 15708394 tid 1]
warning: Shared object "/usr/lib/ldqnx.so.2" could not be validated and will be ignored.
warning: Could not load shared library symbols for /usr/lib/ldqnx.so.2.
Do you need "set solib-search-path" or "set sysroot"?
warning: Host file /usr/lib/ldqnx.so.2 does not match target file <?>
0x017e3918 in ?? ()
(gdb) file main
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from /home/steward/Downloads/main...done.
(gdb) set solib-search-path $BBNDK/target_10_3_1_995/qnx6/armle-v7/lib/:$BBNDK/target_10_3_1_995/qnx6/armle-v7/usr/lib
warning: Shared object "/usr/lib/ldqnx.so.2" could not be validated and will be ignored.
warning: Shared object "/usr/lib/ldqnx.so.2" could not be validated and will be ignored.
warning: Could not load shared library symbols for /usr/lib/ldqnx.so.2.
Do you need "set solib-search-path" or "set sysroot"?
warning: Host file /usr/lib/ldqnx.so.2 does not match target file <?>
Cannot access memory at address 0x0
(gdb) b main
Cannot access memory at address 0x0
Breakpoint 1 at 0x10c6786e: file main.c, line 5.
(gdb) c
Continuing.
Breakpoint 1, main (argc=1, argv=0x106061c4) at main.c:5
5 printf("This is a testing for Blackberry 10\n");
(gdb) quit
使用者也可以透過SSH登入並直接到Appdata目錄執行,如下所示:
$ pwd
/accounts/1000/appdata/com.Steward.main.testDev_teward_main13c0fbb4/app/native
$ ./main
This is a testing for Blackberry 10
P.S. 如果該App不是在目前登入的電腦上製作的話,基本上,使用者是沒有權限進入該App資料夾執行的