0

I have changed the structure of the JIT table (pJitEntryTable in / dalvik/vm/Globals.h) from a chained array(sort of hash) to a combination of hash table and B-tree. It finds hashed value based on PC and enters the corresponding JitEntry(dalvik address,translated address) into the b-tree pointed by the hashed index. I built the code successfully and pushed libdvm.so file into the emulator and rebooted the emulator by killing zygote. But the boot screen is showing "android" for infinite time and when i did a $adb logcat i found the following log

   I/DEBUG   (   33): *** *** *** *** *** *** *** *** *** *** *** *** 
*** *** *** *** 
I/DEBUG   (   33): Build fingerprint: 'generic/sdk/generic:4.0.3/ 
MR1/237985:eng/test-keys' 
I/DEBUG   (   33): pid: 491, tid: 520  >>> system_server <<< 
I/DEBUG   (   33): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault 
addr 002e0080 
I/DEBUG   (   33):  r0 002e0081  r1 4d685228  r2 00000014  r3 002e006d 
I/DEBUG   (   33):  r4 4d685228  r5 51669e38  r6 001de3b8  r7 000086f4 
I/DEBUG   (   33):  r8 407d9dc0  r9 00000002  10 00000000  fp 520a0e68 
I/DEBUG   (   33):  ip 00000030  sp 520a0da0  lr 00000000  pc 
002e0080  cpsr 20000030 
I/DEBUG   (   33):  d0  437000004382353f  d1  3ff0000043700000 
I/DEBUG   (   33):  d2  3ff0000000000000  d3  4197d78400000000 
I/DEBUG   (   33):  d4  3ff0000000000000  d5  4028000000000000 
I/DEBUG   (   33):  d6  43e0000000000000  d7  000000f000000000 
I/DEBUG   (   33):  d8  0000000000000000  d9  0000000000000000 
I/DEBUG   (   33):  d10 0000000000000000  d11 0000000000000000 
I/DEBUG   (   33):  d12 0000000000000000  d13 0000000000000000 
I/DEBUG   (   33):  d14 0000000000000000  d15 0000000000000000 
I/DEBUG   (   33):  scr 80000012 
I/DEBUG   (   33): 
D/dalvikvm(  491): in getCodeAddrCommon function 
D/dalvikvm(  491): searching in the JIT table 
I/DEBUG   (   33):          #00  pc 002e0080 
I/DEBUG   (   33):          #01  lr 00000000  <unknown> 
I/DEBUG   (   33): 
I/DEBUG   (   33): code around pc: 
I/DEBUG   (   33): 002e0060 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 002e0070 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 002e0080 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 002e0090 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 002e00a0 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 
I/DEBUG   (   33): code around lr: 
I/DEBUG   (   33): 00000000 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 00000010 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 00000020 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 00000030 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 00000040 ffffffff ffffffff ffffffff 
ffffffff  ................ 
I/DEBUG   (   33): 
I/DEBUG   (   33): memory map around addr 002e0080: 
I/DEBUG   (   33): 0000b000-00237000 [heap] 
I/DEBUG   (   33): (no map for address) 
I/DEBUG   (   33): 10000000-10001000 
I/DEBUG   (   33): 
I/DEBUG   (   33): stack: 
I/DEBUG   (   33):     520a0d60  4d685228  /system/framework/ 
framework.odex 
I/DEBUG   (   33):     520a0d64  00000000 
I/DEBUG   (   33):     520a0d68  00000000 
I/DEBUG   (   33):     520a0d6c  407d9dc0  /system/lib/libdvm.so 
I/DEBUG   (   33):     520a0d70  00000002 
I/DEBUG   (   33):     520a0d74  00000000 
I/DEBUG   (   33):     520a0d78  520a0e68 
I/DEBUG   (   33):     520a0d7c  4083c78b  /system/lib/libdvm.so 
I/DEBUG   (   33):     520a0d80  4d685228  /system/framework/ 
framework.odex 
I/DEBUG   (   33):     520a0d84  51669e38 
I/DEBUG   (   33):     520a0d88  001de3b8  [heap] 
I/DEBUG   (   33):     520a0d8c  000086f4  /system/bin/app_process 
I/DEBUG   (   33):     520a0d90  407d9dc0  /system/lib/libdvm.so 
I/DEBUG   (   33):     520a0d94  4083c7e5  /system/lib/libdvm.so 
I/DEBUG   (   33):     520a0d98  df0027ad 
I/DEBUG   (   33):     520a0d9c  00000000 
I/DEBUG   (   33): #00 520a0da0  00000000 
I/DEBUG   (   33):     520a0da4  001de3b8  [heap] 
I/DEBUG   (   33):     520a0da8  4086ef90  /system/lib/libdvm.so 
I/DEBUG   (   33):     520a0dac  520a0dd8 
I/DEBUG   (   33):     520a0db0  44e6bb60  /dev/ashmem/dalvik- 
LinearAlloc (deleted) 
I/DEBUG   (   33):     520a0db4  520a0e1c 
I/DEBUG   (   33):     520a0db8  00000000 
I/DEBUG   (   33):     520a0dbc  fffffe60 
I/DEBUG   (   33):     520a0dc0  520a0e68 
I/DEBUG   (   33):     520a0dc4  407ef200  /system/lib/libdvm.so 
I/DEBUG   (   33):     520a0dc8  00000000 
I/DEBUG   (   33):     520a0dcc  00000000 
I/DEBUG   (   33):     520a0dd0  00000000 
I/DEBUG   (   33):     520a0dd4  520a0eb8 
I/DEBUG   (   33):     520a0dd8  00000000 
I/DEBUG   (   33):     520a0ddc  00000000 
I/DEBUG   (   33):     520a0de0  00000000 
I/DEBUG   (   33):     520a0de4  00000000 
I don't understand the error. Do i need to make any adjustments to the 
jit code cache size and heap size? Any help regarding this will be 
appreciated. 
Thanks
Boe-Dev
  • 1,585
  • 2
  • 14
  • 26

1 Answers1

1

This is a segfault crash. Something is trying to access a segment of memory that hasn't been allocated, or it is otherwise not allowed to. This most likely indicates a bug in the libdvm changes that you made.

Debugging will be tricky. What I would try is to build a libdvm_new.so and dalvikvm_new binary that links against it, and push those to a device/emulator (rather than replacing the existing libdvm.so and dalvikvm) and then use gdb-server and gdb to debug dalvikvm_new, on a command line type program (the typical static void main(String[] args) type program).

JesusFreke
  • 19,784
  • 5
  • 65
  • 68
  • Good idea - while most DVM processes are forked off of zygote and automatically use whatever is installed as "the" dvm, it's actually possible to start one separately from the command line, and for testing that would be preferable since it leaves the rest of the platform running on unmodified dvm's. – Chris Stratton Apr 26 '12 at 17:12
  • Hi thanks for the reply. I would like to try out this method but i am totally ignorant of usage of gdb so could you please point me to a link where i can get started? – user1262185 Apr 27 '12 at 03:49
  • It's really not that hard to find this info. A quick search leads to http://stackoverflow.com/questions/5945086/how-to-debug-an-dalvik-executable-on-android-with-gdb – JesusFreke Apr 27 '12 at 03:54
  • Do i need to add -g flag in the Android.mk file to enable for gdb debugging or is it taken care of? I ask this because in discussion here http://groups.google.com/group/android-platform/browse_thread/thread/b4de9ed8f99a550a/ac3d63cefb12b0f3?lnk=gst&q=dalvik+debug+gdb#ac3d63cefb12b0f3 they did not specify to add -g flag – user1262185 Apr 27 '12 at 07:39
  • could you please tell me how to create a binary which links to libdvm.so and how do we execute a program using that binary? – user1262185 Apr 27 '12 at 10:38
  • hey i tried the above method and the segmentation fault is at at bionic/linker/linker.c:139 139 HOODLUM(calloc, void *, (size_t cnt, size_t size)); warning: (Internal error: pc 0xe in read in psymtab, but not in symtab.) warning: (Internal error: pc 0xe in read in psymtab, but not in symtab.) i have no idea why error is at linker.c when i have made no modifications there? – user1262185 Apr 27 '12 at 13:06