How to use RDebug

來源:互聯網
上載者:User
General

RDebug is a useful utility for checking a log of specific messages generated by the running code. This feature is helpful when the breakpoint/step debug tricks' using space has been limited.

To use RDebug, include the header file, e32debug.h. (In 2nd Edition SDK, RDebug class declared in
E32SVR.H)

#include <e32debug.h>

Then, add the following to any place in your code:

// code before logRDebug::Print(_L("### Log %d %08x"), 5, 0xABCDEF12);// code after log

The output debug message is now viewable with a the
DebugView tool.

This trick is especially useful for tasks with special requirements.

RDebug::Print format

The RDebug::Print parameter format is easy because it follows the C
printf format. The one that most have trouble with is %S to print a descriptor. It expects a pointer to a descriptor, so you must use the
& operator if you are printing a TBuf, for example.

// Print a HBufCRDebug::Print( _L("Test string: %S"), hbuf ); // Print a TBufRDebug::Print( _L("Test string: %S"), &tbuf );   //  useful macro, LINE , evaluates to the current line number in     RDebug::Print(_L("Debug on line %d"), __LINE__);

Enabling RDebug output in the emulator

The output of RDebug in emulator is written to:

  • A text file, called EPOCWIND.OUT. The file is located in the TEMP folder. If you do not know the location of your TEMP folder, check Control Panel | Settings | Advanced | Environment Variables.
  • Debugger view of the IDE (see the following sections).

For S60 3rd Edition, there are two options in the /epoc32/data/epoc.ini file to enable or disable
RDebug output, that is:

  • LogToFile
  • LogToDebugger

The following code shows the content of epoc.ini with LogToFile and
LogToDebugger enabled:

LogToFile 1LogToDebugger 1

Note: If changing the epoc.ini is something that you feel comfortable with, then try it. You can also control the same settings through the emulator's window menu. Select Tools -> Preferences. The logging options can be found in the General
tab.

Viewing RDebug output in Carbide.c++

Viewing RDebug output in the Carbide.c++ IDE can be done by enabling "View process output". To enable it, right click project name and select Debug as | Debug.... Click the Debugger tab and enable "View process output" (see picture below).

After the "View process output" option has been enabled, debug the project. To display the debug messages, click Open Console and select the Debug Messages menu. The picture below shows the output of
RDebug in the Carbide.c++ IDE.

Viewing RDebug output in Carbide.c++ (advanced)

Carbide.c++ is an Eclipse based IDE. The advantage of this is that many existing Eclipse plug-ins can be easily integrated with Carbide.c++. One such example is the

Eclipse Logfile Viewer plug-in, a tool that can dynamically load a log file, parse it according to user defined rules, and then display it in real time with customised formatting.

Plug-in configuration example:

Viewing the RDebug messages:

Here you can see how the plug-in can be used to highlight the log messages sent by your application, recognised as starting with the keyword
RDebug.

RDebug::Print( _L("RDebug Hello") );

Viewing RDebug output outside of an IDE

It is also possible to view debug output without any IDE or debugger attached. This can speed up launch times for the emulator (for example, if you are using Just-in-time debugging as described in

How to debug with emulator on the fly).

For this, you can use several tools that show Windows debug strings, such as
DebugView from Microsoft. DebugView also has additional features such as highlighting or excluding strings with a particular pattern.

One thing to keep in mind is that the debug output can occasionally come from other processes in your system, not just the Symbian emulator, so with a tool like DebugView you can capture other strings not related to the application you are debugging. Again,
filtering can be very helpful here.

Capturing RDebug output in epocwind.out

epocwind.out is a normal text file which is appended by the emulator so you can open it with any text editor. To be able to see the log prints as they come, you can use the

tail freeware program. It is a port of the unix tail program that prints the "tail" of a file.

Create a bat file as follows:

tail -f %temp%/epocwind.out

This opens a dos-prompt to show the log prints as they come. It can be closed by pressing Ctrl-C.

Retrieved from " http://wiki.forum.nokia.com/index.php/How_to_use_RDebug"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.