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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 24
Registered: ‎01-27-2014
My Device: Z10
My Carrier: Rogers

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
Posts: 19
Registered: ‎07-02-2013
My Device: BlackBerry Q10
My Carrier: Telus

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
Posts: 24
Registered: ‎01-27-2014
My Device: Z10
My Carrier: Rogers

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
Posts: 139
Registered: ‎05-24-2011
My Device: Z30 running 10.2 and Playbook 4GLTE running OS2.1
My Carrier: rogers

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
Posts: 24
Registered: ‎01-27-2014
My Device: Z10
My Carrier: Rogers

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.

Retired
Posts: 249
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
Posts: 24
Registered: ‎01-27-2014
My Device: Z10
My Carrier: Rogers

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

Glad to hear it.

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

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
Highlighted
Developer
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
Posts: 24
Registered: ‎01-27-2014
My Device: Z10
My Carrier: Rogers

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.