Table of Contents

Debugging Java code

After the package had been deployed, you can debug either Java or native code in the application. Simultaneous Java + native debugging is a work in progress and will be available in a future release of WinGDB.

In all cases, the Debuggable attribute must be set to be able to debug (Application property page on the project node).

This section describes Java code debugging in more detail.

Before starting debugging, you might want to set some options. They have default values which are appropriate in most cases. These options are located on the Debug property page for the project node.

The most important one is Debug target device. Ensure that emulator is entered here to debug on the emulator, or device for a single connected device. There might be also a device (or emulator process) name entered, as listed by adb devices command.

For Java code debugging, Debug session type should be set to Java.

The emulator should be running before starting debugging. WinGDB does not start it, as the SDK already has appropriate user interface called AVD. You can create multiple emulator configurations in AVD, and then launch desired one. WinGDB works with any emulator that is started at the moment.

In order to be able to debug on a device, usually a debug mode must be enabled on it. Please consult Android SDK documentation on that topic.

You can debug in two modes:

Displaying Android system log

In many cases, Android system log is a very useful tool to diagnose problems. You can view it manually using the logcat command. WinGDB also offers some ways to view it without leaving Visual Studio. One way is to use Device monitor. The second one is to enable log dump into the Debug window during the debugging session.

To view the log in Debug window, set Display Android system log option to any other format than None. You can also set a filter for log messages -- consult logcat documentation on that topic.

Visualizers

Visualizers are special scripts allowing to view contents of complex containers, e.g. Map or List. In case of Java language, WinGDB debugger provides built-in Python interpreter which is being used to evaluate visualizers. Currently there are visualizers for standard Java containers, however in future releases it will be extended to some Android-specific containers. Also the format will be described, allowing you to write your own visualizer scripts. The format is not compatible with GDB visualizer format, although Python language is used in both cases.

In order to enable visualizers for a debug session, the Visualizer profile setting on Preferences/Configuration/Debug page must be set to _JavaStandard. This is the default setting.

Table of Contents


Copyright (C) 2008-2013 WinGDB.com. All rights reserved.