Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
Posts: 26
Registered: ‎06-09-2013
My Device: N serial
My Carrier: NIM
Accepted Solution

How does /base/sbin/launcher work?

Who knows how does /base/sbin/launcher works?

I am searching how can I startup an app to foreground by telnet to devie and run it up by command, instead of tap the icon on device screen.

 

I found the parent process of app below is at /base/sbin/launcher, but don't know how to use it?

execute /base/sbin/launcher path/exe can not startup the app...

I lookup SDK, but nothing found. Smiley Sad

 

 

1 # pidin | grep exe_name

47562854   1 app/native/exe_name10r RECEIVE     2
47562854   2 app/native/exe_name10r CONDVAR     (0x80bb17c)

......

get PID 47562854  

 

2 # pidin -f Pmbe | grep 47562854
47562854   28K(516K)*   1 5505163
47562854   28K(132K)    2 5505163

....

get PPID 5505163

 

3 # pidin | grep 5505163
 5505163   1 base/sbin/launcher  12r RECEIVE     1
 5505163   2 base/sbin/launcher   1r REPLY       2146348
 5505163   3 base/sbin/launcher  12r SIGWAITINFO

 

 

 

Highlighted
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How does /base/sbin/launcher work?

It's very unlikely you'll be able to do that that way. Things like launcher are surrounded by a permission system that restricts which users can do what.

The only known way to launch an app with a UI (screen context) remotely like that is using the blackberry-deploy tool, with the -launchApp option. You can run console apps, i.e. without a window, from the SSH command line.

If you do happen to figure out how to do this with launcher, you might want to report it as a bug. ;-)

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Contributor
Posts: 26
Registered: ‎06-09-2013
My Device: N serial
My Carrier: NIM

Re: How does /base/sbin/launcher work?

Appreciative for your comments. It helps me a lot I think.
Actually, another issue makes me stuck:
http://supportforums.blackberry.com/t5/Native-Development/gdb-long-time-uploading/m-p/2427709

My intent is debug app from begining of startup in console remotely, bring it up in window and interact with it.
I tried to capture message between IDE and device, but it's cryptographic and unreadable.
So I thought how to launch app, maybe helpful to bring it up in window.

Now I'm clear with that, as you said, if I want to launch remotely, must with the help of blackberry-deploy tool, with the -launchApp option.

Contributor
Posts: 26
Registered: ‎06-09-2013
My Device: N serial
My Carrier: NIM

Re: How does /base/sbin/launcher work?

Hi Peter,

Thanks for your suggestion. Smiley Happy

Now I can launch app into screen window and debug it from main() by command line.

 

The solution is:

1 Launch and allow native debugging by blackberry-deploy.bat (host_xxx_x\win32\x86\usr\bin)

 

The option below is very usefull:
  -debugNative   - hold native application immediately after the spawn to allow native debugging

 

Full command is:

blackberry-deploy.bat -launchApp -debugNative -device <host | IP> -password <password> -package-fullname <package full name>

 

Finished, it returns the PID info:

Info: Sending request: Launch
Info: Action: Launch
Info: Debug native: on
Info: Launching <app>
result::27476062
Info: done

 

2 gdb remotely and attach the process by ntoarm-gdb (host_xxx_x\win32\x86\usr\bin)

 

target qnx IP:8000

 

file app

 

b main

Cannot access memory at address 0x0
Breakpoint 1 at 0x809bfaa: file ../src/main.cpp, line 27.
(gdb) c
Continuing.

 

Breakpoint 1, main (argc=1, argv=0x75cf074) at ../src/main.cpp:27
27          Application app(argc, argv);

 

 

 

Contributor
Posts: 26
Registered: ‎06-09-2013
My Device: N serial
My Carrier: NIM

Re: How does /base/sbin/launcher work?

forgot one line in gdb:
need to attach the process, before set the breakpoint
(gdb) attach 27476062
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How does /base/sbin/launcher work?

Nice summary of your results. Thanks! Smiley Happy

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Contributor
Posts: 26
Registered: ‎06-09-2013
My Device: N serial
My Carrier: NIM

Re: How does /base/sbin/launcher work?

I can not make it without your help, Smiley Happy

I'd like to share more with all. I found debug app in command line is more efficient than in IDE. So I am going to use this way to debug in the future.

 

Debug shared library by gdb in command line:

 

1 get the shared library base address in memory

continue with before steps, ssh/telnet to device, then:

pidin -f aO | grep libNoname

Unable to find link_map.: No error
        0x78208000                     libNoname.so /apps/package-name/native/lib/libNoname.so

 

2 get the offset of text section in shared library

GNU toolchain on windows, bbndk/host_xxx/win32/x86/usr/bin/ntoarm-objdump

 

ntoarm-objdump -h libNoname.so | grep text
  8 .text         0000c7cc  00008ea8  00008ea8  00008ea8  2**3

 

 

3 add symbols to gdb

0x78208000  + 00008ea8 = 0x786b8ea8

add-symbol-file libNoname.so 0x786b8ea8

        .text_addr = 0x786b8ea8
(y or n) y
Reading symbols from....

 

4 then set the breakpoint and debug

The breakpoint can be hit correctly.