dalvikvm is not showing LOGD messages of JIT Options - android

I have made some minor changes to /dalvik/vm/interp/Jit.cpp
(wrote some LOGD messages) and built dalvikvm using
$make dalvikvm
and the build was successful and got the executable in /out/
target/product/generic/system/bin/dalvikvm.
Now i started an emulator and pushed dalvikvm into /data and
executed a sample java program (with some 30 loops) using
$/data/dalvikvm -Xbootclasspath:/system/
framework/core.jar -classpath /data/CmdLine.jar TestAppActivity
(created CmdLine.jar from sample program by following
instructions given in http://davanum.wordpress.com/2007/12/04/command-line-java-on-dalvikvm/
)
now when i check the logcat there is no messages which i have
written using LOGD is displayed. Do we need to add any option to
dalvikvm command line to enable JIT? what could be the problem here?
Thanks

Jit is enabled by default if you are using android version above 2.2 i suppose. Your problem is the profiling of JIT has to be enabled in dvm. This can be don by looking into dalvikvm --help .... I think dalvikvm -Xjitprofile -Xjitverbose should do and before that export your environment variable to log the message too.

Try exporting the logs before running the dalvikvm something like this
export ANDROID_LOG_TAGS="ActivityManager:I MyApp:D *:S" the variables D -Debug S: lowest level V - verbose which is the level of log you need the application to be logged.

dalvikvm is just the starter binary. The important stuff lives in libdvm.so so you have to build and replace this rather than dalvikvm.

Related

Can we debug the APK with ASAN active on Android Studio?

My project is a simple game with native C++ code and Java, which uses cmake to compile C/C++ code. I'm using address sanitizer to check my the code. I follow the instruction here
My OS is windows 10 64bit.
However, when I press debug on Android Studio, I got the message as
2020-03-19 13:50:56.946 5152-5152/? E/logwrapper: executing /data/app/com.indie.haiphan.Breakout-ZFFz_f8ETleajrgP6rg9gw==/lib/arm64/wrap.sh failed: No such file or directory
2020-03-19 13:50:56.946 5151-5151/? I/wrap.sh: executing /data/app/com.indie.haiphan.Breakout-ZFFz_f8ETleajrgP6rg9gw==/lib/arm64/wrap.sh failed: No such file or directory
2020-03-19 13:50:56.956 5151-5151/? I/wrap.sh: wrap.sh terminated by exit(255)
2020-03-19 13:50:56.957 873-873/? W/Zygote: Error reading pid from wrapped process, child may have died
I checked on my APK (with Analyze APK of Android Studio) the wrap.sh exist.
So my question is I can't debug with wrap.sh inside the APK?
Thanks
You probably have BOM or an extra carriage return at the end of the first line of your wrap.sh. Which is possible in windows.
To fix it you can use dos2unix tool.
See this: https://unix.stackexchange.com/a/27067/197738

Android: debug shared library

I'd like to debug android NDK application, more precisely - I want to check what arguments (r4 - r8 r1 - r4 registers) are passed to function from shared library in apk.
What I have tried:
I've run gdbserver :1234 --attach on the device
I've run arm-linux-androideabi-gdb from ndk package by Google on the PC
I've set solib-search-path and written target remote :1234
So far, so good. Now I try to set breakpoint (break <function name>) (function name from
objdump), but I get repond: Cannot access memory at address <...>. info shared says the library is loaded, Does it mean I can't set breakpoint there? Or am I doing something wrong?
The ndk-build skript does much more then you would expect.
One of the things it to copy both the gdbserver, a file called gbd.setup and the generated .so into a hidden folder called .obj/armei/
There you will have to add the libraries you would like to debug because the symbols are referencing them.
The libraries are copied from the device to your PC by some adb shell pull - commands.
I wrote an article about the topic at: http://www.professional-android-development.com/articles/android-ndk-large-c-projects
When placing the libraries into the right folder, you can set your breakpoints.
Still, for some internal reasons, they can fail.
In this case run ndk-gdb --start (the first try will also fail), enforce the application to close and rerun ndk-gdb --start (this time not forcing the application to close).
"Cannot access memory at address <...>" usually means there is a mismatch between the .so file on your PC and the .so file that is on Android. Did you recompile and reinstall?
Btw, what is the reason you're not using "ndk-gdb"? That's a script (part of the NDK) that takes care of all the gory details for you.

Eclipse w/ADT crashing with "import android." statement in editor

I'm new to Android Dev and am following developer.android.com/training. I'm at the "starting another activity" section and whenever I try to enter "import android.view.View;" into MainActivity.Java, Eclipse crashes on me. Specifically I can type in "import android" and once I add the period it crashes. Am I missing or need to install additional files? My OS is Linux Mint.
Thanks for your help
Beginning of the error log that was generated:
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fb090ea7c91, pid=2473, tid=140399027877632
#
# JRE version: 7.0_25-b30
# Java VM: OpenJDK 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [libsoup-2.4.so.1+0x6ac91] soup_session_feature_detach+0x11
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
I tried looking at the error log more closely and after searching this line:
C [libsoup-2.4.so.1+0x6ac91] soup_session_feature_detach+0x11
I came across this solution.
Adding the following to my eclipse.ini file fixed the problem, though I am clueless as to how or why...
-Dorg.eclipse.swt.browser.DefaultType=mozilla
I don't typically type in import statements. In Eclipse I use the Ctrl + Shift + O shortcut that will bring in all the missing imports.
Do you have your environment variables set, something like
setenv PATH /usr/local/jdk1.6.0_15/bin:$PATH
setenv JAVA_HOME /usr/local/jdk1.6.0_15

For a native android application that seg faults, why is there no stack trace in logcat?

Pretty self explanatory. I compiled a native c++ exe using the ndk. When I run the app, it gets a SIGSEGV, seg faults and exits. There is no stack trace or cpu context in the logcat.
Why? Any suggestions on how to fix it?
there are two tools you can use to debug your sigsev. ndk-stack and arm-linux-androideabi-addr2line located into your $NDK dir.The first help you to filter the stacktrace and addr2line translates program addresses into file names and line num. Check into your $NDK dir, for the documentation.
You're all wrong, you need to enable logging to logcat for STDIO and STDERR.
http://developer.android.com/tools/debugging/debugging-log.html#viewingStd

how to see more infomation in ndk-gdb when the program breakdown

I use eclipse and ndk-gdb to debug my AndroidNDK program,but i find a problem,the ndk-gdb tools seems do not have the function of "saving the stack" when the program breakdown,i cannot find detail infomation from the ndk-gdb,it does not point which function,which class and which line,just give the info like this:*Program received signal SIGSEGV, Segmentation fault.0xafd0cda4 in memcpy ()
from D:/android/ndk/samples/mango_d/obj/local/armeabi/libc.so*
so , i was wondering if there is a way to see more infomation(the last sentence the program called or others) when the program breakdown,thank you fist
You could try utilize the ndk-stack program, consult to the doc in the ndk, docs/NDK-STACK.html
If you compile the c source by
ndk-build NDK_DEBUG=1 APP_OPTIM=debug
you should be able to call something similar like this one
adb -s %TARGET_INSTALL% logcat DEBUG:I | ndk-stack -sym ./obj/local/armeabi-v7a
that one will give you the source code and line stack trace for the seg-fault.

Categories

Resources