- 浏览: 1508079 次
- 性别:
- 来自: 南京
-
文章分类
- 全部博客 (419)
- XMPP (19)
- Android (180)
- Java (59)
- Network (4)
- HTML5 (13)
- Eclipse (9)
- SCM (23)
- C/C++ (4)
- UML (4)
- Libjingle (15)
- Tools&Softwares (29)
- Linphone (5)
- Linux&UNIX (6)
- Windows (18)
- Google (10)
- MISC (3)
- SIP (6)
- SQLite (5)
- Security (4)
- Opensource (29)
- Online (2)
- 文章 (3)
- MemoryLeak (10)
- Decompile (5)
- Ruby (1)
- Image (1)
- Bat (4)
- TTS&ASR (28)
- Multimedia (1)
- iOS (20)
- Asciiflow - ASCII Flow Diagram Tool.htm (1)
- Networking (1)
- DLNA&UPnP (2)
- Chrome (2)
- CI (1)
- SmartHome (0)
- CloudComputing (1)
- NodeJS (3)
- MachineLearning (2)
最新评论
-
bzhao:
点赞123!
Windows的adb shell中使用vi不乱码方法及AdbPutty -
wahahachuang8:
我觉得这种东西自己开发太麻烦了,就别自己捣鼓了,找个第三方,方 ...
HTML5 WebSocket 技术介绍 -
obehavior:
view.setOnTouchListenerview是什么
[转]android 一直在最前面的浮动窗口效果 -
wutenghua:
[转]android 一直在最前面的浮动窗口效果 -
zee3.lin:
Sorry~~
When I build "call ...
Step by Step about How to Build libjingle 0.4
Dalvik Debugger Support
The Dalvik virtual machine supports source-level debugging with many popular development environments. Any tool that allows remote debugging over JDWP (the Java Debug Wire Protocol ) is expected work. Supported debuggers include jdb, Eclipse, IntelliJ, and JSwat.
The VM does not support tools based on JVMTI (Java Virtual Machine Tool Interface). This is a relatively intrusive approach that relies on bytecode insertion, something the Dalvik VM does not currently support.
Dalvik's implementation of JDWP also includes hooks for supporting DDM (Dalvik Debug Monitor) features, notably as implemented by DDMS (Dalvik Debug Monitor Server) and the Eclipse ADT plugin. The protocol and VM interaction is described in some detail here .
All of the debugger support in the VM lives in the dalvik/vm/jdwp
directory, and is almost entirely isolated from the rest of the VM sources.
dalvik/vm/Debugger.c
bridges the gap. The goal in doing so
was to make it easier to re-use the JDWP code in other projects.
Implementation
Every VM that has debugging enabled starts a "JDWP" thread. The thread typically sits idle until DDMS or a debugger connects. The thread is only responsible for handling requests from the debugger; VM-initated communication, such as notifying the debugger when the VM has stopped at a breakpoint, are sent from the affected thread.
When the VM is started from the Android app framework, debugging is enabled
for all applications when the system property ro.debuggable
is set to 1 (use adb shell getprop ro.debuggable
to check it). If it's zero, debugging can be enabled via the application's
manifest, which must include android:debuggable="true"
in the
<application>
element.
The VM recognizes the difference between a connection from DDMS and a connection from a debugger (either directly or in concert with DDMS). A connection from DDMS alone doesn't result in a change in VM behavior, but when the VM sees debugger packets it allocates additional data structures and may switch to a different implementation of the interpreter.
Pre-Froyo implementations of the Dalvik VM used read-only memory mappings for all bytecode, which made it necessary to scan for breakpoints by comparing the program counter to a set of addresses. In Froyo this was changed to allow insertion of breakpoint opcodes. This allows the VM to execute code more quickly, and does away with the hardcoded limit of 20 breakpoints. Even with this change, however, the debug-enabled interpreter is much slower than the regular interpreter (perhaps 5x).
The JDWP protocol is stateless, so the VM handles individual debugger requests as they arrive, and posts events to the debugger as they happen.
Debug Data
Source code debug data, which includes mappings of source code to
bytecode and lists describing which registers are used to hold method
arguments and local variables, are optionally emitted by the Java compiler.
When dx
converts Java bytecode to Dalvik bytecode, it must
also convert this debug data.
dx
must also ensure that it doesn't perform operations
that confuse the debugger. For example, re-using registers that hold
method arguments and the "this
" pointer is allowed in
Dalvik bytecode if the values are never used or no longer needed.
This can be very confusing for the debugger (and the programmer)
since the values have method scope and aren't expected to disappear. For
this reason, dx
generates sub-optimal code in some situations
when debugging support is enabled.
Some of the debug data is used for other purposes; in particular, having
filename and line number data is necessary for generating useful exception
stack traces. This data can be omitted by dx
to make the DEX
file smaller.
Usage
The Dalvik VM supports many of the same command-line flags that other popular desktop VMs do. To start a VM with debugging enabled, you add a command-line flag with some basic options. The basic incantation looks something like this:
-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
or
-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=y
After the initial prefix, options are provided as name=value pairs. The options currently supported by the Dalvik VM are:
dt_socket
) and connection over USB
through ADB (dt_android_adb
).
hostname:port
when server=n
,
but can be just port
when server=y
. This
specifies the IP address and port number to connect or listen to.
Listening on port 0 has a special meaning: try to listen on port 8000; if that fails, try 8001, 8002, and so on. (This behavior is non-standard and may be removed from a future release.)
This option has no meaning for
transport=dt_android_adb
.
To debug a program on an Android device using DDMS over USB, you could use a command like this:
% dalvikvm -agentlib:jdwp=transport=dt_android_adb,suspend=y,server=y -cp /data/foo.jar Foo
This tells the Dalvik VM to run the program with debugging enabled, listening
for a connection from DDMS, and waiting for a debugger. The program will show
up with an app name of "?" in the process list, because it wasn't started
from the Android application framework. From here you would connect your
debugger to the appropriate DDMS listen port (e.g.
jdb -attach localhost:8700
after selecting it in the app list).
To debug a program on an Android device using TCP/IP bridged across ADB, you would first need to set up forwarding:
% adb forward tcp:8000 tcp:8000 % adb shell dalvikvm -agentlib:jdwp=transport=dt_socket,address=8000,suspend=y,server=y -cp /data/foo.jar Foo
and then jdb -attach localhost:8000
.
(In the above examples, the VM will be suspended when you attach. In jdb,
type cont
to continue.)
The DDMS integration makes the dt_android_adb
transport much
more convenient when debugging on an Android device, but when working with
Dalvik on the desktop it makes sense to use the TCP/IP transport.
Known Issues and Limitations
Most of the optional features JDWP allows are not implemented. These include field access watchpoints and better tracking of monitors.
Not all JDWP requests are implemented. In particular, anything that never gets emitted by the debuggers we've used is not supported and will result in error messages being logged. Support will be added when a use case is uncovered.
The debugger and garbage collector are somewhat loosely integrated at present. The VM currently guarantees that any object the debugger is aware of will not be garbage collected until after the debugger disconnects. This can result in a build-up over time while the debugger is connected. For example, if the debugger sees a running thread, the associated Thread object will not be collected, even after the thread terminates.
The only way to "unlock" the references is to detach and reattach the debugger.
The translation from Java bytecode to Dalvik bytecode may result in identical sequences of instructions being combined. This can make it look like the wrong bit of code is being executed. For example:
int test(int i) { if (i == 1) { return 0; } return 1; }
The Dalvik bytecode uses a common return
instruction for both
return
statements, so when i
is 1 the debugger
will single-step through return 0
and then return 1
.
Dalvik handles synchronized methods differently from other VMs.
Instead of marking a method as synchronized
and expecting
the VM to handle the locks, dx
inserts a "lock"
instruction at the top of the method and an "unlock" instruction in a
synthetic finally
block. As a result, when single-stepping
a return
statement, the "current line" cursor may jump to
the last line in the method.
This can also affect the way the debugger processes exceptions. The
debugger may decide to break on an
exception based on whether that exception is "caught" or "uncaught". To
be considered uncaught, there must be no matching catch
block
or finally
clause between the current point of execution and
the top of the thread. An exception thrown within or below a synchronized
method will always be considered "caught", so the debugger won't stop
until the exception is re-thrown from the synthetic finally
block.
Copyright © 2009 The Android Open Source Project
发表评论
-
JAAS authentication in Tomcat example
2018-11-19 20:32 649... -
druid 数据库密码加密
2015-03-12 17:43 1398cmd命令:1、切换的druid-0.2.9.jar包所在目 ... -
[Android] 为Android安装BusyBox —— 完整的bash shell
2013-12-27 10:19 1503http://www.cnblogs.com/xiaowen ... -
Windows的adb shell中使用vi不乱码方法及AdbPutty
2013-12-27 10:17 7605http://www.veryhuo.com/down/ht ... -
AppMobi推出新XDK,可创建测试PhoneGap项目
2012-09-03 13:39 2643AppMobi今天发布了一个新的工具PhoneGap Mobi ... -
Sencha
2012-09-03 12:59 1193http://www.sencha.com/ Se ... -
jQuery Mobile学习
2012-09-01 12:33 1702使用Jquery Mobile设计Android通讯录 ... -
BackBone
2012-09-01 12:34 1265Backbone.js 是一种重量级javascript M ... -
jQTouch
2012-08-30 15:57 990A Zepto/jQuery plugin for mobil ... -
SwiFTP
2012-08-30 15:43 1312SwiFTP is a FTP server that run ... -
kWS
2012-08-30 15:41 1206kWS is a lightweight and fast W ... -
jQuery Mobile
2012-08-30 15:07 1037http://jquerymobile.com/ -
PhoneGap
2012-08-30 15:07 1051http://phonegap.com/ -
Android Button background image pressed/highlighted and disabled states without
2012-08-06 12:49 1686http://shikii.net/blog/android- ... -
[AndriodTips]Image, saved to sdcard, doesn't appear in Android's Gallery app
2012-08-04 16:15 1166http://stackoverflow.com/questi ... -
Voice detection for Android
2012-07-23 11:39 2359Here it is, my fist JAVA applic ... -
[AndroidTip]local reference table overflow (max=512)的错误解决
2012-07-22 22:56 6062JNI层coding经常会遇到ReferenceTable o ... -
[AndroidTip]EditText如何初始状态不获得焦点?
2012-07-22 15:35 1228最简单的办法是在EditText前面放置一个看不到的Linea ... -
[AndroidTip]android textview滚动条
2012-07-21 14:29 1303本来是想做一个显示文字信息的,当文字很多时View的高度不能超 ... -
Google公布Android 4.1完整功能
2012-07-16 09:48 3191http://www.android.com/about/je ...
相关推荐
Dalvik虚拟机是Android操作系统中用于执行应用程序的虚拟机。它的作用主要是解释执行Android应用程序中的Dalvik可执行文件(DEX格式),使得Java程序能够在Android设备上运行。Dalvik虚拟机与Java虚拟机(JVM)有很...
Android应用程序是运行在Dalvik虚拟机里面的,并且每一个应用程序对应有一个单独的Dalvik虚拟机实例。Android应用程序中的Dalvik虚拟机实例实际上是从Zygote进程的地址空间拷贝而来的,这样就可以加快Android应用...
**Android Dalvik虚拟机讲义** Android Dalvik虚拟机是Android操作系统的核心组成部分,它是Google为移动设备特别设计的一种高效、轻量级的虚拟机。在Android系统中,应用程序以Dalvik可执行文件(.dex)的形式运行...
Android Dalvik 文件编译方法 Android Dalvik 文件编译方法是 Android 应用程序开发过程中的一步关键步骤。 Dalvik 是 Android 操作系统中的虚拟机字节码格式,所有 Android 应用程序都需要将 Java 代码编译成 ...
《Android 4.0.4 Dalvik字节码详解》 在Android系统中,Dalvik虚拟机是核心组件之一,负责执行应用程序的字节码。本文档将深入探讨Android 4.0.4版本中Dalvik虚拟机所使用的字节码指令集,帮助开发者更好地理解和...
进入 Android Dalvik 虚拟机,android dalvik介绍 Dalvik 虚拟机的特点——掌握 Android 程序的运行原理 Android 系统的架构采用分层思想,这样的好处是拥有减少各层之间的依赖性、便于独 立分发、容易收敛问题和...
**Android Dalvik 源码解析** Android操作系统以其开源特性吸引了众多开发者,而Dalvik虚拟机作为Android系统的核心组成部分,负责运行应用程序。了解Dalvik的源码有助于我们深入理解Android应用的执行机制,优化...
【dalvik_hook_demo】是一个关于Android系统中Dalvik Hook技术的实际应用示例。在这个项目中,开发者通过hook技术对Dalvik虚拟机进行了深入的操作,展示了如何在运行时改变应用程序的行为,以此来达到调试、监控或者...
在Android操作系统中,Dalvik虚拟机扮演着至关重要的角色,它是Android系统早期版本中的核心组件,负责执行应用程序的字节码。在Android 4.2版本中,Dalvik虚拟机进一步优化,提升了性能和效率。这里我们将深入探讨...
根据提供的信息,我们可以深入探讨Dalvik虚拟机及其指令集的关键知识点。 ### Dalvik虚拟机概述 #### 1. Dalvik虚拟机的历史与地位 - **发布背景**:2007年底,随着Android SDK的正式发布,Dalvik虚拟机作为...
**Android的Dalvik虚拟机(Dalvik Virtual Machine, DVM)是Android系统中运行应用程序的核心组件之一。在Android系统早期版本中,应用是以Dalvik字节码(Dalvik Bytecode)的形式存储和执行的,而DEX(Dalvik ...
Dalvik opcodes是Android操作系统中Dalvik虚拟机执行指令集的一种核心元素。Dalvik虚拟机,作为Android系统早期的关键组成部分,是基于寄存器架构的轻量级VM,设计目标是优化资源有限的移动设备。在Dalvik虚拟机中,...
《Android编程之虚拟机Dalvik教程》是一份深入解析Android操作系统核心组件——Dalvik虚拟机的宝贵资料。本文将从多个角度详细介绍Dalvik虚拟机及其在Android开发中的重要性,帮助开发者深化对Android系统运行机制的...
【dalvik.zip】是一个包含Dalvik虚拟机源码的离线帮助文档,旨在为开发者提供一个全面、便捷的参考资源,无需在线搜索即可进行查阅。Dalvik是Android系统早期采用的一种专门为移动设备优化的Java虚拟机,它在Android...
Android Dalvik虚拟机是Android操作系统的核心组成部分,它为Android应用程序提供了运行环境。在这个环境中,应用程序的代码被转换成Dalvik可执行格式,称为.dex(Dalvik Executable)文件,然后在此虚拟机上运行。...
在Android系统中,Dalvik虚拟机是其运行应用程序的核心组件,它使用了一种特定的指令集,称为Dalvik字节码或操作码(Opcode)。这些操作码是Dalvik虚拟机执行程序的基础,对于理解Android应用的运行机制以及进行逆向...
**Android Dalvik虚拟机源码解析** Android操作系统中,Dalvik虚拟机扮演着至关重要的角色。它是Android系统的核心组件之一,负责运行应用程序的字节码(.dex文件)。Dalvik虚拟机是基于寄存器架构的,这与传统的...
《深入解析Android虚拟机Dalvik》 Android操作系统的核心之一就是其独特的虚拟机——Dalvik。这个名字源于美国科罗拉多州的一个小镇,寓意着在移动设备有限的资源下,为应用提供高效运行环境的愿景。本篇文章将深入...
Dalvik字节码是Android平台上的虚拟机Dalvik所执行的指令集,是Android应用开发中一个核心概念。Dalvik虚拟机是专门为Android操作系统设计的,用于运行Android应用程序。Android 4.0文档中提到的Dalvik字节码,它在...
### Dalvik虚拟机内存管理详解 #### 一、引言 Dalvik虚拟机作为Google针对Android平台设计的专有Java虚拟机实现,在Android系统中扮演着核心角色。它负责执行应用层代码,并提供了高效的内存管理和垃圾回收机制。...