Android jdb Debug

Source: Internet
Author: User

There are many ways to debug Android on Ubuntu, which can be used with Eclipse,android studio. But sometimes, for convenience, you can use the command line to debug. The following is a list of command line debug procedures

xxx:~$ CD source/
xxx:~/source$ cd packages/apps/settings/
xx:~/source/packages/apps/settings$ adb Shell PS | grep com.android.settings
System 3119 202 550436 38152 ffffffff 400dd888 S com.android.settings
xxx:~/source/ packages/apps/settings$ adb forward tcp:7777 jdwp:3119
xxx:~/source/packages/apps/settings$ ls
Androidmanifest.xml android.mk cleanspec.mk module_license_apache2 NOTICE proguard.flags res src tests
Xxx:~/source /packages/apps/settings$ Jdb-sourcepath src-attach localhost:7777
Set uncaught java.lang.Throwable
Set Deferred uncaught java.lang.Throwable
Initializing jdb ...
> Stop in com.android.settings.Settings.onCreate
Set Breakpoint Com.android.settings.Settings.onCreate
>
Breakpoint Hit: "Thread=<1> main", Com.android.settings.Settings.onCreate (), line=197 bci=2
197 if (Getintent (). Hasextra (extra_ui_options)) {

<1> main[1] list
193};
194
195 @Override
196 protected void OnCreate (Bundle savedinstancestate) {
197 = if (getintent (). Hasextra (extra_ui_options)) {
198 GetWindow (). Setuioptions (Getintent (). Getintextra (extra_ui_options, 0));
199}
200
201 Mauthenticatorhelper = new Authenticatorhelper ();
202 mauthenticatorhelper.updateauthdescriptions (this);
<1> Main[1] next

.....

<1> main[1] Print Minlocalheaderswitch
Minlocalheaderswitch = True

.....

Above, the operation is quite simple.

attached: * * JDB Command list * *

  • connectors-lists the connectors and transports available in this VM
  • Run [class [args]]-] starts executing the main class of the application
  • threads [threadgroup]-Column Outgoing thread
  • thread-Setting the default thread
  • suspend [thread ID (s)]-suspend thread (default: All)
  • Resume [thread ID (s)]-restore Thread (default: All)
  • where [| all]-the stack of the dump thread
  • Wherei [| all]– the stack of the dump thread, and the PC information
  • Up [n frames]-the stack of the thread up
  • Down [n frames]-the stack for the thread to move down
  • kill-terminating a thread with the given exception error object
  • Interrupt-in the thread
  • Print-the value of an output expression
  • dump-output All object information
  • eval-Evaluation of expressions (same as print)
  • Set =-Assigning a new value to a field/variable/array element
  • locals-output all local variables in the current stack frame
  • classes-lists the currently-known classes
  • class-displaying details of named classes
  • methods-Methods for listing classes
  • fields-list The fields of a class
  • threadgroups-List of outgoing thread groups
  • threadgroup-Setting the current thread group
  • Stop in. [(Argument_type,...)] -Set breakpoints in method
  • Stop at:-Set breakpoints in rows
  • Clear. [(Argument_type,...)] -Clears breakpoints in the method
  • Clear:-Clears the breakpoint in the line
  • clear-List Breakpoints
  • catch [Uncaught|caught|all] | -Interrupt when a specified exception error occurs
  • Ignore [Uncaught|caught|all] | -For the specified exception error, Cancel ' catch '
  • Watch [Access|all]. -Monitor access/modification of fields
  • Unwatch [Access|all]. -Stop monitoring access/modification of fields
  • Trace [Go] methods [thread]-Tracking method entry and exit. -Suspend all threads unless ' go ' is specified
  • Trace [Go] method exit | Exits [thread]-tracks the exit of the current method, or the exit of all methods-suspends all threads unless ' go ' is specified
  • Untrace [methods]-Stop Tracking Method entry and/or exit
  • Step-performing the Forward
  • Step up-is executed until the current method returns to its caller
  • stepi-executing the current instruction
  • Next step-stepping one line (step over call)
  • Cont-Continue from Breakpoint
  • list [line number|method]-output source code
  • Use (or sourcepath) [source file path]-Display or change the origin path
  • Exclude [, ... | "None"-for the specified class, no step or method events are reported
  • classpath-output classpath information from the target VM
  • monitor-Execute command every time the program is stopped
  • monitor-List Monitors
  • Unmonitor <monitor#>-Deleting a monitor
  • read-reading and executing command files
  • lock-lock information for output objects
  • threadlocks [Thread id]-The lock information for the output thread
  • Pop-the current frame and contains the current frame
  • Reenter-is the same as pop but re-enters the current frame
  • Redefine-redefining the code of a class
  • disablegc-garbage collection of prohibited objects
  • enablegc-allow garbage collection of objects
  • !! -Execute last command repeatedly
  • -Execute the command repeatedly n times
  • # <command>-Abort (no action)
  • Help (or?)-List commands
  • version-Output Version Information
  • Exit (or quit)-Exit debugger
  • : Full class name with package qualifier
  • : Class name with a leading or trailing wildcard (' * ')
  • : The thread number reported in the ' Threads ' command
  • : Java (TM) programming language expression.
  • Most common syntax is supported.

Reference:

http://codeseekah.com/2012/02/16/command-line-android-development-debugging/

http://resources.infosecinstitute.com/android-hacking-security-part-5-debugging-java-applications-using-jdb/

Android jdb Debug

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.