I figured the problem, the typedef DexTypeItem was getting padded to 4
bytes even though it has only one u2 property. This was causing the
structure array to be misaligned. The strange thing is when I compiled
libdex, I passed the same gcc options as that of in the Android
environment.

Now I am debugging the next issue "Too many exceptions during init".
Any pointers?

r...@172:/system/bin# dalvikvm -Xbootclasspath:/system/framework/
core.jar -classpath /data/HelloWorld.jar org.apache.HelloWorld
V( 5387) VM init args (3):  (dalvikvm)
V( 5387)   0: '-Xbootclasspath:/system/framework/core.jar'  (dalvikvm)
V( 5387)   1: '-classpath'  (dalvikvm)
V( 5387)   2: '/data/HelloWorld.jar'  (dalvikvm)
V( 5387) VM options (3):  (dalvikvm)
V( 5387)   0: '-Xbootclasspath:/system/framework/core.jar'  (dalvikvm)
V( 5387)   1: '-classpath'  (dalvikvm)
V( 5387)   2: '/data/HelloWorld.jar'  (dalvikvm)
V( 5387) Using executionMode 2  (dalvikvm)
V( 5387) mterp: interp is 16384 bytes, sisters are 2608 bytes
(dalvikvm)
V( 5387) Creating VM heap of size 2097152  (dalvikvm-heap)
V( 5387) threadid=3: interp stack at 0x40016000  (dalvikvm)
V( 5387) LinearAlloc: created region at 0x4153b000-0x4193afff
(dalvikvm)
V( 5387) Opening archive '/system/framework/core.jar' 0xbe877ab4
(dalvikvm)
V( 5387) +++ numEntries=26 cdOffset=1557197  (dalvikvm)
V( 5387) Couldn't open /system/framework/core.odex: No such file or
directory  (dalvikvm)
V( 5387) Cache file for '/system/framework/core.jar' 'classes.dex' is
'/data/dalvik-cache/sys...@framework@core....@classes.dex'  (dalvikvm)
V( 5387) dvmDexCacheStatus: Checking cache for /system/framework/
core.jar (/data/dalvik-cache/sys...@framework@core....@classes.dex)
(dalvikvm)
V( 5387) DexOpt: locking cache file /data/dalvik-cache/
sys...@framework@core....@classes.dex (fd=4, boot=1)  (dalvikvm)
V( 5387) DexOpt:  locked cache file  (dalvikvm)
V( 5387) checking deps, expecting vfy=1 opt=1  (dalvikvm)
W( 5387) DexOpt: incorrect opt magic number (0xff ff ff ff)
(dalvikvm)
D( 5387) Stale deps in cache file; removing and retrying  (dalvikvm)
V( 5387) DexOpt: locking cache file /data/dalvik-cache/
sys...@framework@core....@classes.dex (fd=4, boot=1)  (dalvikvm)
V( 5387) DexOpt:  locked cache file  (dalvikvm)
V( 5387) DexOpt: successfully initialized new cache file  (dalvikvm)
D( 5387) DexOpt: --- BEGIN 'core.jar' (bootstrap=1) ---  (dalvikvm)
V( 5387) DexOpt: waiting for verify+opt, pid=5388  (dalvikvm)
V( 5388) Creating VM heap of size 2097152  (dalvikvm-heap)
V( 5388) threadid=3: interp stack at 0x40016000  (dalvikvm)
V( 5388) LinearAlloc: created region at 0x4153b000-0x4193afff
(dalvikvm)
V( 5388) Continuing optimization (/system/framework/core.jar, isb=1,
vfy=1, opt=1)  (dalvikvm)
V( 5388) +++ swapping and verifying  (dalvikvm)
V( 5396) +++ DEX 0x191e0: allocateAux 27166+2910+24694+9879 * 4 =
258596 bytes  (dalvikvm)
V( 5396) Class lookup: classes=2760 slots=8192 (33% occ) alloc=98312
total=768 max=10  (dalvikvm)
V( 5396) DexOpt: +++ trying to load 2760 classes  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70cd0, now 1  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/lang/Class;' (nil) (isnew=1) -->
0x404fb340  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70ce8, now 2  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/lang/Object;' (nil) (isnew=1) --
> 0x404fb3e8  (dalvikvm)
V( 5396) +++ threadid=3: removed 0x70ce8, now 1  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70ce8, now 2  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/io/Serializable;' (nil)
(isnew=1) --> 0x404fb490  (dalvikvm)
V( 5396) +++ threadid=3: removed 0x70ce8, now 1  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70ce8, now 2  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/lang/reflect/
GenericDeclaration;' (nil) (isnew=1) --> 0x404fb538  (dalvikvm)
V( 5396) +++ threadid=3: removed 0x70ce8, now 1  (dalvikvm)
V( 5396) THROW 'Ljava/lang/NoClassDefFoundError;' msg='D' cause=
(none)  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70ce8, now 2  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/lang/
NoClassDefFoundError;' (nil) (isnew=1) --> 0x404fb5e0  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70d40, now 3  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/lang/LinkageError;' (nil)
(isnew=1) --> 0x404fb688  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70d78, now 4  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/lang/Error;' (nil) (isnew=1) -->
0x404fb730  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70db0, now 5  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/lang/Throwable;' (nil) (isnew=1)
--> 0x404fb7d8  (dalvikvm)
V( 5396) --- LinearRealloc(84) old=92  (dalvikvm)
V( 5396) +++ threadid=3: removed 0x70db0, now 4  (dalvikvm)
V( 5396) +++ threadid=3: removed 0x70d78, now 3  (dalvikvm)
V( 5396) +++ threadid=3: removed 0x70d40, now 2  (dalvikvm)
V( 5396) +++ threadid=3: removed 0x70ce8, now 1  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70ce8, now 2  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70d78, now 3  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/lang/String;' (nil) (isnew=1) --
> 0x404fb880  (dalvikvm)
V( 5396) +++ threadid=3: added 0x70db0, now 4  (dalvikvm)
V( 5396) +++ dvmAddClassToHash 'Ljava/lang/CharSequence;' (nil)
(isnew=1) --> 0x404fb928  (dalvikvm)
V( 5396) +++ threadid=3: removed 0x70db0, now 3  (dalvikvm)
V( 5396) THROW 'Ljava/lang/NoClassDefFoundError;' msg='F' cause=
(none)  (dalvikvm)
E( 5396) Too many exceptions during init (failed on 'Ljava/lang/
NoClassDefFoundError;' 'F')  (dalvikvm)
E( 5396) VM aborting  (dalvikvm)
W( 5395) DexOpt: --- END 'core.jar' --- status=0x008b, process failed
(dalvikvm)
E( 5395) Unable to extract+optimize DEX from '/system/framework/
core.jar'  (dalvikvm)
V( 5395) Closing archive 0xbe825aa4  (dalvikvm)
V( 5395) munmap(0x4193b000, 1559732) succeeded  (dalvikvm)
D( 5395) Failed on '/system/framework/core.jar' (boot=1)  (dalvikvm)
V( 5395) VM shutting down  (dalvikvm)
D( 5395) VM cleaning up  (dalvikvm)
V( 5395) Unmapping linear allocator base=0x4153b000  (dalvikvm)
D( 5395) LinearAlloc (nil) used 4100 of 4194304 (0%)  (dalvikvm)
W( 5395) JNI_CreateJavaVM failed  (dalvikvm)
Dalvik VM init failed (check log file)


On Mar 12, 7:54 pm, fadden <fad...@android.com> wrote:
> On Mar 12, 10:02 am, Sean McNeil <seanmcne...@gmail.com> wrote:
>
> > I'm not sure, but could this also be related to short enums? I seem to
> > remember seeing something like this when I had a mixture of old code
> > compiled with and new code compiled without short enums.
>
> Everything related to DEX file access should be using the "physical"
> size types; by tradition u1/u2/u4/u8.  Optimized DEX files are allowed
> to be non-portable, but the base classes.dex should not be subject to
> the whims of compilers (either while reading or writing).
>
> Of course, if half the code is compiled one way and half the other
> way, many obscure failure modes are possible.
>
> The easiest way to debug this might be to run the VM on the same
> core.jar on a working platform, and step through both simultaneously
> (either with a debugger or with logs) and identify the point where one
> goes off the rails.
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting
-~----------~----~----~----~------~----~------~--~---

Reply via email to