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
Developer
0x9F
Posts: 23
Registered: ‎01-27-2014
My Device: Z10

Can't debug the headless portion of a headless app

I'm playing around with the headless app template in Momentics but I can't get the headless part to log anything anywhere. I don't know how to attach the debugger to it either. I can only log from and debug the GUI part of the headless app.

 

How do I log from the headless part of a headless app or debug from it?

 

I'd rather be able to debug it than log from it.

Developer
canadainc
Posts: 19
Registered: ‎07-02-2013
My Device: BlackBerry Q10

Re: Can't debug the headless portion of a headless app

Hi, try the following in your main.cpp for the headless service:

 

namespace {

FILE* f = NULL;

void redirectedMessageOutput(QtMsgType type, const char *msg)
{
	Q_UNUSED(type);
	fprintf(f, "%s\n", msg);
}

}

Q_DECL_EXPORT int main(int argc, char **argv)
{
	f = fopen("/accounts/1000/shared/misc/logfile.txt", "w");
	qInstallMsgHandler(redirectedMessageOutput);

	qDebug() << "log something");

	Application app(argc, argv);
	new Service(&app);

	qDebug() << "Log something else";

	return Application::exec();
}

 

Make sure the "Shared Files" permission is enabled and then you will find the log in the shared/misc folder as "logfile.txt". However, in order to see the logs, you will need to go to the Application Monitor and stop the service, and THEN look at the logfile in the shared folder.

Developer
0x9F
Posts: 23
Registered: ‎01-27-2014
My Device: Z10

Re: Can't debug the headless portion of a headless app

Thanks for the advice. That's better than nothing but I would like to be able to step through the headless part of the app in the debugger.

 

I found a few sentences about it on page 45 of this presentation

 

PDF: JAM840

 

but it doesn't say anything about how to do it.

 

I'm going to try sending some logging over a UDP or TCP socket or I might write some logging to a text widget in the GUI part of the app.

 

If anyone knows how to attach the debugger to the headless part of the app, please let me know.

Developer
oddboy
Posts: 136
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1

Re: Can't debug the headless portion of a headless app

Ever find an answer to this?
bron: a cron-like scheduler for BlackBerry 10
http://apps.oddelement.com
Developer
0x9F
Posts: 23
Registered: ‎01-27-2014
My Device: Z10

Re: Can't debug the headless portion of a headless app

I've talked to people who talk to the developers at BlackBerry. They could not answer the question. Perhaps it is a feature for the future.

BlackBerry Development Advisor
shaque
Posts: 237
Registered: ‎07-14-2008
My Device: Not Specified

Re: Can't debug the headless portion of a headless app

Fully understand the difficulty you are facing for this. You Are correct, headless debugging (steping through code) is targeted for the next momentics release. 

 

Shadid

Developer
0x9F
Posts: 23
Registered: ‎01-27-2014
My Device: Z10

Re: Can't debug the headless portion of a headless app

Glad to hear it.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Can't debug the headless portion of a headless app

we log to a shared database (using qInstallMessageHandler) and read that from the UI part.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
footose
Posts: 300
Registered: ‎03-12-2009
My Device: Not Specified

Re: Can't debug the headless portion of a headless app

Has this been fixed yet?

 

Debugging a headless app is a nightmare..

Developer
0x9F
Posts: 23
Registered: ‎01-27-2014
My Device: Z10

Re: Can't debug the headless portion of a headless app

I talked to some people at BlackBerry. It has not been fixed yet but it should be fixed in the next release of Momentics. It should come out some time this summer.