Merge change If4f13b68 into eclair

* changes:
  Fix upstream ARM emulation bug that broke singlestep mode.
diff --git a/Makefile.android b/Makefile.android
index 6a8e3fd..e9a71c3 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -637,6 +637,20 @@
 
 LOCAL_GENERATED_SOURCES += $(QEMU_GDBSTUB_XML_C)
 
+# hw-config-defs.h is generated from android/avd/hardware-properties.ini
+#
+QEMU_HARDWARE_PROPERTIES_INI := $(LOCAL_PATH)/android/avd/hardware-properties.ini
+QEMU_HW_CONFIG_DEFS_H := $(LOCAL_PATH)/android/avd/hw-config-defs.h
+$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_PATH := $(LOCAL_PATH)
+$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_SOURCES := $(QEMU_HARDWARE_PROPERTIES_INI)
+$(QEMU_HW_CONFIG_DEFS_H): PRIVATE_CUSTOM_TOOL = $(PRIVATE_PATH)/android/tools/gen-hw-config.py $(QEMU_HARDWARE_PROPERTIES_INI) $@
+$(QEMU_HW_CONFIG_DEFS_H): $(QEMU_HARDWARE_PROPERTIES_INI) $(LOCAL_PATH)/android/tools/gen-hw-config.py
+	$(hide) rm -f $@
+	$(transform-generated-source)
+
+$(LOCAL_PATH)/android/avd/hw-config.h: $(QEMU_HW_CONFIG_DEFS_H)
+
+LOCAL_GENERATED_SOURCES += $(QEMU_HW_CONFIG_DEFS_H)
 
 # this is already done by the Android build system, but is done for the
 # benefit of the stand-alone one.
diff --git a/android/avd/hardware-properties.ini b/android/avd/hardware-properties.ini
index 8744d64..b3e486b 100644
--- a/android/avd/hardware-properties.ini
+++ b/android/avd/hardware-properties.ini
@@ -154,3 +154,11 @@
 default     = 160
 abstract    = Abstracted LCD density
 description = Must be one of 120, 160 or 240. A value used to roughly describe the density of the LCD screen for automatic resource/asset selection.
+
+# Maximum VM heap size
+# Higher values are required for high-dpi devices
+name        = vm.heapSize
+type        = integer
+default     = 16
+abstract    = Max VM application heap size
+description = The maximum heap size a Dalvik application might allocate before being killed by the system. Value is in megabytes.
diff --git a/android/avd/hw-config-defs.h b/android/avd/hw-config-defs.h
index b98f511..069ae23 100644
--- a/android/avd/hw-config-defs.h
+++ b/android/avd/hw-config-defs.h
@@ -157,6 +157,13 @@
   "Abstracted LCD density",
   "Must be one of 120, 160 or 240. A value used to roughly describe the density of the LCD screen for automatic resource/asset selection.")
 
+HWCFG_INT(
+  vm_heapSize,
+  "vm.heapSize",
+  16,
+  "Max VM application heap size",
+  "The maximum heap size a Dalvik application might allocate before being killed by the system. Value is in megabytes.")
+
 #undef HWCFG_INT
 #undef HWCFG_BOOL
 #undef HWCFG_DISKSIZE
diff --git a/android/main.c b/android/main.c
index 682cfce..6f73571 100644
--- a/android/main.c
+++ b/android/main.c
@@ -2399,7 +2399,7 @@
     }
 
     /* Check the size of the /data partition. The only interesting cases here are:
-     * - when the USERDATA image already exists and is larger than the deffault
+     * - when the USERDATA image already exists and is larger than the default
      * - when we're wiping data and the INITDATA is larger than the default.
      */
 
@@ -2638,6 +2638,14 @@
 
     hwLcd_setBootProperty(get_device_dpi(opts));
 
+    /* Set the VM's max heap size, passed as a boot property */
+    if (hw->vm_heapSize > 0) {
+        char  tmp[32], *p=tmp, *end=p + sizeof(tmp);
+        p = bufprint(p, end, "%dm", hw->vm_heapSize);
+
+        boot_property_add("dalvik.vm.heapsize",tmp);
+    }
+
     if (opts->prop != NULL) {
         ParamList*  pl = opts->prop;
         for ( ; pl != NULL; pl = pl->next ) {
diff --git a/android/tools/gen-hw-config.py b/android/tools/gen-hw-config.py
index 928ccc5..3822485 100755
--- a/android/tools/gen-hw-config.py
+++ b/android/tools/gen-hw-config.py
@@ -43,12 +43,17 @@
 targetHeader = """\
 /* this file is automatically generated from 'hardware-properties.ini'
  * DO NOT EDIT IT. To re-generate it, use android/tools/gen-hw-config.py'
- */"""
+ */
+"""
 
 # locate source and target
 programDir = os.path.dirname(sys.argv[0])
-sourceFile = os.path.normpath(os.path.join(programDir,relativeSourcePath))
-targetFile = os.path.normpath(os.path.join(programDir,relativeTargetPath))
+if len(sys.argv) != 3:
+    print "Usage: %s source target\n" % os.path.basename(sys.argv[0])
+    sys.exit(1)
+
+sourceFile = sys.argv[1]
+targetFile = sys.argv[2]
 
 # parse the source file and record items
 # I would love to use Python's ConfigParser, but it doesn't
@@ -94,16 +99,21 @@
 if lastItem:
     items.append(lastItem)
 
+if targetFile == '--':
+    out = sys.stdout
+else:
+    out = open(targetFile,"wb")
 
-print  targetHeader
+out.write(targetHeader)
 
 # write guards to prevent bad compiles
 for m in macroNames:
-    print """\
+    out.write("""\
 #ifndef %(macro)s
 #error  %(macro)s not defined
-#endif""" % { 'macro':m }
-print ""
+#endif
+""" % { 'macro':m })
+out.write("\n")
 
 for item in items:
     if item.type == None:
@@ -131,11 +141,12 @@
         # quote default value for strings
         varDefault = quoteStringForC(varDefault)
 
-    print "%s(\n  %s,\n  %s,\n  %s,\n  %s,\n  %s)\n" % \
-            (varMacro,varName,varNameStr,varDefault,varAbstract,varDesc)
+    out.write("%s(\n  %s,\n  %s,\n  %s,\n  %s,\n  %s)\n\n" % \
+            (varMacro,varName,varNameStr,varDefault,varAbstract,varDesc))
 
 
 for m in macroNames:
-    print "#undef %s" % m
+    out.write("#undef %s\n" % m)
 
-print "/* end of auto-generated file */"
+out.write("/* end of auto-generated file */\n")
+out.close()