aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--annotations/NOTICE (renamed from files/sdk_files_NOTICE.txt)7
-rw-r--r--annotations/build.gradle20
-rw-r--r--apps/SdkController/NOTICE190
-rw-r--r--avdlauncher/Android.mk2
-rw-r--r--avdlauncher/build.gradle36
-rw-r--r--avdlauncher/src/source/avdlauncher.c (renamed from avdlauncher/avdlauncher.c)0
-rw-r--r--bash_completion/adb.bash4
-rw-r--r--build.gradle150
-rwxr-xr-xbuild/patch_windows_sdk.sh14
-rw-r--r--build/product_sdk.mk5
-rw-r--r--build/tools.atree143
-rw-r--r--build/tools.darwin.atree39
-rw-r--r--build/tools.linux.atree33
-rwxr-xr-xbuild/tools.windows.atree125
-rw-r--r--build/windows_sdk_tools.mk25
-rw-r--r--build/windows_sdk_whitelist.mk30
-rw-r--r--eclipse/.gitignore3
-rw-r--r--eclipse/TYCHO_BUILD6
-rw-r--r--eclipse/artifacts/bundles/.project11
-rw-r--r--eclipse/artifacts/bundles/category.xml32
-rw-r--r--eclipse/artifacts/bundles/ide.p2.inf9
-rw-r--r--eclipse/artifacts/bundles/ide.product60
-rw-r--r--eclipse/artifacts/bundles/monitor.product61
-rw-r--r--eclipse/artifacts/bundles/pom.xml63
-rw-r--r--eclipse/artifacts/p2repo/.project11
-rw-r--r--eclipse/artifacts/p2repo/category.xml29
-rw-r--r--eclipse/artifacts/p2repo/pom.xml17
-rw-r--r--eclipse/build.gradle196
-rw-r--r--eclipse/features/com.android.ide.eclipse.adt.package/build.properties3
-rw-r--r--eclipse/features/com.android.ide.eclipse.adt.package/feature.xml90
-rw-r--r--eclipse/features/com.android.ide.eclipse.adt.package/p2.inf2
-rw-r--r--eclipse/features/com.android.ide.eclipse.adt.package/pom.xml17
-rw-r--r--eclipse/features/com.android.ide.eclipse.adt/feature.xml14
-rw-r--r--eclipse/features/com.android.ide.eclipse.adt/pom.xml17
-rw-r--r--eclipse/features/com.android.ide.eclipse.ddms/feature.xml8
-rw-r--r--eclipse/features/com.android.ide.eclipse.ddms/pom.xml17
-rw-r--r--eclipse/features/com.android.ide.eclipse.gldebugger/feature.xml4
-rw-r--r--eclipse/features/com.android.ide.eclipse.gldebugger/pom.xml17
-rw-r--r--eclipse/features/com.android.ide.eclipse.hierarchyviewer/feature.xml8
-rw-r--r--eclipse/features/com.android.ide.eclipse.hierarchyviewer/pom.xml17
-rw-r--r--eclipse/features/com.android.ide.eclipse.monitor/.project17
-rw-r--r--eclipse/features/com.android.ide.eclipse.monitor/build.properties1
-rw-r--r--eclipse/features/com.android.ide.eclipse.monitor/feature.xml233
-rw-r--r--eclipse/features/com.android.ide.eclipse.monitor/pom.xml17
-rw-r--r--eclipse/features/com.android.ide.eclipse.ndk/feature.xml4
-rw-r--r--eclipse/features/com.android.ide.eclipse.ndk/pom.xml17
-rw-r--r--eclipse/features/com.android.ide.eclipse.pdt/feature.xml2
-rw-r--r--eclipse/features/com.android.ide.eclipse.tests/feature.xml2
-rw-r--r--eclipse/features/com.android.ide.eclipse.traceview/feature.xml10
-rw-r--r--eclipse/features/com.android.ide.eclipse.traceview/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.overlay/META-INF/MANIFEST.MF2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.overlay/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/.classpath8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/.project6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/META-INF/MANIFEST.MF13
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/about.mappings1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/build.properties2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/ide.product46
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/plugin.xml38
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/plugin_customization.ini2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt.package/src/com/android/ide/eclipse/adt/internal/AdtIntro.java168
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/.classpath30
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF10
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/adt-platform-juno-sr2.target25
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/adt.launch33
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/build.properties3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/libs/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java43
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java52
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/VersionCheck.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java111
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AvdManagerAction.java2
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/DexDumpAction.java19
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkManagerAction.java10
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexWrapper.java3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java15
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/ResourceManagerBuilder.java31
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java69
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/Configuration.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationChooser.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationDescription.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ThemeMenuAction.java43
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java40
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LintOverlay.java3
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java15
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java171
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java194
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetAttributeFix.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java97
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java24
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java23
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java46
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/welcome/AdtStartup.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java22
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/BuildFileCreator.java100
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/GradleExportWizard.java1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/ImportInsteadPage.java56
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java29
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java30
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java147
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java9
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java39
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateWizard.java19
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TypedVariable.java50
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.base/.classpath28
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.base/META-INF/MANIFEST.MF13
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.base/build.properties5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.base/libs/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.base/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/.classpath12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/META-INF/MANIFEST.MF2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/build.properties1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/libs/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOptionsDialogV1.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/.classpath5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/META-INF/MANIFEST.MF2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/pom.xml17
-rwxr-xr-xeclipse/plugins/com.android.ide.eclipse.gldebugger/.classpath6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/META-INF/MANIFEST.MF4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/build.properties7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/DisplayRadix.java21
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLBooleanProperty.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLIntegerProperty.java4
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLLongProperty.java73
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLObjectProperty.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java7
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java10
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/build.properties1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/.classpath6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/META-INF/MANIFEST.MF2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/build.properties5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/libs/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/monitor.launch32
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/monitor.product89
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/plugin.properties2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml12
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorWorkbenchWindowAdvisor.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ndk/.classpath6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ndk/META-INF/MANIFEST.MF2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.ndk/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/.classpath32
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF15
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/build.properties1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/pom.xml17
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java45
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java8
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandlerTest.java24
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java6
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationTest.java5
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/.classpath2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/build.properties2
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/libs/.gitignore1
-rw-r--r--eclipse/plugins/com.android.ide.eclipse.traceview/pom.xml17
-rw-r--r--eclipse/pom.xml196
-rwxr-xr-xeclipse/scripts/build_adt.sh49
-rwxr-xr-xeclipse/scripts/build_server.sh8
-rwxr-xr-xeclipse/scripts/create_all_symlinks.sh4
-rwxr-xr-xeclipse/scripts/update_version.sh16
-rw-r--r--eclipse/settings.xml8
-rw-r--r--eclipse/sites/external/site.xml12
-rw-r--r--eclipse/sites/internal/site.xml16
-rw-r--r--emulator/NOTICE190
-rw-r--r--emulator/mksdcard/.gitignore3
-rw-r--r--emulator/mksdcard/Android.mk2
-rw-r--r--emulator/mksdcard/NOTICE213
-rw-r--r--emulator/mksdcard/build.gradle51
-rw-r--r--emulator/mksdcard/src/source/mksdcard.c (renamed from emulator/mksdcard/mksdcard.c)0
-rw-r--r--emulator/opengl/Android.mk37
-rw-r--r--emulator/opengl/common.mk26
-rwxr-xr-xemulator/opengl/gen-encoder.sh9
-rw-r--r--emulator/opengl/googletest.mk43
-rw-r--r--emulator/opengl/host/libs/GLESv1_dec/Android.mk18
-rw-r--r--emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp20
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/Android.mk18
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp7
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/Android.mk13
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglContext.h4
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp51
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglDisplay.h7
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp10
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h11
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglImp.cpp54
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglSurface.h7
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp31
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp24
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp17
-rw-r--r--emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp58
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/Android.mk13
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp2
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h6
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp2
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h1
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp26
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/Android.mk12
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp5
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h1
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp19
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp1
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp4
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/Android.mk28
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp41
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp12
-rw-r--r--emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp174
-rw-r--r--emulator/opengl/host/libs/Translator/include/ETC1/etc1.h106
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h6
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h2
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h4
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h41
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h163
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h4
-rw-r--r--emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h16
-rw-r--r--emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h282
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/Android.mk28
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp28
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h4
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp1
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp38
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h7
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/RenderContext.h4
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp14
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp2
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp19
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp5
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/WindowSurface.h4
-rw-r--r--emulator/opengl/host/libs/renderControl_dec/Android.mk16
-rw-r--r--emulator/opengl/host/libs/renderControl_dec/renderControl.in1
-rw-r--r--emulator/opengl/host/renderer/main.cpp2
-rw-r--r--emulator/opengl/host/tools/emugen/Android.mk36
-rw-r--r--emulator/opengl/host/tools/emugen/ApiGen.cpp40
-rw-r--r--emulator/opengl/host/tools/emugen/ApiGen.h2
-rw-r--r--emulator/opengl/host/tools/emugen/getopt.c76
-rw-r--r--emulator/opengl/host/tools/emugen/getopt.h18
-rw-r--r--emulator/opengl/host/tools/emugen/main.cpp1
-rw-r--r--emulator/opengl/sdl.mk25
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/Android.mk22
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h22
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp1
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h4
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp294
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h30
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/SmartPtr.h167
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp5
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp72
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp8
-rw-r--r--emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp2
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/Android.mk19
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp10
-rw-r--r--emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp3
-rw-r--r--emulator/opengl/shared/emugl/common/Android.mk54
-rw-r--r--emulator/opengl/shared/emugl/common/id_to_object_map.cpp236
-rw-r--r--emulator/opengl/shared/emugl/common/id_to_object_map.h176
-rw-r--r--emulator/opengl/shared/emugl/common/id_to_object_map_unittest.cpp116
-rw-r--r--emulator/opengl/shared/emugl/common/lazy_instance.cpp101
-rw-r--r--emulator/opengl/shared/emugl/common/lazy_instance.h156
-rw-r--r--emulator/opengl/shared/emugl/common/lazy_instance_unittest.cpp146
-rw-r--r--emulator/opengl/shared/emugl/common/mutex.h92
-rw-r--r--emulator/opengl/shared/emugl/common/mutex_unittest.cpp108
-rw-r--r--emulator/opengl/shared/emugl/common/pod_vector.cpp150
-rw-r--r--emulator/opengl/shared/emugl/common/pod_vector.h265
-rw-r--r--emulator/opengl/shared/emugl/common/pod_vector_unittest.cpp127
-rw-r--r--emulator/opengl/shared/emugl/common/scoped_pointer_vector.h27
-rw-r--r--emulator/opengl/shared/emugl/common/smart_ptr.cpp113
-rw-r--r--emulator/opengl/shared/emugl/common/smart_ptr.h150
-rw-r--r--emulator/opengl/shared/emugl/common/smart_ptr_unittest.cpp140
-rw-r--r--emulator/opengl/shared/emugl/common/sockets.cpp222
-rw-r--r--emulator/opengl/shared/emugl/common/sockets.h57
-rw-r--r--emulator/opengl/shared/emugl/common/testing/test_thread.h78
-rw-r--r--emulator/opengl/shared/emugl/common/thread_store.cpp242
-rw-r--r--emulator/opengl/shared/emugl/common/thread_store.h110
-rw-r--r--emulator/opengl/shared/emugl/common/thread_store_unittest.cpp146
-rw-r--r--emulator/opengl/tests/emulator_test_renderer/Android.mk13
-rw-r--r--emulator/opengl/tests/event_injector/sockets.c4
-rw-r--r--emulator/opengl/tests/translator_tests/GLES_CM/Android.mk13
-rw-r--r--emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp11
-rw-r--r--emulator/opengl/tests/translator_tests/GLES_V2/Android.mk12
-rw-r--r--emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp16
-rw-r--r--emulator/opengl/tests/ut_renderer/Android.mk2
-rw-r--r--emulator/opengl/tests/ut_renderer/Renderer.cpp12
-rw-r--r--emulator/opengl/tests/ut_renderer/Renderer.h4
-rw-r--r--emulator/qtools/Android.mk157
-rw-r--r--emulator/qtools/armdis.cpp905
-rw-r--r--emulator/qtools/armdis.h45
-rw-r--r--emulator/qtools/bb2sym.cpp140
-rw-r--r--emulator/qtools/bb_dump.cpp47
-rw-r--r--emulator/qtools/bbprof.cpp222
-rw-r--r--emulator/qtools/bitvector.h40
-rw-r--r--emulator/qtools/callstack.h775
-rw-r--r--emulator/qtools/check_stack.cpp270
-rw-r--r--emulator/qtools/check_trace.cpp61
-rw-r--r--emulator/qtools/coverage.cpp153
-rw-r--r--emulator/qtools/decoder.cpp278
-rw-r--r--emulator/qtools/decoder.h28
-rw-r--r--emulator/qtools/dmtrace.cpp255
-rw-r--r--emulator/qtools/dmtrace.h61
-rw-r--r--emulator/qtools/dump_regions.cpp59
-rw-r--r--emulator/qtools/exc_dump.cpp28
-rw-r--r--emulator/qtools/gtrace.cpp152
-rw-r--r--emulator/qtools/gtrace.h69
-rw-r--r--emulator/qtools/hash_table.h219
-rw-r--r--emulator/qtools/hist_trace.cpp64
-rw-r--r--emulator/qtools/opcode.cpp204
-rw-r--r--emulator/qtools/opcode.h166
-rw-r--r--emulator/qtools/parse_options-inl.h155
-rw-r--r--emulator/qtools/parse_options.cpp119
-rw-r--r--emulator/qtools/parse_options.h32
-rw-r--r--emulator/qtools/post_trace.cpp151
-rw-r--r--emulator/qtools/profile_pid.cpp94
-rw-r--r--emulator/qtools/profile_trace.cpp131
-rw-r--r--emulator/qtools/q2dm.cpp274
-rw-r--r--emulator/qtools/q2g.cpp108
-rw-r--r--emulator/qtools/read_addr.cpp29
-rw-r--r--emulator/qtools/read_elf.cpp210
-rw-r--r--emulator/qtools/read_elf.h20
-rw-r--r--emulator/qtools/read_method.cpp137
-rw-r--r--emulator/qtools/read_pid.cpp71
-rw-r--r--emulator/qtools/read_trace.cpp165
-rw-r--r--emulator/qtools/stack_dump.cpp156
-rw-r--r--emulator/qtools/tests/common_head.mk25
-rw-r--r--emulator/qtools/tests/common_tail.mk3
-rw-r--r--emulator/qtools/tests/gtrace/Makefile18
-rw-r--r--emulator/qtools/tests/gtrace/test.c201
-rw-r--r--emulator/qtools/tests/macros.h93
-rw-r--r--emulator/qtools/tests/tests.ld10
-rw-r--r--emulator/qtools/thumbdis.cpp503
-rw-r--r--emulator/qtools/trace_reader.cpp1201
-rw-r--r--emulator/qtools/trace_reader.h1559
-rw-r--r--emulator/qtools/trace_reader_base.h332
-rw-r--r--files/NOTICE190
-rw-r--r--files/ant/NOTICE190
-rw-r--r--files/ant/build.xml2
-rw-r--r--files/devices.xml6
-rw-r--r--files/plugin.prop4
-rw-r--r--files/tools_source.properties4
-rw-r--r--find_java/build.gradle41
-rwxr-xr-xfind_java/src/source/find_java.h (renamed from find_java/find_java.h)0
-rw-r--r--find_java/src/source/find_java_exe.cpp (renamed from find_java/find_java_exe.cpp)0
-rwxr-xr-xfind_java/src/source/find_java_lib.cpp (renamed from find_java/find_java_lib.cpp)0
-rwxr-xr-xfind_java/src/source/utils.cpp (renamed from find_java/utils.cpp)0
-rwxr-xr-xfind_java/src/source/utils.h (renamed from find_java/utils.h)0
-rw-r--r--monitor/build.gradle114
-rw-r--r--p2gen/README.txt73
-rw-r--r--p2gen/pom.xml137
-rw-r--r--sdklauncher/Android.mk2
-rw-r--r--sdklauncher/build.gradle36
-rw-r--r--sdklauncher/src/source/sdklauncher.c (renamed from sdklauncher/sdklauncher.c)0
-rw-r--r--templates/NOTICE190
-rw-r--r--templates/docs/default.css38
-rw-r--r--templates/docs/default.js33
-rwxr-xr-x[-rw-r--r--]templates/docs/index.html245
378 files changed, 9546 insertions, 12878 deletions
diff --git a/files/sdk_files_NOTICE.txt b/annotations/NOTICE
index 1fdb31d..967eceb 100644
--- a/files/sdk_files_NOTICE.txt
+++ b/annotations/NOTICE
@@ -1,9 +1,5 @@
-Notice for all the files in this folder.
-------------------------------------------------------------
-
-
- Copyright (c) 2005-2008, The Android Open Source Project
+ Copyright (c) 2012-2014, The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@@ -192,4 +188,3 @@ Notice for all the files in this folder.
END OF TERMS AND CONDITIONS
-
diff --git a/annotations/build.gradle b/annotations/build.gradle
new file mode 100644
index 0000000..21f1d7b
--- /dev/null
+++ b/annotations/build.gradle
@@ -0,0 +1,20 @@
+apply plugin: 'java'
+apply plugin: 'sdk-files'
+
+jar {
+ archiveName = 'annotations.jar'
+}
+
+sourceSets {
+ main.java.srcDirs 'src'
+}
+
+sdk {
+ common {
+ item(jar.archivePath) {
+ into 'support'
+ notice 'NOTICE'
+ builtBy jar
+ }
+ }
+}
diff --git a/apps/SdkController/NOTICE b/apps/SdkController/NOTICE
new file mode 100644
index 0000000..06a9081
--- /dev/null
+++ b/apps/SdkController/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-2014, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/avdlauncher/Android.mk b/avdlauncher/Android.mk
index fb48e15..97b6d73 100644
--- a/avdlauncher/Android.mk
+++ b/avdlauncher/Android.mk
@@ -16,7 +16,7 @@ include $(CLEAR_VARS)
ifeq ($(HOST_OS),windows)
LOCAL_SRC_FILES := \
- avdlauncher.c
+ src/source/avdlauncher.c
LOCAL_CFLAGS += -Wall -Wno-unused-parameter
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE -DSH_HISTORY
diff --git a/avdlauncher/build.gradle b/avdlauncher/build.gradle
new file mode 100644
index 0000000..dc08951
--- /dev/null
+++ b/avdlauncher/build.gradle
@@ -0,0 +1,36 @@
+apply plugin: 'c'
+apply plugin: 'sdk-files'
+apply plugin: 'windows-setup'
+
+executables {
+ avdLauncher {}
+}
+
+sources {
+ avdLauncher {
+ c {
+ source {
+ srcDir "src/source"
+ include "**/*.c"
+ }
+ }
+ }
+}
+
+sdk {
+ windows {
+ item( { getExeName("windows") } ) {
+ into 'lib'
+ name 'AVD Manager.exe'
+ builtBy 'avdLauncherExecutable'
+ }
+ }
+}
+
+def getExeName(String platform) {
+ // binaries will return a set of binaries
+ def binaries = executables.avdLauncher.binaries.matching { it.name == "avdLauncherExecutable" }
+ // calling .exeFile on the set returns an array with the result from each item in the set...
+ return binaries.executableFile.get(0)
+}
+
diff --git a/avdlauncher/avdlauncher.c b/avdlauncher/src/source/avdlauncher.c
index 12b1285..12b1285 100644
--- a/avdlauncher/avdlauncher.c
+++ b/avdlauncher/src/source/avdlauncher.c
diff --git a/bash_completion/adb.bash b/bash_completion/adb.bash
index d4d7b4e..b9b52c7 100644
--- a/bash_completion/adb.bash
+++ b/bash_completion/adb.bash
@@ -129,7 +129,7 @@ _adb_cmd_install() {
cur="${COMP_WORDS[COMP_CWORD]}"
if [[ $where == OPTIONS ]]; then
- COMPREPLY=( $(compgen -W "-l -r -s" -- "${cur}") )
+ COMPREPLY=( $(compgen -W "-d -l -r -s" -- "${cur}") )
return
fi
@@ -341,7 +341,7 @@ _adb_util_list_files() {
_adb_util_complete_local_file()
{
- local file xspec i j
+ local file xspec i j IFS=$'\n'
local -a dirs files
file=$1
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..733ba3c
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,150 @@
+apply plugin: 'sdk-files'
+
+sdk {
+ common {
+ item('files/tools_source.properties') {
+ name 'source.properties'
+ notice null
+ }
+ item('files/plugin.prop') {
+ into 'lib'
+ notice null
+ }
+
+ item('emulator/snapshot/snapshots.img') {
+ into 'lib/emulator'
+ notice 'emulator/NOTICE'
+ }
+ item('emulator/skins/dynamic') {
+ into 'lib/emulator/skins/dynamic'
+ notice 'emulator/NOTICE'
+ }
+
+ item('templates/build.template') {
+ into 'lib'
+ notice 'templates/NOTICE'
+ }
+ item('templates/uibuild.template') {
+ into 'lib'
+ notice 'templates/NOTICE'
+ }
+ item('templates/build_gradle.template') {
+ into 'lib'
+ notice 'templates/NOTICE'
+ }
+
+ item('files/ant') {
+ into 'ant'
+ notice 'files/ant/NOTICE'
+ }
+ item('files/proguard-project.txt') {
+ into 'lib'
+ notice null
+ }
+ item('files/proguard-project.txt') {
+ into 'proguard'
+ notice null
+ }
+ item('files/proguard-android.txt') {
+ into 'proguard'
+ notice null
+ }
+ item('files/proguard-android-optimize.txt') {
+ into 'proguard'
+ notice null
+ }
+
+ item('files/devices.xml') {
+ into 'lib'
+ notice 'files/NOTICE'
+ }
+ item('files/android.el') {
+ into 'lib'
+ notice 'files/NOTICE'
+ }
+
+ item('apps/SdkController') {
+ into 'apps/SdkController'
+ notice 'apps/SdkController/NOTICE'
+ }
+
+ item('files/typos') {
+ into 'support'
+ notice 'files/NOTICE'
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/qemu-kernel/x86/pc-bios/bios.bin") {
+ into 'lib/pc-bios'
+ notice null
+ }
+ item("$rootProject.projectDir.parentFile/prebuilts/qemu-kernel/x86/pc-bios/vgabios-cirrus.bin") {
+ into 'lib/pc-bios'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/license.html") {
+ into 'proguard'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/README") {
+ into 'proguard'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/docs") {
+ into 'proguard/docs'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/examples") {
+ into 'proguard/examples'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/lib") {
+ into 'proguard/lib'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/src/proguard/ant/task.properties") {
+ into 'proguard/ant'
+ notice null
+ }
+ }
+
+ common(mac, linux) {
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/bin/proguard.sh") {
+ into 'proguard/bin'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/bin/proguardgui.sh") {
+ into 'proguard/bin'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/bin/retrace.sh") {
+ into 'proguard/bin'
+ notice null
+ }
+ }
+
+ windows {
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/bin/proguard.bat") {
+ into 'proguard/bin'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/bin/proguardgui.bat") {
+ into 'proguard/bin'
+ notice null
+ }
+
+ item("$rootProject.projectDir.parentFile/prebuilts/tools/common/proguard/proguard4.7/bin/retrace.bat") {
+ into 'proguard/bin'
+ notice null
+ }
+ }
+
+}
diff --git a/build/patch_windows_sdk.sh b/build/patch_windows_sdk.sh
index 54fc7b7..addcc02 100755
--- a/build/patch_windows_sdk.sh
+++ b/build/patch_windows_sdk.sh
@@ -23,12 +23,11 @@
set -e # any error stops the build
# Verbose by default. Use -q to make more silent.
-V=""
if [[ "$1" == "-q" ]]; then
shift
else
echo "Win SDK: $0 $*"
- set -x # show bash commands; no need for V=-v
+ set -x # show bash commands
fi
TEMP_SDK_DIR=$1
@@ -36,9 +35,10 @@ WIN_OUT_DIR=$2
TOPDIR=${TOPDIR:-$3}
# Invoke atree to copy the files
-# TODO: pass down OUT_HOST_EXECUTABLE to get the right bin/atree directory
-${TOPDIR}out/host/linux-x86/bin/atree -f ${TOPDIR}sdk/build/tools.windows.atree \
- -I $WIN_OUT_DIR/host/windows-x86 \
- -I ${TOPDIR:-.} \
- -o $TEMP_SDK_DIR
+if [[ -f ${TOPDIR}sdk/build/tools.windows.atree ]]; then
+ ${TOPDIR}out/host/linux-x86/bin/atree -f ${TOPDIR}sdk/build/tools.windows.atree \
+ -I $WIN_OUT_DIR/host/windows-x86 \
+ -I ${TOPDIR:-.} \
+ -o $TEMP_SDK_DIR
+fi
diff --git a/build/product_sdk.mk b/build/product_sdk.mk
index 0587656..f1acd5f 100644
--- a/build/product_sdk.mk
+++ b/build/product_sdk.mk
@@ -27,9 +27,4 @@
# Host tools and java libraries that are parts of the SDK.
PRODUCT_PACKAGES += \
- ant-glob \
- annotations \
- mksdcard \
- fastboot \
- emugen
diff --git a/build/tools.atree b/build/tools.atree
deleted file mode 100644
index 801c4a6..0000000
--- a/build/tools.atree
+++ /dev/null
@@ -1,143 +0,0 @@
-#
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-##############################################################################
-# Tools Component
-##############################################################################
-
-#
-# These are the files that comprise the tools component of the SDK.
-#
-
-prebuilts/devtools/tools/lib tools/lib
-# manual copy of lombok-ast for now
-prebuilts/tools/common/lombok-ast/lombok-ast-0.2.1.jar tools/lib/lombok-ast.jar
-prebuilts/tools/common/lombok-ast/LICENSE.txt tools/lib/lombok-ast-NOTICE.txt
-
-prebuilts/devtools/tools/android tools/android
-prebuilts/devtools/tools/draw9patch tools/draw9patch
-prebuilts/devtools/tools/ddms tools/ddms
-prebuilts/devtools/tools/hierarchyviewer tools/hierarchyviewer
-prebuilts/devtools/tools/jobb tools/jobb
-prebuilts/devtools/tools/lint tools/lint
-prebuilts/devtools/tools/monkeyrunner tools/monkeyrunner
-prebuilts/devtools/tools/traceview tools/traceview
-prebuilts/devtools/tools/uiautomatorviewer tools/uiautomatorviewer
-
-prebuilts/devtools/notices/NOTICE.txt tools/NOTICE.txt
-
-
-# version files for the SDK updater, from sdk.git
-sdk/files/tools_source.properties tools/source.properties
-
-# copy plugin.prop from sdk.git
-sdk/files/plugin.prop tools/lib/plugin.prop
-
-# readme regarding adb move to platform-tools
-sdk/files/adb_has_moved.txt tools/adb_has_moved.txt
-
-# native host tools from out/host/$(HOST_OS)-$(HOST_ARCH)/
-bin/sqlite3 strip tools/sqlite3
-bin/dmtracedump strip tools/dmtracedump
-bin/etc1tool strip tools/etc1tool
-bin/hprof-conv strip tools/hprof-conv
-bin/mksdcard strip tools/mksdcard
-bin/zipalign strip tools/zipalign
-
-# emulator
-bin/emulator strip tools/emulator
-bin/emulator-x86 strip tools/emulator-x86
-bin/emulator-arm strip tools/emulator-arm
-bin/emulator-mips strip tools/emulator-mips
-bin/emulator64-x86 strip tools/emulator64-x86
-bin/emulator64-arm strip tools/emulator64-arm
-bin/emulator64-mips strip tools/emulator64-mips
-sdk/emulator/snapshot/snapshots.img tools/lib/emulator/snapshots.img
-usr/share/pc-bios/bios.bin tools/lib/pc-bios/bios.bin
-usr/share/pc-bios/vgabios-cirrus.bin tools/lib/pc-bios/vgabios-cirrus.bin
-sdk/emulator/skins/dynamic tools/lib/emulator/skins/dynamic
-
-# OpenGLES emulation libraries
-lib/libOpenglRender${DLL_EXTENSION} strip tools/lib/libOpenglRender${DLL_EXTENSION}
-lib/libGLES_CM_translator${DLL_EXTENSION} strip tools/lib/libGLES_CM_translator${DLL_EXTENSION}
-lib/libGLES_V2_translator${DLL_EXTENSION} strip tools/lib/libGLES_V2_translator${DLL_EXTENSION}
-lib/libEGL_translator${DLL_EXTENSION} strip tools/lib/libEGL_translator${DLL_EXTENSION}
-lib/lib64OpenglRender${DLL_EXTENSION} strip tools/lib/lib64OpenglRender${DLL_EXTENSION}
-lib/lib64GLES_CM_translator${DLL_EXTENSION} strip tools/lib/lib64GLES_CM_translator${DLL_EXTENSION}
-lib/lib64GLES_V2_translator${DLL_EXTENSION} strip tools/lib/lib64GLES_V2_translator${DLL_EXTENSION}
-lib/lib64EGL_translator${DLL_EXTENSION} strip tools/lib/lib64EGL_translator${DLL_EXTENSION}
-
-
-# sdk.git Ant and gradle templates for project build files
-sdk/templates/build.template tools/lib/build.template
-sdk/templates/uibuild.template tools/lib/uibuild.template
-sdk/templates/build_gradle.template tools/lib/build_gradle.template
-sdk/files/proguard-project.txt tools/lib/proguard-project.txt
-sdk/files/proguard-android.txt tools/proguard/proguard-android.txt
-sdk/files/proguard-android-optimize.txt tools/proguard/proguard-android-optimize.txt
-
-# Ant Build Rules
-sdk/files/ant tools/ant
-sdk/files/sdk_files_NOTICE.txt tools/ant/NOTICE.txt
-
-# layout device definition
-sdk/files/devices.xml tools/lib/devices.xml
-
-# AVD Hardware property list
-external/qemu/android/avd/hardware-properties.ini tools/lib/hardware-properties.ini
-
-# emacs support from sdk.git
-sdk/files/android.el tools/lib/android.el
-
-# 3rd Party java libraries
-framework/emmalib.jar tools/lib/emma_device.jar
-external/emma/lib/emma.jar tools/lib/emma.jar
-external/emma/lib/emma_ant.jar tools/lib/emma_ant.jar
-
-# Proguard
-# We're skipping the build and src/ trees (except for src/proguard/ant/task.properties)
-# and copying in a license.html file
-prebuilts/tools/common/proguard/license.html tools/proguard/license.html
-prebuilts/tools/common/proguard/proguard4.7/README tools/proguard/README
-prebuilts/tools/common/proguard/proguard4.7/docs tools/proguard/docs
-prebuilts/tools/common/proguard/proguard4.7/examples tools/proguard/examples
-prebuilts/tools/common/proguard/proguard4.7/lib tools/proguard/lib
-prebuilts/tools/common/proguard/proguard4.7/bin/proguard.sh tools/proguard/bin/proguard.sh
-prebuilts/tools/common/proguard/proguard4.7/bin/proguardgui.sh tools/proguard/bin/proguardgui.sh
-prebuilts/tools/common/proguard/proguard4.7/bin/retrace.sh tools/proguard/bin/retrace.sh
-prebuilts/tools/common/proguard/proguard4.7/src/proguard/ant/task.properties tools/proguard/ant/task.properties
-
-# Templates
-tools/base/templates/projects tools/templates/projects
-tools/base/templates/activities tools/templates/activities
-tools/base/templates/gradle tools/templates/gradle
-tools/base/templates/other tools/templates/other
-
-# SDK Controller
-sdk/apps/SdkController tools/apps/SdkController
-
-# tools specific support jar
-framework/annotations.jar tools/support/annotations.jar
-
-# Misspelling databases for lint
-sdk/files/typos tools/support
-
-##############################################################################
-# Tests Component
-##############################################################################
-
-sdk/testapps tests/testapps
-
diff --git a/build/tools.darwin.atree b/build/tools.darwin.atree
deleted file mode 100644
index c37480b..0000000
--- a/build/tools.darwin.atree
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#
-# These are the files that comprise the MacOS X tools component of the SDK.
-#
-
-##############################################################################
-# Tools Component
-##############################################################################
-
-# RCP Monitor. Temporarily disabled: See b/8992787
-#bin/monitor tools/monitor
-#eclipse/monitor-macosx.cocoa.x86_64/monitor tools/lib/monitor-x86_64
-
-# swt
-prebuilts/tools/darwin-x86/swt/swt.jar tools/lib/x86/swt.jar
-prebuilts/tools/darwin-x86_64/swt/swt.jar tools/lib/x86_64/swt.jar
-
-
-# JetCreator (only available on mac/windows)
-external/sonivox/jet_tools/JetCreator tools/Jet/JetCreator
-prebuilts/tools/darwin-x86/jetcreator/libEASLIb.dylib tools/Jet/JetCreator/libEASLIb.dylib
-external/sonivox/jet_tools/JetCreator_content tools/Jet/demo_content
-external/sonivox/jet_tools/logic_templates tools/Jet/logic_templates
-
diff --git a/build/tools.linux.atree b/build/tools.linux.atree
deleted file mode 100644
index 58f3576..0000000
--- a/build/tools.linux.atree
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#
-# These are the files that comprise the Linux tools component of the SDK.
-#
-
-##############################################################################
-# Tools Component
-##############################################################################
-
-# RCP Monitor. Temporarily disabled: See b/8992787
-#bin/monitor tools/monitor
-#eclipse/monitor-linux.gtk.x86/monitor tools/lib/monitor-x86
-#eclipse/monitor-linux.gtk.x86_64/monitor tools/lib/monitor-x86_64
-
-
-# swt
-prebuilts/tools/linux-x86/swt/swt.jar tools/lib/x86/swt.jar
-prebuilts/tools/linux-x86_64/swt/swt.jar tools/lib/x86_64/swt.jar
diff --git a/build/tools.windows.atree b/build/tools.windows.atree
deleted file mode 100755
index 36a6feb..0000000
--- a/build/tools.windows.atree
+++ /dev/null
@@ -1,125 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-#
-# These are the files that comprise the tools component of the Windows SDK.
-#
-# IMPORTANT: for a binary to be included here, it must be built --
-# typically by adding it to WIN_SDK_TARGETS in windows_sdk_tools.mk.
-#
-
-rm tools/android
-prebuilts/devtools/tools/android.bat tools/android.bat
-
-rm tools/ddms
-prebuilts/devtools/tools/ddms.bat tools/ddms.bat
-
-rm tools/dmtracedump
-bin/dmtracedump.exe strip tools/dmtracedump.exe
-
-rm tools/draw9patch
-prebuilts/devtools/tools/draw9patch.bat tools/draw9patch.bat
-
-rm tools/lint
-prebuilts/devtools/tools/lint.bat tools/lint.bat
-
-rm tools/jobb
-prebuilts/devtools/tools/jobb.bat tools/jobb.bat
-
-
-rm tools/emulator
-rm tools/emulator-arm
-rm tools/emulator-x86
-rm tools/emulator-mips
-bin/emulator.exe strip tools/emulator.exe
-bin/emulator-arm.exe strip tools/emulator-arm.exe
-bin/emulator-x86.exe strip tools/emulator-x86.exe
-bin/emulator-mips.exe strip tools/emulator-mips.exe
-# Emulator libraries
-rm tools/lib/libOpenglRender.so
-rm tools/lib/libGLES_CM_translator.so
-rm tools/lib/libGLES_V2_translator.so
-rm tools/lib/libEGL_translator.so
-lib/libOpenglRender.dll tools/lib/libOpenglRender.dll
-lib/libGLES_CM_translator.dll tools/lib/libGLES_CM_translator.dll
-lib/libGLES_V2_translator.dll tools/lib/libGLES_V2_translator.dll
-lib/libEGL_translator.dll tools/lib/libEGL_translator.dll
-# Copy the emulator NOTICE in the tools dir
-external/qemu/NOTICE tools/emulator_NOTICE.txt
-
-rm tools/etc1tool
-bin/etc1tool.exe strip tools/etc1tool.exe
-
-rm tools/hierarchyviewer
-prebuilts/devtools/tools/hierarchyviewer.bat tools/hierarchyviewer.bat
-
-rm tools/hprof-conv
-bin/hprof-conv.exe strip tools/hprof-conv.exe
-
-rm tools/mksdcard
-bin/mksdcard.exe strip tools/mksdcard.exe
-
-rm tools/monkeyrunner
-prebuilts/devtools/tools/monkeyrunner.bat tools/monkeyrunner.bat
-
-rm tools/proguard/bin
-prebuilts/tools/common/proguard/proguard4.7/bin/proguard.bat tools/proguard/bin/proguard.bat
-prebuilts/tools/common/proguard/proguard4.7/bin/retrace.bat tools/proguard/bin/retrace.bat
-prebuilts/tools/common/proguard/proguard4.7/bin/proguardgui.bat tools/proguard/bin/proguardgui.bat
-
-rm tools/sqlite3
-bin/sqlite3.exe strip tools/sqlite3.exe
-
-rm tools/traceview
-prebuilts/devtools/tools/traceview.bat tools/traceview.bat
-
-rm tools/uiautomatorviewer
-prebuilts/devtools/tools/uiautomatorviewer.bat tools/uiautomatorviewer.bat
-
-rm tools/zipalign
-bin/zipalign.exe strip tools/zipalign.exe
-
-# RCP Monitor. Remove linux stuff and replace by Windows files.
-# Temporarily disabled: See b/8992787
-#rm tools/monitor
-#rm tools/lib/monitor-x86
-#rm tools/lib/monitor-x86_64
-#sdk/monitor/monitor.bat tools/monitor.bat
-#eclipse/monitor-win32.win32.x86/monitor tools/lib/monitor-x86
-#eclipse/monitor-win32.win32.x86_64/monitor tools/lib/monitor-x86_64
-
-
-# Copy the AVD & SDK Manager (aka avd/sdklauncher) to the root of the SDK as
-# well as in SDK/tools/lib (so that tools updates can update the root one too)
-bin/avdlauncher.exe "AVD Manager.exe"
-bin/sdklauncher.exe "SDK Manager.exe"
-bin/avdlauncher.exe "tools/lib/AVD Manager.exe"
-bin/sdklauncher.exe "tools/lib/SDK Manager.exe"
-
-# Supporting bat files
-sdk/files/post_tools_install.bat tools/lib/post_tools_install.bat
-sdk/find_java/find_java.bat tools/lib/find_java.bat
-bin/find_java.exe strip tools/lib/find_java.exe
-bin/find_lock.exe strip tools/lib/find_lock.exe
-
-prebuilts/tools/windows/swt/swt.jar tools/lib/x86/swt.jar
-prebuilts/tools/windows-x86_64/swt/swt.jar tools/lib/x86_64/swt.jar
-
-external/sonivox/jet_tools/JetCreator tools/Jet/JetCreator
-external/sonivox/jet_tools/JetCreator_content tools/Jet/demo_content
-external/sonivox/jet_tools/logic_templates tools/Jet/logic_templates
-prebuilts/tools/windows/jetcreator/EASDLL.dll tools/Jet/JetCreator/EASDLL.dll
-
diff --git a/build/windows_sdk_tools.mk b/build/windows_sdk_tools.mk
index 80f00c0..8bdcdba 100644
--- a/build/windows_sdk_tools.mk
+++ b/build/windows_sdk_tools.mk
@@ -3,28 +3,13 @@
# This makefile is included by development/build/tools/windows_sdk.mk
# to device which tools we want to build from the sdk.git project.
-# Define the list of tool-dependent modules to build for the Windows SDK.
-# All these will be build using USE_MINGW=1
-WIN_SDK_TARGETS := \
- avdlauncher \
- emulator \
- emulator-arm \
- emulator-x86 \
- emulator-mips \
- find_java \
- find_lock \
- mksdcard \
- sdklauncher
+# This contains the SDK Tools modules to build during a
+# *platform* builds. Right now we are not building any SDK Tools
+# during platform builds anymore.
+# They are now built in an unbundled branch.
+WIN_SDK_TARGETS :=
-# Add OpenGLES emulation host libraries if needed.
-ifeq (true,$(BUILD_EMULATOR_OPENGL))
-WIN_SDK_TARGETS += \
- libOpenglRender \
- libGLES_CM_translator \
- libGLES_V2_translator \
- libEGL_translator
-endif
# Define the list of tool-dependent modules requisites needed
# for the Windows SDK. These will be built using HOST_OS=linux.
diff --git a/build/windows_sdk_whitelist.mk b/build/windows_sdk_whitelist.mk
index 40b70e5..ea29f11 100644
--- a/build/windows_sdk_whitelist.mk
+++ b/build/windows_sdk_whitelist.mk
@@ -27,27 +27,27 @@
subdirs += \
external/openssl \
- external/qemu \
- prebuilts/tools \
- sdk/avdlauncher \
- sdk/emulator/mksdcard \
- sdk/emulator/opengl \
- sdk/find_java \
- sdk/find_lock \
- sdk/sdklauncher
+# external/qemu \
+# prebuilts/tools \
+# sdk/avdlauncher \
+# sdk/emulator/mksdcard \
+# sdk/emulator/opengl \
+# sdk/find_java \
+# sdk/find_lock \
+# sdk/sdklauncher
# -----
# Whitelist of SDK specific projects that DO require Java
ifneq (,$(shell which javac 2>/dev/null))
subdirs += \
- external/ant-glob \
- external/eclipse-windowbuilder/propertysheet \
- external/hamcrest \
- external/junit \
- sdk/apkbuilder \
- sdk/eclipse/scripts/rcp \
- sdk/testutils
+# external/ant-glob \
+# external/eclipse-windowbuilder/propertysheet \
+# external/hamcrest \
+# external/junit \
+# sdk/apkbuilder \
+# sdk/eclipse/scripts/rcp \
+# sdk/testutils
else
$(warning SDK_ONLY: javac not available.)
diff --git a/eclipse/.gitignore b/eclipse/.gitignore
new file mode 100644
index 0000000..78dbaee
--- /dev/null
+++ b/eclipse/.gitignore
@@ -0,0 +1,3 @@
+*.iml
+plugins/*/libs
+plugins/*/*.target
diff --git a/eclipse/TYCHO_BUILD b/eclipse/TYCHO_BUILD
new file mode 100644
index 0000000..7836ec9
--- /dev/null
+++ b/eclipse/TYCHO_BUILD
@@ -0,0 +1,6 @@
+To build using Tycho, perform:
+
+ $ cd sdk/eclipse
+ $ make -f maven.mk
+
+The resulting artifacts will be in $OUT/host/maven/bundles-<version>-SNAPSHOT/products/
diff --git a/eclipse/artifacts/bundles/.project b/eclipse/artifacts/bundles/.project
new file mode 100644
index 0000000..9174087
--- /dev/null
+++ b/eclipse/artifacts/bundles/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>tycho-bundles</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
diff --git a/eclipse/artifacts/bundles/category.xml b/eclipse/artifacts/bundles/category.xml
new file mode 100644
index 0000000..9d20482
--- /dev/null
+++ b/eclipse/artifacts/bundles/category.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<site>
+ <description url="https://dl-ssl.google.com/android/eclipse/">
+ Update Site for Android Development Toolkit
+ </description>
+ <feature url="features/com.android.ide.eclipse.ddms_23.0.2.qualifier.jar" id="com.android.ide.eclipse.ddms.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.hierarchyviewer_23.0.2.qualifier.jar" id="com.android.ide.eclipse.hierarchyviewer.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.traceview_23.0.2.qualifier.jar" id="com.android.ide.eclipse.traceview.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.gldebugger_23.0.2.qualifier.jar" id="com.android.ide.eclipse.gldebugger.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.adt_23.0.2.qualifier.jar" id="com.android.ide.eclipse.adt.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.adt.package_23.0.2.qualifier.jar" id="com.android.ide.eclipse.adt.package.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.ndk_23.0.2.qualifier.jar" id="com.android.ide.eclipse.ndk.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <category-def name="developer" label="Developer Tools">
+ <description>
+ Features that add Android support to Eclipse for application developers.
+ </description>
+ </category-def>
+</site>
diff --git a/eclipse/artifacts/bundles/ide.p2.inf b/eclipse/artifacts/bundles/ide.p2.inf
new file mode 100644
index 0000000..cabaa55
--- /dev/null
+++ b/eclipse/artifacts/bundles/ide.p2.inf
@@ -0,0 +1,9 @@
+#tell pde.build not to generate start levels
+org.eclipse.pde.build.append.startlevels=false
+
+requires.1.namespace=org.eclipse.equinox.p2.iu
+requires.1.name=org.eclipse.platform.ide
+requires.1.greedy=true
+
+instructions.configure=\
+org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(location:http${#58}//dl-ssl.google.com/android/eclipse/,type:0,name:Android Developer Tools Update Site,enabled:true);
diff --git a/eclipse/artifacts/bundles/ide.product b/eclipse/artifacts/bundles/ide.product
new file mode 100644
index 0000000..db2b181
--- /dev/null
+++ b/eclipse/artifacts/bundles/ide.product
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?pde version="3.5"?>
+
+<product name="Eclipse IDE for Android Developers" uid="adtproduct" id="com.android.ide.eclipse.adt.package.adtproduct" application="org.eclipse.ui.ide.workbench" version="23.0.2.qualifier" useFeatures="true" includeLaunchers="true">
+
+ <aboutInfo>
+ <image path="/plugin-adt-package/adt-about.png"/>
+ <text>
+ Specified in the plugin.xml of the branding plugin.
+ </text>
+ </aboutInfo>
+
+ <configIni use="default">
+ </configIni>
+
+ <launcherArgs>
+ <programArgs>-product com.android.ide.eclipse.adt.package.adtproduct</programArgs>
+ <vmArgs>-Dosgi.requiredJavaVersion=1.6
+-XX:MaxPermSize=256m
+-Xms512m
+-Xmx1024m</vmArgs>
+ <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
+ </launcherArgs>
+
+ <windowImages i16="/plugin-adt-package/icons/adt16.png" i32="/plugin-adt-package/icons/adt32.png" i48="/plugin-adt-package/icons/adt48.png"/>
+
+ <splash
+ location="com.android.ide.eclipse.adt.package" />
+ <launcher name="eclipse">
+ <solaris/>
+ <win useIco="false">
+ <bmp/>
+ </win>
+ </launcher>
+
+
+ <vm>
+ <linux include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</linux>
+ <macos include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</macos>
+ <windows include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</windows>
+ </vm>
+
+ <plugins>
+ </plugins>
+
+ <features>
+ <feature id="com.android.ide.eclipse.adt.package.feature" version="23.0.2.qualifier"/>
+ </features>
+
+ <configurations>
+ <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="0" />
+ <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="0" />
+ <plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="0" />
+ <property name="eclipse.product" value="com.android.ide.eclipse.adt.package.adtproduct" />
+ <property name="org.eclipse.update.reconcile" value="false" />
+ <property name="osgi.bundles.defaultStartLevel" value="4" />
+ <property name="osgi.splashPath" value="platform\:/base/plugins/com.android.ide.eclipse.adt.package" />
+ </configurations>
+
+</product>
diff --git a/eclipse/artifacts/bundles/monitor.product b/eclipse/artifacts/bundles/monitor.product
new file mode 100644
index 0000000..bee295e
--- /dev/null
+++ b/eclipse/artifacts/bundles/monitor.product
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?pde version="3.5"?>
+
+<product name="monitor" uid="monitorproduct" id="com.android.ide.eclipse.monitor.product" application="com.android.ide.eclipse.monitor.Application" version="23.0.2.qualifier" useFeatures="true" includeLaunchers="true">
+
+
+ <configIni use="default">
+ </configIni>
+
+ <launcherArgs>
+ <programArgs>-data @noDefault</programArgs>
+ <vmArgs>-XX:MaxPermSize=256m
+-Xms512m
+-Xmx1024m</vmArgs>
+ <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
+ </launcherArgs>
+
+ <windowImages/>
+
+ <splash
+ location="com.android.ide.eclipse.monitor" />
+ <launcher name="monitor">
+ <solaris/>
+ <win useIco="false">
+ <bmp/>
+ </win>
+ </launcher>
+
+
+ <vm>
+ </vm>
+
+
+ <plugins>
+ </plugins>
+
+ <features>
+ <feature id="com.android.ide.eclipse.ddms.feature"/>
+ <feature id="com.android.ide.eclipse.gldebugger.feature"/>
+ <feature id="com.android.ide.eclipse.hierarchyviewer.feature"/>
+ <feature id="com.android.ide.eclipse.traceview.feature"/>
+ <feature id="com.android.ide.eclipse.monitor.feature"/>
+ <feature id="org.eclipse.rcp"/>
+ <feature id="org.eclipse.emf.ecore"/>
+ <feature id="org.eclipse.e4.rcp"/>
+ <feature id="org.eclipse.emf.common"/>
+ <feature id="org.eclipse.platform"/>
+ <feature id="org.eclipse.equinox.p2.core.feature"/>
+ <feature id="org.eclipse.help"/>
+ <feature id="org.eclipse.equinox.p2.rcp.feature"/>
+ <feature id="org.eclipse.equinox.p2.extras.feature"/>
+ <feature id="org.eclipse.equinox.p2.user.ui"/>
+ </features>
+
+ <configurations>
+ <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="2" />
+ <plugin id="org.eclipse.equinox.common" autoStart="true" startLevel="2" />
+ <plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="2" />
+ </configurations>
+
+</product>
diff --git a/eclipse/artifacts/bundles/pom.xml b/eclipse/artifacts/bundles/pom.xml
new file mode 100644
index 0000000..2673bd1
--- /dev/null
+++ b/eclipse/artifacts/bundles/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>bundles</artifactId>
+ <packaging>eclipse-repository</packaging>
+ <name>bundles</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-director-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <executions>
+ <!-- install the product for all configured os/ws/arch environments
+ using p2 director -->
+ <execution>
+ <id>materialize-products</id>
+ <goals>
+ <goal>materialize-products</goal>
+ </goals>
+ </execution>
+ <!-- create product zips (one per os/ws/arch) -->
+ <execution>
+ <id>archive-products</id>
+ <goals>
+ <goal>archive-products</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <formats>
+ <win32>zip</win32>
+ <linux>zip</linux>
+ <macosx>zip</macosx>
+ </formats>
+ <products>
+ <product>
+ <id>monitorproduct</id>
+ <attachId>com.android.ide.eclipse.monitor.product</attachId>
+ <rootFolder>monitor</rootFolder>
+ </product>
+ <product>
+ <id>adtproduct</id>
+ <attachId>adtproduct</attachId>
+ <rootFolder>adt</rootFolder>
+ </product>
+ </products>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/eclipse/artifacts/p2repo/.project b/eclipse/artifacts/p2repo/.project
new file mode 100644
index 0000000..5360679
--- /dev/null
+++ b/eclipse/artifacts/p2repo/.project
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>tycho-p2repo</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ </buildSpec>
+ <natures>
+ </natures>
+</projectDescription>
diff --git a/eclipse/artifacts/p2repo/category.xml b/eclipse/artifacts/p2repo/category.xml
new file mode 100644
index 0000000..78d1edf
--- /dev/null
+++ b/eclipse/artifacts/p2repo/category.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<site>
+ <description url="https://dl-ssl.google.com/android/eclipse/">
+ Update Site for Android Development Toolkit
+ </description>
+ <feature url="features/com.android.ide.eclipse.ddms_23.0.2.qualifier.jar" id="com.android.ide.eclipse.ddms.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.hierarchyviewer_23.0.2.qualifier.jar" id="com.android.ide.eclipse.hierarchyviewer.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.traceview_23.0.2.qualifier.jar" id="com.android.ide.eclipse.traceview.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.gldebugger_23.0.2.qualifier.jar" id="com.android.ide.eclipse.gldebugger.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.adt_23.0.2.qualifier.jar" id="com.android.ide.eclipse.adt.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <feature url="features/com.android.ide.eclipse.ndk_23.0.2.qualifier.jar" id="com.android.ide.eclipse.ndk.feature" version="23.0.2.qualifier">
+ <category name="developer"/>
+ </feature>
+ <category-def name="developer" label="Developer Tools">
+ <description>
+ Features that add Android support to Eclipse for application developers.
+ </description>
+ </category-def>
+</site>
diff --git a/eclipse/artifacts/p2repo/pom.xml b/eclipse/artifacts/p2repo/pom.xml
new file mode 100644
index 0000000..249499e
--- /dev/null
+++ b/eclipse/artifacts/p2repo/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>p2repo</artifactId>
+ <packaging>eclipse-repository</packaging>
+ <name>p2repo</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/build.gradle b/eclipse/build.gradle
new file mode 100644
index 0000000..8671690
--- /dev/null
+++ b/eclipse/build.gradle
@@ -0,0 +1,196 @@
+// Script used to build ADT plugins, IDE and monitor
+// There are 2 major tasks done by this plugin:
+// copydeps: copies tools/base, tools/swt and prebuilt jars into plugins' libs folder
+// buildEclipse: builds Eclipse by running Tycho from the commandline
+//
+// Usage: $ ANDROID_SRC/tools/gradlew -i -b /path/to/this/build.gradle copydeps|buildEclipse
+
+// get tools/base version
+apply from: "../../tools/buildSrc/base/version.gradle"
+
+repositories {
+ maven { url '../../prebuilts/tools/common/m2/repository' }
+ maven { url '../../out/repo' }
+}
+
+ext {
+ // list of plugins whose manifest should be examined to identify dependencies
+ adtPlugins = new File(projectDir, 'plugins').listFiles().findAll { it.name.startsWith("com.android") }
+
+ //
+ def eclipseBuildDeps = new File(projectDir, "../../prebuilts/eclipse-build-deps").getCanonicalFile()
+ targetComponents = [
+ "platform": new File(eclipseBuildDeps, "platform/org.eclipse.platform-4.2.2.zip"),
+ "cdt" : new File(eclipseBuildDeps, "cdt/cdt-master-8.0.2.zip"),
+ "emf" : new File(eclipseBuildDeps, "emf/emf-xsd-Update-2.9.1.zip"),
+ "jdt" : new File(eclipseBuildDeps, "jdt/org.eclipse.jdt.source-4.2.2.zip"),
+ "wtp" : new File(eclipseBuildDeps, "wtp/wtp-repo-R-3.3.2-20120210195245.zip"),
+ "gef" : new File(eclipseBuildDeps, "gef/GEF-Update-3.9.1.zip"),
+ "pde" : new File(eclipseBuildDeps, "pde/org.eclipse.pde-3.8.zip"),
+ "egit" : new File(eclipseBuildDeps, "egit/org.eclipse.egit.repository-2.2.0.201212191850-r.zip"),
+ ]
+
+ buildNumber = System.getenv("BUILD_NUMBER")
+ if (buildNumber == null) {
+ buildNumber = "SNAPSHOT"
+ }
+}
+
+// a mapping from the library names as used inside the plugin's MANIFEST.MF to the Maven artifact id
+def artifacts = [
+ // tools/base and tools/swt dependencies
+ 'manifest-merger' : "com.android.tools.build:manifest-merger:$ext.baseVersion",
+ 'ddmlib' : "com.android.tools.ddms:ddmlib:$ext.baseVersion",
+ 'ddmuilib' : "com.android.tools.ddms:ddmuilib:$ext.baseVersion",
+ 'layoutlib-api' : "com.android.tools.layoutlib:layoutlib-api:$ext.baseVersion",
+ 'lint-api' : "com.android.tools.lint:lint-api:$ext.baseVersion",
+ 'lint-checks' : "com.android.tools.lint:lint-checks:$ext.baseVersion",
+ 'asset-studio' : "com.android.tools:asset-studio:$ext.baseVersion",
+ 'common' : "com.android.tools:common:$ext.baseVersion",
+ 'dvlib' : "com.android.tools:dvlib:$ext.baseVersion",
+ 'hierarchyviewer2lib' : "com.android.tools:hierarchyviewer2lib:$ext.baseVersion",
+ 'ninepatch' : "com.android.tools:ninepatch:$ext.baseVersion",
+ 'rule-api' : "com.android.tools:rule-api:$ext.baseVersion",
+ 'sdk-common' : "com.android.tools:sdk-common:$ext.baseVersion",
+ 'sdklib' : "com.android.tools:sdklib:$ext.baseVersion",
+ 'sdkstats' : "com.android.tools:sdkstats:$ext.baseVersion",
+ 'sdkuilib' : "com.android.tools:sdkuilib:$ext.baseVersion",
+ 'swtmenubar' : "com.android.tools:swtmenubar:$ext.baseVersion",
+ 'testutils' : "com.android.tools:testutils:$ext.baseVersion",
+ 'traceview' : "com.android.tools:traceview:$ext.baseVersion",
+ 'uiautomatorviewer' : "com.android.tools:uiautomatorviewer:$ext.baseVersion",
+
+ // prebuilts
+ 'ant-glob' : 'com.android.tools.external:ant-glob:1.0',
+ 'asm-4.0' : 'org.ow2.asm:asm:4.0',
+ 'asm-analysis-4.0' : 'org.ow2.asm:asm-analysis:4.0',
+ 'asm-tree-4.0' : 'org.ow2.asm:asm-tree:4.0',
+ 'commons-codec-1.4' : 'commons-codec:commons-codec:1.4',
+ 'commons-compress-1.0' : 'org.apache.commons:commons-compress:1.8.1',
+ 'commons-logging-1.1.1' : 'commons-logging:commons-logging:1.1.1',
+ 'easymock' : 'org.easymock:easymock:2.4',
+ 'freemarker-2.3.20' : 'org.freemarker:freemarker:2.3.20',
+ 'guava-15.0' : 'com.google.guava:guava:15.0',
+ 'host-libprotobuf-java-2.3.0-lite' : 'com.android.tools.external:libprotobuf-java-lite:2.3.0',
+ 'httpclient-4.1.1' : 'org.apache.httpcomponents:httpclient:4.1.1',
+ 'httpcore-4.1' : 'org.apache.httpcomponents:httpcore:4.1',
+ 'httpmime-4.1' : 'org.apache.httpcomponents:httpmime:4.1',
+ 'jcommon-1.0.12' : 'jfree:jcommon:1.0.12',
+ 'jfreechart-1.0.9' : 'jfree:jfreechart:1.0.9',
+ 'jfreechart-swt-1.0.9' : 'jfree:jfreechart-swt:1.0.9',
+ 'kxml2-2.3.0' : 'net.sf.kxml:kxml2:2.3.0',
+ 'liblzf-1.0' : 'com.android.tools.external:liblzf:1.0',
+ 'lombok-ast-0.2.2' : 'com.android.tools.external.lombok:lombok-ast:0.2.2',
+ 'propertysheet' : 'com.android.tools.external:propertysheet:1.0',
+]
+
+configurations {
+ compile
+}
+
+dependencies {
+ compile artifacts.values()
+}
+
+task copydeps << {
+ // get the resolved dependencies from the compile configuration
+ def resolvedDependencies = configurations.compile.resolvedConfiguration.firstLevelModuleDependencies
+
+ // generate a map from "xy.jar" -> "/path/to/xy-1.0.jar"
+ def artifactMap = [:]
+ resolvedDependencies.each { dependency ->
+ def dependencyId = dependency.getName()
+ def artifactName = artifacts.find{ it.value == dependencyId}?.key
+
+ // get the jar file corresponding to the dependency
+ def artifact = getArtifact(dependency)
+ artifactMap.put(artifactName + ".jar", artifact)
+ }
+
+ project.adtPlugins.each { File pluginFile ->
+ def manifestDeps = getManifestDependencies(new File(pluginFile, "META-INF/MANIFEST.MF"))
+ logger.info("Dependencies for " + pluginFile.toString() + ": " + manifestDeps.join(","))
+
+ File dest = new File(pluginFile, "libs")
+ if (!manifestDeps.isEmpty() && !dest.isDirectory()) {
+ dest.mkdirs()
+ }
+
+ manifestDeps.each {
+ if (!artifactMap.containsKey(it)) {
+ throw new RuntimeException("No resolved artifact for: " + it + ", required for: "
+ + pluginFile.getPath())
+ }
+
+ String destName = artifactMap.get(it)
+ logger.info("\tCopying " + destName + " to " + dest)
+ ant.copy(file: destName, tofile: new File(dest, it))
+ }
+ }
+}
+
+// unzip eclipse prebuilts into the out folder to create a target platform for the build
+task unzipTargetPlatform << {
+ File targetDir = new File(projectDir, "../../out/host/maven/target").getCanonicalFile()
+ targetDir.mkdirs()
+
+ project.targetComponents.each { String k, File v ->
+ File d = new File(targetDir, k)
+ logger.info("Unzipping " + v.getPath() + " into: " + d.getPath())
+ ant.unzip(src: v, dest: d)
+ }
+}
+
+task buildEclipse(type: Exec, dependsOn: unzipTargetPlatform) {
+ def maven = new File(projectDir, "../../prebuilts/eclipse/maven/apache-maven-3.2.1/bin/mvn").getCanonicalFile()
+ def androidOut = new File(projectDir, "../../out").getCanonicalPath()
+ environment("M2_HOME", maven.getParentFile().getParentFile().getCanonicalPath())
+ workingDir projectDir
+ commandLine maven.getCanonicalPath(), "-s", "settings.xml", "-DforceContextQualifier=$project.buildNumber", "-DANDROID_OUT=$androidOut", "package"
+}
+
+private File getArtifact(ResolvedDependency dependency) {
+ if (dependency.moduleArtifacts.size() != 1) {
+ String msg = String.format("Each dependency is expected to map to a single jar file, " +
+ "but %s maps to the following artifacts: %s",
+ dependency,
+ dependency.moduleArtifacts.collect { it.file })
+ throw new RuntimeException(msg);
+ }
+
+ return dependency.moduleArtifacts.iterator().next().file
+}
+
+// parse a plugin's manifest file and return the list of jar dependencies expected to be
+// bundled inside
+private List<String> getManifestDependencies(File manifest) {
+ if (manifest == null || !manifest.exists()) {
+ return []
+ }
+
+ def entries = []
+
+ def fis = new FileInputStream(manifest)
+ try {
+ java.util.jar.Manifest m = new java.util.jar.Manifest(fis)
+ def classPath = m.getMainAttributes().getValue("Bundle-ClassPath")
+ if (classPath == null) {
+ return []
+ }
+
+ classPath.split(',').each {
+ if (!it.equals(".")) {
+ if (!it.startsWith("libs/") || !it.endsWith(".jar")) {
+ throw new RuntimeException(
+ "Unexpected classpath entry: " + it + " in file: " + manifest)
+ }
+
+ entries.add(it.substring("libs/".length()))
+ }
+ }
+ } finally {
+ fis.close()
+ }
+
+ return entries
+}
diff --git a/eclipse/features/com.android.ide.eclipse.adt.package/build.properties b/eclipse/features/com.android.ide.eclipse.adt.package/build.properties
index 36ca16c..64dc64a 100644
--- a/eclipse/features/com.android.ide.eclipse.adt.package/build.properties
+++ b/eclipse/features/com.android.ide.eclipse.adt.package/build.properties
@@ -1,4 +1,3 @@
bin.includes = feature.xml,\
- p2.inf,\
- ide.product
+ p2.inf
includeLaunchers=false
diff --git a/eclipse/features/com.android.ide.eclipse.adt.package/feature.xml b/eclipse/features/com.android.ide.eclipse.adt.package/feature.xml
index ec3843b..0d581fa 100644
--- a/eclipse/features/com.android.ide.eclipse.adt.package/feature.xml
+++ b/eclipse/features/com.android.ide.eclipse.adt.package/feature.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
- id="com.android.ide.eclipse.adt.package"
+ id="com.android.ide.eclipse.adt.package.feature"
label="ADT Package"
- version="22.3.0.qualifier"
+ version="23.0.2.qualifier"
provider-name="The Android Open Source Project"
plugin="com.android.ide.eclipse.adt.package">
@@ -11,81 +11,33 @@
</description>
<copyright>
- Copyright (C) 2007-2012 The Android Open Source Project
+ Copyright (C) 2007-2014 The Android Open Source Project
</copyright>
<license url="http://www.eclipse.org/org/documents/epl-v10.php">
Note: kxml2-2.3.0.jar is under the BSD license rather ...
</license>
- <url>
- <update label="Android Update Site" url="https://dl-ssl.google.com/android/eclipse/"/>
- </url>
-
<requires>
- <import feature="org.eclipse.platform"/>
- <import plugin="org.eclipse.equinox.app"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.debug.core"/>
- <import plugin="org.eclipse.debug.ui"/>
- <import feature="org.eclipse.jdt" version="3.7.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.ant.core"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.jdt.ui"/>
- <import plugin="org.eclipse.jdt.launching"/>
- <import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.ui.editors"/>
- <import plugin="org.eclipse.ui.workbench.texteditor"/>
- <import plugin="org.eclipse.ui.console"/>
- <import plugin="org.eclipse.core.filesystem"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.ui.forms"/>
- <import plugin="org.eclipse.ui.browser"/>
- <import plugin="org.eclipse.ui.views"/>
- <import plugin="org.eclipse.ui.views.log"/>
- <import plugin="org.eclipse.wst.sse.core"/>
- <import plugin="org.eclipse.wst.sse.ui"/>
- <import plugin="org.eclipse.wst.xml.core"/>
- <import plugin="org.eclipse.wst.xml.ui"/>
- <import plugin="org.eclipse.jdt.junit"/>
- <import plugin="org.eclipse.jdt.junit.runtime"/>
- <import plugin="org.eclipse.ltk.core.refactoring"/>
- <import plugin="org.eclipse.ltk.ui.refactoring"/>
- <import plugin="org.eclipse.core.expressions"/>
+ <import plugin="com.android.ide.eclipse.adt" version="22.3.0" match="greaterOrEqual"/>
+ <import plugin="com.android.ide.eclipse.base" version="22.3.0" match="greaterOrEqual"/>
+ <import plugin="com.android.ide.eclipse.ddms" version="22.3.0" match="greaterOrEqual"/>
+ <import plugin="com.android.ide.eclipse.gldebugger" version="22.3.0" match="greaterOrEqual"/>
+ <import plugin="com.android.ide.eclipse.hierarchyviewer" version="22.3.0" match="greaterOrEqual"/>
+ <import plugin="com.android.ide.eclipse.traceview" version="22.3.0" match="greaterOrEqual"/>
+ <import plugin="overlay.com.android.ide.eclipse.adt.overlay"/>
<import feature="org.eclipse.equinox.p2.user.ui"/>
- <import feature="org.eclipse.help"/>
- <import feature="org.eclipse.rcp" version="3.7.0" match="greaterOrEqual"/>
- <import feature="org.eclipse.wst.common_core.feature"/>
- <import feature="org.eclipse.wst.common_ui.feature"/>
- <import feature="org.eclipse.wst.xml_core.feature"/>
- <import feature="org.eclipse.wst.xml_ui.feature"/>
- <import plugin="org.eclipse.core.variables"/>
- <import plugin="org.eclipse.cdt.core"/>
- <import plugin="org.eclipse.cdt.ui"/>
- <import plugin="org.eclipse.cdt.managedbuilder.core"/>
- <import plugin="org.eclipse.cdt.managedbuilder.ui"/>
- <import plugin="org.eclipse.cdt.debug.core"/>
- <import plugin="org.eclipse.cdt.debug.ui"/>
- <import plugin="org.eclipse.cdt.dsf"/>
- <import plugin="org.eclipse.cdt.dsf.gdb"/>
- <import plugin="org.eclipse.cdt.dsf.gdb.ui"/>
- <import plugin="org.eclipse.cdt.launch"/>
- <import feature="org.eclipse.egit" />
- <import feature="com.android.ide.eclipse.ddms" version="22.2.0" match="greaterOrEqual" />
- <import feature="com.android.ide.eclipse.adt" version="22.2.0" match="greaterOrEqual" />
- <import feature="com.android.ide.eclipse.gldebugger" version="22.2.0" match="greaterOrEqual" />
- <import feature="com.android.ide.eclipse.hierarchyviewer" version="22.2.0" match="greaterOrEqual" />
- <import feature="com.android.ide.eclipse.ndk" version="22.2.0" match="greaterOrEqual" />
- <import feature="com.android.ide.eclipse.traceview" version="22.2.0" match="greaterOrEqual" />
- <!--
- The build scripts will pull in the translation plugin if its plugin repository is accessible.
- The following line should remain without any modifications as the build script looks for
- exactly this pattern and removes the comment tags.
- See sdk.git/adtproductbuild/build.xml.
- -->
- <!--import feature="com.google.i18n.inkstone.eclipse.localization" -->
+ <import feature="org.eclipse.platform"/>
+ <import feature="org.eclipse.rcp"/>
+ <import feature="org.eclipse.egit"/>
+ <import feature="org.eclipse.egit.import"/>
+ <import feature="org.eclipse.cdt"/>
</requires>
+ <plugin
+ id="com.android.ide.eclipse.adt.package"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
</feature>
diff --git a/eclipse/features/com.android.ide.eclipse.adt.package/p2.inf b/eclipse/features/com.android.ide.eclipse.adt.package/p2.inf
index cabaa55..93a365c 100644
--- a/eclipse/features/com.android.ide.eclipse.adt.package/p2.inf
+++ b/eclipse/features/com.android.ide.eclipse.adt.package/p2.inf
@@ -6,4 +6,4 @@ requires.1.name=org.eclipse.platform.ide
requires.1.greedy=true
instructions.configure=\
-org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(location:http${#58}//dl-ssl.google.com/android/eclipse/,type:0,name:Android Developer Tools Update Site,enabled:true);
+org.eclipse.equinox.p2.touchpoint.eclipse.addRepository(location:https${#58}//dl.google.com/android/eclipse/,type:0,name:Android Developer Tools Update Site,enabled:true);
diff --git a/eclipse/features/com.android.ide.eclipse.adt.package/pom.xml b/eclipse/features/com.android.ide.eclipse.adt.package/pom.xml
new file mode 100644
index 0000000..885a547
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.adt.package/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.adt.package.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+ <name>adt.package</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/features/com.android.ide.eclipse.adt/feature.xml b/eclipse/features/com.android.ide.eclipse.adt/feature.xml
index f90725c..7bdc7a5 100644
--- a/eclipse/features/com.android.ide.eclipse.adt/feature.xml
+++ b/eclipse/features/com.android.ide.eclipse.adt/feature.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
- id="com.android.ide.eclipse.adt"
+ id="com.android.ide.eclipse.adt.feature"
label="Android Development Tools"
- version="22.3.0.qualifier"
+ version="23.0.2.qualifier"
provider-name="The Android Open Source Project"
plugin="com.android.ide.eclipse.adt">
@@ -113,7 +113,7 @@ This Agreement is governed by the laws of the State of New York and the intellec
<requires>
<import plugin="com.android.ide.eclipse.base" match="perfect"/>
<import plugin="com.android.ide.eclipse.ddms" match="perfect"/>
- <import plugin="org.eclipse.core.runtime" version="3.6.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.core.runtime" version="3.7.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.debug.core"/>
<import plugin="org.eclipse.debug.ui"/>
@@ -127,7 +127,7 @@ This Agreement is governed by the laws of the State of New York and the intellec
<import plugin="org.eclipse.ui.workbench.texteditor"/>
<import plugin="org.eclipse.ui.console"/>
<import plugin="org.eclipse.core.filesystem"/>
- <import plugin="org.eclipse.ui" version="3.6" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.ui" version="3.7" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.ui.forms"/>
<import plugin="org.eclipse.ui.browser"/>
@@ -158,10 +158,4 @@ This Agreement is governed by the laws of the State of New York and the intellec
version="0.0.0"
unpack="false"/>
- <plugin
- id="com.android.ide.eclipse.adt.package"
- download-size="0"
- install-size="0"
- version="0.0.0"/>
-
</feature>
diff --git a/eclipse/features/com.android.ide.eclipse.adt/pom.xml b/eclipse/features/com.android.ide.eclipse.adt/pom.xml
new file mode 100644
index 0000000..c326c7a
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.adt/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.adt.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+ <name>adt</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/features/com.android.ide.eclipse.ddms/feature.xml b/eclipse/features/com.android.ide.eclipse.ddms/feature.xml
index 3efcab4..a9b7913 100644
--- a/eclipse/features/com.android.ide.eclipse.ddms/feature.xml
+++ b/eclipse/features/com.android.ide.eclipse.ddms/feature.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
- id="com.android.ide.eclipse.ddms"
+ id="com.android.ide.eclipse.ddms.feature"
label="Android DDMS"
- version="22.3.0.qualifier"
+ version="23.0.2.qualifier"
provider-name="The Android Open Source Project"
plugin="com.android.ide.eclipse.ddms">
@@ -228,8 +228,8 @@
</url>
<requires>
- <import plugin="org.eclipse.ui" version="3.6.2" match="greaterOrEqual"/>
- <import plugin="org.eclipse.core.runtime" version="3.6.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.ui" version="3.7.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.core.runtime" version="3.7.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui.console"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.ui.ide"/>
diff --git a/eclipse/features/com.android.ide.eclipse.ddms/pom.xml b/eclipse/features/com.android.ide.eclipse.ddms/pom.xml
new file mode 100644
index 0000000..065a3b6
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.ddms/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.ddms.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+ <name>ddms</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/features/com.android.ide.eclipse.gldebugger/feature.xml b/eclipse/features/com.android.ide.eclipse.gldebugger/feature.xml
index dda3e0c..3a1028f 100644
--- a/eclipse/features/com.android.ide.eclipse.gldebugger/feature.xml
+++ b/eclipse/features/com.android.ide.eclipse.gldebugger/feature.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
- id="com.android.ide.eclipse.gldebugger"
+ id="com.android.ide.eclipse.gldebugger.feature"
label="Tracer for OpenGL ES"
- version="22.3.0.qualifier"
+ version="23.0.2.qualifier"
provider-name="The Android Open Source Project">
<description>
diff --git a/eclipse/features/com.android.ide.eclipse.gldebugger/pom.xml b/eclipse/features/com.android.ide.eclipse.gldebugger/pom.xml
new file mode 100644
index 0000000..65554d9
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.gldebugger/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.gldebugger.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+ <name>gldebugger</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/features/com.android.ide.eclipse.hierarchyviewer/feature.xml b/eclipse/features/com.android.ide.eclipse.hierarchyviewer/feature.xml
index ea14352..a5e7997 100644
--- a/eclipse/features/com.android.ide.eclipse.hierarchyviewer/feature.xml
+++ b/eclipse/features/com.android.ide.eclipse.hierarchyviewer/feature.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
- id="com.android.ide.eclipse.hierarchyviewer"
+ id="com.android.ide.eclipse.hierarchyviewer.feature"
label="Android Hierarchy Viewer"
- version="22.3.0.qualifier"
+ version="23.0.2.qualifier"
provider-name="The Android Open Source Project"
plugin="com.android.ide.eclipse.hierarchyviewer">
@@ -223,8 +223,8 @@
</url>
<requires>
- <import plugin="org.eclipse.ui" version="3.6.2" match="greaterOrEqual"/>
- <import plugin="org.eclipse.core.runtime" version="3.6.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.ui" version="3.7.0" match="greaterOrEqual"/>
+ <import plugin="org.eclipse.core.runtime" version="3.7.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.ui.console"/>
<import plugin="com.android.ide.eclipse.ddms" match="perfect"/>
</requires>
diff --git a/eclipse/features/com.android.ide.eclipse.hierarchyviewer/pom.xml b/eclipse/features/com.android.ide.eclipse.hierarchyviewer/pom.xml
new file mode 100644
index 0000000..b39f791
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.hierarchyviewer/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.hierarchyviewer.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+ <name>hierarchyviewer</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/features/com.android.ide.eclipse.monitor/.project b/eclipse/features/com.android.ide.eclipse.monitor/.project
new file mode 100644
index 0000000..347f1dc
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.monitor/.project
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>feature-monitor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
diff --git a/eclipse/features/com.android.ide.eclipse.monitor/build.properties b/eclipse/features/com.android.ide.eclipse.monitor/build.properties
new file mode 100644
index 0000000..64f93a9
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.monitor/build.properties
@@ -0,0 +1 @@
+bin.includes = feature.xml
diff --git a/eclipse/features/com.android.ide.eclipse.monitor/feature.xml b/eclipse/features/com.android.ide.eclipse.monitor/feature.xml
new file mode 100644
index 0000000..568230e
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.monitor/feature.xml
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="com.android.ide.eclipse.monitor.feature"
+ label="Android Monitor"
+ version="23.0.2.qualifier"
+ provider-name="The Android Open Source Project"
+ plugin="com.android.ide.eclipse.monitor">
+
+ <description>
+ Android Debug Monitor
+ </description>
+
+ <copyright>
+ Copyright (C) 2007-2014 The Android Open Source Project
+ </copyright>
+
+ <license url="http://www.apache.org/licenses/LICENSE-2.0">
+ Note: jcommon-1.0.12.jar is under the BSD license rather than the APL. You can find a copy of the BSD License at http://www.opensource.org/licenses/bsd-license.php
+
+ jfreechart-1.0.9.jar and jfreechart-1.0.9-swt.jar are under the LGPL rather than the APL. You can find a copy of the LGPL at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt. You can get the source code for these two components at http://android.git.kernel.org/pub/jfreechart-1.0.9.zip
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ &quot;License&quot; shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ &quot;Licensor&quot; shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ &quot;Legal Entity&quot; shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ &quot;control&quot; means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ &quot;You&quot; (or &quot;Your&quot;) shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ &quot;Source&quot; form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ &quot;Object&quot; form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ &quot;Work&quot; shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ &quot;Derivative Works&quot; shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ &quot;Contribution&quot; shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, &quot;submitted&quot;
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as &quot;Not a Contribution.&quot;
+
+ &quot;Contributor&quot; shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a &quot;NOTICE&quot; text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an &quot;AS IS&quot; BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets &quot;[]&quot;
+ replaced with your own identifying information. (Don&apos;t include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same &quot;printed page&quot; as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ </license>
+
+ <plugin
+ id="com.android.ide.eclipse.monitor"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
diff --git a/eclipse/features/com.android.ide.eclipse.monitor/pom.xml b/eclipse/features/com.android.ide.eclipse.monitor/pom.xml
new file mode 100644
index 0000000..ecffc6f
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.monitor/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.monitor.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+ <name>monitor</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/features/com.android.ide.eclipse.ndk/feature.xml b/eclipse/features/com.android.ide.eclipse.ndk/feature.xml
index 2ca0a61..327cf6e 100644
--- a/eclipse/features/com.android.ide.eclipse.ndk/feature.xml
+++ b/eclipse/features/com.android.ide.eclipse.ndk/feature.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
- id="com.android.ide.eclipse.ndk"
+ id="com.android.ide.eclipse.ndk.feature"
label="Android Native Development Tools"
- version="22.3.0.qualifier"
+ version="23.0.2.qualifier"
provider-name="The Android Open Source Project">
<description>
diff --git a/eclipse/features/com.android.ide.eclipse.ndk/pom.xml b/eclipse/features/com.android.ide.eclipse.ndk/pom.xml
new file mode 100644
index 0000000..2f01d5c
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.ndk/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.ndk.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+ <name>ndk</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/features/com.android.ide.eclipse.pdt/feature.xml b/eclipse/features/com.android.ide.eclipse.pdt/feature.xml
index bd3f876..6339999 100644
--- a/eclipse/features/com.android.ide.eclipse.pdt/feature.xml
+++ b/eclipse/features/com.android.ide.eclipse.pdt/feature.xml
@@ -2,7 +2,7 @@
<feature
id="com.android.ide.eclipse.pdt"
label="Android Platform Development Tools"
- version="22.3.0.qualifier"
+ version="23.0.2.qualifier"
provider-name="The Android Open Source Project">
<description>
diff --git a/eclipse/features/com.android.ide.eclipse.tests/feature.xml b/eclipse/features/com.android.ide.eclipse.tests/feature.xml
index 932822d..42f4aff 100644
--- a/eclipse/features/com.android.ide.eclipse.tests/feature.xml
+++ b/eclipse/features/com.android.ide.eclipse.tests/feature.xml
@@ -2,7 +2,7 @@
<feature
id="com.android.ide.eclipse.tests"
label="ADT Tests"
- version="22.3.0.qualifier"
+ version="23.0.2.qualifier"
provider-name="The Android Open Source Project">
<copyright>
diff --git a/eclipse/features/com.android.ide.eclipse.traceview/feature.xml b/eclipse/features/com.android.ide.eclipse.traceview/feature.xml
index 37bf9a4..330b9a5 100644
--- a/eclipse/features/com.android.ide.eclipse.traceview/feature.xml
+++ b/eclipse/features/com.android.ide.eclipse.traceview/feature.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<feature
- id="com.android.ide.eclipse.traceview"
+ id="com.android.ide.eclipse.traceview.feature"
label="Android Traceview"
- version="22.3.0.qualifier"
+ version="23.0.2.qualifier"
provider-name="The Android Open Source Project"
plugin="com.android.ide.eclipse.traceview">
@@ -223,14 +223,10 @@
</url>
<requires>
- <import plugin="org.eclipse.ui" version="3.6.2" match="greaterOrEqual"/>
- <import plugin="org.eclipse.core.runtime" version="3.6.0" match="greaterOrEqual"/>
- <import plugin="org.eclipse.ui.ide"/>
+ <import plugin="org.eclipse.core.runtime" version="3.7.0" match="greaterOrEqual"/>
<import plugin="com.android.ide.eclipse.ddms" version="10.0.0" match="greaterOrEqual"/>
<import plugin="org.eclipse.core.filesystem"/>
<import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.jdt.core"/>
- <import plugin="org.eclipse.jdt.ui"/>
</requires>
<plugin
diff --git a/eclipse/features/com.android.ide.eclipse.traceview/pom.xml b/eclipse/features/com.android.ide.eclipse.traceview/pom.xml
new file mode 100644
index 0000000..7e2e444
--- /dev/null
+++ b/eclipse/features/com.android.ide.eclipse.traceview/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.traceview.feature</artifactId>
+ <packaging>eclipse-feature</packaging>
+ <name>traceview</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.overlay/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.adt.overlay/META-INF/MANIFEST.MF
index 8ba1dcd..e492b1d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt.overlay/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.adt.overlay/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ADT XML Overlay
Bundle-SymbolicName: overlay.com.android.ide.eclipse.adt.overlay;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Vendor: The Android Open Source Project
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.overlay/pom.xml b/eclipse/plugins/com.android.ide.eclipse.adt.overlay/pom.xml
new file mode 100644
index 0000000..29bdf7c
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt.overlay/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>overlay.com.android.ide.eclipse.adt.overlay</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>adt.overlay</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/.classpath b/eclipse/plugins/com.android.ide.eclipse.adt.package/.classpath
deleted file mode 100644
index 522e779..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt.package/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
-
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/.project b/eclipse/plugins/com.android.ide.eclipse.adt.package/.project
index 50d3fd1..eedf4c6 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt.package/.project
+++ b/eclipse/plugins/com.android.ide.eclipse.adt.package/.project
@@ -6,11 +6,6 @@
</projects>
<buildSpec>
<buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
@@ -23,6 +18,5 @@
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.adt.package/META-INF/MANIFEST.MF
index 010bf28..c5fd42c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt.package/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.adt.package/META-INF/MANIFEST.MF
@@ -2,16 +2,9 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ADT Package
Bundle-SymbolicName: com.android.ide.eclipse.adt.package;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Vendor: The Android Open Source Project
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Eclipse-BundleShape: dir
Require-Bundle: org.eclipse.platform,
- org.eclipse.equinox.app,
- org.eclipse.ui.intro,
- org.eclipse.ui.workbench,
- org.eclipse.swt,
- org.eclipse.core.runtime,
- org.eclipse.core.commands,
- org.eclipse.ui.forms,
- org.eclipse.jface,
- com.android.ide.eclipse.adt
+ org.eclipse.equinox.app
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/about.mappings b/eclipse/plugins/com.android.ide.eclipse.adt.package/about.mappings
deleted file mode 100644
index c77017a..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt.package/about.mappings
+++ /dev/null
@@ -1 +0,0 @@
-0=buildId \ No newline at end of file
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/build.properties b/eclipse/plugins/com.android.ide.eclipse.adt.package/build.properties
index ad2df37..0688953 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt.package/build.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.adt.package/build.properties
@@ -4,9 +4,7 @@ bin.includes = META-INF/,\
plugin.xml,\
.,\
plugin_customization.ini,\
- ide.product,\
adt-about.png,\
- about.mappings,\
splash.bmp,\
icons/,\
about.ini,\
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/ide.product b/eclipse/plugins/com.android.ide.eclipse.adt.package/ide.product
deleted file mode 100644
index b532c53..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt.package/ide.product
+++ /dev/null
@@ -1,46 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?pde version="3.5"?>
-
-<product name="Android Developer Tools" uid="com.android.ide.eclipse.adt.package.product" id="com.android.ide.eclipse.adt.package.product" application="org.eclipse.ui.ide.workbench" version="22.3.0.qualifier" useFeatures="true" includeLaunchers="true">
-
- <configIni use="default">
- </configIni>
-
- <launcherArgs>
- <programArgs>-product com.android.ide.eclipse.adt.package.product</programArgs>
- <programArgsWin>--launcher.XXMaxPermSize 256M</programArgsWin>
- <vmArgs>-Dosgi.requiredJavaVersion=1.6 -Xms40m -Xmx768m</vmArgs>
- <vmArgsLin>-XX:MaxPermSize=256m</vmArgsLin>
- <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
- </launcherArgs>
-
- <windowImages/>
-
- <splash
- location="com.android.ide.eclipse.adt.package" />
- <launcher>
- <solaris/>
- <win useIco="true">
- <ico path="/plugin-adt-package/icons/adt.ico"/>
- <bmp/>
- </win>
- </launcher>
-
- <vm>
- <linux include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</linux>
- <macos include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</macos>
- <windows include="false">org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6</windows>
- </vm>
-
- <plugins>
- </plugins>
-
- <features>
- <feature id="com.android.ide.eclipse.adt.package"/>
- </features>
-
- <configurations>
- <property name="eclipse.product" value="com.android.ide.eclipse.adt.package.product" />
- </configurations>
-
-</product>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.adt.package/plugin.xml
index fbeabb9..7974659 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt.package/plugin.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.adt.package/plugin.xml
@@ -2,25 +2,25 @@
<?eclipse version="3.4"?>
<plugin>
<extension
- id="product"
+ id="adtproduct"
+ name="ADT Bundle"
point="org.eclipse.core.runtime.products">
<product
application="org.eclipse.ui.ide.workbench"
- description="Android Developer Tools"
- name="ADT">
+ name="Eclipse">
<property
name="preferenceCustomization"
value="plugin_customization.ini" />
<property
name="appName"
- value="ADT" />
+ value="Eclipse" />
<property
name="aboutImage"
value="adt-about.png">
</property>
<property
name="aboutText"
- value="Android Developer Tools&#x0A;&#x0A;Build: {0}&#x0A;&#x0A;This product includes Eclipse Platform, JDT, CDT, EMF, GEF and WTP,&#x0A;all of which are Copyright (c) Eclipse contributors and others.&#x0A;Visit http://eclipse.org/&#x0A;&#x0A;Android Developer Tools are Copyright (c) The Android Open Source Project.&#x0A;Visit http://developer.android.com">
+ value="Android Developer Tools&#x0A;&#x0A;This product includes Eclipse Platform, JDT, CDT, EMF, GEF and WTP, all of which are&#x0A;Copyright (c) Eclipse contributors and others.&#x0A;Visit http://eclipse.org/&#x0A;&#x0A;Android Developer Tools are Copyright (c) The Android Open Source Project.&#x0A;Visit http://developer.android.com">
</property>
<property
name="startupProgressRect"
@@ -36,27 +36,35 @@
value="icons/adt16.png,icons/adt32.png,icons/adt48.png">
</property>
<property
+ name="introBrandingImage"
+ value="product:intro-eclipse.png">
+ </property>
+ <property
+ name="introTitle"
+ value="Welcome to the Eclipse IDE for Android Developers">
+ </property>
+ <property
+ name="introBrandingImageText"
+ value="Eclipse Project">
+ </property>
+ <property
+ name="applicationXMI"
+ value="org.eclipse.platform/LegacyIDE.e4xmi">
+ </property>
+ <property
name="cssTheme"
value="org.eclipse.e4.ui.css.theme.e4_default">
</property>
<property
name="applicationCSSResources"
- value="platform:/plugin/org.eclipse.platform/images/">
+ value="platform:/plugin/org.eclipse.ui.themes/images/">
</property>
</product>
</extension>
<extension
point="org.eclipse.ui.intro">
- <intro
- class="com.android.ide.eclipse.adt.internal.AdtIntro"
- icon="icons/adt16.png"
- id="com.android.ide.eclipse.adt.intro"
- label="Android IDE"/>
- </extension>
- <extension
- point="org.eclipse.ui.intro">
<introProductBinding
- introId="com.android.ide.eclipse.adt.intro"
+ introId="org.eclipse.ui.intro.universal"
productId="com.android.ide.eclipse.adt.package.product">
</introProductBinding>
</extension>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/plugin_customization.ini b/eclipse/plugins/com.android.ide.eclipse.adt.package/plugin_customization.ini
index 996af37..5585184 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt.package/plugin_customization.ini
+++ b/eclipse/plugins/com.android.ide.eclipse.adt.package/plugin_customization.ini
@@ -3,6 +3,6 @@ org.eclipse.ui/SHOW_TRADITIONAL_STYLE_TABS=false
org.eclipse.ui/DOCK_PERSPECTIVE_BAR=topRight
org.eclipse.ui/PERSPECTIVE_BAR_EXTRAS=com.android.ide.eclipse.ddms.Perspective
org.eclipse.ui/PERSPECTIVE_BAR_SIZE=250
-org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP=true
+org.eclipse.ui/SHOW_PROGRESS_ON_STARTUP = false
org.eclipse.ui.workbench/SHOW_BUILDID_ON_STARTUP=true
org.eclipse.ui/SHOW_MEMORY_MONITOR=true \ No newline at end of file
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/pom.xml b/eclipse/plugins/com.android.ide.eclipse.adt.package/pom.xml
new file mode 100644
index 0000000..ab9f665
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt.package/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.adt.package</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>adt.package</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt.package/src/com/android/ide/eclipse/adt/internal/AdtIntro.java b/eclipse/plugins/com.android.ide.eclipse.adt.package/src/com/android/ide/eclipse/adt/internal/AdtIntro.java
deleted file mode 100644
index 27e758c..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt.package/src/com/android/ide/eclipse/adt/internal/AdtIntro.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.eclipse.adt.internal;
-
-import com.android.ide.eclipse.adt.AdtPlugin;
-import com.android.ide.eclipse.adt.internal.wizards.actions.NewProjectAction;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.browser.IWebBrowser;
-import org.eclipse.ui.browser.IWorkbenchBrowserSupport;
-import org.eclipse.ui.forms.events.HyperlinkAdapter;
-import org.eclipse.ui.forms.events.HyperlinkEvent;
-import org.eclipse.ui.forms.events.IHyperlinkListener;
-import org.eclipse.ui.forms.widgets.FormToolkit;
-import org.eclipse.ui.forms.widgets.Hyperlink;
-import org.eclipse.ui.forms.widgets.ScrolledForm;
-import org.eclipse.ui.forms.widgets.Section;
-import org.eclipse.ui.intro.IIntroPart;
-import org.eclipse.ui.part.IntroPart;
-
-import java.net.URL;
-
-public class AdtIntro extends IntroPart implements IIntroPart {
- private static final int TEXT_WIDTH = 600;
-
- private FormToolkit mToolkit;
- private ScrolledForm mForm;
-
- @Override
- public void standbyStateChanged(boolean standby) {
- }
-
- @Override
- public void createPartControl(Composite parent) {
- mToolkit = new FormToolkit(parent.getDisplay());
- mForm = mToolkit.createScrolledForm(parent);
-
- mForm.setText("Welcome!");
- mToolkit.decorateFormHeading(mForm.getForm());
- mForm.getToolBarManager().update(true);
-
- //TableWrapLayout layout = new TableWrapLayout();
- //layout.numColumns = 2;
- GridLayout layout = new GridLayout(1, false);
- mForm.getBody().setLayout(layout);
-
- createText(mForm.getBody(),
- "The Android Developer Tools provide a first-class development environment for " +
- "building Android apps. This integrated development environment is set up with " +
- "the latest version of the Android platform and system image so you can " +
- "immediately begin building apps and running them on the Android emulator."
- );
-
- Button newProject = mToolkit.createButton(mForm.getBody(),
- "New Android Application...",
- SWT.PUSH);
- newProject.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- NewProjectAction npwAction = new NewProjectAction();
- npwAction.run(null /*action*/);
- PlatformUI.getWorkbench().getIntroManager().closeIntro(AdtIntro.this);
- }
- });
-
- Section section = mToolkit.createSection(mForm.getBody(),
- Section.SHORT_TITLE_BAR | Section.CLIENT_INDENT);
- section.setText("Tutorials");
-
- Composite c = mToolkit.createComposite(section);
- c.setLayout(new GridLayout(2, false));
-
- createHyperlink(c, "Build Your First App",
- "http://developer.android.com/training/basics/firstapp/index.html");
- createText(c, "If you're new to Android, follow this class to learn the fundamental " +
- "Android APIs for creating a user interface that responds to input.");
-
- createHyperlink(c, "Design Your App", "http://developer.android.com/design/index.html");
- createText(c,
- "Before you begin developing your app, be sure you understand the design patterns "
- + "that Android users expect from your app.");
-
- createHyperlink(c, "Test Your App",
- "http://developer.android.com/tools/testing/testing_android.html");
- createText(c, "The Android Framework provides tools that help you test every aspect of "
- + "your app to be sure it behaves as expected under various conditions.");
-
- section.setClient(c);
-
- mForm.reflow(true);
- }
-
- private void createText(Composite body, String text) {
- Label l = mToolkit.createLabel(body, text, SWT.WRAP);
- GridData gd = new GridData();
- gd.widthHint = TEXT_WIDTH;
- l.setLayoutData(gd);
- }
-
- private void createHyperlink(Composite c, String text, String url) {
- Hyperlink link = mToolkit.createHyperlink(c, text, SWT.WRAP);
- link.setHref(url);
- link.addHyperlinkListener(sHyperLinkListener);
- GridData gd = new GridData();
- gd.verticalAlignment = SWT.TOP;
- link.setLayoutData(gd);
- }
-
- private static final IHyperlinkListener sHyperLinkListener = new HyperlinkAdapter() {
- @Override
- public void linkActivated(HyperlinkEvent e) {
- if (!(e.getHref() instanceof String)) {
- return;
- }
-
- String url = (String) e.getHref();
- if (url.isEmpty()) {
- return;
- }
-
- IWorkbenchBrowserSupport support = PlatformUI.getWorkbench().getBrowserSupport();
- IWebBrowser browser;
- try {
- browser = support.getExternalBrowser();
- browser.openURL(new URL(url));
- } catch (Exception ex) {
- AdtPlugin.log(ex, "Error launching browser for URL: %1$s", url);
- }
- }
- };
-
- @Override
- public void setFocus() {
- mForm.setFocus();
- }
-
- @Override
- public void dispose() {
- if (mToolkit != null) {
- mToolkit.dispose();
- mToolkit = null;
- }
-
- super.dispose();
- }
-}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/.classpath b/eclipse/plugins/com.android.ide.eclipse.adt/.classpath
index 89b762f..fcf27a5 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/.classpath
@@ -3,20 +3,20 @@
<classpathentry excluding="Makefile|resources/" kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry exported="true" kind="lib" path="libs/ninepatch.jar" sourcepath="/ninepatch"/>
- <classpathentry exported="true" kind="lib" path="libs/sdkuilib.jar" sourcepath="/sdkuilib"/>
- <classpathentry exported="true" kind="lib" path="libs/rule-api.jar" sourcepath="/rule-api"/>
- <classpathentry exported="true" kind="lib" path="libs/lint-api.jar" sourcepath="/lint-api"/>
- <classpathentry exported="true" kind="lib" path="libs/lint-checks.jar" sourcepath="/lint-checks"/>
- <classpathentry exported="true" kind="lib" path="libs/asset-studio.jar" sourcepath="/asset-studio"/>
- <classpathentry exported="true" kind="lib" path="libs/ant-glob.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/freemarker-2.3.19.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/manifest-merger.jar" sourcepath="/ManifestMerger"/>
- <classpathentry exported="true" kind="lib" path="libs/lombok-ast-0.2.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/propertysheet.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/asm-4.0.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/asm-analysis-4.0.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/asm-tree-4.0.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/swtmenubar.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ninepatch.jar" sourcepath="/ninepatch"/>
+ <classpathentry exported="true" kind="lib" path="libs/sdkuilib.jar" sourcepath="/sdkuilib"/>
+ <classpathentry exported="true" kind="lib" path="libs/rule-api.jar" sourcepath="/rule-api"/>
+ <classpathentry exported="true" kind="lib" path="libs/lint-api.jar" sourcepath="/lint-api"/>
+ <classpathentry exported="true" kind="lib" path="libs/lint-checks.jar" sourcepath="/lint-checks"/>
+ <classpathentry exported="true" kind="lib" path="libs/asset-studio.jar" sourcepath="/asset-studio"/>
+ <classpathentry exported="true" kind="lib" path="libs/ant-glob.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/freemarker-2.3.20.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/manifest-merger.jar" sourcepath="/ManifestMerger"/>
+ <classpathentry exported="true" kind="lib" path="libs/lombok-ast-0.2.2.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/propertysheet.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/asm-4.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/asm-analysis-4.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/asm-tree-4.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/swtmenubar.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/.gitignore b/eclipse/plugins/com.android.ide.eclipse.adt/.gitignore
deleted file mode 100644
index d392f0e..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF
index bd72b31..77eb219 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/META-INF/MANIFEST.MF
@@ -2,16 +2,16 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Android Development Toolkit
Bundle-SymbolicName: com.android.ide.eclipse.adt;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-ClassPath: .,
libs/sdkuilib.jar,
libs/ninepatch.jar,
- libs/freemarker-2.3.19.jar,
+ libs/freemarker-2.3.20.jar,
libs/rule-api.jar,
libs/asset-studio.jar,
libs/lint-api.jar,
libs/lint-checks.jar,
- libs/lombok-ast-0.2.jar,
+ libs/lombok-ast-0.2.2.jar,
libs/asm-4.0.jar,
libs/asm-tree-4.0.jar,
libs/asm-analysis-4.0.jar,
@@ -53,9 +53,7 @@ Require-Bundle: com.android.ide.eclipse.base,
org.eclipse.core.expressions,
org.eclipse.compare
Bundle-ActivationPolicy: lazy
-Export-Package: com.android.assetstudiolib;x-friends:="com.android.ide.eclipse.tests",
- com.android.ide.common.api;x-friends:="com.android.ide.eclipse.tests",
- com.android.ide.common.layout;x-friends:="com.android.ide.eclipse.tests",
+Export-Package: com.android.ide.common.layout;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.common.layout.grid;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.common.layout.relative;x-friends:="com.android.ide.eclipse.tests",
com.android.ide.common.resources.platform;x-friends:="com.android.ide.eclipse.tests",
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/adt-platform-juno-sr2.target b/eclipse/plugins/com.android.ide.eclipse.adt/adt-platform-juno-sr2.target
new file mode 100644
index 0000000..b63f382
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/adt-platform-juno-sr2.target
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<?pde version="3.8"?>
+
+<target name="adt-platform-juno-sr2" sequenceNumber="4">
+<locations>
+<location includeAllPlatforms="false" includeConfigurePhase="true" includeMode="planner" includeSource="true" type="InstallableUnit">
+<unit id="org.eclipse.platform.ide" version="4.2.2.M20130204-1200"/>
+<unit id="org.eclipse.gef.feature.group" version="3.9.0.201212170307"/>
+<unit id="org.eclipse.wst.xml_ui.feature.feature.group" version="3.4.2.v201211061806-7H7GFeJDxumUrsn5qkiQgOEhsz0p60HAmPyU6VX"/>
+<unit id="org.eclipse.pde.source.feature.group" version="3.8.2.v20130116-091538-7c7wFj0FFt6Zr9bd4AM1JEQMS"/>
+<unit id="org.eclipse.emf.codegen.feature.group" version="2.8.0.v20130125-0826"/>
+<unit id="org.eclipse.jdt.feature.group" version="3.8.2.v20130116-090414-8-8nFu3FNOfwKLRuqgXKIy9z0I83"/>
+<unit id="org.eclipse.emf.ecore.feature.group" version="2.8.3.v20130125-0546"/>
+<unit id="org.eclipse.emf.common.feature.group" version="2.8.0.v20130125-0546"/>
+<unit id="org.eclipse.jdt.source.feature.group" version="3.8.2.v20130116-090414-8-8nFu3FNOfwKLRuqgXKIy9z0I83"/>
+<unit id="org.eclipse.emf.feature.group" version="2.8.3.v20130125-0826"/>
+<unit id="org.eclipse.cdt.feature.group" version="8.1.2.201302132326"/>
+<unit id="org.eclipse.egit.feature.group" version="2.2.0.201212191850-r"/>
+<unit id="org.eclipse.emf.common.ui.feature.group" version="2.7.0.v20130125-0826"/>
+<unit id="org.eclipse.emf.codegen.ui.feature.group" version="2.7.0.v20130125-0826"/>
+<unit id="org.eclipse.wb.core.xml.feature.feature.group" version="1.5.2.r42x201302111919"/>
+<repository location="http://download.eclipse.org/releases/juno"/>
+</location>
+</locations>
+</target>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/adt.launch b/eclipse/plugins/com.android.ide.eclipse.adt/adt.launch
new file mode 100644
index 0000000..5699837
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/adt.launch
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
+<booleanAttribute key="append.args" value="true"/>
+<booleanAttribute key="askclear" value="true"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="false"/>
+<booleanAttribute key="clearws" value="false"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/adt"/>
+<booleanAttribute key="default" value="false"/>
+<stringAttribute key="deselected_workspace_plugins" value="com.android.ide.eclipse.monitor"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../runtime-adt-idea133-ksr2"/>
+<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-XX:MaxPermSize=256m&#10;-Xms128m&#10;-Xmx1024m"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="org.eclipse.platform.ide"/>
+<stringAttribute key="selected_target_plugins" value="com.android.tools.asset-studio@default:default,com.android.tools.build.er-model@default:default,com.android.tools.build.manifest-merger@default:default,com.android.tools.common@default:default,com.android.tools.ddms.ddmlib@default:default,com.android.tools.ddms.ddmuilib@default:default,com.android.tools.dvlib@default:default,com.android.tools.external.ant-glob@default:default,com.android.tools.external.liblzf@default:default,com.android.tools.external.libprotobuf-java-lite@default:default,com.android.tools.external.lombok.ast@default:default,com.android.tools.external.propertysheet@default:default,com.android.tools.hierarchyviewer2lib@default:default,com.android.tools.layoutlib.api@default:default,com.android.tools.lint.api@default:default,com.android.tools.lint.checks@default:default,com.android.tools.ninepatch@default:default,com.android.tools.rule-api@default:default,com.android.tools.sdk-common@default:default,com.android.tools.sdklib@default:default,com.android.tools.sdkstats@default:default,com.android.tools.sdkuilib@default:default,com.android.tools.swtmenubar@default:default,com.android.tools.testutils@default:default,com.android.tools.traceview@default:default,com.android.tools.uiautomatorviewer@default:default,com.google.guava@default:default,com.ibm.icu@default:default,com.jcraft.jsch@default:default,com.sun.el@default:default,commons-logging@default:default,java_cup.runtime@default:default,javax.activation@default:default,javax.annotation@default:default,javax.el@default:default,javax.inject@default:default,javax.jws@default:default,javax.mail@default:default,javax.persistence@default:default,javax.servlet.jsp@default:default,javax.servlet@default:default,javax.wsdl*1.5.1.v201012040544@default:default,javax.wsdl*1.6.2.v201012040545@default:default,javax.xml.bind@default:default,javax.xml.rpc@default:default,javax.xml.soap@default:default,javax.xml.stream@default:default,javax.xml.ws@default:default,javax.xml@default:default,jfree.chart-swt@default:default,jfree.chart@default:default,jfree.jcommon@default:default,junit@default:default,net.sf.kxml.2@default:default,net.sourceforge.lpg.lpgjavaruntime@default:default,org.apache.ant@default:default,org.apache.axis@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.bcel@default:default,org.apache.commons.codec*1.4.0.v201209201156@default:default,org.apache.commons.codec*1.4.0@default:default,org.apache.commons.collections@default:default,org.apache.commons.compress@default:default,org.apache.commons.discovery@default:default,org.apache.commons.lang@default:default,org.apache.commons.logging*1.0.4.v201101211617@default:default,org.apache.commons.logging*1.1.1.v201101211721@default:default,org.apache.felix.gogo.command@default:default,org.apache.felix.gogo.runtime@default:default,org.apache.felix.gogo.shell@default:default,org.apache.httpcomponents.httpclient*4.1.1@default:default,org.apache.httpcomponents.httpclient*4.1.3.v201209201135@default:default,org.apache.httpcomponents.httpcore*4.1.0@default:default,org.apache.httpcomponents.httpcore*4.1.4.v201203221030@default:default,org.apache.httpcomponents.httpmime@default:default,org.apache.jasper.glassfish@default:default,org.apache.log4j@default:default,org.apache.lucene.analysis@default:default,org.apache.lucene.core@default:default,org.apache.velocity@default:default,org.apache.wsil4j@default:default,org.apache.xalan@default:default,org.apache.xerces@default:default,org.apache.xml.resolver@default:default,org.apache.xml.serializer@default:default,org.eclipse.ant.core@default:default,org.eclipse.ant.launching@default:default,org.eclipse.ant.ui@default:default,org.eclipse.cdt.autotools.core@default:default,org.eclipse.cdt.autotools.docs@default:default,org.eclipse.cdt.autotools.ui@default:default,org.eclipse.cdt.build.crossgcc@default:default,org.eclipse.cdt.codan.checkers.ui@default:default,org.eclipse.cdt.codan.checkers@default:default,org.eclipse.cdt.codan.core.cxx@default:default,org.eclipse.cdt.codan.core@default:default,org.eclipse.cdt.codan.ui.cxx@default:default,org.eclipse.cdt.codan.ui@default:default,org.eclipse.cdt.core.aix@default:false,org.eclipse.cdt.core.linux.ppc64@default:false,org.eclipse.cdt.core.linux.x86@default:false,org.eclipse.cdt.core.linux.x86_64@default:false,org.eclipse.cdt.core.linux@default:false,org.eclipse.cdt.core.lrparser.xlc@default:default,org.eclipse.cdt.core.lrparser@default:default,org.eclipse.cdt.core.macosx@default:false,org.eclipse.cdt.core.parser.upc@default:default,org.eclipse.cdt.core.solaris@default:false,org.eclipse.cdt.core.win32.x86@default:false,org.eclipse.cdt.core.win32.x86_64@default:false,org.eclipse.cdt.core.win32@default:false,org.eclipse.cdt.core@default:default,org.eclipse.cdt.debug.core@default:default,org.eclipse.cdt.debug.gdbjtag.core@default:default,org.eclipse.cdt.debug.gdbjtag.ui@default:default,org.eclipse.cdt.debug.gdbjtag@default:default,org.eclipse.cdt.debug.mi.core@default:default,org.eclipse.cdt.debug.mi.ui@default:default,org.eclipse.cdt.debug.ui.memory.floatingpoint@default:default,org.eclipse.cdt.debug.ui.memory.memorybrowser@default:default,org.eclipse.cdt.debug.ui.memory.search@default:default,org.eclipse.cdt.debug.ui.memory.traditional@default:default,org.eclipse.cdt.debug.ui.memory.transport@default:default,org.eclipse.cdt.debug.ui@default:default,org.eclipse.cdt.doc.isv@default:default,org.eclipse.cdt.doc.user@default:default,org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui@default:default,org.eclipse.cdt.dsf.gdb.ui@default:default,org.eclipse.cdt.dsf.gdb@default:default,org.eclipse.cdt.dsf.ui@default:default,org.eclipse.cdt.dsf@default:default,org.eclipse.cdt.errorparsers.xlc@default:default,org.eclipse.cdt.examples.dsf.pda.ui@default:default,org.eclipse.cdt.examples.dsf.pda@default:default,org.eclipse.cdt.examples.dsf@default:default,org.eclipse.cdt.gdb.ui@default:default,org.eclipse.cdt.gdb@default:default,org.eclipse.cdt.launch.remote@default:default,org.eclipse.cdt.launch@default:default,org.eclipse.cdt.make.core@default:default,org.eclipse.cdt.make.ui@default:default,org.eclipse.cdt.make.xlc.core@default:default,org.eclipse.cdt.managedbuilder.bupc.ui@default:default,org.eclipse.cdt.managedbuilder.core@default:default,org.eclipse.cdt.managedbuilder.gnu.ui@default:default,org.eclipse.cdt.managedbuilder.llvm.ui@default:default,org.eclipse.cdt.managedbuilder.ui@default:default,org.eclipse.cdt.managedbuilder.xlc.core@default:default,org.eclipse.cdt.managedbuilder.xlc.ui@default:default,org.eclipse.cdt.managedbuilder.xlupc.ui@default:default,org.eclipse.cdt.msw.build@default:default,org.eclipse.cdt.qt.core@default:default,org.eclipse.cdt.qt.ui@default:default,org.eclipse.cdt.sdk@default:default,org.eclipse.cdt.testsrunner.boost@default:default,org.eclipse.cdt.testsrunner.gtest@default:default,org.eclipse.cdt.testsrunner.qttest@default:default,org.eclipse.cdt.testsrunner@default:default,org.eclipse.cdt.ui@default:default,org.eclipse.cdt.util@default:default,org.eclipse.cdt.visualizer.core@default:default,org.eclipse.cdt.visualizer.ui@default:default,org.eclipse.cdt@default:default,org.eclipse.compare.core@default:default,org.eclipse.compare@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.beans@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.externaltools@default:default,org.eclipse.core.filebuffers@default:default,org.eclipse.core.filesystem.linux.x86_64@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.net.linux.x86_64@default:false,org.eclipse.core.net@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime.compatibility@default:default,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.debug.core@default:default,org.eclipse.debug.ui@default:default,org.eclipse.draw2d.doc.isv@default:default,org.eclipse.draw2d@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.ecf.filetransfer@default:default,org.eclipse.ecf.identity@default:default,org.eclipse.ecf.provider.filetransfer.httpclient4.ssl@default:false,org.eclipse.ecf.provider.filetransfer.httpclient4@default:default,org.eclipse.ecf.provider.filetransfer.ssl@default:false,org.eclipse.ecf.provider.filetransfer@default:default,org.eclipse.ecf.ssl@default:false,org.eclipse.ecf@default:default,org.eclipse.emf.activities@default:default,org.eclipse.emf.ant@default:default,org.eclipse.emf.cheatsheets@default:default,org.eclipse.emf.codegen.ecore.ui@default:default,org.eclipse.emf.codegen.ecore@default:default,org.eclipse.emf.codegen.ui@default:default,org.eclipse.emf.codegen@default:default,org.eclipse.emf.common.ui@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.converter@default:default,org.eclipse.emf.databinding.edit@default:default,org.eclipse.emf.databinding@default:default,org.eclipse.emf.doc@default:default,org.eclipse.emf.ecore.change.edit@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.edit@default:default,org.eclipse.emf.ecore.editor@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.emf.edit.ui@default:default,org.eclipse.emf.edit@default:default,org.eclipse.emf.example.installer@default:default,org.eclipse.emf.examples.databinding.project.core.model@default:default,org.eclipse.emf.examples.databinding.project.core@default:default,org.eclipse.emf.examples.databinding.project.ui.rcp@default:default,org.eclipse.emf.examples.generator.validator@default:default,org.eclipse.emf.examples.jet.article2@default:default,org.eclipse.emf.examples.library.edit@default:default,org.eclipse.emf.examples.library.editor@default:default,org.eclipse.emf.examples.library@default:default,org.eclipse.emf.examples@default:default,org.eclipse.emf.exporter.html@default:default,org.eclipse.emf.exporter@default:default,org.eclipse.emf.importer.ecore@default:default,org.eclipse.emf.importer.java@default:default,org.eclipse.emf.importer.rose@default:default,org.eclipse.emf.importer@default:default,org.eclipse.emf.java.edit@default:default,org.eclipse.emf.java.editor@default:default,org.eclipse.emf.java@default:default,org.eclipse.emf.mapping.ecore.editor@default:default,org.eclipse.emf.mapping.ecore2ecore.editor@default:default,org.eclipse.emf.mapping.ecore2ecore@default:default,org.eclipse.emf.mapping.ecore2xml.ui@default:default,org.eclipse.emf.mapping.ecore2xml@default:default,org.eclipse.emf.mapping.ecore@default:default,org.eclipse.emf.mapping.ui@default:default,org.eclipse.emf.mapping.xsd2ecore.editor@default:default,org.eclipse.emf.mapping.xsd2ecore@default:default,org.eclipse.emf.mapping@default:default,org.eclipse.emf@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.console@default:default,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.frameworkadmin.equinox@default:default,org.eclipse.equinox.frameworkadmin@default:default,org.eclipse.equinox.http.jetty@default:default,org.eclipse.equinox.http.registry@default:default,org.eclipse.equinox.http.servlet@default:default,org.eclipse.equinox.jsp.jasper.registry@default:default,org.eclipse.equinox.jsp.jasper@default:default,org.eclipse.equinox.launcher.gtk.linux.x86_64@default:false,org.eclipse.equinox.launcher@default:default,org.eclipse.equinox.p2.artifact.repository@default:default,org.eclipse.equinox.p2.console@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.director.app@default:default,org.eclipse.equinox.p2.director@default:default,org.eclipse.equinox.p2.directorywatcher@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.extensionlocation@default:default,org.eclipse.equinox.p2.garbagecollector@default:default,org.eclipse.equinox.p2.jarprocessor@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.operations@default:default,org.eclipse.equinox.p2.publisher.eclipse@default:default,org.eclipse.equinox.p2.publisher@default:default,org.eclipse.equinox.p2.ql@default:default,org.eclipse.equinox.p2.reconciler.dropins@default:default,org.eclipse.equinox.p2.repository.tools@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.p2.touchpoint.eclipse@default:default,org.eclipse.equinox.p2.touchpoint.natives@default:default,org.eclipse.equinox.p2.transport.ecf@default:default,org.eclipse.equinox.p2.ui.importexport@default:default,org.eclipse.equinox.p2.ui.sdk.scheduler@default:default,org.eclipse.equinox.p2.ui.sdk@default:default,org.eclipse.equinox.p2.ui@default:default,org.eclipse.equinox.p2.updatechecker@default:default,org.eclipse.equinox.p2.updatesite@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security.ui@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.simpleconfigurator.manipulator@default:default,org.eclipse.equinox.simpleconfigurator@1:true,org.eclipse.equinox.util@default:default,org.eclipse.gef.doc.isv@default:default,org.eclipse.gef.examples.flow@default:default,org.eclipse.gef.examples.logic@default:default,org.eclipse.gef.examples.shapes@default:default,org.eclipse.gef.examples.text@default:default,org.eclipse.gef.examples.ui.pde@default:default,org.eclipse.gef@default:default,org.eclipse.help.base@default:default,org.eclipse.help.ui@default:default,org.eclipse.help.webapp@default:default,org.eclipse.help@default:default,org.eclipse.jdt.annotation@default:default,org.eclipse.jdt.apt.core@default:default,org.eclipse.jdt.apt.pluggable.core@default:default,org.eclipse.jdt.apt.ui@default:default,org.eclipse.jdt.compiler.apt@default:false,org.eclipse.jdt.compiler.tool@default:false,org.eclipse.jdt.core.manipulation@default:default,org.eclipse.jdt.core@default:default,org.eclipse.jdt.debug.ui@default:default,org.eclipse.jdt.debug@default:default,org.eclipse.jdt.doc.isv@default:default,org.eclipse.jdt.doc.user@default:default,org.eclipse.jdt.junit.core@default:default,org.eclipse.jdt.junit.runtime@default:default,org.eclipse.jdt.junit4.runtime@default:default,org.eclipse.jdt.junit@default:default,org.eclipse.jdt.launching@default:default,org.eclipse.jdt.ui@default:default,org.eclipse.jdt@default:default,org.eclipse.jem.beaninfo.vm.common@default:default,org.eclipse.jem.beaninfo.vm@default:default,org.eclipse.jem.beaninfo@default:default,org.eclipse.jem.proxy@default:default,org.eclipse.jem.util@default:default,org.eclipse.jem.workbench@default:default,org.eclipse.jem@default:default,org.eclipse.jetty.continuation@default:default,org.eclipse.jetty.http@default:default,org.eclipse.jetty.io@default:default,org.eclipse.jetty.security@default:default,org.eclipse.jetty.server@default:default,org.eclipse.jetty.servlet@default:default,org.eclipse.jetty.util@default:default,org.eclipse.jetty.webapp@default:default,org.eclipse.jetty.xml@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface@default:default,org.eclipse.jpt.common.branding@default:default,org.eclipse.jpt.common.core@default:default,org.eclipse.jpt.common.eclipselink.branding@default:default,org.eclipse.jpt.common.eclipselink.core@default:default,org.eclipse.jpt.common.ui@default:default,org.eclipse.jpt.common.utility@default:default,org.eclipse.jpt.dbws.eclipselink.branding@default:default,org.eclipse.jpt.dbws.eclipselink.core.gen@default:default,org.eclipse.jpt.dbws.eclipselink.ui@default:default,org.eclipse.jpt.doc.isv@default:default,org.eclipse.jpt.doc.user@default:default,org.eclipse.jpt.jaxb.branding@default:default,org.eclipse.jpt.jaxb.core.schemagen@default:default,org.eclipse.jpt.jaxb.core@default:default,org.eclipse.jpt.jaxb.eclipselink.branding@default:default,org.eclipse.jpt.jaxb.eclipselink.core.schemagen@default:default,org.eclipse.jpt.jaxb.eclipselink.core@default:default,org.eclipse.jpt.jaxb.eclipselink.ui@default:default,org.eclipse.jpt.jaxb.ui@default:default,org.eclipse.jpt.jpa.annotate@default:default,org.eclipse.jpt.jpa.branding@default:default,org.eclipse.jpt.jpa.core@default:default,org.eclipse.jpt.jpa.db.ui@default:default,org.eclipse.jpt.jpa.db@default:default,org.eclipse.jpt.jpa.eclipselink.branding@default:default,org.eclipse.jpt.jpa.eclipselink.core.ddlgen@default:default,org.eclipse.jpt.jpa.eclipselink.core@default:default,org.eclipse.jpt.jpa.eclipselink.ui@default:default,org.eclipse.jpt.jpa.gen@default:default,org.eclipse.jpt.jpa.ui@default:default,org.eclipse.jpt.jpadiagrameditor.branding@default:default,org.eclipse.jpt.jpadiagrameditor.doc.user@default:default,org.eclipse.jpt.jpadiagrameditor.ui@default:default,org.eclipse.jsch.core@default:default,org.eclipse.jsch.ui@default:default,org.eclipse.jsf.branding@default:default,org.eclipse.jst.common.annotations.controller@default:default,org.eclipse.jst.common.annotations.core@default:default,org.eclipse.jst.common.annotations.ui@default:default,org.eclipse.jst.common.fproj.enablement.jdt.sdk@default:default,org.eclipse.jst.common.frameworks@default:default,org.eclipse.jst.common.project.facet.core@default:default,org.eclipse.jst.common.project.facet.ui@default:default,org.eclipse.jst.common.ui@default:default,org.eclipse.jst.ejb.doc.user@default:default,org.eclipse.jst.ejb.ui.infopop@default:default,org.eclipse.jst.ejb.ui@default:default,org.eclipse.jst.j2ee.core@default:default,org.eclipse.jst.j2ee.doc.user@default:default,org.eclipse.jst.j2ee.ejb.annotation.model@default:default,org.eclipse.jst.j2ee.ejb.annotations.emitter@default:default,org.eclipse.jst.j2ee.ejb.annotations.ui@default:default,org.eclipse.jst.j2ee.ejb.annotations.xdoclet@default:default,org.eclipse.jst.j2ee.ejb@default:default,org.eclipse.jst.j2ee.infopop@default:default,org.eclipse.jst.j2ee.jca.ui@default:default,org.eclipse.jst.j2ee.jca@default:default,org.eclipse.jst.j2ee.navigator.ui@default:default,org.eclipse.jst.j2ee.ui@default:default,org.eclipse.jst.j2ee.web@default:default,org.eclipse.jst.j2ee.webservice.ui@default:default,org.eclipse.jst.j2ee.webservice@default:default,org.eclipse.jst.j2ee.xdoclet.runtime@default:default,org.eclipse.jst.j2ee@default:default,org.eclipse.jst.jee.ejb@default:default,org.eclipse.jst.jee.ui@default:default,org.eclipse.jst.jee.web@default:default,org.eclipse.jst.jee@default:default,org.eclipse.jst.jsf.apache.trinidad.tagsupport@default:default,org.eclipse.jst.jsf.common.runtime@default:default,org.eclipse.jst.jsf.common.ui@default:default,org.eclipse.jst.jsf.common@default:default,org.eclipse.jst.jsf.core@default:default,org.eclipse.jst.jsf.doc.dev@default:default,org.eclipse.jst.jsf.doc.user@default:default,org.eclipse.jst.jsf.facelet.core@default:default,org.eclipse.jst.jsf.facelet.ui@default:default,org.eclipse.jst.jsf.facesconfig.ui@default:default,org.eclipse.jst.jsf.facesconfig@default:default,org.eclipse.jst.jsf.standard.tagsupport@default:default,org.eclipse.jst.jsf.ui@default:default,org.eclipse.jst.jsp.core@default:default,org.eclipse.jst.jsp.ui.infopop@default:default,org.eclipse.jst.jsp.ui@default:default,org.eclipse.jst.pagedesigner.jsf.ui@default:default,org.eclipse.jst.pagedesigner.jsp.core@default:default,org.eclipse.jst.pagedesigner@default:default,org.eclipse.jst.server.core@default:default,org.eclipse.jst.server.generic.core@default:default,org.eclipse.jst.server.generic.jboss@default:default,org.eclipse.jst.server.generic.jonas@default:default,org.eclipse.jst.server.generic.ui@default:default,org.eclipse.jst.server.preview.adapter@default:default,org.eclipse.jst.server.tomcat.core@default:default,org.eclipse.jst.server.tomcat.ui@default:default,org.eclipse.jst.server.ui.doc.user@default:default,org.eclipse.jst.server.ui.infopop@default:default,org.eclipse.jst.server.ui@default:default,org.eclipse.jst.servlet.ui.infopop@default:default,org.eclipse.jst.servlet.ui@default:default,org.eclipse.jst.standard.schemas@default:default,org.eclipse.jst.ws.annotations.core@default:default,org.eclipse.jst.ws.axis.consumption.core@default:default,org.eclipse.jst.ws.axis.consumption.ui@default:default,org.eclipse.jst.ws.axis.creation.ui@default:default,org.eclipse.jst.ws.axis.infopop@default:default,org.eclipse.jst.ws.axis.ui.doc.user@default:default,org.eclipse.jst.ws.axis2.consumption.core@default:default,org.eclipse.jst.ws.axis2.consumption.ui@default:default,org.eclipse.jst.ws.axis2.core@default:default,org.eclipse.jst.ws.axis2.creation.core@default:default,org.eclipse.jst.ws.axis2.creation.ui@default:default,org.eclipse.jst.ws.axis2.ui.doc.user@default:default,org.eclipse.jst.ws.axis2.ui@default:default,org.eclipse.jst.ws.consumption.infopop@default:default,org.eclipse.jst.ws.consumption.ui.doc.user@default:default,org.eclipse.jst.ws.consumption.ui@default:default,org.eclipse.jst.ws.consumption@default:default,org.eclipse.jst.ws.creation.ejb.ui@default:default,org.eclipse.jst.ws.creation.ui@default:default,org.eclipse.jst.ws.cxf.consumption.core@default:default,org.eclipse.jst.ws.cxf.consumption.ui@default:default,org.eclipse.jst.ws.cxf.core@default:default,org.eclipse.jst.ws.cxf.creation.core@default:default,org.eclipse.jst.ws.cxf.creation.ui@default:default,org.eclipse.jst.ws.cxf.doc.user@default:default,org.eclipse.jst.ws.cxf.ui@default:default,org.eclipse.jst.ws.doc.user@default:default,org.eclipse.jst.ws.infopop@default:default,org.eclipse.jst.ws.jaxb.core@default:default,org.eclipse.jst.ws.jaxrs.core@default:default,org.eclipse.jst.ws.jaxrs.ui@default:default,org.eclipse.jst.ws.jaxws.core@default:default,org.eclipse.jst.ws.jaxws.doc.isv@default:default,org.eclipse.jst.ws.jaxws.doc.user@default:default,org.eclipse.jst.ws.jaxws.dom.doc.isv@default:default,org.eclipse.jst.ws.jaxws.dom.integration@default:default,org.eclipse.jst.ws.jaxws.dom.runtime@default:default,org.eclipse.jst.ws.jaxws.dom.ui@default:default,org.eclipse.jst.ws.jaxws.ui@default:default,org.eclipse.jst.ws.jaxws.utils@default:default,org.eclipse.jst.ws.uddiregistry@default:default,org.eclipse.jst.ws.ui@default:default,org.eclipse.jst.ws@default:default,org.eclipse.linuxtools.cdt.autotools.core@default:default,org.eclipse.ltk.core.refactoring@default:default,org.eclipse.ltk.ui.refactoring@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi.util@default:default,org.eclipse.osgi@-1:true,org.eclipse.persistence.antlr@default:default,org.eclipse.persistence.asm@default:default,org.eclipse.persistence.core@default:default,org.eclipse.persistence.dbws.builder@default:default,org.eclipse.persistence.dbws@default:default,org.eclipse.persistence.jpa.jpql@default:default,org.eclipse.persistence.jpa@default:default,org.eclipse.persistence.moxy@default:default,org.eclipse.platform.doc.user@default:default,org.eclipse.platform@default:default,org.eclipse.rcp@default:default,org.eclipse.search@default:default,org.eclipse.servertools.doc.isv@default:default,org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.team.core@default:default,org.eclipse.team.ui@default:default,org.eclipse.text@default:default,org.eclipse.ui.browser@default:default,org.eclipse.ui.cheatsheets@default:default,org.eclipse.ui.console@default:default,org.eclipse.ui.editors@default:default,org.eclipse.ui.externaltools@default:default,org.eclipse.ui.forms@default:default,org.eclipse.ui.ide.application@default:default,org.eclipse.ui.ide@default:default,org.eclipse.ui.intro.universal@default:default,org.eclipse.ui.intro@default:default,org.eclipse.ui.navigator.resources@default:default,org.eclipse.ui.navigator@default:default,org.eclipse.ui.net@default:default,org.eclipse.ui.views.properties.tabbed@default:default,org.eclipse.ui.views@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.eclipse.update.configurator@3:true,org.eclipse.wst.command.env.core@default:default,org.eclipse.wst.command.env.doc.user@default:default,org.eclipse.wst.command.env.infopop@default:default,org.eclipse.wst.command.env.ui@default:default,org.eclipse.wst.command.env@default:default,org.eclipse.wst.common.api.doc@default:default,org.eclipse.wst.common.core@default:default,org.eclipse.wst.common.emf@default:default,org.eclipse.wst.common.emfworkbench.integration@default:default,org.eclipse.wst.common.environment@default:default,org.eclipse.wst.common.fproj.sdk@default:default,org.eclipse.wst.common.frameworks.ui@default:default,org.eclipse.wst.common.frameworks@default:default,org.eclipse.wst.common.infopop@default:default,org.eclipse.wst.common.modulecore.ui@default:default,org.eclipse.wst.common.modulecore@default:default,org.eclipse.wst.common.project.facet.core@default:default,org.eclipse.wst.common.project.facet.doc.api@default:default,org.eclipse.wst.common.project.facet.ui@default:default,org.eclipse.wst.common.snippets@default:default,org.eclipse.wst.common.ui@default:default,org.eclipse.wst.common.uriresolver@default:default,org.eclipse.wst.css.core@default:default,org.eclipse.wst.css.ui@default:default,org.eclipse.wst.doc.user@default:default,org.eclipse.wst.dtd.core@default:default,org.eclipse.wst.dtd.ui.infopop@default:default,org.eclipse.wst.dtd.ui@default:default,org.eclipse.wst.dtdeditor.doc.user@default:default,org.eclipse.wst.html.core@default:default,org.eclipse.wst.html.ui.infopop@default:default,org.eclipse.wst.html.ui@default:default,org.eclipse.wst.internet.cache@default:default,org.eclipse.wst.internet.monitor.core@default:default,org.eclipse.wst.internet.monitor.ui@default:default,org.eclipse.wst.jsdt.core@default:default,org.eclipse.wst.jsdt.debug.core@default:default,org.eclipse.wst.jsdt.debug.crossfire@default:default,org.eclipse.wst.jsdt.debug.rhino.debugger@default:default,org.eclipse.wst.jsdt.debug.rhino.ui@default:default,org.eclipse.wst.jsdt.debug.rhino@default:default,org.eclipse.wst.jsdt.debug.transport@default:default,org.eclipse.wst.jsdt.debug.ui@default:default,org.eclipse.wst.jsdt.doc@default:default,org.eclipse.wst.jsdt.manipulation@default:default,org.eclipse.wst.jsdt.support.firefox@default:default,org.eclipse.wst.jsdt.support.ie@default:default,org.eclipse.wst.jsdt.ui@default:default,org.eclipse.wst.jsdt.web.core@default:default,org.eclipse.wst.jsdt.web.support.jsp@default:default,org.eclipse.wst.jsdt.web.ui@default:default,org.eclipse.wst.server.core@default:default,org.eclipse.wst.server.discovery@default:default,org.eclipse.wst.server.http.core@default:default,org.eclipse.wst.server.http.ui@default:default,org.eclipse.wst.server.preview.adapter@default:default,org.eclipse.wst.server.preview@default:default,org.eclipse.wst.server.ui.doc.user@default:default,org.eclipse.wst.server.ui.infopop@default:default,org.eclipse.wst.server.ui@default:default,org.eclipse.wst.sse.core@default:default,org.eclipse.wst.sse.doc.user@default:default,org.eclipse.wst.sse.ui.infopop@default:default,org.eclipse.wst.sse.ui@default:default,org.eclipse.wst.standard.schemas@default:default,org.eclipse.wst.validation.doc.isv@default:default,org.eclipse.wst.validation.infopop@default:default,org.eclipse.wst.validation.ui@default:default,org.eclipse.wst.validation@default:default,org.eclipse.wst.web.ui.infopop@default:default,org.eclipse.wst.web.ui@default:default,org.eclipse.wst.web@default:default,org.eclipse.wst.webtools.doc.user@default:default,org.eclipse.wst.ws.api.doc@default:default,org.eclipse.wst.ws.explorer@default:default,org.eclipse.wst.ws.infopop@default:default,org.eclipse.wst.ws.parser@default:default,org.eclipse.wst.ws.service.policy.ui@default:default,org.eclipse.wst.ws.service.policy@default:default,org.eclipse.wst.ws.ui@default:default,org.eclipse.wst.ws@default:default,org.eclipse.wst.wsdl.doc.isv@default:default,org.eclipse.wst.wsdl.ui.doc.user@default:default,org.eclipse.wst.wsdl.ui@default:default,org.eclipse.wst.wsdl.validation@default:default,org.eclipse.wst.wsdl@default:default,org.eclipse.wst.wsi.ui.doc.user@default:default,org.eclipse.wst.wsi.ui@default:default,org.eclipse.wst.wsi@default:default,org.eclipse.wst.xml.core@default:default,org.eclipse.wst.xml.ui.infopop@default:default,org.eclipse.wst.xml.ui@default:default,org.eclipse.wst.xml.xpath.core@default:default,org.eclipse.wst.xml.xpath.ui@default:default,org.eclipse.wst.xml.xpath2.processor.doc.user@default:default,org.eclipse.wst.xml.xpath2.processor@default:default,org.eclipse.wst.xml.xpath2.wtptypes@default:default,org.eclipse.wst.xml.xpath2@default:default,org.eclipse.wst.xmleditor.doc.user@default:default,org.eclipse.wst.xsd.core@default:default,org.eclipse.wst.xsd.ui@default:default,org.eclipse.wst.xsdeditor.doc.user@default:default,org.eclipse.wst.xsl.core@default:default,org.eclipse.wst.xsl.debug.ui@default:default,org.eclipse.wst.xsl.doc@default:default,org.eclipse.wst.xsl.exslt.core@default:default,org.eclipse.wst.xsl.exslt.ui@default:default,org.eclipse.wst.xsl.jaxp.debug.ui@default:default,org.eclipse.wst.xsl.jaxp.debug@default:default,org.eclipse.wst.xsl.jaxp.launching@default:default,org.eclipse.wst.xsl.launching@default:default,org.eclipse.wst.xsl.saxon@default:default,org.eclipse.wst.xsl.sdk.documentation@default:default,org.eclipse.wst.xsl.ui@default:default,org.eclipse.wst.xsl.xalan@default:default,org.eclipse.wst.xsl@default:default,org.eclipse.xsd.cheatsheets@default:default,org.eclipse.xsd.doc@default:default,org.eclipse.xsd.ecore.converter@default:default,org.eclipse.xsd.ecore.exporter@default:default,org.eclipse.xsd.ecore.importer@default:default,org.eclipse.xsd.edit@default:default,org.eclipse.xsd.editor@default:default,org.eclipse.xsd.example.installer@default:default,org.eclipse.xsd.mapping.editor@default:default,org.eclipse.xsd.mapping@default:default,org.eclipse.xsd@default:default,org.eclipse.zest.core@default:default,org.eclipse.zest.doc.isv@default:default,org.eclipse.zest.layouts@default:default,org.freemarker.freemarker@default:default,org.hamcrest.core@default:default,org.jdom@default:default,org.junit@default:default,org.mozilla.javascript@default:default,org.ow2.asm.analysis@default:default,org.ow2.asm.tree@default:default,org.ow2.asm@default:default,org.sat4j.core@default:default,org.sat4j.pb@default:default,org.uddi4j@default:default,org.w3c.css.sac@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
+<stringAttribute key="selected_workspace_plugins" value="com.android.ide.eclipse.adt.package@default:default,com.android.ide.eclipse.adt@default:default,com.android.ide.eclipse.base@default:default,com.android.ide.eclipse.ddms@default:default,com.android.ide.eclipse.gldebugger.tests@default:default,com.android.ide.eclipse.gldebugger@default:default,com.android.ide.eclipse.hierarchyviewer@default:default,com.android.ide.eclipse.ndk@default:default,com.android.ide.eclipse.pdt@default:default,com.android.ide.eclipse.tests@default:false,com.android.ide.eclipse.traceview@default:default,overlay.com.android.ide.eclipse.adt.overlay@default:default"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="true"/>
+<booleanAttribute key="useProduct" value="true"/>
+</launchConfiguration>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/build.properties b/eclipse/plugins/com.android.ide.eclipse.adt/build.properties
index 9eb0d29..32d7d7e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/build.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/build.properties
@@ -2,12 +2,11 @@ bin.includes = plugin.xml,\
META-INF/,\
icons/,\
.,\
+ libs/,\
templates/,\
about.ini,\
- libs/,\
about.properties,\
NOTICE,\
about.html
source.. = src/
output.. = bin/
-bin.excludes = libs/.gitignore
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/libs/.gitignore b/eclipse/plugins/com.android.ide.eclipse.adt/libs/.gitignore
deleted file mode 100644
index d392f0e..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.adt/libs/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/pom.xml b/eclipse/plugins/com.android.ide.eclipse.adt/pom.xml
new file mode 100644
index 0000000..2ca92f7
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.adt</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>adt</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
index cbeb274..f7ef41f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtPlugin.java
@@ -378,11 +378,6 @@ public class AdtPlugin extends AbstractUIPlugin implements ILogger {
return SdkConstants.OS_SDK_PLATFORM_TOOLS_FOLDER + SdkConstants.FN_ADB;
}
- /** Returns the zipalign path relative to the sdk folder */
- public static String getOsRelativeZipAlign() {
- return SdkConstants.OS_SDK_TOOLS_FOLDER + SdkConstants.FN_ZIPALIGN;
- }
-
/** Returns the emulator path relative to the sdk folder */
public static String getOsRelativeEmulator() {
return SdkConstants.OS_SDK_TOOLS_FOLDER + SdkConstants.FN_EMULATOR;
@@ -398,11 +393,6 @@ public class AdtPlugin extends AbstractUIPlugin implements ILogger {
return getOsSdkFolder() + getOsRelativeAdb();
}
- /** Returns the absolute zipalign path */
- public static String getOsAbsoluteZipAlign() {
- return getOsSdkFolder() + getOsRelativeZipAlign();
- }
-
/** Returns the absolute traceview path */
public static String getOsAbsoluteTraceview() {
return getOsSdkFolder() + SdkConstants.OS_SDK_TOOLS_FOLDER +
@@ -415,7 +405,7 @@ public class AdtPlugin extends AbstractUIPlugin implements ILogger {
}
public static String getOsAbsoluteHprofConv() {
- return getOsSdkFolder() + SdkConstants.OS_SDK_TOOLS_FOLDER +
+ return getOsSdkFolder() + SdkConstants.OS_SDK_PLATFORM_TOOLS_FOLDER +
AdtConstants.FN_HPROF_CONV;
}
@@ -1810,6 +1800,12 @@ public class AdtPlugin extends AbstractUIPlugin implements ILogger {
* and updates opened projects.
* <p/>
* The operation is asynchronous and happens in a background eclipse job.
+ * <p/>
+ * This operation is called in multiple places and should be reasonably
+ * cheap and conservative. The goal is to automatically refresh the SDK
+ * when it is obvious it has changed so when not sure the code should
+ * tend to not reload and avoid reloading too often (which is an expensive
+ * operation that has a lot of user impact.)
*/
public void refreshSdk() {
// SDK can't have changed if we haven't loaded it yet.
@@ -1822,8 +1818,29 @@ public class AdtPlugin extends AbstractUIPlugin implements ILogger {
@Override
protected IStatus run(IProgressMonitor monitor) {
// SDK has changed if its location path is different.
- boolean changed = sdk.getSdkLocation() == null ||
- !sdk.getSdkLocation().equals(AdtPrefs.getPrefs().getOsSdkFolder());
+ File location = sdk.getSdkFileLocation();
+ boolean changed = location == null || !location.isDirectory();
+
+ if (!changed) {
+ assert location != null;
+ File prefLocation = new File(AdtPrefs.getPrefs().getOsSdkFolder());
+ changed = !location.equals(prefLocation);
+
+ if (changed) {
+ // Basic file path comparison indicates they are not the same.
+ // Let's dig a bit deeper.
+ try {
+ location = location.getCanonicalFile();
+ prefLocation = prefLocation.getCanonicalFile();
+ changed = !location.equals(prefLocation);
+ } catch (IOException ignore) {
+ // There's no real reason for the canonicalization to fail
+ // if the paths map to actual directories. And if they don't
+ // this should have been caught above.
+ }
+ }
+ }
+
if (!changed) {
// Check whether the target directories has potentially changed.
changed = sdk.haveTargetsChanged();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java
index 697a0bc..11896d8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/AdtUtils.java
@@ -20,7 +20,6 @@ import static com.android.SdkConstants.TOOLS_PREFIX;
import static com.android.SdkConstants.TOOLS_URI;
import static org.eclipse.ui.IWorkbenchPage.MATCH_INPUT;
-import com.android.SdkConstants;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
import com.android.ide.common.sdk.SdkVersionInfo;
@@ -940,46 +939,25 @@ public class AdtUtils {
* @return a suitable version display name
*/
public static String getAndroidName(int api) {
- // See http://source.android.com/source/build-numbers.html
- switch (api) {
- case 1: return "API 1: Android 1.0";
- case 2: return "API 2: Android 1.1";
- case 3: return "API 3: Android 1.5 (Cupcake)";
- case 4: return "API 4: Android 1.6 (Donut)";
- case 5: return "API 5: Android 2.0 (Eclair)";
- case 6: return "API 6: Android 2.0.1 (Eclair)";
- case 7: return "API 7: Android 2.1 (Eclair)";
- case 8: return "API 8: Android 2.2 (Froyo)";
- case 9: return "API 9: Android 2.3 (Gingerbread)";
- case 10: return "API 10: Android 2.3.3 (Gingerbread)";
- case 11: return "API 11: Android 3.0 (Honeycomb)";
- case 12: return "API 12: Android 3.1 (Honeycomb)";
- case 13: return "API 13: Android 3.2 (Honeycomb)";
- case 14: return "API 14: Android 4.0 (IceCreamSandwich)";
- case 15: return "API 15: Android 4.0.3 (IceCreamSandwich)";
- case 16: return "API 16: Android 4.1 (Jelly Bean)";
- case 17: return "API 17: Android 4.2 (Jelly Bean)";
- // If you add more versions here, also update LintUtils#getBuildCodes and
- // SdkConstants#HIGHEST_KNOWN_API
-
- default: {
- // Consult SDK manager to see if we know any more (later) names,
- // installed by user
- Sdk sdk = Sdk.getCurrent();
- if (sdk != null) {
- for (IAndroidTarget target : sdk.getTargets()) {
- if (target.isPlatform()) {
- AndroidVersion version = target.getVersion();
- if (version.getApiLevel() == api) {
- return getTargetLabel(target);
- }
- }
+ if (api <= SdkVersionInfo.HIGHEST_KNOWN_API) {
+ return SdkVersionInfo.getAndroidName(api);
+ }
+
+ // Consult SDK manager to see if we know any more (later) names,
+ // installed by user
+ Sdk sdk = Sdk.getCurrent();
+ if (sdk != null) {
+ for (IAndroidTarget target : sdk.getTargets()) {
+ if (target.isPlatform()) {
+ AndroidVersion version = target.getVersion();
+ if (version.getApiLevel() == api) {
+ return getTargetLabel(target);
}
}
-
- return "API " + api;
}
}
+
+ return "API " + api;
}
/**
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/VersionCheck.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/VersionCheck.java
index 45e350d..19d933d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/VersionCheck.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/VersionCheck.java
@@ -51,7 +51,7 @@ public final class VersionCheck {
/**
* The minimum version of the SDK Tools that this version of ADT requires.
*/
- private final static FullRevision MIN_TOOLS_REV = new FullRevision(22, 2, 1, 0);
+ private final static FullRevision MIN_TOOLS_REV = new FullRevision(23, 0, 0, 0);
/**
* Pattern to get the minimum plugin version supported by the SDK. This is read from
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
index c21c8a4..f0af8bb 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AddSupportJarAction.java
@@ -87,7 +87,13 @@ public class AddSupportJarAction implements IObjectActionDelegate {
private static final String FD_GRIDLAYOUT = "gridlayout"; //$NON-NLS-1$
private static final String FD_V7 = "v7"; //$NON-NLS-1$
private static final String FD_V4 = "v4"; //$NON-NLS-1$
+ private static final String FD_V13 = "v13"; //$NON-NLS-1$
+ private static final String FD_APPCOMPAT = "appcompat"; //$NON-NLS-1$
+ private static final String FD_LIBS = "libs"; //$NON-NLS-1$
private static final String ANDROID_SUPPORT_V4_JAR = "android-support-v4.jar"; //$NON-NLS-1$
+ private static final String ANDROID_SUPPORT_V13_JAR = "android-support-v13.jar";//$NON-NLS-1$
+ private static final String APPCOMPAT_V7_JAR = "android-support-v7-appcompat.jar";//$NON-NLS-1$
+ private static final String APP_COMPAT_LIB_NAME = "appcompat_v7"; //$NON-NLS-1$
private ISelection mSelection;
/**
@@ -166,7 +172,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
return null;
}
- String sdkLocation = sdk.getSdkLocation();
+ String sdkLocation = sdk.getSdkOsLocation();
if (minimumRevision > 0) {
File path = getSupportJarFile();
if (path != null) {
@@ -223,7 +229,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
public static int getInstalledRevision() {
final Sdk sdk = Sdk.getCurrent();
if (sdk != null) {
- String sdkLocation = sdk.getSdkLocation();
+ String sdkLocation = sdk.getSdkOsLocation();
SdkManager manager = SdkManager.createManager(sdkLocation, NullLogger.getLogger());
Map<String, Integer> versions = manager.getExtrasVersions();
Integer version = versions.get(VENDOR_ID + '/' + SUPPORT_ID);
@@ -238,7 +244,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
}
}
- return -1;
+ return -1;
}
/**
@@ -278,7 +284,73 @@ public class AddSupportJarAction implements IObjectActionDelegate {
}
// Create workspace copy of the project and add library dependency
- IProject libraryProject = createLibraryProject(libraryPath, project, waitForFinish);
+ IProject libraryProject = createLibraryProject(libraryPath, project,
+ "gridlayout_v7", waitForFinish); //$NON-NLS-1$
+ if (libraryProject != null) {
+ return addLibraryDependency(libraryProject, project, waitForFinish);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Similar to {@link #install}, but rather than copy a jar into the given
+ * project, it creates a new library project in the workspace for the
+ * support library, and adds a library dependency on the newly
+ * installed library from the given project.
+ *
+ * @param project the project to add a dependency on the library to
+ * @param waitForFinish If true, block until the task has finished
+ * @return true if the installation was successful (or if
+ * <code>waitForFinish</code> is false, if the installation is
+ * likely to be successful - e.g. the user has at least agreed to
+ * all installation prompts.)
+ */
+ public static boolean installAppCompatLibrary(final IProject project, boolean waitForFinish) {
+ final IJavaProject javaProject = JavaCore.create(project);
+ if (javaProject != null) {
+
+ // Don't add in the library if it already exists
+ ProjectState state = Sdk.getProjectState(project);
+ ProjectPropertiesWorkingCopy copy = state.getProperties().makeWorkingCopy();
+ for (String property : copy.keySet()) {
+ if (property.startsWith(ProjectProperties.PROPERTY_LIB_REF)) {
+ String libraryReference = copy.getProperty(property);
+ if (libraryReference != null && libraryReference.contains(APP_COMPAT_LIB_NAME)) {
+ return true;
+ }
+ }
+ }
+
+ File supportPath = getSupportPackageDir();
+ if (!supportPath.isDirectory()) {
+ File path = installSupport(7);
+ if (path == null) {
+ return false;
+ }
+ assert path.equals(supportPath);
+ }
+ File libraryPath = new File(supportPath, FD_V7 + File.separator + FD_APPCOMPAT);
+ if (!libraryPath.isDirectory()) {
+ // Upgrade support package: it's out of date. The SDK manager will
+ // perform an upgrade to the latest version if the package is already installed.
+ File path = installSupport(-1);
+ if (path == null) {
+ return false;
+ }
+ assert path.equals(libraryPath) : path;
+ }
+
+ // Check to see if there's already a version of the library available
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ IWorkspaceRoot root = workspace.getRoot();
+ IProject libraryProject = root.getProject(APP_COMPAT_LIB_NAME);
+ if (!libraryProject.exists()) {
+ // Create workspace copy of the project and add library dependency
+ libraryProject = createLibraryProject(libraryPath, project,
+ APP_COMPAT_LIB_NAME, waitForFinish);
+ }
if (libraryProject != null) {
return addLibraryDependency(libraryProject, project, waitForFinish);
}
@@ -296,7 +368,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
private static File getSupportPackageDir() {
final Sdk sdk = Sdk.getCurrent();
if (sdk != null) {
- String sdkLocation = sdk.getSdkLocation();
+ String sdkLocation = sdk.getSdkOsLocation();
SdkManager manager = SdkManager.createManager(sdkLocation, NullLogger.getLogger());
Map<String, Integer> versions = manager.getExtrasVersions();
Integer version = versions.get(VENDOR_ID + '/' + SUPPORT_ID);
@@ -343,6 +415,25 @@ public class AddSupportJarAction implements IObjectActionDelegate {
}
/**
+ * Returns a path to the installed jar file for the support library,
+ * or null if it does not exist
+ *
+ * @return a path to the v13.jar or null
+ */
+ @Nullable
+ public static File getSupport13JarFile() {
+ File supportDir = getSupportPackageDir();
+ if (supportDir != null) {
+ File path = new File(supportDir, FD_V13 + File.separator + ANDROID_SUPPORT_V13_JAR);
+ if (path.exists()) {
+ return path;
+ }
+ }
+
+ return null;
+ }
+
+ /**
* Creates a library project in the Eclipse workspace out of the grid layout project
* in the SDK tree.
*
@@ -354,6 +445,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
private static IProject createLibraryProject(
final File libraryPath,
final IProject project,
+ final String libraryName,
boolean waitForFinish) {
// Install a new library into the workspace. This is a copy rather than
@@ -367,7 +459,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
IWorkspaceRoot root = workspace.getRoot();
String name = AdtUtils.getUniqueProjectName(
- "gridlayout_v7", "_"); //$NON-NLS-1$ //$NON-NLS-2$
+ libraryName, "_"); //$NON-NLS-1$
newProject = root.getProject(name);
IProjectDescription description = workspace.newProjectDescription(name);
String[] natures = new String[] { AdtConstants.NATURE_DEFAULT, JavaCore.NATURE_ID };
@@ -381,13 +473,14 @@ public class AddSupportJarAction implements IObjectActionDelegate {
sourceDir.copy(destDir, EFS.OVERWRITE, null);
// Make sure the src folder exists
- destDir.getChild("src").mkdir(0, null /*monitor*/);
+ destDir.getChild(SdkConstants.SRC_FOLDER).mkdir(0, null /*monitor*/);
// Set the android platform to the same level as the calling project
ProjectState state = Sdk.getProjectState(project);
String target = state.getProperties().getProperty(ProjectProperties.PROPERTY_TARGET);
if (target != null && target.length() > 0) {
- ProjectProperties properties = ProjectProperties.load(libraryPath.getPath(),
+ ProjectProperties properties = ProjectProperties.load(
+ destDir.toLocalFile(EFS.NONE, new NullProgressMonitor()).getPath(),
PropertyType.PROJECT);
ProjectPropertiesWorkingCopy copy = properties.makeWorkingCopy();
copy.setProperty(ProjectProperties.PROPERTY_TARGET, target);
@@ -478,7 +571,7 @@ public class AddSupportJarAction implements IObjectActionDelegate {
return Status.OK_STATUS;
} catch (Exception e) {
return new Status(Status.ERROR, AdtPlugin.PLUGIN_ID, Status.ERROR,
- "Failed", e); //$NON-NLS-1$
+ "Failed", e); //$NON-NLS-1$
} finally {
if (monitor != null) {
monitor.done();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AvdManagerAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AvdManagerAction.java
index 2597090..86f2d3c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AvdManagerAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/AvdManagerAction.java
@@ -57,7 +57,7 @@ public class AvdManagerAction implements IWorkbenchWindowActionDelegate, IObject
AvdManagerWindow window = new AvdManagerWindow(
AdtPlugin.getShell(),
new AdtConsoleSdkLog(),
- sdk.getSdkLocation(),
+ sdk.getSdkOsLocation(),
AvdInvocationContext.IDE);
window.open();
} else {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/DexDumpAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/DexDumpAction.java
index a483e9b..78fcfd4 100755
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/DexDumpAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/DexDumpAction.java
@@ -21,9 +21,10 @@ import com.android.annotations.Nullable;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
-import com.android.sdklib.util.GrabProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.IProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.Wait;
+import com.android.sdklib.BuildToolInfo;
+import com.android.utils.GrabProcessOutput;
+import com.android.utils.GrabProcessOutput.IProcessOutput;
+import com.android.utils.GrabProcessOutput.Wait;
import com.android.utils.SdkUtils;
import org.eclipse.core.filesystem.EFS;
@@ -126,9 +127,15 @@ public class DexDumpAction implements IObjectActionDelegate {
return Status.OK_STATUS;
}
- String sdkOsPath = current.getSdkLocation();
- File dexDumpFile = new File(new File(sdkOsPath, SdkConstants.FD_PLATFORM_TOOLS),
- SdkConstants.FN_DEXDUMP);
+ BuildToolInfo buildToolInfo = current.getLatestBuildTool();
+ if (buildToolInfo == null) {
+ AdtPlugin.printErrorToConsole(project,
+ "SDK missing build tools. Please install build tools using SDK Manager.");
+ return Status.OK_STATUS;
+ }
+
+ File buildToolsFolder = buildToolInfo.getLocation();
+ File dexDumpFile = new File(buildToolsFolder, SdkConstants.FN_DEXDUMP);
IPath binPath = project.getFolder(SdkConstants.FD_OUTPUT).getLocation();
if (binPath == null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkManagerAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkManagerAction.java
index 9d33230..48667be 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkManagerAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/actions/SdkManagerAction.java
@@ -25,9 +25,9 @@ import com.android.ide.eclipse.adt.internal.sdk.AdtConsoleSdkLog;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.sdklib.io.FileOp;
import com.android.sdklib.repository.ISdkChangeListener;
-import com.android.sdklib.util.GrabProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.IProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.Wait;
+import com.android.utils.GrabProcessOutput;
+import com.android.utils.GrabProcessOutput.IProcessOutput;
+import com.android.utils.GrabProcessOutput.Wait;
import com.android.sdkuilib.repository.SdkUpdaterWindow;
import com.android.sdkuilib.repository.SdkUpdaterWindow.SdkInvocationContext;
@@ -147,7 +147,7 @@ public class SdkManagerAction implements IWorkbenchWindowActionDelegate, IObject
// Get the SDK locatiom from the current SDK or as fallback
// directly from the ADT preferences.
Sdk sdk = Sdk.getCurrent();
- String osSdkLocation = sdk == null ? null : sdk.getSdkLocation();
+ String osSdkLocation = sdk == null ? null : sdk.getSdkOsLocation();
if (osSdkLocation == null || !new File(osSdkLocation).isDirectory()) {
osSdkLocation = AdtPrefs.getPrefs().getOsSdkFolder();
}
@@ -272,7 +272,7 @@ public class SdkManagerAction implements IWorkbenchWindowActionDelegate, IObject
// Do not show non-error/warning log in Eclipse.
};
},
- sdk.getSdkLocation(),
+ sdk.getSdkOsLocation(),
SdkInvocationContext.IDE);
ISdkChangeListener listener = new ISdkChangeListener() {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java
index 8e831b7..867e39d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/BuildHelper.java
@@ -40,9 +40,9 @@ import com.android.sdklib.build.RenderScriptProcessor;
import com.android.sdklib.build.SealedApkException;
import com.android.sdklib.internal.build.DebugKeyProvider;
import com.android.sdklib.internal.build.DebugKeyProvider.KeytoolException;
-import com.android.sdklib.util.GrabProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.IProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.Wait;
+import com.android.utils.GrabProcessOutput;
+import com.android.utils.GrabProcessOutput.IProcessOutput;
+import com.android.utils.GrabProcessOutput.Wait;
import com.google.common.hash.HashCode;
import com.google.common.hash.HashFunction;
import com.google.common.hash.Hashing;
@@ -581,9 +581,9 @@ public class BuildHelper {
String[] envp = null;
Map<String, String> envMap = new TreeMap<String, String>(System.getenv());
if (!envMap.containsKey("PROGUARD_HOME")) { //$NON-NLS-1$
- envMap.put("PROGUARD_HOME", Sdk.getCurrent().getSdkLocation() + //$NON-NLS-1$
- SdkConstants.FD_TOOLS + File.separator +
- SdkConstants.FD_PROGUARD);
+ envMap.put("PROGUARD_HOME", Sdk.getCurrent().getSdkOsLocation() + //$NON-NLS-1$
+ SdkConstants.FD_TOOLS + File.separator +
+ SdkConstants.FD_PROGUARD);
envp = new String[envMap.size()];
int i = 0;
for (Map.Entry<String, String> entry : envMap.entrySet()) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexWrapper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexWrapper.java
index 1c7c2e3..3f88284 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexWrapper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/DexWrapper.java
@@ -76,7 +76,8 @@ public final class DexWrapper {
}
URL url = f.toURI().toURL();
- URLClassLoader loader = new URLClassLoader(new URL[] { url },
+ @SuppressWarnings("resource")
+ URLClassLoader loader = new URLClassLoader(new URL[] { url },
DexWrapper.class.getClassLoader());
// get the classes.
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java
index 9882a0c..1625914 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/BaseBuilder.java
@@ -35,6 +35,7 @@ import com.android.io.IAbstractFile;
import com.android.io.StreamException;
import com.android.sdklib.BuildToolInfo;
import com.android.sdklib.IAndroidTarget;
+import com.android.sdklib.repository.FullRevision;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
index 2554c79..0d9ee48 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/PreCompilerBuilder.java
@@ -28,6 +28,7 @@ import com.android.ide.eclipse.adt.internal.build.Messages;
import com.android.ide.eclipse.adt.internal.build.RenderScriptLauncher;
import com.android.ide.eclipse.adt.internal.build.RsSourceChangeHandler;
import com.android.ide.eclipse.adt.internal.build.SourceProcessor;
+import com.android.ide.eclipse.adt.internal.build.builders.BaseBuilder.AbortBuildException;
import com.android.ide.eclipse.adt.internal.lint.EclipseLintClient;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
@@ -57,6 +58,7 @@ import com.android.sdklib.internal.build.SymbolLoader;
import com.android.sdklib.internal.build.SymbolWriter;
import com.android.sdklib.internal.project.ProjectProperties;
import com.android.sdklib.io.FileOp;
+import com.android.sdklib.repository.FullRevision;
import com.android.utils.ILogger;
import com.android.utils.Pair;
import com.android.xml.AndroidManifest;
@@ -431,6 +433,17 @@ public class PreCompilerBuilder extends BaseBuilder {
return result;
}
+ if (projectState.getRenderScriptSupportMode()) {
+ FullRevision minBuildToolsRev = new FullRevision(19,0,3);
+ if (mBuildToolInfo.getRevision().compareTo(minBuildToolsRev) == -1) {
+ String msg = "RenderScript support mode requires Build-Tools 19.0.3 or later.";
+ AdtPlugin.printErrorToConsole(project, msg);
+ markProject(AdtConstants.MARKER_ADT, msg, IMarker.SEVERITY_ERROR);
+
+ return result;
+ }
+ }
+
// get the manifest file
IFile manifestFile = ProjectHelper.getManifest(project);
@@ -1326,7 +1339,7 @@ public class PreCompilerBuilder extends BaseBuilder {
&& new File(aaptPath).exists()
&& new File("/usr/bin/apt-get").exists()) { //$NON-NLS-1$
markProject(AdtConstants.MARKER_ADT,
- "Hint: On 64-bit systems, make sure the 32-bit libraries are installed: sudo apt-get install ia32-libs",
+ "Hint: On 64-bit systems, make sure the 32-bit libraries are installed: \"sudo apt-get install ia32-libs\" or on some systems, \"sudo apt-get install lib32z1\"",
IMarker.SEVERITY_ERROR);
// Note - this uses SEVERITY_ERROR even though it's really SEVERITY_INFO because
// we want this error message to show up adjacent to the aapt error message
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/ResourceManagerBuilder.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/ResourceManagerBuilder.java
index 770710d..8e01cca 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/ResourceManagerBuilder.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/build/builders/ResourceManagerBuilder.java
@@ -24,6 +24,10 @@ import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper;
import com.android.ide.eclipse.adt.internal.project.ProjectHelper;
+import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
+import com.android.ide.eclipse.adt.internal.sdk.Sdk;
+import com.android.sdklib.BuildToolInfo;
+import com.android.sdklib.IAndroidTarget;
import com.android.utils.Pair;
import org.eclipse.core.resources.IFolder;
@@ -110,6 +114,33 @@ public class ResourceManagerBuilder extends BaseBuilder {
errorMessage = String.format(errorMessage,
result.getSecond() == null ? "(no value)" : result.getSecond());
+ if (JavaCore.VERSION_1_7.equals(result.getSecond())) {
+ // If the user is trying to target 1.7 but compiling with something older,
+ // the error message can be a bit misleading; instead point them in the
+ // direction of updating the project's build target.
+ Sdk currentSdk = Sdk.getCurrent();
+ if (currentSdk != null) {
+ IAndroidTarget target = currentSdk.getTarget(project.getProject());
+ if (target != null && target.getVersion().getApiLevel() < 19) {
+ errorMessage = "Using 1.7 requires compiling with Android 4.4 " +
+ "(KitKat); currently using " + target.getVersion();
+ }
+
+ ProjectState projectState = Sdk.getProjectState(project);
+ if (projectState != null) {
+ BuildToolInfo buildToolInfo = projectState.getBuildToolInfo();
+ if (buildToolInfo == null) {
+ buildToolInfo = currentSdk.getLatestBuildTool();
+ }
+ if (buildToolInfo != null && buildToolInfo.getRevision().getMajor() < 19) {
+ errorMessage = "Using 1.7 requires using Android Build Tools " +
+ "version 19 or later; currently using " +
+ buildToolInfo.getRevision();
+ }
+ }
+ }
+ }
+
markProject(AdtConstants.MARKER_ADT, errorMessage, IMarker.SEVERITY_ERROR);
AdtPlugin.printErrorToConsole(project, errorMessage);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java
index 1df2e4d..95cec47 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/Hyperlinks.java
@@ -445,7 +445,7 @@ public class Hyperlinks {
*/
private static URL getDocUrl(String relative) {
// First try to find locally installed documentation
- File sdkLocation = new File(Sdk.getCurrent().getSdkLocation());
+ File sdkLocation = new File(Sdk.getCurrent().getSdkOsLocation());
File docs = new File(sdkLocation, FD_DOCS + File.separator + FD_DOCS_REFERENCE);
try {
if (docs.exists()) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java
index 9f69e41..4cab419 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/formatting/AndroidXmlFormattingStrategy.java
@@ -559,6 +559,11 @@ public class AndroidXmlFormattingStrategy extends ContextBasedFormattingStrategy
String[] segments = resourceFolder.split("-"); //$NON-NLS-1$
ResourceType type = ResourceType.getEnum(segments[0]);
if (type != null) {
+ // <resources> files found in res/xml/ should be formatted as
+ // resource files!
+ if (type == ResourceType.XML && style == XmlFormatStyle.RESOURCE) {
+ return style;
+ }
style = EclipseXmlPrettyPrinter.get(type);
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java
index 41361a5..28b1689 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/ProjectCallback.java
@@ -31,6 +31,7 @@ import static com.android.SdkConstants.VIEW_INCLUDE;
import com.android.SdkConstants;
import com.android.ide.common.rendering.LayoutLibrary;
import com.android.ide.common.rendering.RenderSecurityManager;
+import com.android.ide.common.rendering.api.ActionBarCallback;
import com.android.ide.common.rendering.api.AdapterBinding;
import com.android.ide.common.rendering.api.DataBindingItem;
import com.android.ide.common.rendering.api.ILayoutPullParser;
@@ -168,7 +169,6 @@ public final class ProjectCallback extends LegacyCallback {
// RenderSecurityManager
boolean token = RenderSecurityManager.enterSafeRegion(mCredential);
try {
- System.setSecurityManager(null);
mLoader = new ProjectClassLoader(mParentClassLoader, mProject);
} finally {
RenderSecurityManager.exitSafeRegion(token);
@@ -198,7 +198,7 @@ public final class ProjectCallback extends LegacyCallback {
e = e.getCause();
}
- AdtPlugin.log(e, "%1$s failed to instantiate.", className); //$NON-NLS-1$
+ appendToIdeLog(e, "%1$s failed to instantiate.", className); //$NON-NLS-1$
// Add the missing class to the list so that the renderer can print them later.
if (mLogger instanceof RenderLogger) {
@@ -289,10 +289,15 @@ public final class ProjectCallback extends LegacyCallback {
@Override
public String getNamespace() {
if (mNamespace == null) {
- ManifestData manifestData = AndroidManifestHelper.parseForData(mProject);
- if (manifestData != null) {
- String javaPackage = manifestData.getPackage();
- mNamespace = String.format(AdtConstants.NS_CUSTOM_RESOURCES, javaPackage);
+ boolean token = RenderSecurityManager.enterSafeRegion(mCredential);
+ try {
+ ManifestData manifestData = AndroidManifestHelper.parseForData(mProject);
+ if (manifestData != null) {
+ String javaPackage = manifestData.getPackage();
+ mNamespace = String.format(AdtConstants.NS_CUSTOM_RESOURCES, javaPackage);
+ }
+ } finally {
+ RenderSecurityManager.exitSafeRegion(token);
}
}
@@ -440,23 +445,33 @@ public final class ProjectCallback extends LegacyCallback {
@Override
public ILayoutPullParser getParser(String layoutName) {
- // Try to compute the ResourceValue for this layout since layoutlib
- // must be an older version which doesn't pass the value:
- if (mResourceResolver != null) {
- ResourceValue value = mResourceResolver.getProjectResource(ResourceType.LAYOUT,
- layoutName);
- if (value != null) {
- return getParser(value);
+ boolean token = RenderSecurityManager.enterSafeRegion(mCredential);
+ try {
+ // Try to compute the ResourceValue for this layout since layoutlib
+ // must be an older version which doesn't pass the value:
+ if (mResourceResolver != null) {
+ ResourceValue value = mResourceResolver.getProjectResource(ResourceType.LAYOUT,
+ layoutName);
+ if (value != null) {
+ return getParser(value);
+ }
}
- }
- return getParser(layoutName, null);
+ return getParser(layoutName, null);
+ } finally {
+ RenderSecurityManager.exitSafeRegion(token);
+ }
}
@Override
public ILayoutPullParser getParser(ResourceValue layoutResource) {
- return getParser(layoutResource.getName(),
- new File(layoutResource.getValue()));
+ boolean token = RenderSecurityManager.enterSafeRegion(mCredential);
+ try {
+ return getParser(layoutResource.getName(),
+ new File(layoutResource.getValue()));
+ } finally {
+ RenderSecurityManager.exitSafeRegion(token);
+ }
}
private ILayoutPullParser getParser(String layoutName, File xml) {
@@ -480,11 +495,11 @@ public final class ProjectCallback extends LegacyCallback {
parser.setInput(new StringReader(xmlText));
return parser;
} catch (XmlPullParserException e) {
- AdtPlugin.log(e, null);
+ appendToIdeLog(e, null);
} catch (FileNotFoundException e) {
// Shouldn't happen since we check isFile() above
} catch (IOException e) {
- AdtPlugin.log(e, null);
+ appendToIdeLog(e, null);
}
}
@@ -649,4 +664,20 @@ public final class ProjectCallback extends LegacyCallback {
public void setResourceResolver(ResourceResolver resolver) {
mResourceResolver = resolver;
}
+
+ // Append the given message to the ADT log. Bypass the sandbox if necessary
+ // such that we can write to the log file.
+ private void appendToIdeLog(Throwable exception, String format, Object ... args) {
+ boolean token = RenderSecurityManager.enterSafeRegion(mCredential);
+ try {
+ AdtPlugin.log(exception, format, args);
+ } finally {
+ RenderSecurityManager.exitSafeRegion(token);
+ }
+ }
+
+ @Override
+ public ActionBarCallback getActionBarCallback() {
+ return new ActionBarCallback();
+ }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/Configuration.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/Configuration.java
index 2260303..44faf71 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/Configuration.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/Configuration.java
@@ -39,6 +39,7 @@ import com.android.ide.common.resources.configuration.VersionQualifier;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService;
import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo;
+import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo.ActivityAttributes;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.resources.ResourceHelper;
import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources;
@@ -63,7 +64,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import java.util.List;
-import java.util.Map;
/**
* A {@linkplain Configuration} is a selection of device, orientation, theme,
@@ -707,8 +707,10 @@ public class Configuration {
String activity = getActivity();
if (activity != null) {
- Map<String, String> activityThemes = manifest.getActivityThemes();
- preferred = activityThemes.get(activity);
+ ActivityAttributes attributes = manifest.getActivityAttributes(activity);
+ if (attributes != null) {
+ preferred = attributes.getTheme();
+ }
}
if (preferred == null) {
preferred = defaultTheme;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationChooser.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationChooser.java
index ebd1fb9..5b8e70b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationChooser.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationChooser.java
@@ -58,6 +58,7 @@ import com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorP
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.IncludeFinder.Reference;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.LayoutCanvas;
import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo;
+import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo.ActivityAttributes;
import com.android.ide.eclipse.adt.internal.resources.ResourceHelper;
import com.android.ide.eclipse.adt.internal.resources.manager.ProjectResources;
import com.android.ide.eclipse.adt.internal.resources.manager.ResourceManager;
@@ -1586,8 +1587,11 @@ public class ConfigurationChooser extends Composite
// See if there is a default theme assigned to this activity, and if so, use it
ManifestInfo manifest = ManifestInfo.get(mEditedFile.getProject());
- Map<String, String> activityThemes = manifest.getActivityThemes();
- String preferred = activityThemes.get(activity);
+ String preferred = null;
+ ActivityAttributes attributes = manifest.getActivityAttributes(activity);
+ if (attributes != null) {
+ preferred = attributes.getTheme();
+ }
if (preferred != null && !Objects.equal(preferred, mConfiguration.getTheme())) {
// Yes, switch to it
selectTheme(preferred);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationDescription.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationDescription.java
index 7141f94..cc50398 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationDescription.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationDescription.java
@@ -32,6 +32,7 @@ import com.android.ide.common.resources.configuration.RegionQualifier;
import com.android.ide.common.resources.configuration.ScreenSizeQualifier;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo;
+import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo.ActivityAttributes;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.resources.NightMode;
@@ -50,7 +51,6 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import java.util.List;
-import java.util.Map;
/** A description of a configuration, used for persistence */
public class ConfigurationDescription {
@@ -349,8 +349,10 @@ public class ConfigurationDescription {
// from the outer layout instead
if (activity != null) {
- Map<String, String> activityThemes = manifest.getActivityThemes();
- preferred = activityThemes.get(activity);
+ ActivityAttributes attributes = manifest.getActivityAttributes(activity);
+ if (attributes != null) {
+ preferred = attributes.getTheme();
+ }
}
if (preferred == null) {
preferred = defaultTheme;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ThemeMenuAction.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ThemeMenuAction.java
index 0f6c9eb..b1ce21d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ThemeMenuAction.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ThemeMenuAction.java
@@ -21,6 +21,7 @@ import static com.android.SdkConstants.ANDROID_STYLE_RESOURCE_PREFIX;
import com.android.ide.eclipse.adt.internal.editors.Hyperlinks;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.SubmenuAction;
import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo;
+import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo.ActivityAttributes;
import com.android.ide.eclipse.adt.internal.resources.ResourceHelper;
import com.android.sdklib.IAndroidTarget;
@@ -41,7 +42,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import java.util.Set;
/**
@@ -180,30 +180,39 @@ class ThemeMenuAction extends SubmenuAction {
case MENU_MANIFEST: {
IProject project = mConfigChooser.getEditedFile().getProject();
ManifestInfo manifest = ManifestInfo.get(project);
- Map<String, String> activityThemes = manifest.getActivityThemes();
Configuration configuration = mConfigChooser.getConfiguration();
String activity = configuration.getActivity();
if (activity != null) {
- String theme = activityThemes.get(activity);
- if (theme != null) {
- addMenuItem(menu, theme, isSelectedTheme(theme));
+ ActivityAttributes attributes = manifest.getActivityAttributes(activity);
+ if (attributes != null) {
+ String theme = attributes.getTheme();
+ if (theme != null) {
+ addMenuItem(menu, theme, isSelectedTheme(theme));
+ }
}
}
String manifestTheme = manifest.getManifestTheme();
- if (activityThemes.size() > 0 || manifestTheme != null) {
- Set<String> allThemes = new HashSet<String>(activityThemes.values());
- if (manifestTheme != null) {
- allThemes.add(manifestTheme);
- }
- List<String> sorted = new ArrayList<String>(allThemes);
- Collections.sort(sorted);
- String current = configuration.getTheme();
- for (String theme : sorted) {
- boolean selected = theme.equals(current);
- addMenuItem(menu, theme, selected);
+ boolean found = false;
+ Set<String> allThemes = new HashSet<String>();
+ if (manifestTheme != null) {
+ found = true;
+ allThemes.add(manifestTheme);
+ }
+ for (ActivityAttributes info : manifest.getActivityAttributesMap().values()) {
+ if (info.getTheme() != null) {
+ found = true;
+ allThemes.add(info.getTheme());
}
- } else {
+ }
+ List<String> sorted = new ArrayList<String>(allThemes);
+ Collections.sort(sorted);
+ String current = configuration.getTheme();
+ for (String theme : sorted) {
+ boolean selected = theme.equals(current);
+ addMenuItem(menu, theme, selected);
+ }
+ if (!found) {
addDisabledMessageItem("No themes are registered in the manifest");
}
break;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
index 327279b..b54d5bc 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/GraphicalEditorPart.java
@@ -178,6 +178,8 @@ import org.eclipse.wb.internal.core.editor.structure.PageSiteComposite;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import java.io.File;
+import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -1855,6 +1857,44 @@ public class GraphicalEditorPart extends EditorPart
if (throwable instanceof RenderSecurityException) {
addActionLink(mErrorLabel, ActionLinkStyleRange.LINK_DISABLE_SANDBOX,
"\nTurn off custom view rendering sandbox\n");
+
+ StringBuilder builder = new StringBuilder(200);
+ String lastFailedPath = RenderSecurityManager.getLastFailedPath();
+ if (lastFailedPath != null) {
+ builder.append("Diagnostic info for ADT bug report:\n");
+ builder.append("Failed path: ").append(lastFailedPath).append('\n');
+ String tempDir = System.getProperty("java.io.tmpdir");
+ builder.append("Normal temp dir: ").append(tempDir).append('\n');
+ File normalized = new File(tempDir);
+ builder.append("Normalized temp dir: ").append(normalized.getPath()).append('\n');
+ try {
+ builder.append("Canonical temp dir: ").append(normalized.getCanonicalPath())
+ .append('\n');
+ } catch (IOException e) {
+ // ignore
+ }
+ builder.append("os.name: ").append(System.getProperty("os.name")).append('\n');
+ builder.append("os.version: ").append(System.getProperty("os.version"));
+ builder.append('\n');
+ builder.append("java.runtime.version: ");
+ builder.append(System.getProperty("java.runtime.version"));
+ }
+ if (throwable.getMessage().equals("Unable to create temporary file")) {
+ String javaVersion = System.getProperty("java.version");
+ if (javaVersion.startsWith("1.7.0_")) {
+ int version = Integer
+ .parseInt(javaVersion.substring(javaVersion.indexOf('_') + 1));
+ if (version > 0 && version < 45) {
+ builder.append('\n');
+ builder.append("Tip: This may be caused by using an older version " +
+ "of JDK 1.7.0; try using at least 1.7.0_45 (you are using " +
+ javaVersion + ")");
+ }
+ }
+ }
+ if (builder.length() > 0) {
+ addText(mErrorLabel, builder.toString());
+ }
}
StackTraceElement[] frames = throwable.getStackTrace();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LintOverlay.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LintOverlay.java
index bce1512..ca74493 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LintOverlay.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/LintOverlay.java
@@ -19,6 +19,7 @@ package com.android.ide.eclipse.adt.internal.editors.layout.gle2;
import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
+import com.google.common.collect.Lists;
import org.eclipse.core.resources.IMarker;
import org.eclipse.swt.graphics.GC;
@@ -29,8 +30,6 @@ import org.w3c.dom.Node;
import java.util.Collection;
-import lombok.ast.libs.org.parboiled.google.collect.Lists;
-
/**
* The {@link LintOverlay} paints an icon over each view that contains at least one
* lint error (unless the view is smaller than the icon)
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java
index c274d3c..ffcb258 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/layout/gle2/RenderService.java
@@ -51,6 +51,7 @@ import com.android.ide.eclipse.adt.internal.editors.layout.gre.NodeFactory;
import com.android.ide.eclipse.adt.internal.editors.layout.gre.NodeProxy;
import com.android.ide.eclipse.adt.internal.editors.layout.uimodel.UiViewElementNode;
import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo;
+import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo.ActivityAttributes;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiDocumentNode;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
@@ -167,7 +168,7 @@ public class RenderService {
if (RenderSecurityManager.RESTRICT_READS) {
projectPath = AdtUtils.getAbsolutePath(mProject).toFile().getPath();
Sdk sdk = Sdk.getCurrent();
- sdkPath = sdk != null ? sdk.getSdkLocation() : null;
+ sdkPath = sdk != null ? sdk.getSdkOsLocation() : null;
}
RenderSecurityManager securityManager = new RenderSecurityManager(sdkPath, projectPath);
securityManager.setLogger(AdtPlugin.getDefault());
@@ -483,6 +484,18 @@ public class RenderService {
try {
params.setAppLabel(manifestInfo.getApplicationLabel());
params.setAppIcon(manifestInfo.getApplicationIcon());
+ String activity = mEditor.getConfigurationChooser().getConfiguration().getActivity();
+ if (activity != null) {
+ ActivityAttributes info = manifestInfo.getActivityAttributes(activity);
+ if (info != null) {
+ if (info.getLabel() != null) {
+ params.setAppLabel(info.getLabel());
+ }
+ if (info.getIcon() != null) {
+ params.setAppIcon(info.getIcon());
+ }
+ }
+ }
} catch (Exception e) {
// ignore.
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java
index 9b26057..6d2d1c1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfo.java
@@ -24,11 +24,16 @@ import static com.android.xml.AndroidManifest.ATTRIBUTE_LABEL;
import static com.android.xml.AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION;
import static com.android.xml.AndroidManifest.ATTRIBUTE_NAME;
import static com.android.xml.AndroidManifest.ATTRIBUTE_PACKAGE;
+import static com.android.xml.AndroidManifest.ATTRIBUTE_PARENT_ACTIVITY_NAME;
import static com.android.xml.AndroidManifest.ATTRIBUTE_SUPPORTS_RTL;
import static com.android.xml.AndroidManifest.ATTRIBUTE_TARGET_SDK_VERSION;
import static com.android.xml.AndroidManifest.ATTRIBUTE_THEME;
+import static com.android.xml.AndroidManifest.ATTRIBUTE_UI_OPTIONS;
+import static com.android.xml.AndroidManifest.ATTRIBUTE_VALUE;
import static com.android.xml.AndroidManifest.NODE_ACTIVITY;
+import static com.android.xml.AndroidManifest.NODE_METADATA;
import static com.android.xml.AndroidManifest.NODE_USES_SDK;
+import static com.android.xml.AndroidManifest.VALUE_PARENT_ACTIVITY;
import static org.eclipse.jdt.core.search.IJavaSearchConstants.REFERENCES;
import com.android.SdkConstants;
@@ -99,6 +104,123 @@ import javax.xml.xpath.XPathExpressionException;
* @see AndroidManifest
*/
public class ManifestInfo {
+
+ public static class ActivityAttributes {
+ @Nullable
+ private final String mIcon;
+ @Nullable
+ private final String mLabel;
+ @NonNull
+ private final String mName;
+ @Nullable
+ private final String mParentActivity;
+ @Nullable
+ private final String mTheme;
+ @Nullable
+ private final String mUiOptions;
+
+ public ActivityAttributes(Element activity, String packageName) {
+
+ // Get activity name.
+ String name = activity.getAttributeNS(NS_RESOURCES, ATTRIBUTE_NAME);
+ if (name == null || name.length() == 0) {
+ throw new RuntimeException("Activity name cannot be empty");
+ }
+ int index = name.indexOf('.');
+ if (index <= 0 && packageName != null && !packageName.isEmpty()) {
+ name = packageName + (index == -1 ? "." : "") + name;
+ }
+ mName = name;
+
+ // Get activity icon.
+ String value = activity.getAttributeNS(NS_RESOURCES, ATTRIBUTE_ICON);
+ if (value != null && value.length() > 0) {
+ mIcon = value;
+ } else {
+ mIcon = null;
+ }
+
+ // Get activity label.
+ value = activity.getAttributeNS(NS_RESOURCES, ATTRIBUTE_LABEL);
+ if (value != null && value.length() > 0) {
+ mLabel = value;
+ } else {
+ mLabel = null;
+ }
+
+ // Get activity parent. Also search the meta-data for parent info.
+ value = activity.getAttributeNS(NS_RESOURCES, ATTRIBUTE_PARENT_ACTIVITY_NAME);
+ if (value == null || value.length() == 0) {
+ // TODO: Not sure if meta data can be used for API Level > 16
+ NodeList metaData = activity.getElementsByTagName(NODE_METADATA);
+ for (int j = 0, m = metaData.getLength(); j < m; j++) {
+ Element data = (Element) metaData.item(j);
+ String metadataName = data.getAttributeNS(NS_RESOURCES, ATTRIBUTE_NAME);
+ if (VALUE_PARENT_ACTIVITY.equals(metadataName)) {
+ value = data.getAttributeNS(NS_RESOURCES, ATTRIBUTE_VALUE);
+ if (value != null) {
+ index = value.indexOf('.');
+ if (index <= 0 && packageName != null && !packageName.isEmpty()) {
+ value = packageName + (index == -1 ? "." : "") + value;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (value != null && value.length() > 0) {
+ mParentActivity = value;
+ } else {
+ mParentActivity = null;
+ }
+
+ // Get activity theme.
+ value = activity.getAttributeNS(NS_RESOURCES, ATTRIBUTE_THEME);
+ if (value != null && value.length() > 0) {
+ mTheme = value;
+ } else {
+ mTheme = null;
+ }
+
+ // Get UI options.
+ value = activity.getAttributeNS(NS_RESOURCES, ATTRIBUTE_UI_OPTIONS);
+ if (value != null && value.length() > 0) {
+ mUiOptions = value;
+ } else {
+ mUiOptions = null;
+ }
+ }
+
+ @Nullable
+ public String getIcon() {
+ return mIcon;
+ }
+
+ @Nullable
+ public String getLabel() {
+ return mLabel;
+ }
+
+ public String getName() {
+ return mName;
+ }
+
+ @Nullable
+ public String getParentActivity() {
+ return mParentActivity;
+ }
+
+ @Nullable
+ public String getTheme() {
+ return mTheme;
+ }
+
+ @Nullable
+ public String getUiOptions() {
+ return mUiOptions;
+ }
+ }
+
/**
* The maximum number of milliseconds to search for an activity in the codebase when
* attempting to associate layouts with activities in
@@ -109,7 +231,7 @@ public class ManifestInfo {
private final IProject mProject;
private String mPackage;
private String mManifestTheme;
- private Map<String, String> mActivityThemes;
+ private Map<String, ActivityAttributes> mActivityAttributes;
private IAbstractFile mManifestFile;
private long mLastModified;
private long mLastChecked;
@@ -201,7 +323,7 @@ public class ManifestInfo {
}
mLastModified = fileModified;
- mActivityThemes = new HashMap<String, String>();
+ mActivityAttributes = new HashMap<String, ActivityAttributes>();
mManifestTheme = null;
mTargetSdk = 1; // Default when not specified
mMinSdk = 1; // Default when not specified
@@ -226,15 +348,8 @@ public class ManifestInfo {
NodeList activities = document.getElementsByTagName(NODE_ACTIVITY);
for (int i = 0, n = activities.getLength(); i < n; i++) {
Element activity = (Element) activities.item(i);
- String theme = activity.getAttributeNS(NS_RESOURCES, ATTRIBUTE_THEME);
- if (theme != null && theme.length() > 0) {
- String name = activity.getAttributeNS(NS_RESOURCES, ATTRIBUTE_NAME);
- int index = name.indexOf('.');
- if (index <= 0 && mPackage != null && !mPackage.isEmpty()) {
- name = mPackage + (index == -1 ? "." : "") + name;
- }
- mActivityThemes.put(name, theme);
- }
+ ActivityAttributes info = new ActivityAttributes(activity, mPackage);
+ mActivityAttributes.put(info.getName(), info);
}
NodeList applications = root.getElementsByTagName(AndroidManifest.NODE_APPLICATION);
@@ -318,15 +433,22 @@ public class ManifestInfo {
}
/**
- * Returns a map from activity full class names to the corresponding theme style to be
- * used
+ * Returns a map from activity full class names to the corresponding {@link ActivityAttributes}.
*
- * @return a map from activity fqcn to theme style
+ * @return a map from activity fqcn to ActivityAttributes
*/
@NonNull
- public Map<String, String> getActivityThemes() {
+ public Map<String, ActivityAttributes> getActivityAttributesMap() {
sync();
- return mActivityThemes;
+ return mActivityAttributes;
+ }
+
+ /**
+ * Returns the attributes of an activity given its full class name.
+ */
+ @Nullable
+ public ActivityAttributes getActivityAttributes(String activity) {
+ return getActivityAttributesMap().get(activity);
}
/**
@@ -402,6 +524,7 @@ public class ManifestInfo {
sync();
return mApplicationSupportsRtl;
}
+
/**
* Returns the target SDK version
*
@@ -808,11 +931,19 @@ public class ManifestInfo {
}
}
- Integer i = AndroidManifest.getTargetSdkVersion(manifestFile);
- if (i == null) {
+ value = AndroidManifest.getTargetSdkVersion(manifestFile);
+ if (value == null) {
mTargetSdkVersion = mMinSdkVersion;
- } else {
- mTargetSdkVersion = i.intValue();
+ } else if (value instanceof String) {
+ // handle codename, only if we can resolve it.
+ if (Sdk.getCurrent() != null) {
+ IAndroidTarget target = Sdk.getCurrent().getTargetFromHashString(
+ "android-" + value); //$NON-NLS-1$
+ if (target != null) {
+ // codename future API level is current api + 1
+ mTargetSdkVersion = target.getVersion().getApiLevel() + 1;
+ }
+ }
}
} catch (XPathExpressionException e) {
// do nothing we'll use 1 below.
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java
index 1b850c9..995ccdf 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/DeviceChooserDialog.java
@@ -479,7 +479,7 @@ public class DeviceChooserDialog extends Dialog implements IDeviceChangeListener
offsetComp.setLayout(layout);
mPreferredAvdSelector = new AvdSelector(offsetComp,
- mSdk.getSdkLocation(),
+ mSdk.getSdkOsLocation(),
mSdk.getAvdManager(),
new NonRunningAvdFilter(),
DisplayMode.SIMPLE_SELECTION,
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java
index 248cb7a..779dfa1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/EmulatorConfigTab.java
@@ -233,7 +233,7 @@ public class EmulatorConfigTab extends AbstractLaunchConfigurationTab {
// displayed to ensure we have the latest one (dialog is reused but SDK could have
// been changed in between.
mPreferredAvdSelector = new AvdSelector(avdOffsetComp,
- Sdk.getCurrent().getSdkLocation(),
+ Sdk.getCurrent().getSdkOsLocation(),
null /* avd manager */,
DisplayMode.SIMPLE_CHECK,
new AdtConsoleSdkLog());
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java
index b494f62..54fd207 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/launch/junit/InstrumentationRunnerValidator.java
@@ -134,13 +134,15 @@ class InstrumentationRunnerValidator {
}
// check if this instrumentation is the standard test runner
if (!instrumentation.equals(SdkConstants.CLASS_INSTRUMENTATION_RUNNER)) {
- // check if it extends the standard test runner
+ // Ideally, we'd check if the class extends instrumentation test runner.
+ // However, the Google Instrumentation Test Runner extends Google Instrumentation, and not a test runner,
+ // so we just check that the super class is Instrumentation.
String result = BaseProjectHelper.testClassForManifest(mJavaProject,
- instrumentation, SdkConstants.CLASS_INSTRUMENTATION_RUNNER, true);
+ instrumentation, SdkConstants.CLASS_INSTRUMENTATION, true);
if (result != BaseProjectHelper.TEST_CLASS_OK) {
return String.format(
LaunchMessages.InstrValidator_WrongRunnerTypeMsg_s,
- SdkConstants.CLASS_INSTRUMENTATION_RUNNER);
+ SdkConstants.CLASS_INSTRUMENTATION);
}
}
return INSTRUMENTATION_OK;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java
index 45ae2c5..fd8125e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/EclipseLintClient.java
@@ -33,10 +33,10 @@ import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.sdklib.IAndroidTarget;
import com.android.tools.lint.checks.BuiltinIssueRegistry;
import com.android.tools.lint.client.api.Configuration;
-import com.android.tools.lint.client.api.IDomParser;
-import com.android.tools.lint.client.api.IJavaParser;
import com.android.tools.lint.client.api.IssueRegistry;
+import com.android.tools.lint.client.api.JavaParser;
import com.android.tools.lint.client.api.LintClient;
+import com.android.tools.lint.client.api.XmlParser;
import com.android.tools.lint.detector.api.ClassContext;
import com.android.tools.lint.detector.api.Context;
import com.android.tools.lint.detector.api.DefaultPosition;
@@ -105,7 +105,6 @@ import java.util.List;
import java.util.Map;
import java.util.WeakHashMap;
-import lombok.ast.TypeReference;
import lombok.ast.ecj.EcjTreeConverter;
import lombok.ast.grammar.ParseProblem;
import lombok.ast.grammar.Source;
@@ -114,7 +113,7 @@ import lombok.ast.grammar.Source;
* Eclipse implementation for running lint on workspace files and projects.
*/
@SuppressWarnings("restriction") // DOM model
-public class EclipseLintClient extends LintClient implements IDomParser {
+public class EclipseLintClient extends LintClient {
static final String MARKER_CHECKID_PROPERTY = "checkid"; //$NON-NLS-1$
private static final String MODEL_PROPERTY = "model"; //$NON-NLS-1$
private final List<? extends IResource> mResources;
@@ -206,51 +205,103 @@ public class EclipseLintClient extends LintClient implements IDomParser {
}
@Override
- public IDomParser getDomParser() {
- return this;
- }
+ public XmlParser getXmlParser() {
+ return new XmlParser() {
+ @Override
+ public Document parseXml(@NonNull XmlContext context) {
+ // Map File to IFile
+ IFile file = AdtUtils.fileToIFile(context.file);
+ if (file == null || !file.exists()) {
+ String path = context.file.getPath();
+ AdtPlugin.log(IStatus.ERROR, "Can't find file %1$s in workspace", path);
+ return null;
+ }
- @Override
- public IJavaParser getJavaParser() {
- if (mJavaParser == null) {
- mJavaParser = new EclipseJavaParser();
- }
+ IStructuredModel model = null;
+ try {
+ IModelManager modelManager = StructuredModelManager.getModelManager();
+ if (modelManager == null) {
+ // This can happen if incremental lint is running right as Eclipse is
+ // shutting down
+ return null;
+ }
+ model = modelManager.getModelForRead(file);
+ if (model instanceof IDOMModel) {
+ context.setProperty(MODEL_PROPERTY, model);
+ IDOMModel domModel = (IDOMModel) model;
+ return domModel.getDocument();
+ }
+ } catch (IOException e) {
+ AdtPlugin.log(e, "Cannot read XML file");
+ } catch (CoreException e) {
+ AdtPlugin.log(e, null);
+ }
- return mJavaParser;
- }
+ return null;
+ }
- // ----- Implements IDomParser -----
+ @Override
+ public @NonNull Location getLocation(@NonNull XmlContext context, @NonNull Node node) {
+ IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
+ return new LazyLocation(context.file, model.getStructuredDocument(),
+ (IndexedRegion) node);
+ }
- @Override
- public Document parseXml(@NonNull XmlContext context) {
- // Map File to IFile
- IFile file = AdtUtils.fileToIFile(context.file);
- if (file == null || !file.exists()) {
- String path = context.file.getPath();
- AdtPlugin.log(IStatus.ERROR, "Can't find file %1$s in workspace", path);
- return null;
- }
+ @Override
+ public @NonNull Location getLocation(@NonNull XmlContext context, @NonNull Node node,
+ int start, int end) {
+ IndexedRegion region = (IndexedRegion) node;
+ int nodeStart = region.getStartOffset();
+
+ IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
+ // Get line number
+ LazyLocation location = new LazyLocation(context.file,
+ model.getStructuredDocument(), region);
+ int line = location.getStart().getLine();
+
+ Position startPos = new DefaultPosition(line, -1, nodeStart + start);
+ Position endPos = new DefaultPosition(line, -1, nodeStart + end);
+ return Location.create(context.file, startPos, endPos);
+ }
- IStructuredModel model = null;
- try {
- IModelManager modelManager = StructuredModelManager.getModelManager();
- if (modelManager == null) {
- // This can happen if incremental lint is running right as Eclipse is shutting down
- return null;
+ @Override
+ public int getNodeStartOffset(@NonNull XmlContext context, @NonNull Node node) {
+ IndexedRegion region = (IndexedRegion) node;
+ return region.getStartOffset();
}
- model = modelManager.getModelForRead(file);
- if (model instanceof IDOMModel) {
- context.setProperty(MODEL_PROPERTY, model);
- IDOMModel domModel = (IDOMModel) model;
- return domModel.getDocument();
+
+ @Override
+ public int getNodeEndOffset(@NonNull XmlContext context, @NonNull Node node) {
+ IndexedRegion region = (IndexedRegion) node;
+ return region.getEndOffset();
}
- } catch (IOException e) {
- AdtPlugin.log(e, "Cannot read XML file");
- } catch (CoreException e) {
- AdtPlugin.log(e, null);
+
+ @Override
+ public @NonNull Handle createLocationHandle(final @NonNull XmlContext context,
+ final @NonNull Node node) {
+ IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
+ return new LazyLocation(context.file, model.getStructuredDocument(),
+ (IndexedRegion) node);
+ }
+
+ @Override
+ public void dispose(@NonNull XmlContext context, @NonNull Document document) {
+ IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
+ assert model != null : context.file;
+ if (model != null) {
+ model.releaseFromRead();
+ }
+ }
+ };
+ }
+
+ @Override
+ public JavaParser getJavaParser(@Nullable Project project) {
+ if (mJavaParser == null) {
+ mJavaParser = new EclipseJavaParser();
}
- return null;
+ return mJavaParser;
}
// Cache for {@link getProject}
@@ -735,36 +786,6 @@ public class EclipseLintClient extends LintClient implements IDomParser {
}
}
- @Override
- public @NonNull Location getLocation(@NonNull XmlContext context, @NonNull Node node) {
- IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
- return new LazyLocation(context.file, model.getStructuredDocument(), (IndexedRegion) node);
- }
-
- @Override
- public @NonNull Location getLocation(@NonNull XmlContext context, @NonNull Node node,
- int start, int end) {
- IndexedRegion region = (IndexedRegion) node;
- int nodeStart = region.getStartOffset();
-
- IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
- // Get line number
- LazyLocation location = new LazyLocation(context.file, model.getStructuredDocument(),
- region);
- int line = location.getStart().getLine();
-
- Position startPos = new DefaultPosition(line, -1, nodeStart + start);
- Position endPos = new DefaultPosition(line, -1, nodeStart + end);
- return Location.create(context.file, startPos, endPos);
- }
-
- @Override
- public @NonNull Handle createLocationHandle(final @NonNull XmlContext context,
- final @NonNull Node node) {
- IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
- return new LazyLocation(context.file, model.getStructuredDocument(), (IndexedRegion) node);
- }
-
private Map<Project, ClassPathInfo> mProjectInfo;
@Override
@@ -890,15 +911,6 @@ public class EclipseLintClient extends LintClient implements IDomParser {
}
@Override
- public void dispose(@NonNull XmlContext context, @NonNull Document document) {
- IStructuredModel model = (IStructuredModel) context.getProperty(MODEL_PROPERTY);
- assert model != null : context.file;
- if (model != null) {
- model.releaseFromRead();
- }
- }
-
- @Override
@NonNull
public IAndroidTarget[] getTargets() {
return Sdk.getCurrent().getTargets();
@@ -1090,18 +1102,20 @@ public class EclipseLintClient extends LintClient implements IDomParser {
}
}
- private static class EclipseJavaParser implements IJavaParser {
+ private static class EclipseJavaParser extends JavaParser {
private static final boolean USE_ECLIPSE_PARSER = true;
private final Parser mParser;
EclipseJavaParser() {
if (USE_ECLIPSE_PARSER) {
CompilerOptions options = new CompilerOptions();
- // Read settings from project? Note that this doesn't really matter because
- // we will only be parsing, not actually compiling.
- options.complianceLevel = ClassFileConstants.JDK1_6;
- options.sourceLevel = ClassFileConstants.JDK1_6;
- options.targetJDK = ClassFileConstants.JDK1_6;
+ // Always using JDK 7 rather than basing it on project metadata since we
+ // don't do compilation error validation in lint (we leave that to the IDE's
+ // error parser or the command line build's compilation step); we want an
+ // AST that is as tolerant as possible.
+ options.complianceLevel = ClassFileConstants.JDK1_7;
+ options.sourceLevel = ClassFileConstants.JDK1_7;
+ options.targetJDK = ClassFileConstants.JDK1_7;
options.parseLiteralExpressionsAsConstants = true;
ProblemReporter problemReporter = new ProblemReporter(
DefaultErrorHandlingPolicies.exitOnFirstError(),
@@ -1115,6 +1129,11 @@ public class EclipseLintClient extends LintClient implements IDomParser {
}
@Override
+ public void prepareJavaParse(@NonNull List<JavaContext> contexts) {
+ // TODO: Use batch compiler from lint-cli.jar
+ }
+
+ @Override
public lombok.ast.Node parseJava(@NonNull JavaContext context) {
if (USE_ECLIPSE_PARSER) {
// Use Eclipse's compiler
@@ -1216,14 +1235,15 @@ public class EclipseLintClient extends LintClient implements IDomParser {
@Override
@Nullable
- public lombok.ast.Node resolve(@NonNull JavaContext context,
+ public ResolvedNode resolve(@NonNull JavaContext context,
@NonNull lombok.ast.Node node) {
return null;
}
@Override
@Nullable
- public TypeReference getType(@NonNull JavaContext context, @NonNull lombok.ast.Node node) {
+ public TypeDescriptor getType(@NonNull JavaContext context,
+ @NonNull lombok.ast.Node node) {
return null;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java
index 401703e..658e409 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/LintFix.java
@@ -24,7 +24,7 @@ import com.android.tools.lint.checks.DetectMissingPrefix;
import com.android.tools.lint.checks.DosLineEndingDetector;
import com.android.tools.lint.checks.HardcodedValuesDetector;
import com.android.tools.lint.checks.InefficientWeightDetector;
-import com.android.tools.lint.checks.ManifestOrderDetector;
+import com.android.tools.lint.checks.ManifestDetector;
import com.android.tools.lint.checks.MissingIdDetector;
import com.android.tools.lint.checks.ObsoleteLayoutParamsDetector;
import com.android.tools.lint.checks.PxUsageDetector;
@@ -152,7 +152,7 @@ abstract class LintFix implements ICompletionProposal {
LinearLayoutWeightFix.class);
sFixes.put(AccessibilityDetector.ISSUE.getId(), SetAttributeFix.class);
sFixes.put(InefficientWeightDetector.BASELINE_WEIGHTS.getId(), SetAttributeFix.class);
- sFixes.put(ManifestOrderDetector.ALLOW_BACKUP.getId(), SetAttributeFix.class);
+ sFixes.put(ManifestDetector.ALLOW_BACKUP.getId(), SetAttributeFix.class);
sFixes.put(MissingIdDetector.ISSUE.getId(), SetAttributeFix.class);
sFixes.put(HardcodedValuesDetector.ISSUE.getId(), ExtractStringFix.class);
sFixes.put(UselessViewDetector.USELESS_LEAF.getId(), RemoveUselessViewFix.class);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetAttributeFix.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetAttributeFix.java
index 627eeb8..ea73b9a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetAttributeFix.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/lint/SetAttributeFix.java
@@ -31,7 +31,7 @@ import com.android.ide.eclipse.adt.internal.editors.AndroidXmlEditor;
import com.android.ide.eclipse.adt.internal.editors.descriptors.DescriptorsUtils;
import com.android.tools.lint.checks.AccessibilityDetector;
import com.android.tools.lint.checks.InefficientWeightDetector;
-import com.android.tools.lint.checks.ManifestOrderDetector;
+import com.android.tools.lint.checks.ManifestDetector;
import com.android.tools.lint.checks.MissingIdDetector;
import com.android.tools.lint.checks.SecurityDetector;
import com.android.tools.lint.checks.TextFieldDetector;
@@ -59,7 +59,7 @@ final class SetAttributeFix extends SetPropertyFix {
return ATTR_INPUT_TYPE;
} else if (mId.equals(TranslationDetector.MISSING.getId())) {
return ATTR_TRANSLATABLE;
- } else if (mId.equals(ManifestOrderDetector.ALLOW_BACKUP.getId())) {
+ } else if (mId.equals(ManifestDetector.ALLOW_BACKUP.getId())) {
return ATTR_ALLOW_BACKUP;
} else if (mId.equals(MissingIdDetector.ISSUE.getId())) {
return ATTR_ID;
@@ -90,7 +90,7 @@ final class SetAttributeFix extends SetPropertyFix {
return "Add permission attribute";
} else if (mId.equals(TranslationDetector.MISSING.getId())) {
return "Mark this as a non-translatable resource";
- } else if (mId.equals(ManifestOrderDetector.ALLOW_BACKUP.getId())) {
+ } else if (mId.equals(ManifestDetector.ALLOW_BACKUP.getId())) {
return "Set the allowBackup attribute to true or false";
} else if (mId.equals(MissingIdDetector.ISSUE.getId())) {
return "Set the ID attribute";
@@ -115,7 +115,7 @@ final class SetAttributeFix extends SetPropertyFix {
protected boolean invokeCodeCompletion() {
return mId.equals(SecurityDetector.EXPORTED_SERVICE.getId())
|| mId.equals(TextFieldDetector.ISSUE.getId())
- || mId.equals(ManifestOrderDetector.ALLOW_BACKUP.getId());
+ || mId.equals(ManifestDetector.ALLOW_BACKUP.getId());
}
@Override
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java
index 362fe28..a58f27d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/BaseClasspathContainerInitializer.java
@@ -51,68 +51,53 @@ abstract class BaseClasspathContainerInitializer extends ClasspathContainerIniti
AdtPlugin.printErrorToConsole(project, errorMessage);
}
- try {
- BaseProjectHelper.markProject(project, markerType,
- errorMessage, IMarker.SEVERITY_ERROR, IMarker.PRIORITY_HIGH);
- } catch (CoreException e) {
- // In some cases, the workspace may be locked for modification when we
- // pass here.
- // We schedule a new job to put the marker after.
- final String fmessage = errorMessage;
- Job markerJob = new Job("Android SDK: Resolving error markers") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- BaseProjectHelper.markProject(project,
- markerType,
- fmessage, IMarker.SEVERITY_ERROR,
- IMarker.PRIORITY_HIGH);
- } catch (CoreException e2) {
- AdtPlugin.log(e2, null);
- // Don't return e2.getStatus(); the job control will then produce
- // a popup with this error, which isn't very interesting for the
- // user.
- }
-
- return Status.OK_STATUS;
+ // Use a job to prevent requiring a workspace lock in this thread.
+ final String fmessage = errorMessage;
+ Job markerJob = new Job("Android SDK: Resolving error markers") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ BaseProjectHelper.markProject(project,
+ markerType,
+ fmessage, IMarker.SEVERITY_ERROR,
+ IMarker.PRIORITY_HIGH);
+ } catch (CoreException e2) {
+ AdtPlugin.log(e2, null);
+ // Don't return e2.getStatus(); the job control will then produce
+ // a popup with this error, which isn't very interesting for the
+ // user.
}
- };
- // build jobs are run after other interactive jobs
- markerJob.setPriority(Job.BUILD);
- markerJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
- markerJob.schedule();
- }
- } else {
- // no error, remove existing markers.
- try {
- if (project.isAccessible()) {
- project.deleteMarkers(markerType, true,
- IResource.DEPTH_INFINITE);
+ return Status.OK_STATUS;
}
- } catch (CoreException ce) {
- // In some cases, the workspace may be locked for modification when we pass
- // here, so we schedule a new job to put the marker after.
- Job markerJob = new Job("Android SDK: Resolving error markers") {
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- try {
- if (project.isAccessible()) {
- project.deleteMarkers(markerType, true,
- IResource.DEPTH_INFINITE);
- }
- } catch (CoreException e2) {
- AdtPlugin.log(e2, null);
- }
+ };
- return Status.OK_STATUS;
+ // build jobs are run after other interactive jobs
+ markerJob.setPriority(Job.BUILD);
+ markerJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
+ markerJob.schedule();
+ } else {
+ // Use a job to prevent requiring a workspace lock in this thread.
+ Job markerJob = new Job("Android SDK: Resolving error markers") {
+ @Override
+ protected IStatus run(IProgressMonitor monitor) {
+ try {
+ if (project.isAccessible()) {
+ project.deleteMarkers(markerType, true,
+ IResource.DEPTH_INFINITE);
+ }
+ } catch (CoreException e2) {
+ AdtPlugin.log(e2, null);
}
- };
- // build jobs are run after other interactive jobs
- markerJob.setPriority(Job.BUILD);
- markerJob.schedule();
- }
+ return Status.OK_STATUS;
+ }
+ };
+
+ // build jobs are run after other interactive jobs
+ markerJob.setPriority(Job.BUILD);
+ markerJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
+ markerJob.schedule();
}
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java
index 8168590..56e0c09 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ExportHelper.java
@@ -133,15 +133,7 @@ public final class ExportHelper {
String dexMergerStr = projectState.getProperty(AdtConstants.DEX_OPTIONS_DISABLE_MERGER);
Boolean dexMerger = Boolean.valueOf(dexMergerStr);
- BuildToolInfo buildToolInfo = projectState.getBuildToolInfo();
- if (buildToolInfo == null) {
- buildToolInfo = Sdk.getCurrent().getLatestBuildTool();
- }
-
- if (buildToolInfo == null) {
- throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
- "No Build Tools installed in the SDK."));
- }
+ BuildToolInfo buildToolInfo = getBuildTools(projectState);
BuildHelper helper = new BuildHelper(
projectState,
@@ -339,6 +331,20 @@ public final class ExportHelper {
}
}
+ public static BuildToolInfo getBuildTools(ProjectState projectState)
+ throws CoreException {
+ BuildToolInfo buildToolInfo = projectState.getBuildToolInfo();
+ if (buildToolInfo == null) {
+ buildToolInfo = Sdk.getCurrent().getLatestBuildTool();
+ }
+
+ if (buildToolInfo == null) {
+ throw new CoreException(new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
+ "No Build Tools installed in the SDK."));
+ }
+ return buildToolInfo;
+ }
+
/**
* Exports an unsigned release APK after prompting the user for a location.
*
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java
index 1e0ada0..525e2fd 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/LibraryClasspathContainerInitializer.java
@@ -326,7 +326,7 @@ public class LibraryClasspathContainerInitializer extends BaseClasspathContainer
// annotations support for older version of android
if (state.getTarget() != null && state.getTarget().getVersion().getApiLevel() <= 15) {
- File annotationsJar = new File(Sdk.getCurrent().getSdkLocation(),
+ File annotationsJar = new File(Sdk.getCurrent().getSdkOsLocation(),
SdkConstants.FD_TOOLS + File.separator + SdkConstants.FD_SUPPORT +
File.separator + SdkConstants.FN_ANNOTATIONS_JAR);
@@ -338,7 +338,7 @@ public class LibraryClasspathContainerInitializer extends BaseClasspathContainer
return null;
}
BuildToolInfo buildToolInfo = state.getBuildToolInfo();
- if (buildToolInfo == null) {
+ if (buildToolInfo != null) {
buildToolInfo = Sdk.getCurrent().getLatestBuildTool();
if (buildToolInfo == null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java
index 44827a0..a32b4ca 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/project/ProjectHelper.java
@@ -28,6 +28,7 @@ import com.android.ide.eclipse.adt.internal.build.builders.PreCompilerBuilder;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
+import com.android.sdklib.BuildToolInfo;
import com.android.sdklib.IAndroidTarget;
import com.android.utils.Pair;
@@ -875,13 +876,27 @@ public final class ProjectHelper {
}
if (JavaCore.VERSION_1_7.equals(optionValue)) {
- // Requires API 19
+ // Requires API 19 and buildTools 19
Sdk currentSdk = Sdk.getCurrent();
if (currentSdk != null) {
- IAndroidTarget target = currentSdk.getTarget(project.getProject());
- if (target != null && target.getVersion().getApiLevel() >= 19) {
- return true;
+ IProject p = project.getProject();
+ IAndroidTarget target = currentSdk.getTarget(p);
+ if (target == null || target.getVersion().getApiLevel() < 19) {
+ return false;
}
+
+ ProjectState projectState = Sdk.getProjectState(p);
+ if (projectState != null) {
+ BuildToolInfo buildToolInfo = projectState.getBuildToolInfo();
+ if (buildToolInfo == null) {
+ buildToolInfo = currentSdk.getLatestBuildTool();
+ }
+ if (buildToolInfo == null || buildToolInfo.getRevision().getMajor() < 19) {
+ return false;
+ }
+ }
+
+ return true;
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java
index c8faa5e..8e40f1c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/sdk/Sdk.java
@@ -282,7 +282,7 @@ public final class Sdk {
// create the AVD Manager
AvdManager avdManager = null;
try {
- avdManager = AvdManager.getInstance(manager, log);
+ avdManager = AvdManager.getInstance(manager.getLocalSdk(), log);
} catch (AndroidLocationException e) {
log.error(e, "Error parsing the AVDs");
}
@@ -321,15 +321,47 @@ public final class Sdk {
}
/**
- * Returns the location (OS path) of the current SDK.
+ * Returns the location of the current SDK as an OS path string.
+ * Guaranteed to be terminated by a platform-specific path separator.
+ * <p/>
+ * Due to {@link File} canonicalization, this MAY differ from the string used to initialize
+ * the SDK path.
+ *
+ * @return The SDK OS path or null if no SDK is setup.
+ * @deprecated Consider using {@link #getSdkFileLocation()} instead.
+ * @see #getSdkFileLocation()
*/
- public String getSdkLocation() {
- return mManager.getLocation();
+ @Deprecated
+ @Nullable
+ public String getSdkOsLocation() {
+ String path = mManager == null ? null : mManager.getLocation();
+ if (path != null) {
+ // For backward compatibility make sure it ends with a separator.
+ // This used to be the case when the SDK Manager was created from a String path
+ // but now that a File is internally used the trailing dir separator is lost.
+ if (path.length() > 0 && !path.endsWith(File.separator)) {
+ path = path + File.separator;
+ }
+ }
+ return path;
+ }
+
+ /**
+ * Returns the location of the current SDK as a {@link File} or null.
+ *
+ * @return The SDK OS path or null if no SDK is setup.
+ */
+ @Nullable
+ public File getSdkFileLocation() {
+ if (mManager == null || mManager.getLocalSdk() == null) {
+ return null;
+ }
+ return mManager.getLocalSdk().getLocation();
}
/**
* Returns a <em>new</em> {@link SdkManager} that can parse the SDK located
- * at the current {@link #getSdkLocation()}.
+ * at the current {@link #getSdkOsLocation()}.
* <p/>
* Implementation detail: The {@link Sdk} has its own internal manager with
* a custom logger which is not designed to be useful for outsiders. Callers
@@ -343,7 +375,7 @@ public final class Sdk {
* @return A new {@link SdkManager} parsing the same location.
*/
public @Nullable SdkManager getNewSdkManager(@NonNull ILogger log) {
- return SdkManager.createManager(getSdkLocation(), log);
+ return SdkManager.createManager(getSdkOsLocation(), log);
}
/**
@@ -901,7 +933,7 @@ public final class Sdk {
mDocBaseUrl = getDocumentationBaseUrl(manager.getLocation() +
SdkConstants.OS_SDK_DOCS_FOLDER);
- mDeviceManager = DeviceManager.createInstance(manager.getLocation(),
+ mDeviceManager = DeviceManager.createInstance(manager.getLocalSdk().getLocation(),
AdtPlugin.getDefault());
// update whatever ProjectState is already present with new IAndroidTarget objects.
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/welcome/AdtStartup.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/welcome/AdtStartup.java
index 65eee94..b07893d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/welcome/AdtStartup.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/welcome/AdtStartup.java
@@ -23,9 +23,9 @@ import com.android.ide.eclipse.adt.AdtPlugin.CheckSdkErrorHandler;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.LayoutWindowCoordinator;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.base.InstallDetails;
-import com.android.sdklib.util.GrabProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.IProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.Wait;
+import com.android.utils.GrabProcessOutput;
+import com.android.utils.GrabProcessOutput.IProcessOutput;
+import com.android.utils.GrabProcessOutput.Wait;
import com.android.sdkstats.DdmsPreferenceStore;
import com.android.sdkstats.SdkStatsService;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java
index 62090d4..170da6d 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/export/ExportWizard.java
@@ -18,15 +18,19 @@ package com.android.ide.eclipse.adt.internal.wizards.export;
import com.android.annotations.Nullable;
import com.android.ide.eclipse.adt.AdtPlugin;
+import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
+import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.ide.eclipse.adt.internal.utils.FingerprintUtils;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs.BuildVerbosity;
import com.android.ide.eclipse.adt.internal.project.ExportHelper;
import com.android.ide.eclipse.adt.internal.project.ProjectHelper;
+import com.android.sdklib.BuildToolInfo;
+import com.android.sdklib.BuildToolInfo.PathId;
import com.android.sdklib.internal.build.DebugKeyProvider.IKeyGenOutput;
import com.android.sdklib.internal.build.KeystoreHelper;
-import com.android.sdklib.util.GrabProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.IProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.Wait;
+import com.android.utils.GrabProcessOutput;
+import com.android.utils.GrabProcessOutput.IProcessOutput;
+import com.android.utils.GrabProcessOutput.Wait;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -290,10 +294,14 @@ public final class ExportWizard extends Wizard implements IExportWizard {
// check the private key/certificate again since it may have been created just above.
if (mPrivateKey != null && mCertificate != null) {
+ // check whether we can run zipalign.
boolean runZipAlign = false;
- String path = AdtPlugin.getOsAbsoluteZipAlign();
- File zipalign = new File(path);
- runZipAlign = zipalign.isFile();
+
+ ProjectState projectState = Sdk.getProjectState(mProject);
+ BuildToolInfo buildToolInfo = ExportHelper.getBuildTools(projectState);
+
+ String zipAlignPath = buildToolInfo.getPath(PathId.ZIP_ALIGN);
+ runZipAlign = zipAlignPath != null && new File(zipAlignPath).isFile();
File apkExportFile = mDestinationFile;
if (runZipAlign) {
@@ -307,7 +315,7 @@ public final class ExportWizard extends Wizard implements IExportWizard {
// align if we can
if (runZipAlign) {
- String message = zipAlign(path, apkExportFile, mDestinationFile);
+ String message = zipAlign(zipAlignPath, apkExportFile, mDestinationFile);
if (message != null) {
displayError(message);
return false;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/BuildFileCreator.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/BuildFileCreator.java
index 096b0b1..e749e71 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/BuildFileCreator.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/BuildFileCreator.java
@@ -16,8 +16,14 @@
package com.android.ide.eclipse.adt.internal.wizards.exportgradle;
+import static com.android.SdkConstants.GRADLE_LATEST_VERSION;
+import static com.android.SdkConstants.GRADLE_PLUGIN_LATEST_VERSION;
+import static com.android.SdkConstants.GRADLE_PLUGIN_NAME;
+
import com.android.SdkConstants;
import com.android.annotations.NonNull;
+import com.android.annotations.Nullable;
+import com.android.ide.eclipse.adt.internal.project.BaseProjectHelper;
import com.android.ide.eclipse.adt.internal.sdk.ProjectState;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.ide.eclipse.adt.io.IFolderWrapper;
@@ -27,6 +33,7 @@ import com.android.xml.AndroidManifest;
import com.google.common.base.Charsets;
import com.google.common.base.Joiner;
import com.google.common.collect.Lists;
+import com.google.common.io.Closeables;
import com.google.common.io.Files;
import org.eclipse.core.resources.IFile;
@@ -40,17 +47,22 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
+import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
@@ -66,7 +78,7 @@ public class BuildFileCreator {
private static final String GRADLE_WRAPPER_LOCATION =
"tools/templates/gradle/wrapper"; //$NON-NLS-1$
static final String PLUGIN_CLASSPATH =
- "classpath 'com.android.tools.build:gradle:0.5.+'"; //$NON-NLS-1$
+ "classpath '" + GRADLE_PLUGIN_NAME + GRADLE_PLUGIN_LATEST_VERSION + "'"; //$NON-NLS-1$
static final String MAVEN_REPOSITORY = "mavenCentral()"; //$NON-NLS-1$
private static final String[] GRADLE_WRAPPER_FILES = new String[] {
@@ -98,7 +110,7 @@ public class BuildFileCreator {
@NonNull Shell shell,
@NonNull IProgressMonitor pm) {
- File gradleLocation = new File(Sdk.getCurrent().getSdkLocation(), GRADLE_WRAPPER_LOCATION);
+ File gradleLocation = new File(Sdk.getCurrent().getSdkOsLocation(), GRADLE_WRAPPER_LOCATION);
SubMonitor localmonitor = null;
try {
@@ -307,6 +319,10 @@ public class BuildFileCreator {
File src = new File(from, file);
dest.getParentFile().mkdirs();
new FileOp().copyFile(src, dest);
+
+ if (src.getName().equals(GRADLE_PROPERTIES)) {
+ updateGradleDistributionUrl(GRADLE_LATEST_VERSION, dest);
+ }
dest.setExecutable(src.canExecute());
status.addFileStatus(ExportStatus.FileStatus.OK, dest);
} catch (IOException e) {
@@ -377,6 +393,22 @@ public class BuildFileCreator {
mBuildFile.append(" compileSdkVersion " + buildApi + "\n"); //$NON-NLS-1$
mBuildFile.append(" buildToolsVersion \"" + toolsVersion + "\"\n"); //$NON-NLS-1$
mBuildFile.append("\n"); //$NON-NLS-1$
+
+ try {
+ IJavaProject javaProject = BaseProjectHelper.getJavaProject(projectState.getProject());
+ // otherwise we check source compatibility
+ String source = javaProject.getOption(JavaCore.COMPILER_SOURCE, true);
+ if (JavaCore.VERSION_1_7.equals(source)) {
+ mBuildFile.append(
+ " compileOptions {\n" + //$NON-NLS-1$
+ " sourceCompatibility JavaVersion.VERSION_1_7\n" + //$NON-NLS-1$
+ " targetCompatibility JavaVersion.VERSION_1_7\n" + //$NON-NLS-1$
+ " }\n" + //$NON-NLS-1$
+ "\n"); //$NON-NLS-1$
+ }
+ } catch (CoreException e) {
+ // Ignore compliance level, go with default
+ }
}
/**
@@ -541,4 +573,68 @@ public class BuildFileCreator {
return confirmedFiles;
}
+
+ // -------------------------------------------------------------------------------
+ // Fix gradle wrapper version. This code is from GradleUtil in the Studio plugin:
+ // -------------------------------------------------------------------------------
+
+ private static final String GRADLE_PROPERTIES = "gradle-wrapper.properties";
+ private static final String GRADLEW_PROPERTIES_PATH =
+ "gradle" + File.separator + "wrapper" + File.separator + GRADLE_PROPERTIES;
+ private static final String GRADLEW_DISTRIBUTION_URL_PROPERTY_NAME = "distributionUrl";
+
+ @NonNull
+ private static File getGradleWrapperPropertiesFilePath(@NonNull File projectRootDir) {
+ return new File(projectRootDir, GRADLEW_PROPERTIES_PATH);
+ }
+
+ @Nullable
+ public static File findWrapperPropertiesFile(@NonNull File projectRootDir) {
+ File wrapperPropertiesFile = getGradleWrapperPropertiesFilePath(projectRootDir);
+ return wrapperPropertiesFile.isFile() ? wrapperPropertiesFile : null;
+ }
+
+ private static boolean updateGradleDistributionUrl(
+ @NonNull String gradleVersion,
+ @NonNull File propertiesFile) throws IOException {
+ Properties properties = loadGradleWrapperProperties(propertiesFile);
+ String gradleDistributionUrl = getGradleDistributionUrl(gradleVersion, false);
+ String property = properties.getProperty(GRADLEW_DISTRIBUTION_URL_PROPERTY_NAME);
+ if (property != null
+ && (property.equals(gradleDistributionUrl) || property
+ .equals(getGradleDistributionUrl(gradleVersion, true)))) {
+ return false;
+ }
+ properties.setProperty(GRADLEW_DISTRIBUTION_URL_PROPERTY_NAME, gradleDistributionUrl);
+ FileOutputStream out = null;
+ try {
+ out = new FileOutputStream(propertiesFile);
+ properties.store(out, null);
+ return true;
+ } finally {
+ Closeables.close(out, true);
+ }
+ }
+
+ @NonNull
+ private static Properties loadGradleWrapperProperties(@NonNull File propertiesFile)
+ throws IOException {
+ Properties properties = new Properties();
+ FileInputStream fileInputStream = null;
+ try {
+ fileInputStream = new FileInputStream(propertiesFile);
+ properties.load(fileInputStream);
+ return properties;
+ } finally {
+ Closeables.close(fileInputStream, true);
+ }
+ }
+
+ @NonNull
+ private static String getGradleDistributionUrl(@NonNull String gradleVersion,
+ boolean binOnly) {
+ String suffix = binOnly ? "bin" : "all";
+ return String.format("http://services.gradle.org/distributions/gradle-%1$s-" + suffix
+ + ".zip", gradleVersion);
+ }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/GradleExportWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/GradleExportWizard.java
index 29f8802..8c74187 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/GradleExportWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/GradleExportWizard.java
@@ -54,6 +54,7 @@ public class GradleExportWizard extends Wizard implements IExportWizard {
@Override
public void addPages() {
+ addPage(new ImportInsteadPage());
mFirstPage = new ProjectSelectionPage(mBuilder);
addPage(mFirstPage);
mSecondPage = new ConfirmationPage(mBuilder);
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/ImportInsteadPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/ImportInsteadPage.java
new file mode 100644
index 0000000..73d4937
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/exportgradle/ImportInsteadPage.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Eclipse Public License, Version 1.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.eclipse.org/org/documents/epl-v10.php
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.android.ide.eclipse.adt.internal.wizards.exportgradle;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+
+class ImportInsteadPage extends WizardPage {
+ public ImportInsteadPage() {
+ super("importInstead");
+ setTitle("Import Instead?");
+ setDescription("Consider importing directly into Android Studio instead of exporting from Eclipse");
+ }
+
+ @Override
+ public void createControl(Composite parent) {
+ Composite container = new Composite(parent, SWT.NULL);
+ setControl(container);
+ container.setLayout(new GridLayout(1, false));
+
+ CLabel label = new CLabel(container, SWT.NONE);
+ label.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, true, false, 1, 1));
+ label.setText(
+ "Recent versions of Android Studio now support direct import of ADT projects.\n" +
+ "\n" +
+ "There are advantages to importing from Studio instead of exporting from Eclipse:\n" +
+ "- It can replace jars and library projects with Gradle dependencies instead\n" +
+ "- On import, it creates a new copy of the project and changes the project structure\n" +
+ " to the new Gradle directory layout which better supports multiple resource directories.\n" +
+ "- It can merge instrumentation test projects into the same project\n" +
+ "- Android Studio is released more frequently than the ADT plugin, so the import\n" +
+ " mechanism more closely tracks the rapidly evolving requirements of Studio Gradle\n" +
+ " projects.\n" +
+ "\n" +
+ "If you want to preserve your Eclipse directory structure, or if for some reason import\n" +
+ "in Studio doesn't work (please let us know by filing a bug), continue to export from\n" +
+ "Eclipse instead.");
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
index 101027a..b33d65b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewActivityWizard.java
@@ -20,17 +20,25 @@ import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectW
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_MIN_API_LEVEL;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_PACKAGE_NAME;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewProjectWizard.ATTR_TARGET_API;
+import static org.eclipse.core.resources.IResource.DEPTH_INFINITE;
import com.android.annotations.NonNull;
+import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AdtUtils;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.CompositeChange;
import org.eclipse.ui.IWorkbench;
+import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.Set;
@@ -131,6 +139,20 @@ public class NewActivityWizard extends TemplateWizard {
}
@Override
+ public boolean performFinish(IProgressMonitor monitor) throws InvocationTargetException {
+ boolean success = super.performFinish(monitor);
+
+ if (success) {
+ List<Runnable> finalizingTasks = getFinalizingActions();
+ for (Runnable r : finalizingTasks) {
+ r.run();
+ }
+ return true;
+ }
+ return false;
+ }
+
+ @Override
@NonNull
protected IProject getProject() {
return mActivityValues.project;
@@ -144,6 +166,13 @@ public class NewActivityWizard extends TemplateWizard {
}
@Override
+ @NonNull
+ protected List<Runnable> getFinalizingActions() {
+ TemplateHandler activityTemplate = mActivityValues.getTemplateHandler();
+ return activityTemplate.getFinalizingActions();
+ }
+
+ @Override
protected List<Change> computeChanges() {
return mActivityValues.computeChanges();
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java
index 0b003f3..60dd0f2 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectPage.java
@@ -21,6 +21,7 @@ import static com.android.ide.eclipse.adt.AdtUtils.extractClassName;
import static com.android.ide.eclipse.adt.internal.wizards.templates.NewTemplatePage.WIZARD_PAGE_WIDTH;
import com.android.annotations.Nullable;
+import com.android.ide.common.sdk.SdkVersionInfo;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AdtUtils;
import com.android.ide.eclipse.adt.internal.editors.IconFactory;
@@ -29,6 +30,7 @@ import com.android.ide.eclipse.adt.internal.wizards.newproject.ApplicationInfoPa
import com.android.ide.eclipse.adt.internal.wizards.newproject.ProjectNamePage;
import com.android.sdklib.AndroidVersion;
import com.android.sdklib.IAndroidTarget;
+import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.eclipse.core.resources.IResource;
@@ -63,8 +65,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import lombok.ast.libs.org.parboiled.google.collect.Lists;
-
/**
* First wizard page in the "New Project From Template" wizard
*/
@@ -551,7 +551,9 @@ public class NewProjectPage extends WizardPage
try {
minSdk = Integer.parseInt(mValues.minSdk);
} catch (NumberFormatException nufe) {
- minSdk = 1;
+ // If not a number, then the string is a codename, so treat it
+ // as a preview version.
+ minSdk = SdkVersionInfo.HIGHEST_KNOWN_API + 1;
}
}
mValues.iconState.minSdk = minSdk.intValue();
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
index 84de9a4..d350a00 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewProjectWizard.java
@@ -23,6 +23,7 @@ import com.android.annotations.VisibleForTesting;
import com.android.assetstudiolib.GraphicGenerator;
import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.AdtUtils;
+import com.android.ide.eclipse.adt.internal.actions.AddSupportJarAction;
import com.android.ide.eclipse.adt.internal.assetstudio.AssetType;
import com.android.ide.eclipse.adt.internal.assetstudio.ConfigureAssetSetPage;
import com.android.ide.eclipse.adt.internal.assetstudio.CreateAssetSetWizardState;
@@ -38,6 +39,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
@@ -74,6 +76,7 @@ public class NewProjectWizard extends TemplateWizard {
static final String CATEGORY_PROJECTS = "projects"; //$NON-NLS-1$
static final String CATEGORY_ACTIVITIES = "activities"; //$NON-NLS-1$
static final String CATEGORY_OTHER = "other"; //$NON-NLS-1$
+ static final String ATTR_APP_COMPAT = "appCompat"; //$NON-NLS-1$
/**
* Reserved file name for the launcher icon, resolves to the xhdpi version
*
@@ -266,6 +269,18 @@ public class NewProjectWizard extends TemplateWizard {
// Generate basic output skeleton
Map<String, Object> paramMap = new HashMap<String, Object>();
addProjectInfo(paramMap);
+ TemplateHandler.addDirectoryParameters(paramMap, getProject());
+ // We don't know at this point whether the activity is going to need
+ // AppCompat so we just assume that it will.
+ if (mValues.createActivity && mValues.minSdkLevel < 14) {
+ paramMap.put(ATTR_APP_COMPAT, true);
+ getFinalizingActions().add(new Runnable() {
+ @Override
+ public void run() {
+ AddSupportJarAction.installAppCompatLibrary(mProject, true);
+ }
+ });
+ }
return template.render(mProject, paramMap);
}
@@ -357,6 +372,11 @@ public class NewProjectWizard extends TemplateWizard {
AdtPlugin.log(e, null);
}
+ List<Runnable> finalizingTasks = getFinalizingActions();
+ for (Runnable r : finalizingTasks) {
+ r.run();
+ }
+
return true;
} catch (Exception ioe) {
AdtPlugin.log(ioe, null);
@@ -391,6 +411,7 @@ public class NewProjectWizard extends TemplateWizard {
// Ensure that activities created as part of a new project are marked as
// launcher activities
parameters.put(IS_LAUNCHER, true);
+ TemplateHandler.addDirectoryParameters(parameters, project);
TemplateHandler activityTemplate = activityValues.getTemplateHandler();
activityTemplate.setBackupMergedFiles(false);
@@ -411,6 +432,9 @@ public class NewProjectWizard extends TemplateWizard {
List<String> filesToOpen = activityTemplate.getFilesToOpen();
projectTemplate.getFilesToOpen().addAll(filesToOpen);
+
+ List<Runnable> finalizingActions = activityTemplate.getFinalizingActions();
+ projectTemplate.getFinalizingActions().addAll(finalizingActions);
}
private void addProjectInfo(Map<String, Object> parameters) {
@@ -423,4 +447,10 @@ public class NewProjectWizard extends TemplateWizard {
parameters.put(ATTR_COPY_ICONS, !mValues.createIcon);
parameters.putAll(mValues.parameters);
}
+
+ @Override
+ @NonNull
+ protected List<Runnable> getFinalizingActions() {
+ return mValues.template.getFinalizingActions();
+ }
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java
index 098beea..99814f7 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizard.java
@@ -28,6 +28,7 @@ import com.android.ide.eclipse.adt.AdtUtils;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
@@ -140,6 +141,13 @@ public class NewTemplateWizard extends TemplateWizard {
}
@Override
+ @NonNull
+ protected List<Runnable> getFinalizingActions() {
+ TemplateHandler activityTemplate = mValues.getTemplateHandler();
+ return activityTemplate.getFinalizingActions();
+ }
+
+ @Override
protected List<Change> computeChanges() {
return mValues.computeChanges();
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java
index 805399b..2c97003 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/NewTemplateWizardState.java
@@ -161,6 +161,8 @@ public class NewTemplateWizardState {
parameters.put(IS_LIBRARY_PROJECT,
projectState != null ? projectState.isLibrary() : false);
+ TemplateHandler.addDirectoryParameters(parameters, project);
+
List<Change> changes = getTemplateHandler().render(project, parameters);
if (mIconState != null) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java
index a875712..8e11841 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandler.java
@@ -70,6 +70,7 @@ import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.formatter.CodeFormatter;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ltk.core.refactoring.Change;
@@ -99,6 +100,7 @@ import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
+import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
@@ -124,9 +126,10 @@ class TemplateHandler {
* proper Booleans. Templates which rely on this should specify format >= 2.
* <li> 3: The wizard infrastructure passes the {@code isNewProject} boolean variable
* to indicate whether a wizard is created as part of a new blank project
+ * <li> 4: The templates now specify dependencies in the recipe file.
* </ul>
*/
- static final int CURRENT_FORMAT = 3;
+ static final int CURRENT_FORMAT = 4;
/**
* Special marker indicating that this path refers to the special shared
@@ -165,6 +168,8 @@ class TemplateHandler {
static final String TAG_THUMBS = "thumbs"; //$NON-NLS-1$
static final String TAG_DEPENDENCY = "dependency"; //$NON-NLS-1$
static final String TAG_ICONS = "icons"; //$NON-NLS-1$
+ static final String TAG_FORMFACTOR = "formfactor"; //$NON-NLS-1$
+ static final String TAG_CATEGORY = "category"; //$NON-NLS-1$
static final String ATTR_FORMAT = "format"; //$NON-NLS-1$
static final String ATTR_REVISION = "revision"; //$NON-NLS-1$
static final String ATTR_VALUE = "value"; //$NON-NLS-1$
@@ -187,11 +192,25 @@ class TemplateHandler {
static final String ATTR_SOURCE_TYPE = "source"; //$NON-NLS-1$
static final String ATTR_CLIPART_NAME = "clipartName";//$NON-NLS-1$
static final String ATTR_TEXT = "text"; //$NON-NLS-1$
+ static final String ATTR_SRC_DIR = "srcDir"; //$NON-NLS-1$
+ static final String ATTR_SRC_OUT = "srcOut"; //$NON-NLS-1$
+ static final String ATTR_RES_DIR = "resDir"; //$NON-NLS-1$
+ static final String ATTR_RES_OUT = "resOut"; //$NON-NLS-1$
+ static final String ATTR_MANIFEST_DIR = "manifestDir";//$NON-NLS-1$
+ static final String ATTR_MANIFEST_OUT = "manifestOut";//$NON-NLS-1$
+ static final String ATTR_PROJECT_DIR = "projectDir"; //$NON-NLS-1$
+ static final String ATTR_PROJECT_OUT = "projectOut"; //$NON-NLS-1$
+ static final String ATTR_MAVEN_URL = "mavenUrl"; //$NON-NLS-1$
+ static final String ATTR_DEBUG_KEYSTORE_SHA1 =
+ "debugKeystoreSha1"; //$NON-NLS-1$
static final String CATEGORY_ACTIVITIES = "activities";//$NON-NLS-1$
static final String CATEGORY_PROJECTS = "projects"; //$NON-NLS-1$
static final String CATEGORY_OTHER = "other"; //$NON-NLS-1$
+ static final String MAVEN_SUPPORT_V4 = "support-v4"; //$NON-NLS-1$
+ static final String MAVEN_SUPPORT_V13 = "support-v13"; //$NON-NLS-1$
+ static final String MAVEN_APPCOMPAT = "appcompat-v7"; //$NON-NLS-1$
/** Default padding to apply in wizards around the thumbnail preview images */
static final int PREVIEW_PADDING = 10;
@@ -205,6 +224,11 @@ class TemplateHandler {
*/
private final List<String> mOpen = Lists.newArrayList();
+ /**
+ * List of actions to perform after the wizard has finished.
+ */
+ protected List<Runnable> mFinalizingActions = Lists.newArrayList();
+
/** Path to the directory containing the templates */
@NonNull
private final File mRootPath;
@@ -237,7 +261,7 @@ class TemplateHandler {
*/
private TemplateMetadata mTemplate;
- private TemplateManager mManager;
+ private final TemplateManager mManager;
/** Creates a new {@link TemplateHandler} for the given root path */
static TemplateHandler createFromPath(File rootPath) {
@@ -339,6 +363,23 @@ class TemplateHandler {
return paramMap;
}
+ static void addDirectoryParameters(Map<String, Object> parameters, IProject project) {
+ IPath srcDir = project.getFile(SdkConstants.SRC_FOLDER).getProjectRelativePath();
+ parameters.put(ATTR_SRC_DIR, srcDir.toString());
+
+ IPath resDir = project.getFile(SdkConstants.RES_FOLDER).getProjectRelativePath();
+ parameters.put(ATTR_RES_DIR, resDir.toString());
+
+ IPath manifestDir = project.getProjectRelativePath();
+ parameters.put(ATTR_MANIFEST_DIR, manifestDir.toString());
+ parameters.put(ATTR_MANIFEST_OUT, manifestDir.toString());
+
+ parameters.put(ATTR_PROJECT_DIR, manifestDir.toString());
+ parameters.put(ATTR_PROJECT_OUT, manifestDir.toString());
+
+ parameters.put(ATTR_DEBUG_KEYSTORE_SHA1, "");
+ }
+
@Nullable
public TemplateMetadata getTemplate() {
if (mTemplate == null) {
@@ -353,7 +394,7 @@ class TemplateHandler {
return new File(mRootPath.getPath(), templateName).getPath();
}
- /**
+ /**
* Load a text resource for the given relative path within the template
*
* @param relativePath relative path within the template
@@ -431,7 +472,7 @@ class TemplateHandler {
@Override
public void startElement(String uri, String localName, String name,
Attributes attributes)
- throws SAXException {
+ throws SAXException {
if (TAG_PARAMETER.equals(name)) {
String id = attributes.getValue(ATTR_ID);
if (!paramMap.containsKey(id)) {
@@ -448,8 +489,7 @@ class TemplateHandler {
} else if (TAG_GLOBAL.equals(name)) {
String id = attributes.getValue(ATTR_ID);
if (!paramMap.containsKey(id)) {
- String value = attributes.getValue(ATTR_VALUE);
- paramMap.put(id, value);
+ paramMap.put(id, TypedVariable.parseGlobal(attributes));
}
} else if (TAG_GLOBALS.equals(name)) {
// Handle evaluation of variables
@@ -477,9 +517,10 @@ class TemplateHandler {
}
}
}
- } else if (!name.equals("template") && !name.equals("category")
- && !name.equals("option") && !name.equals(TAG_THUMBS) &&
- !name.equals(TAG_THUMB) && !name.equals(TAG_ICONS)) {
+ } else if (!name.equals("template") && !name.equals(TAG_CATEGORY) &&
+ !name.equals(TAG_FORMFACTOR) && !name.equals("option") &&
+ !name.equals(TAG_THUMBS) && !name.equals(TAG_THUMB) &&
+ !name.equals(TAG_ICONS)) {
System.err.println("WARNING: Unknown template directive " + name);
}
}
@@ -499,27 +540,27 @@ class TemplateHandler {
String.format(
"%1$s already exists.\nWould you like to replace it?",
file.getPath()),
- MessageDialog.QUESTION, new String[] {
- // Yes will be moved to the end because it's the default
- "Yes", "No", "Cancel", "Yes to All"
- }, 0);
+ MessageDialog.QUESTION, new String[] {
+ // Yes will be moved to the end because it's the default
+ "Yes", "No", "Cancel", "Yes to All"
+ }, 0);
int result = dialog.open();
switch (result) {
- case 0:
- // Yes
- break;
- case 3:
- // Yes to all
- mYesToAll = true;
- break;
- case 1:
- // No
- return false;
- case SWT.DEFAULT:
- case 2:
- // Cancel
- mNoToAll = true;
- return false;
+ case 0:
+ // Yes
+ break;
+ case 3:
+ // Yes to all
+ mYesToAll = true;
+ break;
+ case 1:
+ // No
+ return false;
+ case SWT.DEFAULT:
+ case 2:
+ // Cancel
+ mNoToAll = true;
+ return false;
}
}
@@ -556,7 +597,7 @@ class TemplateHandler {
@Override
public void startElement(String uri, String localName, String name,
Attributes attributes)
- throws SAXException {
+ throws SAXException {
if (mNoToAll) {
return;
}
@@ -592,6 +633,36 @@ class TemplateHandler {
if (relativePath != null && !relativePath.isEmpty()) {
mOpen.add(relativePath);
}
+ } else if (TAG_DEPENDENCY.equals(name)) {
+ String dependencyUrl = attributes.getValue(ATTR_MAVEN_URL);
+ File path;
+ if (dependencyUrl.contains(MAVEN_SUPPORT_V4)) {
+ // We assume the revision requirement has been satisfied
+ // by the wizard
+ path = AddSupportJarAction.getSupportJarFile();
+ } else if (dependencyUrl.contains(MAVEN_SUPPORT_V13)) {
+ path = AddSupportJarAction.getSupport13JarFile();
+ } else if (dependencyUrl.contains(MAVEN_APPCOMPAT)) {
+ path = null;
+ mFinalizingActions.add(new Runnable() {
+ @Override
+ public void run() {
+ AddSupportJarAction.installAppCompatLibrary(mProject, true);
+ }
+ });
+ } else {
+ path = null;
+ System.err.println("WARNING: Unknown dependency type");
+ }
+
+ if (path != null) {
+ IPath to = getTargetPath(FD_NATIVE_LIBS +'/' + path.getName());
+ try {
+ copy(path, to);
+ } catch (IOException ioe) {
+ AdtPlugin.log(ioe, null);
+ }
+ }
} else if (!name.equals("recipe") && !name.equals(TAG_DEPENDENCY)) { //$NON-NLS-1$
System.err.println("WARNING: Unknown template directive " + name);
}
@@ -1002,6 +1073,16 @@ class TemplateHandler {
return mOpen;
}
+ /**
+ * Returns the list of actions to perform when the template has been created
+ *
+ * @return the list of actions to perform
+ */
+ @NonNull
+ public List<Runnable> getFinalizingActions() {
+ return mFinalizingActions;
+ }
+
/** Copy a template resource */
private final void copyTemplateResource(
@NonNull String relativeFrom,
@@ -1034,7 +1115,7 @@ class TemplateHandler {
IResource dest = mProject.getFile(path);
if (dest.exists() && !(dest instanceof IFile)) {// Don't attempt to overwrite a folder
assert false : dest.getClass().getName();
- return;
+ return;
}
IFile file = (IFile) dest;
String targetName = path.lastSegment();
@@ -1134,9 +1215,9 @@ class TemplateHandler {
Constants.BUNDLE_VERSION);
Version version = new Version(versionString);
return new Status(IStatus.ERROR, AdtPlugin.PLUGIN_ID,
- String.format("This template requires a more recent version of the " +
- "Android Eclipse plugin. Please update from version %1$d.%2$d.%3$d.",
- version.getMajor(), version.getMinor(), version.getMicro()));
+ String.format("This template requires a more recent version of the " +
+ "Android Eclipse plugin. Please update from version %1$d.%2$d.%3$d.",
+ version.getMajor(), version.getMinor(), version.getMicro()));
}
int templateMinSdk = template.getMinSdk();
if (templateMinSdk > currentMinSdk && currentMinSdk >= 1) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java
index de625e0..30dd09e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateManager.java
@@ -28,6 +28,7 @@ import com.android.ide.eclipse.adt.internal.editors.layout.gle2.DomUtilities;
import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.google.common.base.Charsets;
import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
import com.google.common.io.Files;
import org.w3c.dom.Document;
@@ -39,9 +40,13 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/** Handles locating templates and providing template metadata */
public class TemplateManager {
+ private static final Set<String> EXCLUDED_CATEGORIES = Sets.newHashSet("Folder", "Google");
+ private static final Set<String> EXCLUDED_FORMFACTORS = Sets.newHashSet("Wear", "TV");
+
TemplateManager() {
}
@@ -239,6 +244,10 @@ public class TemplateManager {
Document doc = DomUtilities.parseDocument(xml, true);
if (doc != null && doc.getDocumentElement() != null) {
TemplateMetadata metadata = new TemplateMetadata(doc);
+ if (EXCLUDED_CATEGORIES.contains(metadata.getCategory()) ||
+ EXCLUDED_FORMFACTORS.contains(metadata.getFormFactor())) {
+ return null;
+ }
mTemplateMap.put(templateDir, metadata);
return metadata;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java
index cb184b8..4ce7d74 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateMetadata.java
@@ -30,11 +30,14 @@ import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHan
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_TEXT;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_TRIM;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_TYPE;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.ATTR_VALUE;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.CURRENT_FORMAT;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_DEPENDENCY;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_ICONS;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_PARAMETER;
import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_THUMB;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_FORMFACTOR;
+import static com.android.ide.eclipse.adt.internal.wizards.templates.TemplateHandler.TAG_CATEGORY;
import com.android.annotations.NonNull;
import com.android.annotations.Nullable;
@@ -46,6 +49,7 @@ import com.android.ide.eclipse.adt.internal.assetstudio.CreateAssetSetWizardStat
import com.android.ide.eclipse.adt.internal.editors.IconFactory;
import com.android.ide.eclipse.adt.internal.editors.layout.gle2.ImageUtils;
import com.android.utils.Pair;
+import com.google.common.collect.Lists;
import org.eclipse.core.resources.IProject;
import org.eclipse.swt.graphics.Image;
@@ -64,8 +68,6 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
-import lombok.ast.libs.org.parboiled.google.collect.Lists;
-
/** An ADT template along with metadata */
class TemplateMetadata {
private final Document mDocument;
@@ -77,6 +79,8 @@ class TemplateMetadata {
private Integer mRevision;
private boolean mNoIcons;
private CreateAssetSetWizardState mIconState;
+ private String mFormFactor;
+ private String mCategory;
TemplateMetadata(@NonNull Document document) {
mDocument = document;
@@ -181,6 +185,37 @@ class TemplateMetadata {
return mRevision.intValue();
}
+
+ public String getFormFactor() {
+ if (mFormFactor == null) {
+ mFormFactor = "Mobile";
+
+ NodeList formfactorDeclarations = mDocument.getElementsByTagName(TAG_FORMFACTOR);
+ if (formfactorDeclarations.getLength() > 0) {
+ Element element = (Element) formfactorDeclarations.item(0);
+ String formFactor = element.getAttribute(ATTR_VALUE);
+ if (formFactor != null && !formFactor.isEmpty()) {
+ mFormFactor = formFactor;
+ }
+ }
+ }
+ return mFormFactor;
+ }
+
+ public String getCategory() {
+ if (mCategory == null) {
+ mCategory = "";
+ NodeList categories = mDocument.getElementsByTagName(TAG_CATEGORY);
+ if (categories.getLength() > 0) {
+ Element element = (Element) categories.item(0);
+ String category = element.getAttribute(ATTR_VALUE);
+ if (category != null && !category.isEmpty()) {
+ mCategory = category;
+ }
+ }
+ }
+ return mCategory;
+ }
/**
* Returns a suitable icon wizard state instance if this wizard requests
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateWizard.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateWizard.java
index 5f743bb3..7ca32f9 100644
--- a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateWizard.java
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateWizard.java
@@ -22,6 +22,7 @@ import com.android.ide.eclipse.adt.AdtPlugin;
import com.android.ide.eclipse.adt.internal.assetstudio.ConfigureAssetSetPage;
import com.android.ide.eclipse.adt.internal.assetstudio.CreateAssetSetWizardState;
import com.android.ide.eclipse.adt.internal.editors.IconFactory;
+import com.google.common.collect.Lists;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
@@ -35,13 +36,17 @@ import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.ltk.core.refactoring.Change;
import org.eclipse.ltk.core.refactoring.CompositeChange;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.swing.SwingUtilities;
+
abstract class TemplateWizard extends Wizard implements INewWizard {
private static final String PROJECT_LOGO_LARGE = "android-64"; //$NON-NLS-1$
protected IWorkbench mWorkbench;
@@ -144,6 +149,15 @@ abstract class TemplateWizard extends Wizard implements INewWizard {
protected abstract List<String> getFilesToOpen();
/**
+ * Returns the list of files to open, which might be empty. This method will
+ * only be called <b>after</b> {@link #computeChanges()} has been called.
+ *
+ * @return a list of files to open
+ */
+ @NonNull
+ protected abstract List<Runnable> getFinalizingActions();
+
+ /**
* Computes the changes to the {@link #getProject()} this template should
* perform
*
@@ -173,7 +187,6 @@ abstract class TemplateWizard extends Wizard implements INewWizard {
} catch (CoreException e) {
AdtPlugin.log(e, null);
}
-
return true;
}
@@ -184,11 +197,12 @@ abstract class TemplateWizard extends Wizard implements INewWizard {
getContainer().run(true, false, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
+ InterruptedException {
boolean ok = performFinish(monitor);
success.set(ok);
}
});
+
} catch (InvocationTargetException e) {
AdtPlugin.log(e, null);
return false;
@@ -200,7 +214,6 @@ abstract class TemplateWizard extends Wizard implements INewWizard {
if (success.get()) {
// Open the primary file/files
NewTemplateWizard.openFiles(getProject(), getFilesToOpen(), mWorkbench);
-
return true;
} else {
return false;
diff --git a/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TypedVariable.java b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TypedVariable.java
new file mode 100644
index 0000000..468a10c
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/wizards/templates/TypedVariable.java
@@ -0,0 +1,50 @@
+package com.android.ide.eclipse.adt.internal.wizards.templates;
+
+import java.util.Locale;
+
+import org.xml.sax.Attributes;
+
+public class TypedVariable {
+ public enum Type {
+ STRING,
+ BOOLEAN,
+ INTEGER;
+
+ public static Type get(String name) {
+ if (name == null) {
+ return STRING;
+ }
+ try {
+ return valueOf(name.toUpperCase(Locale.US));
+ } catch (IllegalArgumentException e) {
+ System.err.println("Unexpected global type '" + name + "'");
+ System.err.println("Expected one of :");
+ for (Type s : Type.values()) {
+ System.err.println(" " + s.name().toLowerCase(Locale.US));
+ }
+ }
+
+ return STRING;
+ }
+ }
+
+ public static Object parseGlobal(Attributes attributes) {
+ String value = attributes.getValue(TemplateHandler.ATTR_VALUE);
+ Type type = Type.get(attributes.getValue(TemplateHandler.ATTR_TYPE));
+
+ switch (type) {
+ case STRING:
+ return value;
+ case BOOLEAN:
+ return Boolean.parseBoolean(value);
+ case INTEGER:
+ try {
+ return Integer.parseInt(value);
+ } catch (NumberFormatException e) {
+ return value;
+ }
+ }
+
+ return value;
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.base/.classpath b/eclipse/plugins/com.android.ide.eclipse.base/.classpath
index a81e5b5..fc77c11 100644
--- a/eclipse/plugins/com.android.ide.eclipse.base/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.base/.classpath
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="libs/dvlib.jar" sourcepath="/dvlib"/>
- <classpathentry exported="true" kind="lib" path="libs/common.jar" sourcepath="/common"/>
- <classpathentry exported="true" kind="lib" path="libs/commons-codec-1.4.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/commons-compress-1.0.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/commons-logging-1.1.1.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/guava-13.0.1.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/httpclient-4.1.1.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/httpcore-4.1.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/kxml2-2.3.0.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/layoutlib-api.jar" sourcepath="/layoutlib-api"/>
- <classpathentry exported="true" kind="lib" path="libs/sdklib.jar" sourcepath="/sdklib"/>
- <classpathentry exported="true" kind="lib" path="libs/sdkstats.jar" sourcepath="/sdkstats"/>
- <classpathentry exported="true" kind="lib" path="libs/sdk-common.jar" sourcepath="/sdk-common"/>
- <classpathentry exported="true" kind="lib" path="libs/httpmime-4.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/dvlib.jar" sourcepath="/dvlib"/>
+ <classpathentry exported="true" kind="lib" path="libs/common.jar" sourcepath="/common"/>
+ <classpathentry exported="true" kind="lib" path="libs/commons-codec-1.4.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/commons-compress-1.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/commons-logging-1.1.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/guava-15.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/httpclient-4.1.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/httpcore-4.1.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/kxml2-2.3.0.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/layoutlib-api.jar" sourcepath="/layoutlib-api"/>
+ <classpathentry exported="true" kind="lib" path="libs/sdklib.jar" sourcepath="/sdklib"/>
+ <classpathentry exported="true" kind="lib" path="libs/sdkstats.jar" sourcepath="/sdkstats"/>
+ <classpathentry exported="true" kind="lib" path="libs/sdk-common.jar" sourcepath="/sdk-common"/>
+ <classpathentry exported="true" kind="lib" path="libs/httpmime-4.1.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
diff --git a/eclipse/plugins/com.android.ide.eclipse.base/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.base/META-INF/MANIFEST.MF
index 0cc6348..1f1b2f6 100644
--- a/eclipse/plugins/com.android.ide.eclipse.base/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.base/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Common Android Utilities
Bundle-SymbolicName: com.android.ide.eclipse.base;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Bundle-ActivationPolicy: lazy
@@ -12,7 +12,7 @@ Bundle-ClassPath: .,
libs/commons-codec-1.4.jar,
libs/commons-compress-1.0.jar,
libs/commons-logging-1.1.1.jar,
- libs/guava-13.0.1.jar,
+ libs/guava-15.0.jar,
libs/httpclient-4.1.1.jar,
libs/httpcore-4.1.jar,
libs/httpmime-4.1.jar,
@@ -21,9 +21,8 @@ Bundle-ClassPath: .,
libs/sdklib.jar,
libs/sdkstats.jar,
libs/dvlib.jar,
- libs/sdk-common.jar,
- libs/bcpkix-jdk15on-1.48.jar,
- libs/bcprov-jdk15on-1.48.jar
+ libs/sdk-common.jar
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Export-Package: com.android,
com.android.annotations,
com.android.annotations.concurrency,
@@ -57,6 +56,9 @@ Export-Package: com.android,
com.android.sdklib.internal.repository.updater,
com.android.sdklib.io,
com.android.sdklib.repository,
+ com.android.sdklib.repository.descriptors,
+ com.android.sdklib.repository.local,
+ com.android.sdklib.repository.remote,
com.android.sdklib.util,
com.android.sdkstats,
com.android.util,
@@ -134,4 +136,3 @@ Export-Package: com.android,
org.kxml2.wap.wml,
org.kxml2.wap.wv,
org.xmlpull.v1
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/eclipse/plugins/com.android.ide.eclipse.base/build.properties b/eclipse/plugins/com.android.ide.eclipse.base/build.properties
index 63ed527..d304902 100644
--- a/eclipse/plugins/com.android.ide.eclipse.base/build.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.base/build.properties
@@ -1,8 +1,7 @@
output.. = bin/
bin.includes = .,\
+ libs/,\
META-INF/,\
- plugin.xml,\
- libs/
+ plugin.xml
jars.compile.order = .
source.. = src/
-bin.excludes = libs/.gitignore
diff --git a/eclipse/plugins/com.android.ide.eclipse.base/libs/.gitignore b/eclipse/plugins/com.android.ide.eclipse.base/libs/.gitignore
deleted file mode 100644
index d392f0e..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.base/libs/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.base/pom.xml b/eclipse/plugins/com.android.ide.eclipse.base/pom.xml
new file mode 100644
index 0000000..f8c8ff0
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.base/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.base</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>base</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/.classpath b/eclipse/plugins/com.android.ide.eclipse.ddms/.classpath
index a51b125..d5d21c8 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/.classpath
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry exported="true" kind="lib" path="libs/uiautomatorviewer.jar" sourcepath="/uiautomatorviewer/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="lib" path="libs/jfreechart-1.0.9.jar"/>
- <classpathentry kind="lib" path="libs/jcommon-1.0.12.jar"/>
- <classpathentry exported="true" kind="lib" path="libs/ddmlib.jar" sourcepath="/ddmlib"/>
- <classpathentry exported="true" kind="lib" path="libs/ddmuilib.jar" sourcepath="/ddmuilib"/>
- <classpathentry kind="lib" path="libs/jfreechart-swt-1.0.9.jar"/>
+ <classpathentry kind="lib" path="libs/jfreechart-1.0.9.jar"/>
+ <classpathentry kind="lib" path="libs/jcommon-1.0.12.jar"/>
+ <classpathentry kind="lib" path="libs/jfreechart-swt-1.0.9.jar"/>
+ <classpathentry exported="true" kind="lib" path="libs/ddmlib.jar" sourcepath="/ddmlib"/>
+ <classpathentry exported="true" kind="lib" path="libs/ddmuilib.jar" sourcepath="/ddmuilib"/>
+ <classpathentry exported="true" kind="lib" path="libs/uiautomatorviewer.jar" sourcepath="/uiautomatorviewer/src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.ddms/META-INF/MANIFEST.MF
index e956a16..743a489 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.android.ide.eclipse.ddms;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Activator: com.android.ide.eclipse.ddms.DdmsPlugin
Bundle-Vendor: %Bundle-Vendor
Bundle-Localization: plugin
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/build.properties b/eclipse/plugins/com.android.ide.eclipse.ddms/build.properties
index 6569a9b..3c02154 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/build.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/build.properties
@@ -10,5 +10,4 @@ bin.includes = META-INF/,\
about.ini,\
about.properties,\
plugin.properties
-bin.excludes = libs/.gitignore
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/libs/.gitignore b/eclipse/plugins/com.android.ide.eclipse.ddms/libs/.gitignore
deleted file mode 100644
index d392f0e..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/libs/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/pom.xml b/eclipse/plugins/com.android.ide.eclipse.ddms/pom.xml
new file mode 100644
index 0000000..debf262
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.ddms</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>ddms</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java
index e469dfd..56af601 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/preferences/PreferencePage.java
@@ -18,7 +18,6 @@ package com.android.ide.eclipse.ddms.preferences;
import com.android.ddmlib.DdmPreferences;
import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmuilib.PortFieldEditor;
import com.android.ide.eclipse.base.InstallDetails;
import com.android.ide.eclipse.ddms.DdmsPlugin;
import com.android.ide.eclipse.ddms.i18n.Messages;
@@ -55,8 +54,9 @@ public class PreferencePage extends FieldEditorPreferencePage implements
public void createFieldEditors() {
IntegerFieldEditor ife;
- ife = new PortFieldEditor(PreferenceInitializer.ATTR_DEBUG_PORT_BASE,
+ ife = new IntegerFieldEditor(PreferenceInitializer.ATTR_DEBUG_PORT_BASE,
Messages.PreferencePage_Base_Local_Debugger_Port, getFieldEditorParent());
+ ife.setValidRange(1024, 32767);
addField(ife);
BooleanFieldEditor bfe;
@@ -141,6 +141,7 @@ public class PreferencePage extends FieldEditorPreferencePage implements
} else if (event.getSource().equals(mProfilerBufsize)) {
DdmPreferences.setProfilerBufferSizeMb(mProfilerBufsize.getIntValue());
}
+ super.propertyChange(event);
}
@Override
diff --git a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOptionsDialogV1.java b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOptionsDialogV1.java
index d4b5e5b..b462ada 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOptionsDialogV1.java
+++ b/eclipse/plugins/com.android.ide.eclipse.ddms/src/com/android/ide/eclipse/ddms/systrace/SystraceOptionsDialogV1.java
@@ -413,7 +413,7 @@ public class SystraceOptionsDialogV1 extends TitleAreaDialog implements ISystrac
@Override
public String getTags() {
- return mTag == 0 ? null : Integer.toHexString(mTag);
+ return mTag == 0 ? null : "0x" + Integer.toHexString(mTag);
}
@Override
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/.classpath b/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/.classpath
index b3968a7..2abf483 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/.classpath
@@ -3,6 +3,9 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="/plugin-gldebugger/libs/host-libprotobuf-java-2.3.0-lite.jar"/>
+ <classpathentry kind="lib" path="/plugin-gldebugger/libs/host-libprotobuf-java-2.3.0-lite.jar"/>
+ <classpathentry kind="lib" path="/plugin-gldebugger/libs/liblzf-1.0.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/META-INF/MANIFEST.MF
index fb7ba7f..6ce8d6b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: gldebugger-tests
Bundle-SymbolicName: com.android.ide.eclipse.gldebugger.tests
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.junit4;bundle-version="4.5.0";resolution:=optional,
com.android.ide.eclipse.gldebugger,
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/pom.xml b/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/pom.xml
new file mode 100644
index 0000000..4161d45
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger.tests/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.gldebugger.tests</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>gldebugger.tests</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/.classpath b/eclipse/plugins/com.android.ide.eclipse.gldebugger/.classpath
index 59d5fe5..aaeec62 100755
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/.classpath
@@ -3,9 +3,7 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="libs/host-libprotobuf-java-2.3.0-lite.jar"/>
- <classpathentry kind="lib" path="libs/liblzf.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
+ <classpathentry kind="lib" path="libs/host-libprotobuf-java-2.3.0-lite.jar"/>
+ <classpathentry kind="lib" path="libs/liblzf-1.0.jar" />
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/.gitignore b/eclipse/plugins/com.android.ide.eclipse.gldebugger/.gitignore
deleted file mode 100644
index 2fd4c3b..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-libs/
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.gldebugger/META-INF/MANIFEST.MF
index 0b7852f..c2eb32b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tracer for OpenGL ES
Bundle-SymbolicName: com.android.ide.eclipse.gldebugger;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Activator: com.android.ide.eclipse.gltrace.GlTracePlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
@@ -14,7 +14,7 @@ Require-Bundle: org.eclipse.ui,
com.android.ide.eclipse.base
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: libs/host-libprotobuf-java-2.3.0-lite.jar,
- libs/liblzf.jar,
+ libs/liblzf-1.0.jar,
.
Bundle-Vendor: The Android Open Source Project
Export-Package: com.android.ide.eclipse.gltrace;x-friends:="com.android.ide.eclipse.gldebugger.tests",
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/build.properties b/eclipse/plugins/com.android.ide.eclipse.gldebugger/build.properties
index 3b4a698..4f3d57a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/build.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/build.properties
@@ -3,9 +3,6 @@ output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
+ libs/,\
icons/,\
- lib/host-libprotobuf-java-2.3.0-lite.jar,\
- lib/liblzf.jar,\
- lib/sdklib.jar,\
- entries.in,\
- libs/
+ entries.in,
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/pom.xml b/eclipse/plugins/com.android.ide.eclipse.gldebugger/pom.xml
new file mode 100644
index 0000000..df7d432
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.gldebugger</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>gldebugger</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/DisplayRadix.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/DisplayRadix.java
new file mode 100644
index 0000000..935f4d7
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/DisplayRadix.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.gltrace.state;
+
+public enum DisplayRadix {
+ DECIMAL, HEX
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLBooleanProperty.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLBooleanProperty.java
index 22d8d47..8332b0a 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLBooleanProperty.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLBooleanProperty.java
@@ -30,7 +30,7 @@ public final class GLBooleanProperty extends GLAbstractAtomicProperty {
@Override
public boolean isDefault() {
- return mDefaultValue == mCurrentValue;
+ return mDefaultValue != null & mDefaultValue.equals(mCurrentValue);
}
public void setValue(Boolean newValue) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLIntegerProperty.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLIntegerProperty.java
index 1a71fe2..7374ff0 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLIntegerProperty.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLIntegerProperty.java
@@ -18,8 +18,6 @@ package com.android.ide.eclipse.gltrace.state;
/** Properties that hold an integer value. */
public class GLIntegerProperty extends GLAbstractAtomicProperty {
- public enum DisplayRadix { DECIMAL, HEX };
-
private final Integer mDefaultValue;
private Integer mCurrentValue;
private final DisplayRadix mRadix;
@@ -37,7 +35,7 @@ public class GLIntegerProperty extends GLAbstractAtomicProperty {
@Override
public boolean isDefault() {
- return mCurrentValue == mDefaultValue;
+ return mDefaultValue != null & mDefaultValue.equals(mCurrentValue);
}
public void setValue(Integer newValue) {
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLLongProperty.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLLongProperty.java
new file mode 100644
index 0000000..44c04ec
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLLongProperty.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.ide.eclipse.gltrace.state;
+
+/** Properties that hold a long value. */
+public class GLLongProperty extends GLAbstractAtomicProperty {
+ private final Long mDefaultValue;
+ private Long mCurrentValue;
+ private final DisplayRadix mRadix;
+
+ public GLLongProperty(GLStateType name, Long defaultValue, DisplayRadix radix) {
+ super(name);
+
+ mDefaultValue = mCurrentValue = defaultValue;
+ mRadix = radix;
+ }
+
+ public GLLongProperty(GLStateType name, Long defaultValue) {
+ this(name, defaultValue, DisplayRadix.DECIMAL);
+ }
+
+ @Override
+ public boolean isDefault() {
+ return mDefaultValue != null & mDefaultValue.equals(mCurrentValue);
+ }
+
+ public void setValue(Long newValue) {
+ mCurrentValue = newValue;
+ }
+
+ @Override
+ public String getStringValue() {
+ if (mRadix == DisplayRadix.HEX) {
+ return String.format("0x%08x", Long.valueOf(mCurrentValue));
+ }
+
+ return mCurrentValue.toString();
+ }
+
+ @Override
+ public String toString() {
+ return getType() + "=" + getStringValue(); //$NON-NLS-1$
+ }
+
+ @Override
+ public void setValue(Object value) {
+ if (value instanceof Long) {
+ mCurrentValue = (Long) value;
+ } else {
+ throw new IllegalArgumentException("Attempt to set non-integer value for " //$NON-NLS-1$
+ + getType());
+ }
+ }
+
+ @Override
+ public Object getValue() {
+ return mCurrentValue;
+ }
+}
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLObjectProperty.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLObjectProperty.java
index 84ad6ec..703d4da 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLObjectProperty.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLObjectProperty.java
@@ -34,7 +34,7 @@ public class GLObjectProperty extends GLAbstractAtomicProperty {
@Override
public boolean isDefault() {
- return mDefaultValue == mCurrentValue;
+ return mDefaultValue != null & mDefaultValue.equals(mCurrentValue);
}
@Override
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java
index 1743499..6230586 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/GLState.java
@@ -17,12 +17,12 @@
package com.android.ide.eclipse.gltrace.state;
import com.android.ide.eclipse.gltrace.GLEnum;
-import com.android.ide.eclipse.gltrace.state.GLIntegerProperty.DisplayRadix;
+import com.android.ide.eclipse.gltrace.state.DisplayRadix;
import java.util.Collections;
public class GLState {
- /** # of texture units modelled in the GL State. */
+ /** # of texture units modeled in the GL State. */
public static final int TEXTURE_UNIT_COUNT = 16;
/** # of vertex attributes */
@@ -56,7 +56,8 @@ public class GLState {
stride = new GLIntegerProperty(GLStateType.VERTEX_ATTRIB_ARRAY_STRIDE, 0);
type = new GLEnumProperty(GLStateType.VERTEX_ATTRIB_ARRAY_TYPE, GLEnum.GL_FLOAT);
normalized = new GLBooleanProperty(GLStateType.VERTEX_ATTRIB_ARRAY_NORMALIZED, false);
- pointer = new GLIntegerProperty(GLStateType.VERTEX_ATTRIB_ARRAY_POINTER, 0);
+ pointer = new GLLongProperty(GLStateType.VERTEX_ATTRIB_ARRAY_POINTER, 0L,
+ DisplayRadix.HEX);
IGLProperty perVertexAttribArrayState = new GLCompositeProperty(
GLStateType.VERTEX_ATTRIB_ARRAY_COMPOSITE,
diff --git a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java
index fb9f227..023f84b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java
+++ b/eclipse/plugins/com.android.ide.eclipse.gldebugger/src/com/android/ide/eclipse/gltrace/state/transforms/StateTransformFactory.java
@@ -189,7 +189,13 @@ public class StateTransformFactory {
int type = msg.getArgs(2).getIntValue(0);
boolean normalized = msg.getArgs(3).getBoolValue(0);
int stride = msg.getArgs(4).getIntValue(0);
- int pointer = msg.getArgs(5).getIntValue(0);
+
+ long pointer;
+ if (msg.getArgs(5).getIntValueCount() > 0) {
+ pointer = msg.getArgs(5).getIntValue(0);
+ } else {
+ pointer = msg.getArgs(5).getInt64Value(0);
+ }
List<IStateTransform> transforms = new ArrayList<IStateTransform>();
transforms.add(new PropertyChangeTransform(
@@ -226,7 +232,7 @@ public class StateTransformFactory {
GLStateType.VERTEX_ATTRIB_ARRAY,
Integer.valueOf(index),
GLStateType.VERTEX_ATTRIB_ARRAY_POINTER),
- Integer.valueOf(pointer)));
+ Long.valueOf(pointer)));
return transforms;
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath
index 7dccd1f..7073f20 100644
--- a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.classpath
@@ -3,8 +3,8 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="libs/hierarchyviewer2lib.jar" sourcepath="/hierarchyviewer2lib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
+ <classpathentry kind="lib" path="libs/hierarchyviewer2lib.jar" sourcepath="/hierarchyviewer2lib"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.gitignore b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.gitignore
deleted file mode 100644
index 2fd4c3b..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-libs/
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF
index 7caacf5..2731b60 100644
--- a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Hierarchy Viewer
Bundle-SymbolicName: com.android.ide.eclipse.hierarchyviewer;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Activator: com.android.ide.eclipse.hierarchyviewer.HierarchyViewerPlugin
Bundle-Vendor: The Android Open Source Project
Bundle-Localization: plugin
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/build.properties b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/build.properties
index a8775c5..f7e5d3f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/build.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/build.properties
@@ -8,4 +8,3 @@ bin.includes = META-INF/,\
about.html,\
about.ini,\
about.properties
-bin.excludes = libs/.gitignore
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs/.gitignore b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs/.gitignore
deleted file mode 100644
index f23b948..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/libs/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.jar \ No newline at end of file
diff --git a/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/pom.xml b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/pom.xml
new file mode 100644
index 0000000..1713098
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.hierarchyviewer/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.hierarchyviewer</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>hierarchyviewer</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/.classpath b/eclipse/plugins/com.android.ide.eclipse.monitor/.classpath
index 1be4b68..fa341c0 100644
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/.classpath
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry exported="true" kind="lib" path="libs/sdkuilib.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
+ <classpathentry exported="true" kind="lib" path="libs/sdkuilib.jar"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.monitor/META-INF/MANIFEST.MF
index 689da94..6d492f1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-SymbolicName: com.android.ide.eclipse.monitor;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Activator: com.android.ide.eclipse.monitor.MonitorPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/build.properties b/eclipse/plugins/com.android.ide.eclipse.monitor/build.properties
index a2a2a99..643fe5e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/build.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/build.properties
@@ -3,9 +3,8 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
- libs/,\
plugin_customization.ini,\
plugin.properties,\
images/,\
- splash.bmp,\
- libs/sdkuilib.jar
+ libs/,\
+ splash.bmp
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/libs/.gitignore b/eclipse/plugins/com.android.ide.eclipse.monitor/libs/.gitignore
deleted file mode 100644
index d392f0e..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/libs/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/monitor.launch b/eclipse/plugins/com.android.ide.eclipse.monitor/monitor.launch
new file mode 100644
index 0000000..f56a37d
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/monitor.launch
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.pde.ui.RuntimeWorkbench">
+<booleanAttribute key="append.args" value="true"/>
+<booleanAttribute key="askclear" value="true"/>
+<booleanAttribute key="automaticAdd" value="true"/>
+<booleanAttribute key="automaticValidate" value="false"/>
+<stringAttribute key="bootstrap" value=""/>
+<stringAttribute key="checked" value="[NONE]"/>
+<booleanAttribute key="clearConfig" value="false"/>
+<booleanAttribute key="clearws" value="false"/>
+<booleanAttribute key="clearwslog" value="false"/>
+<stringAttribute key="configLocation" value="${workspace_loc}/.metadata/.plugins/org.eclipse.pde.core/monitor"/>
+<booleanAttribute key="default" value="false"/>
+<stringAttribute key="deselected_workspace_plugins" value="com.android.ide.eclipse.adt,com.android.ide.eclipse.adt.package,com.android.ide.eclipse.gldebugger.tests,overlay.com.android.ide.eclipse.adt.overlay"/>
+<booleanAttribute key="includeOptional" value="true"/>
+<stringAttribute key="location" value="${workspace_loc}/../runtime-monitor-idea133-ksr2"/>
+<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -data @noDefault"/>
+<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
+<stringAttribute key="pde.version" value="3.3"/>
+<stringAttribute key="product" value="com.android.ide.eclipse.monitor.product"/>
+<stringAttribute key="selected_target_plugins" value="com.android.tools.common@default:default,com.android.tools.ddms.ddmlib@default:default,com.android.tools.ddms.ddmuilib@default:default,com.android.tools.dvlib@default:default,com.android.tools.external.liblzf@default:default,com.android.tools.external.libprotobuf-java-lite@default:default,com.android.tools.hierarchyviewer2lib@default:default,com.android.tools.layoutlib.api@default:default,com.android.tools.sdklib@default:default,com.android.tools.sdkstats@default:default,com.android.tools.sdkuilib@default:default,com.android.tools.swtmenubar@default:default,com.android.tools.traceview@default:default,com.android.tools.uiautomatorviewer@default:default,com.google.guava@default:default,com.ibm.icu@default:default,javax.annotation@default:default,javax.inject@default:default,javax.servlet@default:default,javax.xml@default:default,jfree.chart-swt@default:default,jfree.chart@default:default,jfree.jcommon@default:default,net.sf.kxml.2@default:default,org.apache.batik.css@default:default,org.apache.batik.util.gui@default:default,org.apache.batik.util@default:default,org.apache.commons.codec*1.4.0.v201209201156@default:default,org.apache.commons.compress@default:default,org.apache.commons.logging*1.1.1.v201101211721@default:default,org.apache.httpcomponents.httpclient*4.1.3.v201209201135@default:default,org.apache.httpcomponents.httpcore*4.1.4.v201203221030@default:default,org.eclipse.ant.core@default:default,org.eclipse.compare.core@default:default,org.eclipse.core.commands@default:default,org.eclipse.core.contenttype@default:default,org.eclipse.core.databinding.observable@default:default,org.eclipse.core.databinding.property@default:default,org.eclipse.core.databinding@default:default,org.eclipse.core.expressions@default:default,org.eclipse.core.filesystem.linux.x86_64@default:false,org.eclipse.core.filesystem@default:default,org.eclipse.core.jobs@default:default,org.eclipse.core.resources@default:default,org.eclipse.core.runtime.compatibility.registry@default:false,org.eclipse.core.runtime@default:true,org.eclipse.core.variables@default:default,org.eclipse.e4.core.commands@default:default,org.eclipse.e4.core.contexts@default:default,org.eclipse.e4.core.di.extensions@default:default,org.eclipse.e4.core.di@default:default,org.eclipse.e4.core.services@default:default,org.eclipse.e4.ui.bindings@default:default,org.eclipse.e4.ui.css.core@default:default,org.eclipse.e4.ui.css.swt.theme@default:default,org.eclipse.e4.ui.css.swt@default:default,org.eclipse.e4.ui.di@default:default,org.eclipse.e4.ui.model.workbench@default:default,org.eclipse.e4.ui.services@default:default,org.eclipse.e4.ui.widgets@default:default,org.eclipse.e4.ui.workbench.addons.swt@default:default,org.eclipse.e4.ui.workbench.renderers.swt@default:default,org.eclipse.e4.ui.workbench.swt@default:default,org.eclipse.e4.ui.workbench3@default:default,org.eclipse.e4.ui.workbench@default:default,org.eclipse.emf.common@default:default,org.eclipse.emf.ecore.change@default:default,org.eclipse.emf.ecore.xmi@default:default,org.eclipse.emf.ecore@default:default,org.eclipse.equinox.app@default:default,org.eclipse.equinox.bidi@default:default,org.eclipse.equinox.common@2:true,org.eclipse.equinox.ds@1:true,org.eclipse.equinox.event@default:default,org.eclipse.equinox.p2.core@default:default,org.eclipse.equinox.p2.engine@default:default,org.eclipse.equinox.p2.metadata.repository@default:default,org.eclipse.equinox.p2.metadata@default:default,org.eclipse.equinox.p2.repository@default:default,org.eclipse.equinox.preferences@default:default,org.eclipse.equinox.registry@default:default,org.eclipse.equinox.security@default:default,org.eclipse.equinox.util@default:default,org.eclipse.help@default:default,org.eclipse.jface.databinding@default:default,org.eclipse.jface.text@default:default,org.eclipse.jface@default:default,org.eclipse.osgi.services@default:default,org.eclipse.osgi@-1:true,org.eclipse.swt.gtk.linux.x86_64@default:false,org.eclipse.swt@default:default,org.eclipse.text@default:default,org.eclipse.ui.console@default:default,org.eclipse.ui.forms@default:default,org.eclipse.ui.ide@default:default,org.eclipse.ui.views@default:default,org.eclipse.ui.workbench.texteditor@default:default,org.eclipse.ui.workbench@default:default,org.eclipse.ui@default:default,org.w3c.css.sac@default:default,org.w3c.dom.smil@default:default,org.w3c.dom.svg@default:default"/>
+<stringAttribute key="selected_workspace_plugins" value="com.android.ide.eclipse.base@default:default,com.android.ide.eclipse.ddms@default:default,com.android.ide.eclipse.gldebugger@default:default,com.android.ide.eclipse.hierarchyviewer@default:default,com.android.ide.eclipse.monitor@default:default,com.android.ide.eclipse.ndk@default:default,com.android.ide.eclipse.pdt@default:default,com.android.ide.eclipse.tests@default:false,com.android.ide.eclipse.traceview@default:default"/>
+<booleanAttribute key="show_selected_only" value="false"/>
+<stringAttribute key="templateConfig" value="${target_home}/configuration/config.ini"/>
+<booleanAttribute key="tracing" value="false"/>
+<booleanAttribute key="useCustomFeatures" value="false"/>
+<booleanAttribute key="useDefaultConfig" value="true"/>
+<booleanAttribute key="useDefaultConfigArea" value="true"/>
+<booleanAttribute key="useProduct" value="true"/>
+</launchConfiguration>
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/monitor.product b/eclipse/plugins/com.android.ide.eclipse.monitor/monitor.product
deleted file mode 100644
index 03376e4..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/monitor.product
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?pde version="3.5"?>
-
-<product name="monitor" uid="com.android.ide.eclipse.monitor.product.config" id="com.android.ide.eclipse.monitor.product" application="com.android.ide.eclipse.monitor.Application" version="22.3.0" useFeatures="false" includeLaunchers="true">
-
-
- <configIni use="default">
- </configIni>
-
- <launcherArgs>
- <programArgs>-data @noDefault</programArgs>
- <vmArgsMac>-XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts</vmArgsMac>
- </launcherArgs>
-
- <windowImages/>
-
- <splash
- location="com.android.ide.eclipse.monitor" />
- <launcher>
- <solaris/>
- <win useIco="false">
- <bmp/>
- </win>
- </launcher>
-
- <vm>
- </vm>
-
- <plugins>
- <plugin id="com.android.ide.eclipse.base"/>
- <plugin id="com.android.ide.eclipse.ddms"/>
- <plugin id="com.android.ide.eclipse.gldebugger"/>
- <plugin id="com.android.ide.eclipse.hierarchyviewer"/>
- <plugin id="com.android.ide.eclipse.monitor"/>
- <plugin id="com.android.ide.eclipse.traceview"/>
- <plugin id="com.ibm.icu"/>
- <plugin id="org.eclipse.compare.core"/>
- <plugin id="org.eclipse.core.commands"/>
- <plugin id="org.eclipse.core.contenttype"/>
- <plugin id="org.eclipse.core.databinding"/>
- <plugin id="org.eclipse.core.databinding.observable"/>
- <plugin id="org.eclipse.core.databinding.property"/>
- <plugin id="org.eclipse.core.expressions"/>
- <plugin id="org.eclipse.core.filesystem"/>
- <plugin id="org.eclipse.core.filesystem.linux.x86_64" fragment="true"/>
- <plugin id="org.eclipse.core.jobs"/>
- <plugin id="org.eclipse.core.resources"/>
- <plugin id="org.eclipse.core.runtime"/>
- <plugin id="org.eclipse.core.runtime.compatibility.registry" fragment="true"/>
- <plugin id="org.eclipse.core.variables"/>
- <plugin id="org.eclipse.ecf"/>
- <plugin id="org.eclipse.ecf.filetransfer"/>
- <plugin id="org.eclipse.ecf.identity"/>
- <plugin id="org.eclipse.ecf.provider.filetransfer"/>
- <plugin id="org.eclipse.ecf.provider.filetransfer.ssl" fragment="true"/>
- <plugin id="org.eclipse.ecf.ssl" fragment="true"/>
- <plugin id="org.eclipse.equinox.app"/>
- <plugin id="org.eclipse.equinox.common"/>
- <plugin id="org.eclipse.equinox.p2.core"/>
- <plugin id="org.eclipse.equinox.p2.engine"/>
- <plugin id="org.eclipse.equinox.p2.metadata"/>
- <plugin id="org.eclipse.equinox.p2.metadata.repository"/>
- <plugin id="org.eclipse.equinox.p2.repository"/>
- <plugin id="org.eclipse.equinox.preferences"/>
- <plugin id="org.eclipse.equinox.registry"/>
- <plugin id="org.eclipse.equinox.security"/>
- <plugin id="org.eclipse.help"/>
- <plugin id="org.eclipse.jface"/>
- <plugin id="org.eclipse.jface.databinding"/>
- <plugin id="org.eclipse.jface.text"/>
- <plugin id="org.eclipse.osgi"/>
- <plugin id="org.eclipse.osgi.services"/>
- <plugin id="org.eclipse.swt"/>
- <plugin id="org.eclipse.swt.cocoa.macosx.x86_64" fragment="true"/>
- <plugin id="org.eclipse.swt.gtk.linux.x86" fragment="true"/>
- <plugin id="org.eclipse.swt.gtk.linux.x86_64" fragment="true"/>
- <plugin id="org.eclipse.swt.win32.win32.x86" fragment="true"/>
- <plugin id="org.eclipse.swt.win32.win32.x86_64" fragment="true"/>
- <plugin id="org.eclipse.text"/>
- <plugin id="org.eclipse.ui"/>
- <plugin id="org.eclipse.ui.cocoa"/>
- <plugin id="org.eclipse.ui.console"/>
- <plugin id="org.eclipse.ui.ide"/>
- <plugin id="org.eclipse.ui.workbench"/>
- <plugin id="org.eclipse.ui.workbench.texteditor"/>
- </plugins>
-
-
-</product>
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.properties b/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.properties
index 4191caf..48a785f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.properties
@@ -4,5 +4,5 @@ Bundle-Vendor = The Android Open Source Project
Bundle-Name = Monitor
aboutText = \n\
Android Device Monitor\n\
-Version: 22.3.0 \n\
+Version: 23.0.2 \n\
Copyright 2012, The Android Open Source Project \n\
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml b/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml
index 7a09eda..32c44d0 100644
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/plugin.xml
@@ -117,4 +117,16 @@
</action>
</actionSet>
</extension>
+ <extension
+ id="product"
+ point="org.eclipse.core.runtime.products">
+ <product
+ application="com.android.ide.eclipse.monitor.Application"
+ name="monitor">
+ <property
+ name="appName"
+ value="monitor">
+ </property>
+ </product>
+ </extension>
</plugin>
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/pom.xml b/eclipse/plugins/com.android.ide.eclipse.monitor/pom.xml
new file mode 100644
index 0000000..e076411
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.monitor</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>monitor</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorWorkbenchWindowAdvisor.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorWorkbenchWindowAdvisor.java
index 461c0fd..137d3b1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorWorkbenchWindowAdvisor.java
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/MonitorWorkbenchWindowAdvisor.java
@@ -36,6 +36,6 @@ public class MonitorWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setShowStatusLine(true);
configurer.setShowPerspectiveBar(true);
- configurer.setTitle("Android Debug Monitor");
+ configurer.setTitle("Android Device Monitor");
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java
index 64129d2..bd8ef60 100644
--- a/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java
+++ b/eclipse/plugins/com.android.ide.eclipse.monitor/src/com/android/ide/eclipse/monitor/SdkToolsLocator.java
@@ -61,7 +61,7 @@ public class SdkToolsLocator {
}
public String getHprofConvLocation() {
- return new File(getSdkToolsFolder(), FN_HPROF_CONV).getAbsolutePath();
+ return new File(getSdkPlatformToolsFolder(), FN_HPROF_CONV).getAbsolutePath();
}
private String getSdkToolsFolder() {
diff --git a/eclipse/plugins/com.android.ide.eclipse.ndk/.classpath b/eclipse/plugins/com.android.ide.eclipse.ndk/.classpath
index 58a22d6..36a1bda 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ndk/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.ndk/.classpath
@@ -3,8 +3,8 @@
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
<classpathentry kind="output" path="bin"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
+ <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.ndk/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.ndk/META-INF/MANIFEST.MF
index 10e3367..c499691 100644
--- a/eclipse/plugins/com.android.ide.eclipse.ndk/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.ndk/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: ADT CDT Integration
Bundle-SymbolicName: com.android.ide.eclipse.ndk;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Activator: com.android.ide.eclipse.ndk.internal.Activator
Bundle-Vendor: The Android Open Source Project
Require-Bundle: org.eclipse.core.runtime,
diff --git a/eclipse/plugins/com.android.ide.eclipse.ndk/pom.xml b/eclipse/plugins/com.android.ide.eclipse.ndk/pom.xml
new file mode 100644
index 0000000..a0de7c8
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.ndk/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.ndk</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>ndk</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF
index d2c7fa2..077dd2c 100644
--- a/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.pdt/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Pdt
Bundle-SymbolicName: com.android.ide.eclipse.pdt;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Vendor: The Android Open Source Project
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath
index 247c1c2..83bfa23 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/.classpath
@@ -4,21 +4,21 @@
<classpathentry kind="src" path="unittests"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="lib" path="kxml2-2.3.0.jar"/>
- <classpathentry kind="lib" path="easymock.jar"/>
- <classpathentry kind="lib" path="testutils.jar"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/ninepatch.jar" sourcepath="/ninepatch"/>
- <classpathentry kind="lib" path="/plugin-base/libs/sdklib.jar" sourcepath="/SdkLib"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/sdkuilib.jar" sourcepath="/SdkUiLib"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/rule-api.jar" sourcepath="/rule-api"/>
- <classpathentry kind="lib" path="/plugin-base/libs/common.jar" sourcepath="/common"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/lint-api.jar" sourcepath="/lint-api"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/lint-checks.jar" sourcepath="/lint-checks"/>
- <classpathentry kind="lib" path="/plugin-base/libs/sdk-common.jar"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/lombok-ast-0.2.jar"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/asm-4.0.jar"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/asm-analysis-4.0.jar"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/asm-tree-4.0.jar"/>
- <classpathentry kind="lib" path="/plugin-adt/libs/manifest-merger.jar" sourcepath="/manifest-merger"/>
<classpathentry kind="output" path="bin"/>
+ <classpathentry kind="lib" path="libs/kxml2-2.3.0.jar"/>
+ <classpathentry kind="lib" path="libs/easymock.jar"/>
+ <classpathentry kind="lib" path="libs/testutils.jar"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/ninepatch.jar" sourcepath="/ninepatch"/>
+ <classpathentry kind="lib" path="/plugin-base/libs/sdklib.jar" sourcepath="/SdkLib"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/sdkuilib.jar" sourcepath="/SdkUiLib"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/rule-api.jar" sourcepath="/rule-api"/>
+ <classpathentry kind="lib" path="/plugin-base/libs/common.jar" sourcepath="/common"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/lint-api.jar" sourcepath="/lint-api"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/lint-checks.jar" sourcepath="/lint-checks"/>
+ <classpathentry kind="lib" path="/plugin-base/libs/sdk-common.jar"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/lombok-ast-0.2.2.jar"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/asm-4.0.jar"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/asm-analysis-4.0.jar"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/asm-tree-4.0.jar"/>
+ <classpathentry kind="lib" path="/plugin-adt/libs/manifest-merger.jar" sourcepath="/manifest-merger"/>
</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/.gitignore b/eclipse/plugins/com.android.ide.eclipse.tests/.gitignore
deleted file mode 100644
index d392f0e..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.tests/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF
index 4e9382c..462c9a1 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/META-INF/MANIFEST.MF
@@ -2,15 +2,14 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Android Plugin Tests
Bundle-SymbolicName: com.android.ide.eclipse.tests
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Vendor: The Android Open Source Project
Fragment-Host: com.android.ide.eclipse.adt;bundle-version="21.0.0"
Require-Bundle: org.junit
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ClassPath: kxml2-2.3.0.jar,
- .,
- testutils.jar,
- layoutlib.jar,
- lint-api.jar,
- lint-checks.jar,
- easymock.jar
+Bundle-ClassPath: .,
+ libs/kxml2-2.3.0.jar,
+ libs/testutils.jar,
+ libs/lint-api.jar,
+ libs/lint-checks.jar,
+ libs/easymock.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/build.properties b/eclipse/plugins/com.android.ide.eclipse.tests/build.properties
index e8daa3e..2a82227 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/build.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/build.properties
@@ -15,4 +15,3 @@ bin.includes = META-INF/,\
unittests/com/android/layoutlib/testdata/,\
unittests/com/android/ide/eclipse/testdata/,\
easymock.jar
-
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/pom.xml b/eclipse/plugins/com.android.ide.eclipse.tests/pom.xml
new file mode 100644
index 0000000..18988b8
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.tests</artifactId>
+ <packaging>eclipse-test-plugin</packaging>
+ <name>tests</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java
index e9010c4..43f9d68 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/editors/manifest/ManifestInfoTest.java
@@ -19,17 +19,21 @@ import static com.android.resources.ScreenSize.LARGE;
import static com.android.resources.ScreenSize.NORMAL;
import static com.android.resources.ScreenSize.XLARGE;
+import com.android.annotations.NonNull;
import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjectTest;
+import com.android.ide.eclipse.adt.internal.editors.manifest.ManifestInfo.ActivityAttributes;
import com.android.ide.eclipse.adt.internal.resources.ResourceHelper;
import com.android.sdklib.AndroidVersion;
import com.android.sdklib.BuildToolInfo;
import com.android.sdklib.IAndroidTarget;
import com.android.sdklib.ISystemImage;
+import com.android.sdklib.repository.descriptors.IdDisplay;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.NullProgressMonitor;
import java.io.ByteArrayInputStream;
+import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -48,7 +52,7 @@ public class ManifestInfoTest extends AdtProjectTest {
" package='com.android.unittest'>\n" +
" <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='4'/>\n" +
"</manifest>\n");
- Map<String, String> map = info.getActivityThemes();
+ Map<String, ActivityAttributes> map = info.getActivityAttributesMap();
assertEquals(map.toString(), 0, map.size());
assertEquals("com.android.unittest", info.getPackage());
assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, NORMAL)));
@@ -62,7 +66,7 @@ public class ManifestInfoTest extends AdtProjectTest {
" package='com.android.unittest'>\n" +
" <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='11'/>\n" +
"</manifest>\n");
- Map<String, String> map = info.getActivityThemes();
+ Map<String, ActivityAttributes> map = info.getActivityAttributesMap();
assertEquals(map.toString(), 0, map.size());
assertEquals("com.android.unittest", info.getPackage());
assertEquals("Theme.Holo", ResourceHelper.styleToTheme(info.getDefaultTheme(null,
@@ -76,7 +80,7 @@ public class ManifestInfoTest extends AdtProjectTest {
" package='com.android.unittest'>\n" +
" <uses-sdk android:minSdkVersion='11'/>\n" +
"</manifest>\n");
- Map<String, String> map = info.getActivityThemes();
+ Map<String, ActivityAttributes> map = info.getActivityAttributesMap();
assertEquals(map.toString(), 0, map.size());
assertEquals("com.android.unittest", info.getPackage());
assertEquals("Theme.Holo", ResourceHelper.styleToTheme(info.getDefaultTheme(null,
@@ -108,11 +112,11 @@ public class ManifestInfoTest extends AdtProjectTest {
assertEquals("com.android.unittest", info.getPackage());
assertEquals("Theme", ResourceHelper.styleToTheme(info.getDefaultTheme(null, XLARGE)));
- Map<String, String> map = info.getActivityThemes();
- assertEquals(map.toString(), 1, map.size());
- assertNull(map.get("com.android.unittest.prefs.PrefsActivity"));
+ Map<String, ActivityAttributes> map = info.getActivityAttributesMap();
+ assertEquals(map.toString(), 2, map.size());
+ assertNull(map.get("com.android.unittest.prefs.PrefsActivity").getTheme());
assertEquals("@android:style/Theme.Dialog",
- map.get("com.android.unittest.app.IntroActivity"));
+ map.get("com.android.unittest.app.IntroActivity").getTheme());
}
public void testGetActivityThemes5() throws Exception {
@@ -143,11 +147,11 @@ public class ManifestInfoTest extends AdtProjectTest {
assertEquals("NoBackground", ResourceHelper.styleToTheme(info.getDefaultTheme(null,
NORMAL)));
- Map<String, String> map = info.getActivityThemes();
- assertEquals(map.toString(), 1, map.size());
- assertNull(map.get("com.android.unittest.prefs.PrefsActivity"));
+ Map<String, ActivityAttributes> map = info.getActivityAttributesMap();
+ assertEquals(map.toString(), 2, map.size());
+ assertNull(map.get("com.android.unittest.prefs.PrefsActivity").getTheme());
assertEquals("@android:style/Theme.Dialog",
- map.get("com.android.unittest.app.IntroActivity"));
+ map.get("com.android.unittest.app.IntroActivity").getTheme());
}
public void testGetActivityThemes6() throws Exception {
@@ -158,7 +162,7 @@ public class ManifestInfoTest extends AdtProjectTest {
" package='com.android.unittest'>\n" +
" <uses-sdk android:minSdkVersion='3' android:targetSdkVersion='11'/>\n" +
"</manifest>\n");
- Map<String, String> map = info.getActivityThemes();
+ Map<String, ActivityAttributes> map = info.getActivityAttributesMap();
assertEquals(map.toString(), 0, map.size());
assertEquals("com.android.unittest", info.getPackage());
assertEquals("Theme.Holo", ResourceHelper.styleToTheme(info.getDefaultTheme(null,
@@ -180,7 +184,7 @@ public class ManifestInfoTest extends AdtProjectTest {
" </application>\n" +
"" +
"</manifest>\n");
- Map<String, String> map = info.getActivityThemes();
+ Map<String, ActivityAttributes> map = info.getActivityAttributesMap();
assertEquals(map.toString(), 0, map.size());
assertEquals("com.android.unittest", info.getPackage());
@@ -197,7 +201,7 @@ public class ManifestInfoTest extends AdtProjectTest {
" </application>\n" +
"" +
"</manifest>\n");
- Map<String, String> map = info.getActivityThemes();
+ Map<String, ActivityAttributes> map = info.getActivityAttributesMap();
assertEquals(map.toString(), 0, map.size());
assertEquals("com.android.unittest", info.getPackage());
@@ -271,7 +275,7 @@ public class ManifestInfoTest extends AdtProjectTest {
}
@Override
- public String getDefaultSkin() {
+ public File getDefaultSkin() {
return null;
}
@@ -286,7 +290,7 @@ public class ManifestInfoTest extends AdtProjectTest {
}
@Override
- public ISystemImage getSystemImage(String abiType) {
+ public ISystemImage getSystemImage(IdDisplay tag, String abiType) {
return null;
}
@@ -321,6 +325,12 @@ public class ManifestInfoTest extends AdtProjectTest {
}
@Override
+ public File getFile(int pathId) {
+ return null;
+ }
+
+
+ @Override
public String[] getPlatformLibraries() {
return null;
}
@@ -351,7 +361,7 @@ public class ManifestInfoTest extends AdtProjectTest {
}
@Override
- public String[] getSkins() {
+ public File[] getSkins() {
return null;
}
@@ -401,6 +411,7 @@ public class ManifestInfoTest extends AdtProjectTest {
}
@Override
+ @NonNull
public List<String> getBootClasspath() {
return new ArrayList<String>();
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java
index 088ece7..7fd042e 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/lint/ProjectLintConfigurationTest.java
@@ -21,9 +21,9 @@ import com.android.ide.eclipse.adt.internal.editors.layout.refactoring.AdtProjec
import com.android.tools.lint.checks.DuplicateIdDetector;
import com.android.tools.lint.checks.UnusedResourceDetector;
import com.android.tools.lint.client.api.Configuration;
-import com.android.tools.lint.client.api.IDomParser;
-import com.android.tools.lint.client.api.IJavaParser;
+import com.android.tools.lint.client.api.JavaParser;
import com.android.tools.lint.client.api.LintClient;
+import com.android.tools.lint.client.api.XmlParser;
import com.android.tools.lint.detector.api.Context;
import com.android.tools.lint.detector.api.Issue;
import com.android.tools.lint.detector.api.Location;
@@ -200,7 +200,7 @@ public class ProjectLintConfigurationTest extends AdtProjectTest {
}
@Override
- public IDomParser getDomParser() {
+ public XmlParser getXmlParser() {
return null;
}
@@ -210,7 +210,7 @@ public class ProjectLintConfigurationTest extends AdtProjectTest {
}
@Override
- public IJavaParser getJavaParser() {
+ public JavaParser getJavaParser(@Nullable Project project) {
return null;
}
}
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandlerTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandlerTest.java
index 48681d0..e5fb3a3 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandlerTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/internal/wizards/templates/TemplateHandlerTest.java
@@ -32,18 +32,18 @@ import com.android.ide.eclipse.adt.internal.preferences.AdtPrefs;
import com.android.ide.eclipse.adt.internal.sdk.Sdk;
import com.android.ide.eclipse.tests.SdkLoadingTestCase;
import com.android.sdklib.IAndroidTarget;
-import com.android.sdklib.util.GrabProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.IProcessOutput;
-import com.android.sdklib.util.GrabProcessOutput.Wait;
+import com.android.utils.GrabProcessOutput;
+import com.android.utils.GrabProcessOutput.IProcessOutput;
+import com.android.utils.GrabProcessOutput.Wait;
import com.android.tools.lint.checks.BuiltinIssueRegistry;
-import com.android.tools.lint.checks.ManifestOrderDetector;
+import com.android.tools.lint.checks.ManifestDetector;
import com.android.tools.lint.checks.SecurityDetector;
import com.android.tools.lint.client.api.Configuration;
import com.android.tools.lint.client.api.DefaultConfiguration;
-import com.android.tools.lint.client.api.IDomParser;
-import com.android.tools.lint.client.api.IJavaParser;
+import com.android.tools.lint.client.api.JavaParser;
import com.android.tools.lint.client.api.LintClient;
import com.android.tools.lint.client.api.LintDriver;
+import com.android.tools.lint.client.api.XmlParser;
import com.android.tools.lint.detector.api.Category;
import com.android.tools.lint.detector.api.Context;
import com.android.tools.lint.detector.api.Issue;
@@ -783,7 +783,7 @@ public class TemplateHandlerTest extends SdkLoadingTestCase {
return false;
}
- if (issue == ManifestOrderDetector.TARGET_NEWER) {
+ if (issue == ManifestDetector.TARGET_NEWER) {
// Don't complain about targetSdk < latest: we're deliberately
// testing that (to make sure templates compile etc in compat
// mode)
@@ -831,15 +831,13 @@ public class TemplateHandlerTest extends SdkLoadingTestCase {
@Override
@Nullable
- public IJavaParser getJavaParser() {
- return new EclipseLintClient(null, null, null, false).getJavaParser();
+ public JavaParser getJavaParser(@Nullable Project project) {
+ return new EclipseLintClient(null, null, null, false).getJavaParser(project);
}
@Override
- @Nullable
- public IDomParser getDomParser() {
- //return new LintCliXmlParser();
- return new EclipseLintClient(null, null, null, false).getDomParser();
+ public XmlParser getXmlParser() {
+ return new EclipseLintClient(null, null, null, false).getXmlParser();
}
});
File projectDir = AdtUtils.getAbsolutePath(project).toFile();
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java
index 8b46f87..d6b401b 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/tests/functests/layoutRendering/ApiDemosRenderingTest.java
@@ -18,6 +18,7 @@ package com.android.ide.eclipse.tests.functests.layoutRendering;
import com.android.SdkConstants;
import com.android.ide.common.rendering.LayoutLibrary;
+import com.android.ide.common.rendering.api.ActionBarCallback;
import com.android.ide.common.rendering.api.AdapterBinding;
import com.android.ide.common.rendering.api.HardwareConfig;
import com.android.ide.common.rendering.api.ILayoutPullParser;
@@ -164,6 +165,11 @@ public class ApiDemosRenderingTest extends SdkLoadingTestCase {
public ILayoutPullParser getParser(ResourceValue layoutResource) {
return null;
}
+
+ @Override
+ public ActionBarCallback getActionBarCallback() {
+ return new ActionBarCallback();
+ }
}
public void testApiDemos() throws IOException, XmlPullParserException {
diff --git a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationTest.java b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationTest.java
index d4062ab..2e02509 100644
--- a/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationTest.java
+++ b/eclipse/plugins/com.android.ide.eclipse.tests/unittests/com/android/ide/eclipse/adt/internal/editors/layout/configuration/ConfigurationTest.java
@@ -27,6 +27,7 @@ import com.android.sdklib.devices.Screen;
import com.android.utils.StdLogger;
import java.lang.reflect.Constructor;
+import java.util.EnumSet;
import java.util.List;
import junit.framework.TestCase;
@@ -52,7 +53,7 @@ public class ConfigurationTest extends TestCase {
DeviceManager deviceManager = DeviceManager.createInstance(
null /*osSdkPath*/,
new StdLogger(StdLogger.Level.VERBOSE));
- List<Device> devices = deviceManager.getDevices(DeviceManager.DEFAULT_DEVICES);
+ List<Device> devices = deviceManager.getDevices(DeviceManager.DeviceFilter.DEFAULT);
assertNotNull(devices);
assertTrue(devices.size() > 0);
configuration.setDevice(devices.get(0), false);
@@ -112,7 +113,7 @@ public class ConfigurationTest extends TestCase {
DeviceManager deviceManager = DeviceManager.createInstance(
null /*osSdkPath*/,
new StdLogger(StdLogger.Level.VERBOSE));
- List<Device> devices = deviceManager.getDevices(DeviceManager.DEFAULT_DEVICES);
+ List<Device> devices = deviceManager.getDevices(DeviceManager.DeviceFilter.DEFAULT);
assertNotNull(devices);
assertTrue(devices.size() > 0);
configuration.setDevice(devices.get(0), false);
diff --git a/eclipse/plugins/com.android.ide.eclipse.traceview/.classpath b/eclipse/plugins/com.android.ide.eclipse.traceview/.classpath
index 176babf..3083795 100644
--- a/eclipse/plugins/com.android.ide.eclipse.traceview/.classpath
+++ b/eclipse/plugins/com.android.ide.eclipse.traceview/.classpath
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="lib" path="libs/traceview.jar" sourcepath="/traceview"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="lib" path="libs/traceview.jar" sourcepath="/traceview"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF b/eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF
index 4686211..02847a9 100644
--- a/eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF
+++ b/eclipse/plugins/com.android.ide.eclipse.traceview/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Traceview
Bundle-SymbolicName: com.android.ide.eclipse.traceview;singleton:=true
-Bundle-Version: 22.3.0.qualifier
+Bundle-Version: 23.0.2.qualifier
Bundle-Activator: com.android.ide.eclipse.traceview.TraceviewPlugin
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
diff --git a/eclipse/plugins/com.android.ide.eclipse.traceview/build.properties b/eclipse/plugins/com.android.ide.eclipse.traceview/build.properties
index f529710..4895f9f 100644
--- a/eclipse/plugins/com.android.ide.eclipse.traceview/build.properties
+++ b/eclipse/plugins/com.android.ide.eclipse.traceview/build.properties
@@ -2,8 +2,8 @@ source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
+ libs/,\
plugin.xml,\
- libs/traceview.jar,\
icons/,\
about.ini,\
about.properties
diff --git a/eclipse/plugins/com.android.ide.eclipse.traceview/libs/.gitignore b/eclipse/plugins/com.android.ide.eclipse.traceview/libs/.gitignore
deleted file mode 100644
index d392f0e..0000000
--- a/eclipse/plugins/com.android.ide.eclipse.traceview/libs/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-*.jar
diff --git a/eclipse/plugins/com.android.ide.eclipse.traceview/pom.xml b/eclipse/plugins/com.android.ide.eclipse.traceview/pom.xml
new file mode 100644
index 0000000..e61501a
--- /dev/null
+++ b/eclipse/plugins/com.android.ide.eclipse.traceview/pom.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <version>23.0.2-SNAPSHOT</version>
+ <artifactId>com.android.ide.eclipse.traceview</artifactId>
+ <packaging>eclipse-plugin</packaging>
+ <name>traceview</name>
+
+ <parent>
+ <relativePath>../../pom.xml</relativePath>
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </parent>
+</project>
diff --git a/eclipse/pom.xml b/eclipse/pom.xml
new file mode 100644
index 0000000..4001d44
--- /dev/null
+++ b/eclipse/pom.xml
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ This script builds Eclipse plugins, and the monitor & adt-bundle products.
+
+ To run this script:
+ - Have Maven3 in your path
+ - $ mvn package -DANDROID_OUT=/path/to/android/out
+
+ See http://wiki.eclipse.org/Tycho/Reference_Card#Examplary_parent_POM
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>adt.group</groupId>
+ <artifactId>parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+ <name>ADT</name>
+
+ <!-- Common properties used in all modules -->
+ <properties>
+ <tycho-version>0.20.0</tycho-version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <!--
+ The following profiles allow us to change the build environment easily. The first profile uses
+ the target platform as present inside the Android tree's out folder, while the other profile
+ uses the target platform directly from eclipse.org.
+
+ The first profile is automatically activated if the ANDROID_OUT system property is set:
+ $ mvn clean install -DANDROID_OUT=/path/to/android/out
+ The other profile can be tested out by:
+ $ mvn clean install -Pexternal-p2-repositories
+ -->
+ <profiles>
+ <profile>
+ <id>mirrored-p2-repositories</id>
+ <activation>
+ <property>
+ <name>ANDROID_OUT</name>
+ </property>
+ </activation>
+ <properties>
+ <!-- The target platform should have been created under the Android ANDROID_OUT folder -->
+ <target-platform.base.url>file://${ANDROID_OUT}/host/maven/target</target-platform.base.url>
+ </properties>
+ <repositories>
+ <repository>
+ <id>kepler</id>
+ <url>${target-platform.base.url}/platform</url>
+ <layout>p2</layout>
+ </repository>
+ <repository>
+ <id>jdt</id>
+ <url>${target-platform.base.url}/jdt</url>
+ <layout>p2</layout>
+ </repository>
+ <repository>
+ <id>cdt</id>
+ <url>${target-platform.base.url}/cdt</url>
+ <layout>p2</layout>
+ </repository>
+ <repository>
+ <id>emf</id>
+ <url>${target-platform.base.url}/emf</url>
+ <layout>p2</layout>
+ </repository>
+ <repository>
+ <id>wtp</id>
+ <url>${target-platform.base.url}/wtp</url>
+ <layout>p2</layout>
+ </repository>
+ <repository>
+ <id>gef</id>
+ <url>${target-platform.base.url}/gef</url>
+ <layout>p2</layout>
+ </repository>
+ <repository>
+ <id>pde</id>
+ <url>${target-platform.base.url}/pde</url>
+ <layout>p2</layout>
+ </repository>
+ <repository>
+ <id>egit</id>
+ <url>${target-platform.base.url}/egit</url>
+ <layout>p2</layout>
+ </repository>
+ </repositories>
+ </profile>
+ <profile>
+ <id>external-p2-repositories</id>
+ <repositories>
+ <repository>
+ <id>kepler</id>
+ <url>http://download.eclipse.org/releases/kepler</url>
+ <layout>p2</layout>
+ </repository>
+ </repositories>
+ </profile>
+ </profiles>
+
+ <modules>
+ <module>plugins/com.android.ide.eclipse.base</module>
+ <module>plugins/com.android.ide.eclipse.ddms</module>
+ <module>plugins/com.android.ide.eclipse.gldebugger</module>
+ <module>plugins/com.android.ide.eclipse.hierarchyviewer</module>
+ <module>plugins/com.android.ide.eclipse.monitor</module>
+ <module>plugins/com.android.ide.eclipse.traceview</module>
+
+ <module>plugins/com.android.ide.eclipse.adt</module>
+ <module>plugins/com.android.ide.eclipse.adt.overlay</module>
+ <module>plugins/com.android.ide.eclipse.adt.package</module>
+ <module>plugins/com.android.ide.eclipse.ndk</module>
+
+ <module>features/com.android.ide.eclipse.ddms</module>
+ <module>features/com.android.ide.eclipse.gldebugger</module>
+ <module>features/com.android.ide.eclipse.hierarchyviewer</module>
+ <module>features/com.android.ide.eclipse.traceview</module>
+ <module>features/com.android.ide.eclipse.monitor</module>
+
+ <module>features/com.android.ide.eclipse.adt</module>
+ <module>features/com.android.ide.eclipse.adt.package</module>
+ <module>features/com.android.ide.eclipse.ndk</module>
+
+ <module>artifacts/p2repo</module>
+ <module>artifacts/bundles</module>
+ </modules>
+
+ <build>
+ <!-- Path is relative to each of the build modules defined above. -->
+ <directory>../../../../out/host/maven/${project.artifactId}-${project.version}</directory>
+
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>target-platform-configuration</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <!--
+ <target>
+ <artifact>
+ <groupId>adt.group</groupId>
+ <artifactId>helios</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </artifact>
+ </target> -->
+ <environments>
+ <environment>
+ <os>win32</os>
+ <ws>win32</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>win32</os>
+ <ws>win32</ws>
+ <arch>x86_64</arch>
+ </environment>
+ <environment>
+ <os>linux</os>
+ <ws>gtk</ws>
+ <arch>x86</arch>
+ </environment>
+ <environment>
+ <os>macosx</os>
+ <ws>cocoa</ws>
+ <arch>x86_64</arch>
+ </environment>
+ <environment>
+ <os>linux</os>
+ <ws>gtk</ws>
+ <arch>x86_64</arch>
+ </environment>
+ </environments>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-maven-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <extensions>true</extensions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-p2-repository-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <includeAllDependencies>true</includeAllDependencies>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/eclipse/scripts/build_adt.sh b/eclipse/scripts/build_adt.sh
new file mode 100755
index 0000000..7006aab
--- /dev/null
+++ b/eclipse/scripts/build_adt.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Expected arguments:
+# $1 = out_dir
+# $2 = dist_dir
+# $3 = build_number
+
+# exit on error
+set -e
+
+if [ $# -ne 3 ]
+then
+ echo "Usage: $0 <out_dir> <dest_dir> <build_number>" > /dev/stderr
+ echo "Given arguments: $*" > /dev/stderr
+ exit 1
+fi
+
+PROG_DIR=$(dirname "$0")
+
+cd "$PROG_DIR"/../../..
+ANDROID_SRC="$PWD"
+
+OUT="$1"
+DIST="$2"
+BNUM="$3"
+
+echo "ANDROID_SRC=$ANDROID_SRC"
+echo "OUT=$OUT"
+echo "DIST=$DIST"
+echo "BNUM=$BNUM"
+
+# Steps to build Eclipse
+# 1. Generate Maven repository containing all tools
+echo Running gradle to build tools libraries...
+cd "$ANDROID_SRC"/tools
+./gradlew --no-daemon publishLocal
+
+# 2. Copy dependent jars into the libs folder of each plugin
+echo Copying jars to be embedded inside the ADT plugins
+cd "$ANDROID_SRC"
+./tools/gradlew -i -b sdk/eclipse/build.gradle --no-daemon copydeps
+
+# 3. Launch Tycho build
+echo Launching Tycho to build ADT plugins and bundle
+( set -x ; BUILD_NUMBER="$BNUM" ./tools/gradlew -i -b sdk/eclipse/build.gradle --no-daemon buildEclipse)
+
+echo Copying ADT plugins and bundle into destination folder
+cd "$ANDROID_SRC"
+cp -rv out/host/maven/bundles-*/products/*.zip "$DIST"/
+cp -rv out/host/maven/p2repo-*/p2repo-*.zip "$DIST"/p2repo-$BNUM.zip
diff --git a/eclipse/scripts/build_server.sh b/eclipse/scripts/build_server.sh
index 54deaa6..46947ed 100755
--- a/eclipse/scripts/build_server.sh
+++ b/eclipse/scripts/build_server.sh
@@ -16,6 +16,14 @@
# Note: currently wrap around existing shell script, reuse most of it,
# eventually both might merge as needed.
+
+###################
+# temporary disable to deal with build server issues
+# see b/14685861
+exit 0
+###################
+
+
set -e # Fail this script as soon as a command fails -- fail early, fail fast
PROG_DIR=$(dirname "$0")
diff --git a/eclipse/scripts/create_all_symlinks.sh b/eclipse/scripts/create_all_symlinks.sh
index 80eaa54..e3cef1a 100755
--- a/eclipse/scripts/create_all_symlinks.sh
+++ b/eclipse/scripts/create_all_symlinks.sh
@@ -134,7 +134,7 @@ BASE_PLUGIN_LIBS="base:common swt:sdkstats base:sdklib base:dvlib base:layoutlib
BASE_PLUGIN_PREBUILTS="\
prebuilts/tools/common/m2/repository/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar \
prebuilts/tools/common/m2/repository/org/apache/commons/commons-compress/1.0/commons-compress-1.0.jar \
- prebuilts/tools/common/m2/repository/com/google/guava/guava/13.0.1/guava-13.0.1.jar \
+ prebuilts/tools/common/m2/repository/com/google/guava/guava/15.0/guava-15.0.jar \
prebuilts/tools/common/m2/repository/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar \
prebuilts/tools/common/m2/repository/commons-codec/commons-codec/1.4/commons-codec-1.4.jar \
prebuilts/tools/common/m2/repository/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.jar \
@@ -159,7 +159,7 @@ ADT_PREBUILTS="\
prebuilts/tools/common/m2/repository/org/ow2/asm/asm/4.0/asm-4.0.jar \
prebuilts/tools/common/m2/repository/org/ow2/asm/asm-tree/4.0/asm-tree-4.0.jar \
prebuilts/tools/common/m2/repository/org/ow2/asm/asm-analysis/4.0/asm-analysis-4.0.jar \
- prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar"
+ prebuilts/tools/common/m2/repository/com/android/tools/external/lombok/lombok-ast/0.2.2/lombok-ast-0.2.2.jar"
LIBS="$LIBS $ADT_LIBS"
CP_FILES="$CP_FILES @:$ADT_DEST $ADT_LIBS $ADT_PREBUILTS"
diff --git a/eclipse/scripts/update_version.sh b/eclipse/scripts/update_version.sh
index 5b54c99..d3b71b1 100755
--- a/eclipse/scripts/update_version.sh
+++ b/eclipse/scripts/update_version.sh
@@ -9,7 +9,7 @@ if [ -z "$OLD" ] || [ -z "$NEW" ]; then
Usage: $0 <old> <new>
Changes the ADT plugin revision number.
Example:
- cd tools/eclipse
+ cd sdk/eclipse
scripts/update_version.sh 0.1.2 0.2.3
EOF
exit 1
@@ -17,7 +17,7 @@ fi
# sanity check on current dir
if [ `basename "$PWD"` != "eclipse" ]; then
- echo "Please run this from tools/eclipse."
+ echo "Please run this from sdk/eclipse."
exit 1
fi
@@ -46,7 +46,7 @@ function replace() {
SED_OLD="${OLD//./\.}\.qualifier"
SED_NEW="${NEW//./\.}\.qualifier"
-for i in $(grep -rl "$OLD" * | grep -E "\.xml$|\.MF$"); do
+for i in $(grep -rl "$OLD" * | grep -E "\.xml$|\.MF$|\.product$"); do
if [[ -f "$i" && $(basename "$i") != "build.xml" ]]; then
replace "$i"
fi
@@ -55,9 +55,13 @@ done
# ---2--- Change unqualified version numbers in specific files
SED_OLD="${OLD//./\.}"
SED_NEW="${NEW//./\.}"
-for i in plugins/com.android.ide.eclipse.adt.package/ide.product \
- plugins/com.android.ide.eclipse.monitor/monitor.product \
- plugins/com.android.ide.eclipse.monitor/plugin.properties; do
+for i in artifacts/*/pom.xml \
+ plugins/com.android.ide.eclipse.adt.package/ide.product \
+ plugins/com.android.ide.eclipse.monitor/monitor.product \
+ plugins/com.android.ide.eclipse.monitor/plugin.properties \
+ plugins/com.android.ide.eclipse.*/pom.xml \
+ features/com.android.ide.eclipse.*/pom.xml \
+ features/com.android.ide.eclipse.adt.package/feature.xml ; do
if grep -qs "$OLD" "$i"; then
replace "$i"
fi
diff --git a/eclipse/settings.xml b/eclipse/settings.xml
new file mode 100644
index 0000000..e5e53b2
--- /dev/null
+++ b/eclipse/settings.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Run as: mvn -s /path/to/settings.xml -->
+<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
+ <localRepository>../../prebuilts/eclipse/mavenplugins/tycho/tycho-dependencies-m2repo/</localRepository>
+ <offline>true</offline>
+</settings>
diff --git a/eclipse/sites/external/site.xml b/eclipse/sites/external/site.xml
index 17033d9..3105e85 100644
--- a/eclipse/sites/external/site.xml
+++ b/eclipse/sites/external/site.xml
@@ -3,22 +3,22 @@
<description url="https://dl-ssl.google.com/android/eclipse/">
Update Site for Android Development Toolkit
</description>
- <feature url="features/com.android.ide.eclipse.adt_22.3.0.qualifier.jar" id="com.android.ide.eclipse.adt" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.adt_23.0.2.qualifier.jar" id="com.android.ide.eclipse.adt" version="23.0.2.qualifier">
<category name="developer"/>
</feature>
- <feature url="features/com.android.ide.eclipse.ddms_22.3.0.qualifier.jar" id="com.android.ide.eclipse.ddms" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.ddms_23.0.2.qualifier.jar" id="com.android.ide.eclipse.ddms" version="23.0.2.qualifier">
<category name="developer"/>
</feature>
- <feature url="features/com.android.ide.eclipse.hierarchyviewer_22.3.0.qualifier.jar" id="com.android.ide.eclipse.hierarchyviewer" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.hierarchyviewer_23.0.2.qualifier.jar" id="com.android.ide.eclipse.hierarchyviewer" version="23.0.2.qualifier">
<category name="developer"/>
</feature>
- <feature url="features/com.android.ide.eclipse.traceview_22.3.0.qualifier.jar" id="com.android.ide.eclipse.traceview" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.traceview_23.0.2.qualifier.jar" id="com.android.ide.eclipse.traceview" version="23.0.2.qualifier">
<category name="developer"/>
</feature>
- <feature url="features/com.android.ide.eclipse.gldebugger_22.3.0.qualifier.jar" id="com.android.ide.eclipse.gldebugger" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.gldebugger_23.0.2.qualifier.jar" id="com.android.ide.eclipse.gldebugger" version="23.0.2.qualifier">
<category name="developer"/>
</feature>
- <feature url="features/com.android.ide.eclipse.ndk_22.3.0.qualifier.jar" id="com.android.ide.eclipse.ndk" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.ndk_23.0.2.qualifier.jar" id="com.android.ide.eclipse.ndk" version="23.0.2.qualifier">
<category name="ndk"/>
</feature>
<category-def name="developer" label="Developer Tools">
diff --git a/eclipse/sites/internal/site.xml b/eclipse/sites/internal/site.xml
index c91db12..bd98b15 100644
--- a/eclipse/sites/internal/site.xml
+++ b/eclipse/sites/internal/site.xml
@@ -3,32 +3,32 @@
<description url="https://android.corp.google.com/adt/">
Update Site for Android Development Toolkit
</description>
- <feature url="features/com.android.ide.eclipse.adt_22.3.0.qualifier.jar" id="com.android.ide.eclipse.adt" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.adt_23.0.2.qualifier.jar" id="com.android.ide.eclipse.adt" version="23.0.2.qualifier">
<category name="developer"/>
</feature>
- <feature url="features/com.android.ide.eclipse.ddms_22.3.0.qualifier.jar" id="com.android.ide.eclipse.ddms" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.ddms_23.0.2.qualifier.jar" id="com.android.ide.eclipse.ddms" version="23.0.2.qualifier">
<category name="developer"/>
<category name="platform"/>
</feature>
- <feature url="features/com.android.ide.eclipse.hierarchyviewer_22.3.0.qualifier.jar" id="com.android.ide.eclipse.hierarchyviewer" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.hierarchyviewer_23.0.2.qualifier.jar" id="com.android.ide.eclipse.hierarchyviewer" version="23.0.2.qualifier">
<category name="developer"/>
<category name="platform"/>
</feature>
- <feature url="features/com.android.ide.eclipse.tests_22.3.0.qualifier.jar" id="com.android.ide.eclipse.tests" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.tests_23.0.2.qualifier.jar" id="com.android.ide.eclipse.tests" version="23.0.2.qualifier">
<category name="test"/>
</feature>
- <feature url="features/com.android.ide.eclipse.pdt_22.3.0.qualifier.jar" id="com.android.ide.eclipse.pdt" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.pdt_23.0.2.qualifier.jar" id="com.android.ide.eclipse.pdt" version="23.0.2.qualifier">
<category name="platform"/>
</feature>
- <feature url="features/com.android.ide.eclipse.traceview_22.3.0.qualifier.jar" id="com.android.ide.eclipse.traceview" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.traceview_23.0.2.qualifier.jar" id="com.android.ide.eclipse.traceview" version="23.0.2.qualifier">
<category name="developer"/>
<category name="platform"/>
</feature>
- <feature url="features/com.android.ide.eclipse.gldebugger_22.3.0.qualifier.jar" id="com.android.ide.eclipse.gldebugger" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.gldebugger_23.0.2.qualifier.jar" id="com.android.ide.eclipse.gldebugger" version="23.0.2.qualifier">
<category name="developer"/>
<category name="platform"/>
</feature>
- <feature url="features/com.android.ide.eclipse.ndk_22.3.0.qualifier.jar" id="com.android.ide.eclipse.ndk" version="22.3.0.qualifier">
+ <feature url="features/com.android.ide.eclipse.ndk_23.0.2.qualifier.jar" id="com.android.ide.eclipse.ndk" version="23.0.2.qualifier">
<category name="developer"/>
<category name="platform"/>
</feature>
diff --git a/emulator/NOTICE b/emulator/NOTICE
new file mode 100644
index 0000000..06a9081
--- /dev/null
+++ b/emulator/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-2014, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/emulator/mksdcard/.gitignore b/emulator/mksdcard/.gitignore
new file mode 100644
index 0000000..4a78fc8
--- /dev/null
+++ b/emulator/mksdcard/.gitignore
@@ -0,0 +1,3 @@
+build
+.gradle
+
diff --git a/emulator/mksdcard/Android.mk b/emulator/mksdcard/Android.mk
index a5641b4..0547f00 100644
--- a/emulator/mksdcard/Android.mk
+++ b/emulator/mksdcard/Android.mk
@@ -5,7 +5,7 @@ LOCAL_PATH:= $(call my-dir)
# host executable
#
include $(CLEAR_VARS)
-LOCAL_SRC_FILES:= mksdcard.c
+LOCAL_SRC_FILES:= src/source/mksdcard.c
LOCAL_MODULE = mksdcard
include $(BUILD_HOST_EXECUTABLE)
diff --git a/emulator/mksdcard/NOTICE b/emulator/mksdcard/NOTICE
index e4f5db9..06a9081 100644
--- a/emulator/mksdcard/NOTICE
+++ b/emulator/mksdcard/NOTICE
@@ -1,23 +1,190 @@
-Copyright 2007, The Android Open Source Project
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
- * Neither the name of Google Inc. nor the names of its contributors may
- be used to endorse or promote products derived from this software
- without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY Google Inc. ``AS IS'' AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL Google Inc. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
-OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
-WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
-OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
-ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ Copyright (c) 2005-2014, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/emulator/mksdcard/build.gradle b/emulator/mksdcard/build.gradle
new file mode 100644
index 0000000..adb731a
--- /dev/null
+++ b/emulator/mksdcard/build.gradle
@@ -0,0 +1,51 @@
+apply plugin: 'c'
+apply plugin: 'sdk-files'
+apply plugin: 'native-setup'
+
+executables {
+ mksdcard {}
+}
+
+sources {
+ mksdcard {
+ c {
+ source {
+ srcDir "src/source"
+ include "**/*.c"
+ }
+ }
+ }
+}
+
+binaries.all {
+ cCompiler.args "-D_FILE_OFFSET_BITS=64"
+}
+
+sdk {
+ mac {
+ item( { getExeName("darwin") } ) {
+ executable true
+ builtBy 'darwinMksdcardExecutable'
+ }
+ }
+ linux {
+ item( { getExeName("linux") } ) {
+ executable true
+ builtBy 'linuxMksdcardExecutable'
+ }
+ }
+ windows {
+ item( { getExeName("windows") } ) {
+ name 'mksdcard.exe'
+ builtBy 'windowsMksdcardExecutable'
+ }
+ }
+}
+
+def getExeName(String platform) {
+ // binaries will return a set of binaries
+ def binaries = executables.mksdcard.binaries.matching { it.name == "${platform}MksdcardExecutable" }
+ // calling .exeFile on the set returns an array with the result from each item in the set...
+ return binaries.executableFile.get(0)
+}
+
diff --git a/emulator/mksdcard/mksdcard.c b/emulator/mksdcard/src/source/mksdcard.c
index c9a3eeb..c9a3eeb 100644
--- a/emulator/mksdcard/mksdcard.c
+++ b/emulator/mksdcard/src/source/mksdcard.c
diff --git a/emulator/opengl/Android.mk b/emulator/opengl/Android.mk
index a349b96..856826a 100644
--- a/emulator/opengl/Android.mk
+++ b/emulator/opengl/Android.mk
@@ -1,13 +1,10 @@
# This is the top-level build file for the Android HW OpenGL ES emulation
# in Android.
#
-# You must define BUILD_EMULATOR_OPENGL to 'true' in your environment to
+# You must define BUILD_EMULATOR_HOST_OPENGL to 'true' in your environment to
# build the following files.
#
-# Also define BUILD_EMULATOR_OPENGL_DRIVER to 'true' to build the gralloc
-# stuff as well.
-#
-ifeq (true,$(BUILD_EMULATOR_OPENGL))
+ifeq (true,$(BUILD_EMULATOR_HOST_OPENGL))
# Top-level for all modules
EMUGL_PATH := $(call my-dir)
@@ -16,7 +13,19 @@ EMUGL_PATH := $(call my-dir)
# This is always set to a module's LOCAL_C_INCLUDES
# See the definition of emugl-begin-module in common.mk
#
-EMUGL_COMMON_INCLUDES := $(EMUGL_PATH)/host/include/libOpenglRender
+EMUGL_COMMON_INCLUDES := \
+ $(EMUGL_PATH)/host/include/libOpenglRender \
+ $(EMUGL_PATH)/shared
+
+ifeq ($(BUILD_STANDALONE_EMULATOR),true)
+EMUGL_COMMON_INCLUDES := $(EMUGL_PATH)/host/libs/Translator/include
+endif
+
+ifeq ($(BUILD_STANDALONE_EMULATOR),true)
+EMUGL_BUILD_64BITS := $(strip $(EMULATOR_BUILD_64BITS))
+else
+EMUGL_BUILD_64BITS := true
+endif
# common cflags used by several modules
# This is always set to a module's LOCAL_CFLAGS
@@ -24,6 +33,12 @@ EMUGL_COMMON_INCLUDES := $(EMUGL_PATH)/host/include/libOpenglRender
#
EMUGL_COMMON_CFLAGS := -DWITH_GLES2
+# Define EMUGL_BUILD_DEBUG=1 in your environment to build a
+# debug version of the EmuGL host binaries.
+ifneq (,$(strip $(EMUGL_BUILD_DEBUG)))
+EMUGL_COMMON_CFLAGS += -O0 -g -DEMUGL_DEBUG=1
+endif
+
# Uncomment the following line if you want to enable debug traces
# in the GLES emulation libraries.
# EMUGL_COMMON_CFLAGS += -DEMUGL_DEBUG=1
@@ -53,6 +68,11 @@ include $(EMUGL_PATH)/common.mk
# source files (see all emugl-gen-decoder/encoder in common.mk)
#
include $(EMUGL_PATH)/host/tools/emugen/Android.mk
+
+# Required by our units test.
+include $(EMUGL_PATH)/googletest.mk
+
+include $(EMUGL_PATH)/shared/emugl/common/Android.mk
include $(EMUGL_PATH)/shared/OpenglOsUtils/Android.mk
include $(EMUGL_PATH)/shared/OpenglCodecCommon/Android.mk
@@ -66,6 +86,9 @@ include $(EMUGL_PATH)/host/libs/Translator/GLES_CM/Android.mk
include $(EMUGL_PATH)/host/libs/Translator/GLES_V2/Android.mk
include $(EMUGL_PATH)/host/libs/Translator/EGL/Android.mk
+# Required to declare SDL-related flags for some host tests.
+include $(EMUGL_PATH)/sdl.mk
+
# Host shared libraries
include $(EMUGL_PATH)/host/libs/libOpenglRender/Android.mk
@@ -78,4 +101,4 @@ include $(EMUGL_PATH)/tests/translator_tests/MacCommon/Android.mk
include $(EMUGL_PATH)/tests/translator_tests/GLES_CM/Android.mk
include $(EMUGL_PATH)/tests/translator_tests/GLES_V2/Android.mk
-endif # BUILD_EMULATOR_OPENGL == true
+endif # BUILD_EMULATOR_HOST_OPENGL == true
diff --git a/emulator/opengl/common.mk b/emulator/opengl/common.mk
index be5eaf5..255b9e3 100644
--- a/emulator/opengl/common.mk
+++ b/emulator/opengl/common.mk
@@ -24,10 +24,20 @@ emugl-begin-host-static-library = $(call emugl-begin-module,$1,HOST_STATIC_LIBRA
emugl-begin-host-shared-library = $(call emugl-begin-module,$1,HOST_SHARED_LIBRARY,HOST)
emugl-begin-host-executable = $(call emugl-begin-module,$1,HOST_EXECUTABLE,HOST)
+emugl-begin-host64-static-library = $(call emugl-begin-module64,$1,HOST_STATIC_LIBRARY,HOST)
+emugl-begin-host64-shared-library = $(call emugl-begin-module64,$1,HOST_SHARED_LIBRARY,HOST)
+emugl-begin-host64-executable = $(call emugl-begin-module64,$1,HOST_EXECUTABLE,HOST)
+
# Internal list of all declared modules (used for sanity checking)
_emugl_modules :=
_emugl_HOST_modules :=
+ifeq ($(BUILD_STANDALONE_EMULATOR),true)
+EMUGL_LOCAL_EXTRAS = $(end-emulator-module-ev)
+else # BUILD_STANDALONE_EMULATOR != true
+EMUGL_LOCAL_EXTRAS =
+endif # BUILD_STANDALONE_EMULATOR != true
+
# do not use directly, see functions above instead
emugl-begin-module = \
$(eval include $(CLEAR_VARS)) \
@@ -35,14 +45,21 @@ emugl-begin-module = \
$(eval LOCAL_MODULE_TAGS := $(if $3,,debug)) \
$(eval LOCAL_MODULE_CLASS := $(patsubst HOST_%,%,$(patsubst %EXECUTABLE,%EXECUTABLES,$(patsubst %LIBRARY,%LIBRARIES,$2)))) \
$(eval LOCAL_IS_HOST_MODULE := $(if $3,true,))\
- $(eval LOCAL_C_INCLUDES := $(EMUGL_COMMON_INCLUDES)) \
- $(eval LOCAL_CFLAGS := $(EMUGL_COMMON_CFLAGS)) \
+ $(eval LOCAL_C_INCLUDES += $(EMUGL_COMMON_INCLUDES)) \
+ $(eval LOCAL_CFLAGS += $(EMUGL_COMMON_CFLAGS)) \
+ $(eval LOCAL_LDLIBS += -lstdc++) \
$(eval LOCAL_PRELINK_MODULE := false)\
$(eval _EMUGL_INCLUDE_TYPE := $(BUILD_$2)) \
+ $(eval LOCAL_MODULE_BITS := 32) \
$(call _emugl-init-module,$1,$2,$3)
+emugl-begin-module64 = \
+ $(call emugl-begin-module,$1,$2,$3) \
+ $(eval LOCAL_MODULE_BITS := 64) \
+
# Used to end a module definition, see function definitions above
emugl-end-module = \
+ $(eval $(EMUGL_LOCAL_EXTRAS)) \
$(eval include $(_EMUGL_INCLUDE_TYPE))\
$(eval _EMUGL_INCLUDE_TYPE :=) \
$(eval _emugl_$(_emugl_HOST)modules += $(_emugl_MODULE))\
@@ -87,6 +104,7 @@ emugl-end-module = \
# This is the list of recognized export types we support for now.
EMUGL_EXPORT_TYPES := \
CFLAGS \
+ CXXFLAGS \
LDLIBS \
LDFLAGS \
C_INCLUDES \
@@ -118,7 +136,7 @@ _emugl-init-module = \
# $2: Value(s) to append to the export
emugl-export = \
$(eval _emugl.$(_emugl_MODULE).export.$1 += $2)\
- $(eval LOCAL_$1 := $2 $(LOCAL_$1))
+ $(eval LOCAL_$1 := $(LOCAL_$1) $2)
emugl-export-outer = \
$(eval _emugl.$(_emugl_MODULE).export.$1 += $2)
@@ -148,7 +166,7 @@ _emugl-module-import = \
$(call _emugl-module-import,$(_sub))\
)\
$(foreach _type,$(EMUGL_EXPORT_TYPES),\
- $(eval LOCAL_$(_type) := $(_emugl.$1.export.$(_type)) $(LOCAL_$(_type)))\
+ $(eval LOCAL_$(_type) := $(LOCAL_$(_type)) $(_emugl.$1.export.$(_type)))\
)\
$(if $(filter EXECUTABLE SHARED_LIBRARY,$(_emugl.$(_emugl_MODULE).type)),\
$(if $(filter STATIC_LIBRARY,$(_emugl.$1.type)),\
diff --git a/emulator/opengl/gen-encoder.sh b/emulator/opengl/gen-encoder.sh
index 23ecf03..c55a170 100755
--- a/emulator/opengl/gen-encoder.sh
+++ b/emulator/opengl/gen-encoder.sh
@@ -12,17 +12,12 @@ if [ -z "$ANDROID_BUILD_TOP" ]; then
fi
cd "$ANDROID_BUILD_TOP" >/dev/null
SRCDIR="sdk/emulator/opengl/host/libs"
-DSTDIR="development/tools/emulator/opengl/system"
+DSTDIR="device/generic/goldfish/opengl/system"
+EMUGEN="external/qemu/objs/emugen"
if [ ! -d "$SRCDIR" -o ! -d "$DSTDIR" ]; then
echo error: can\'t find source and/or destination directory
exit 1
fi
-
-if [ -z "$ANDROID_HOST_OUT" ]; then
- echo error: ANDROID_HOST_OUT not set
- exit 1
-fi
-EMUGEN="$ANDROID_HOST_OUT/bin/emugen"
if [ ! -x "$EMUGEN" ]; then
echo error: emugen not available, did you forget to build?
exit 1
diff --git a/emulator/opengl/googletest.mk b/emulator/opengl/googletest.mk
new file mode 100644
index 0000000..8147874
--- /dev/null
+++ b/emulator/opengl/googletest.mk
@@ -0,0 +1,43 @@
+# This contains common definitions used to define a host module
+# to link GoogleTest with the EmuGL test programs.
+#
+# This is used instead of including external/gtest/Android.mk to
+# be able to build both the 32-bit and 64-bit binaries while
+# building a 32-bit only SDK (sdk-eng, sdk_x86-eng, sdk_mips-eng).
+
+
+ifeq (true,$(BUILD_STANDALONE_EMULATOR))
+LOCAL_PATH := $(EMULATOR_GTEST_SOURCES_DIR)
+else
+LOCAL_PATH := $(EMUGL_PATH)/../../../external/gtest
+endif
+
+common_SRC_FILES := \
+ src/gtest-all.cc \
+ src/gtest_main.cc
+
+common_CFLAGS := -O0
+
+ifneq (windows,$(HOST_OS))
+ common_LDLIBS += -lpthread
+endif
+
+$(call emugl-begin-host-static-library,libemugl_gtest)
+LOCAL_SRC_FILES := $(common_SRC_FILES)
+LOCAL_CFLAGS += $(common_CFLAGS)
+LOCAL_CPP_EXTENSION := .cc
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include)
+$(call emugl-export,LDLIBS,$(common_LDLIBS))
+$(call emugl-end-module)
+
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64emugl_gtest)
+ LOCAL_SRC_FILES := $(common_SRC_FILES)
+ LOCAL_CFLAGS += $(common_CFLAGS)
+ LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
+ LOCAL_CPP_EXTENSION := .cc
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include)
+ $(call emugl-export,CFLAGS,-m64)
+ $(call emugl-export,LDLIBS,$(common_LDLIBS) -m64)
+ $(call emugl-end-module)
+endif # EMUGL_BUILD_64BITS
diff --git a/emulator/opengl/host/libs/GLESv1_dec/Android.mk b/emulator/opengl/host/libs/GLESv1_dec/Android.mk
index a6d8670..7ab3f0a 100644
--- a/emulator/opengl/host/libs/GLESv1_dec/Android.mk
+++ b/emulator/opengl/host/libs/GLESv1_dec/Android.mk
@@ -18,20 +18,24 @@ $(call emugl-gen-decoder,$(LOCAL_PATH),gl)
LOCAL_SRC_FILES := GLDecoder.cpp
$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS))
+$(call emugl-export,LDLIBS,-lstdc++)
$(call emugl-end-module)
### host library, 64-bit ####################################
-$(call emugl-begin-host-static-library,lib64GLESv1_dec)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64GLESv1_dec)
-$(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ $(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-$(call emugl-gen-decoder,$(LOCAL_PATH),gl)
+ $(call emugl-gen-decoder,$(LOCAL_PATH),gl)
-LOCAL_SRC_FILES := GLDecoder.cpp
+ LOCAL_SRC_FILES := GLDecoder.cpp
-$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS) -m64)
+ $(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS) -m64)
+ $(call emugl-export,LDLIBS,-lstdc++)
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp b/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp
index 5399445..3c5bd70 100644
--- a/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp
+++ b/emulator/opengl/host/libs/GLESv1_dec/GLDecoder.cpp
@@ -21,6 +21,10 @@
#include <GLES/gl.h>
#include <GLES/glext.h>
+static inline void* SafePointerFromUInt(GLuint value) {
+ return (void*)(uintptr_t)value;
+}
+
GLDecoder::GLDecoder()
{
m_contextData = NULL;
@@ -88,43 +92,43 @@ int GLDecoder::s_glFinishRoundTrip(void *self)
void GLDecoder::s_glVertexPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glVertexPointer(size, type, stride, (void *)offset);
+ ctx->glVertexPointer(size, type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glColorPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glColorPointer(size, type, stride, (void *)offset);
+ ctx->glColorPointer(size, type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glTexCoordPointerOffset(void *self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glTexCoordPointer(size, type, stride, (void *) offset);
+ ctx->glTexCoordPointer(size, type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glNormalPointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glNormalPointer(type, stride, (void *)offset);
+ ctx->glNormalPointer(type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glPointSizePointerOffset(void *self, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glPointSizePointerOES(type, stride, (void *)offset);
+ ctx->glPointSizePointerOES(type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glWeightPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glWeightPointerOES(size, type, stride, (void*)offset);
+ ctx->glWeightPointerOES(size, type, stride, SafePointerFromUInt(offset));
}
void GLDecoder::s_glMatrixIndexPointerOffset(void * self, GLint size, GLenum type, GLsizei stride, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glMatrixIndexPointerOES(size, type, stride, (void*)offset);
+ ctx->glMatrixIndexPointerOES(size, type, stride, SafePointerFromUInt(offset));
}
@@ -204,7 +208,7 @@ void GLDecoder::s_glMatrixIndexPointerData(void * self, GLint size, GLenum type,
void GLDecoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset)
{
GLDecoder *ctx = (GLDecoder *)self;
- ctx->glDrawElements(mode, count, type, (void *)offset);
+ ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset));
}
void GLDecoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GLenum type, void * data, GLuint datalen)
diff --git a/emulator/opengl/host/libs/GLESv2_dec/Android.mk b/emulator/opengl/host/libs/GLESv2_dec/Android.mk
index 7a034ec..bc04c25 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/Android.mk
+++ b/emulator/opengl/host/libs/GLESv2_dec/Android.mk
@@ -22,15 +22,17 @@ LOCAL_SRC_FILES := GL2Decoder.cpp
$(call emugl-end-module)
### host library, 64-bit ####################################
-$(call emugl-begin-host-static-library,lib64GLESv2_dec)
-$(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
-$(call emugl-gen-decoder,$(LOCAL_PATH),gl2)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64GLESv2_dec)
+ $(call emugl-import, lib64OpenglCodecCommon lib64OpenglOsUtils)
+ $(call emugl-gen-decoder,$(LOCAL_PATH),gl2)
-# For gl2_types.h !
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ # For gl2_types.h !
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-$(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS) -m64)
+ $(call emugl-export,CFLAGS,$(host_common_debug_CFLAGS) -m64)
-LOCAL_SRC_FILES := GL2Decoder.cpp
+ LOCAL_SRC_FILES := GL2Decoder.cpp
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp b/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
index a777c50..ccf2f06 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
+++ b/emulator/opengl/host/libs/GLESv2_dec/GL2Decoder.cpp
@@ -19,6 +19,9 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
+static inline void* SafePointerFromUInt(GLuint value) {
+ return (void*)(uintptr_t)value;
+}
GL2Decoder::GL2Decoder()
{
@@ -115,7 +118,7 @@ void GL2Decoder::s_glVertexAttribPointerOffset(void *self, GLuint indx, GLint si
GLboolean normalized, GLsizei stride, GLuint data)
{
GL2Decoder *ctx = (GL2Decoder *) self;
- ctx->glVertexAttribPointer(indx, size, type, normalized, stride, (GLvoid *)data);
+ ctx->glVertexAttribPointer(indx, size, type, normalized, stride, SafePointerFromUInt(data));
}
@@ -129,7 +132,7 @@ void GL2Decoder::s_glDrawElementsData(void *self, GLenum mode, GLsizei count, GL
void GL2Decoder::s_glDrawElementsOffset(void *self, GLenum mode, GLsizei count, GLenum type, GLuint offset)
{
GL2Decoder *ctx = (GL2Decoder *)self;
- ctx->glDrawElements(mode, count, type, (void *)offset);
+ ctx->glDrawElements(mode, count, type, SafePointerFromUInt(offset));
}
void GL2Decoder::s_glShaderString(void *self, GLuint shader, const GLchar* string, GLsizei len)
diff --git a/emulator/opengl/host/libs/Translator/EGL/Android.mk b/emulator/opengl/host/libs/Translator/EGL/Android.mk
index f1a6d3a..5d1c9b2 100644
--- a/emulator/opengl/host/libs/Translator/EGL/Android.mk
+++ b/emulator/opengl/host/libs/Translator/EGL/Android.mk
@@ -47,11 +47,12 @@ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
$(call emugl-end-module)
### EGL host implementation, 64-bit ########################
-$(call emugl-begin-host-shared-library,lib64EGL_translator)
-$(call emugl-import,lib64GLcommon)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-shared-library,lib64EGL_translator)
+ $(call emugl-import,lib64GLcommon)
-LOCAL_LDLIBS += $(host_common_LDLIBS) -m64
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-
-$(call emugl-end-module)
+ LOCAL_LDLIBS += $(host_common_LDLIBS) -m64
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ $(call emugl-end-module)
+endif
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglContext.h b/emulator/opengl/host/libs/Translator/EGL/EglContext.h
index e4917c6..d8eb05e 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglContext.h
+++ b/emulator/opengl/host/libs/Translator/EGL/EglContext.h
@@ -19,10 +19,10 @@
#include <map>
#include <EGL/egl.h>
#include <GLcommon/GLutils.h>
-#include <GLcommon/SmartPtr.h>
#include <GLcommon/TranslatorIfaces.h>
#include <GLcommon/objectNameManager.h>
+#include "emugl/common/smart_ptr.h"
#include "EglConfig.h"
#include "EglSurface.h"
@@ -30,7 +30,7 @@
class EglContext;
-typedef SmartPtr<EglContext> ContextPtr;
+typedef emugl::SmartPtr<EglContext> ContextPtr;
class EglDisplay;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
index 99f9d8b..24b9a0d 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.cpp
@@ -16,7 +16,6 @@
#include "EglDisplay.h"
#include "EglOsApi.h"
#include <GLcommon/GLutils.h>
-#include <utils/threads.h>
EglDisplay::EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault) :
m_dpy(dpy),
@@ -31,7 +30,7 @@ EglDisplay::EglDisplay(EGLNativeInternalDisplayType dpy,bool isDefault) :
};
EglDisplay::~EglDisplay() {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
//
// Destroy the global context if one was created.
@@ -59,7 +58,7 @@ EglDisplay::~EglDisplay() {
EGLNativeInternalDisplayType EglDisplay::nativeType(){return m_dpy;}
void EglDisplay::initialize(int renderableType) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_initialized = true;
initConfigurations(renderableType);
m_configInitialized = true;
@@ -68,7 +67,7 @@ void EglDisplay::initialize(int renderableType) {
bool EglDisplay::isInitialize() { return m_initialized;}
void EglDisplay::terminate(){
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_contexts.clear();
m_surfaces.clear();
m_initialized = false;
@@ -128,7 +127,7 @@ void EglDisplay::initConfigurations(int renderableType) {
}
EglConfig* EglDisplay::getConfig(EGLConfig conf) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() ;it++) {
if(static_cast<EGLConfig>(*it) == conf) {
@@ -140,9 +139,9 @@ EglConfig* EglDisplay::getConfig(EGLConfig conf) {
}
SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* surface is "key" in map<unsigned int, SurfacePtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)surface);
+ unsigned int hndl = SafeUIntFromPointer(surface);
SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
return it != m_surfaces.end() ?
(*it).second :
@@ -150,9 +149,9 @@ SurfacePtr EglDisplay::getSurface(EGLSurface surface) {
}
ContextPtr EglDisplay::getContext(EGLContext ctx) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* ctx is "key" in map<unsigned int, ContextPtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)ctx);
+ unsigned int hndl = SafeUIntFromPointer(ctx);
ContextsHndlMap::iterator it = m_contexts.find(hndl);
return it != m_contexts.end() ?
(*it).second :
@@ -160,9 +159,9 @@ ContextPtr EglDisplay::getContext(EGLContext ctx) {
}
bool EglDisplay::removeSurface(EGLSurface s) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* s is "key" in map<unsigned int, SurfacePtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)s);
+ unsigned int hndl = SafeUIntFromPointer(s);
SurfacesHndlMap::iterator it = m_surfaces.find(hndl);
if(it != m_surfaces.end()) {
m_surfaces.erase(it);
@@ -172,7 +171,7 @@ bool EglDisplay::removeSurface(EGLSurface s) {
}
bool EglDisplay::removeSurface(SurfacePtr s) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
SurfacesHndlMap::iterator it;
for(it = m_surfaces.begin(); it!= m_surfaces.end();it++)
@@ -189,9 +188,9 @@ bool EglDisplay::removeSurface(SurfacePtr s) {
}
bool EglDisplay::removeContext(EGLContext ctx) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* ctx is "key" in map<unsigned int, ContextPtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)ctx);
+ unsigned int hndl = SafeUIntFromPointer(ctx);
ContextsHndlMap::iterator it = m_contexts.find(hndl);
if(it != m_contexts.end()) {
m_contexts.erase(it);
@@ -201,7 +200,7 @@ bool EglDisplay::removeContext(EGLContext ctx) {
}
bool EglDisplay::removeContext(ContextPtr ctx) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ContextsHndlMap::iterator it;
for(it = m_contexts.begin(); it != m_contexts.end();it++) {
@@ -217,7 +216,7 @@ bool EglDisplay::removeContext(ContextPtr ctx) {
}
EglConfig* EglDisplay::getConfig(EGLint id) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() ;it++) {
if((*it)->id() == id) {
@@ -229,7 +228,7 @@ EglConfig* EglDisplay::getConfig(EGLint id) {
}
int EglDisplay::getConfigs(EGLConfig* configs,int config_size) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
int i = 0;
for(ConfigsList::iterator it = m_configs.begin(); it != m_configs.end() && i < config_size ;i++,it++) {
configs[i] = static_cast<EGLConfig>(*it);
@@ -238,7 +237,7 @@ int EglDisplay::getConfigs(EGLConfig* configs,int config_size) {
}
int EglDisplay::chooseConfigs(const EglConfig& dummy,EGLConfig* configs,int config_size) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
return doChooseConfigs(dummy, configs, config_size);
}
@@ -258,7 +257,7 @@ int EglDisplay::doChooseConfigs(const EglConfig& dummy,EGLConfig* configs,int co
}
EGLSurface EglDisplay::addSurface(SurfacePtr s ) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
unsigned int hndl = s.Ptr()->getHndl();
EGLSurface ret =reinterpret_cast<EGLSurface> (hndl);
@@ -271,7 +270,7 @@ EGLSurface EglDisplay::addSurface(SurfacePtr s ) {
}
EGLContext EglDisplay::addContext(ContextPtr ctx ) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
unsigned int hndl = ctx.Ptr()->getHndl();
EGLContext ret = reinterpret_cast<EGLContext> (hndl);
@@ -285,7 +284,7 @@ EGLContext EglDisplay::addContext(ContextPtr ctx ) {
EGLImageKHR EglDisplay::addImageKHR(ImagePtr img) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
do { ++m_nextEglImageId; } while(m_nextEglImageId == 0);
img->imageId = m_nextEglImageId;
m_eglImages[m_nextEglImageId] = img;
@@ -293,17 +292,17 @@ EGLImageKHR EglDisplay::addImageKHR(ImagePtr img) {
}
ImagePtr EglDisplay::getImage(EGLImageKHR img) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* img is "key" in map<unsigned int, ImagePtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)img);
+ unsigned int hndl = SafeUIntFromPointer(img);
ImagesHndlMap::iterator i( m_eglImages.find(hndl) );
return (i != m_eglImages.end()) ? (*i).second :ImagePtr(NULL);
}
bool EglDisplay:: destroyImageKHR(EGLImageKHR img) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
/* img is "key" in map<unsigned int, ImagePtr>. */
- unsigned int hndl = ToTargetCompatibleHandle((uintptr_t)img);
+ unsigned int hndl = SafeUIntFromPointer(img);
ImagesHndlMap::iterator i( m_eglImages.find(hndl) );
if (i != m_eglImages.end())
{
@@ -314,7 +313,7 @@ bool EglDisplay:: destroyImageKHR(EGLImageKHR img) {
}
EGLNativeContextType EglDisplay::getGlobalSharedContext(){
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
#ifndef _WIN32
// find an existing OpenGL context to share with, if exist
EGLNativeContextType ret =
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h
index 587e92a..47a2598 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h
+++ b/emulator/opengl/host/libs/Translator/EGL/EglDisplay.h
@@ -20,8 +20,8 @@
#include <map>
#include <EGL/egl.h>
#include <EGL/eglext.h>
-#include <utils/threads.h>
-#include <GLcommon/SmartPtr.h>
+#include "emugl/common/mutex.h"
+#include "emugl/common/smart_ptr.h"
#include "EglConfig.h"
#include "EglContext.h"
@@ -30,6 +30,7 @@
+
typedef std::list<EglConfig*> ConfigsList;
typedef std::map< unsigned int, ContextPtr> ContextsHndlMap;
typedef std::map< unsigned int, SurfacePtr> SurfacesHndlMap;
@@ -81,7 +82,7 @@ private:
SurfacesHndlMap m_surfaces;
GlobalNameSpace m_globalNameSpace;
ObjectNameManager *m_manager[MAX_GLES_VERSION];
- android::Mutex m_lock;
+ emugl::Mutex m_lock;
ImagesHndlMap m_eglImages;
unsigned int m_nextEglImageId;
EGLNativeContextType m_globalSharedContext;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp
index 8e5b462..95b696e 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.cpp
@@ -51,7 +51,7 @@ void EglGlobalInfo::delInstance() {
EglDisplay* EglGlobalInfo::addDisplay(EGLNativeDisplayType dpy,EGLNativeInternalDisplayType idpy) {
//search if it is not already exists
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(DisplaysMap::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if((*it).second == dpy) return (*it).first;
}
@@ -68,7 +68,7 @@ EglDisplay* EglGlobalInfo::addDisplay(EGLNativeDisplayType dpy,EGLNativeInternal
}
bool EglGlobalInfo::removeDisplay(EGLDisplay dpy) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(DisplaysMap::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if(static_cast<EGLDisplay>((*it).first) == dpy) {
delete (*it).first;
@@ -80,7 +80,7 @@ bool EglGlobalInfo::removeDisplay(EGLDisplay dpy) {
}
EglDisplay* EglGlobalInfo::getDisplay(EGLNativeDisplayType dpy) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
for(DisplaysMap::iterator it = m_displays.begin(); it != m_displays.end() ;it++) {
if((*it).second == dpy) return (*it).first;
}
@@ -88,7 +88,7 @@ EglDisplay* EglGlobalInfo::getDisplay(EGLNativeDisplayType dpy) {
}
EglDisplay* EglGlobalInfo::getDisplay(EGLDisplay dpy) {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
DisplaysMap::iterator it = m_displays.find(static_cast<EglDisplay*>(dpy));
return (it != m_displays.end() ? (*it).first : NULL);
}
@@ -99,7 +99,7 @@ EGLNativeInternalDisplayType EglGlobalInfo::generateInternalDisplay(EGLNativeDis
void EglGlobalInfo::initClientExtFuncTable(GLESVersion ver)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
if (!m_gles_extFuncs_inited[ver]) {
ClientAPIExts::initClientFuncs(m_gles_ifaces[ver], (int)ver - 1);
m_gles_extFuncs_inited[ver] = true;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h
index ec07ffe..f56b79e 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h
+++ b/emulator/opengl/host/libs/Translator/EGL/EglGlobalInfo.h
@@ -16,14 +16,15 @@
#ifndef EGL_GLOBAL_INFO
#define EGL_GLOBAL_INFO
-#include <list>
-#include <EGL/egl.h>
-#include <utils/threads.h>
-#include <GLcommon/TranslatorIfaces.h>
#include "EglDisplay.h"
#include "EglConfig.h"
#include "EglContext.h"
+#include <GLcommon/TranslatorIfaces.h>
+#include "emugl/common/mutex.h"
+#include <list>
+#include <EGL/egl.h>
+
typedef std::map<EglDisplay*,EGLNativeDisplayType>DisplaysMap;
@@ -58,7 +59,7 @@ private:
EGLNativeInternalDisplayType m_default;
GLESiface* m_gles_ifaces[MAX_GLES_VERSION];
bool m_gles_extFuncs_inited[MAX_GLES_VERSION];
- android::Mutex m_lock;
+ emugl::Mutex m_lock;
};
#endif
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp b/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
index d03c9db..06dcf67 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglImp.cpp
@@ -50,11 +50,11 @@ GLEScontext* getGLESContext();
#define tls_thread EglThreadInfo::get()
EglGlobalInfo* g_eglInfo = NULL;
-android::Mutex s_eglLock;
+emugl::Mutex s_eglLock;
void initGlobalInfo()
{
- android::Mutex::Autolock mutex(s_eglLock);
+ emugl::Mutex::AutoLock mutex(s_eglLock);
if (!g_eglInfo) {
g_eglInfo = EglGlobalInfo::getInstance();
}
@@ -72,8 +72,8 @@ static EGLiface s_eglIface = {
#define EGL_EXTENTIONS 2
//decleration
-EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
-EGLBoolean eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image);
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list);
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image);
// extentions descriptors
static ExtentionDescriptor s_eglExtentions[] = {
@@ -273,28 +273,31 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
}
//selection defaults
+ // NOTE: Some variables below are commented out to reduce compiler warnings.
+ // TODO(digit): Look if these variables are really needed or not, and if so
+ // fix the code to do it properly.
EGLint surface_type = EGL_WINDOW_BIT;
EGLint renderable_type = EGL_OPENGL_ES_BIT;
- EGLBoolean bind_to_tex_rgb = EGL_DONT_CARE;
- EGLBoolean bind_to_tex_rgba = EGL_DONT_CARE;
+ //EGLBoolean bind_to_tex_rgb = EGL_DONT_CARE;
+ //EGLBoolean bind_to_tex_rgba = EGL_DONT_CARE;
EGLenum caveat = EGL_DONT_CARE;
EGLint config_id = EGL_DONT_CARE;
EGLBoolean native_renderable = EGL_DONT_CARE;
EGLint native_visual_type = EGL_DONT_CARE;
- EGLint max_swap_interval = EGL_DONT_CARE;
- EGLint min_swap_interval = EGL_DONT_CARE;
+ //EGLint max_swap_interval = EGL_DONT_CARE;
+ //EGLint min_swap_interval = EGL_DONT_CARE;
EGLint trans_red_val = EGL_DONT_CARE;
EGLint trans_green_val = EGL_DONT_CARE;
EGLint trans_blue_val = EGL_DONT_CARE;
EGLenum transparent_type = EGL_NONE;
- EGLint buffer_size = 0;
+ //EGLint buffer_size = 0;
EGLint red_size = 0;
EGLint green_size = 0;
EGLint blue_size = 0;
EGLint alpha_size = 0;
EGLint depth_size = 0;
EGLint frame_buffer_level = 0;
- EGLint sample_buffers_num = 0;
+ //EGLint sample_buffers_num = 0;
EGLint samples_per_pixel = 0;
EGLint stencil_size = 0;
@@ -318,7 +321,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
- buffer_size = attrib_list[i+1];
+ //buffer_size = attrib_list[i+1];
break;
case EGL_RED_SIZE:
if(attrib_list[i+1] < 0) {
@@ -345,10 +348,10 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
alpha_size = attrib_list[i+1];
break;
case EGL_BIND_TO_TEXTURE_RGB:
- bind_to_tex_rgb = attrib_list[i+1];
+ //bind_to_tex_rgb = attrib_list[i+1];
break;
case EGL_BIND_TO_TEXTURE_RGBA:
- bind_to_tex_rgba = attrib_list[i+1];
+ //bind_to_tex_rgba = attrib_list[i+1];
break;
case EGL_CONFIG_CAVEAT:
if(attrib_list[i+1] != EGL_NONE && attrib_list[i+1] != EGL_SLOW_CONFIG && attrib_list[i+1] != EGL_NON_CONFORMANT_CONFIG) {
@@ -373,13 +376,13 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
- max_swap_interval = attrib_list[i+1];
+ //max_swap_interval = attrib_list[i+1];
break;
case EGL_MIN_SWAP_INTERVAL:
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
- min_swap_interval = attrib_list[i+1];
+ //min_swap_interval = attrib_list[i+1];
break;
case EGL_NATIVE_RENDERABLE:
native_renderable = attrib_list[i+1];
@@ -394,7 +397,7 @@ EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay display, const EGLint *
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
}
case EGL_SAMPLE_BUFFERS:
- sample_buffers_num = attrib_list[i+1];
+ //sample_buffers_num = attrib_list[i+1];
break;
if(attrib_list[i+1] < 0) {
RETURN_ERROR(EGL_FALSE,EGL_BAD_ATTRIBUTE);
@@ -635,13 +638,11 @@ EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay display, EGLConfig con
}
ContextPtr sharedCtxPtr;
- EGLNativeContextType nativeShared = NULL;
if(share_context != EGL_NO_CONTEXT) {
sharedCtxPtr = dpy->getContext(share_context);
if(!sharedCtxPtr.Ptr()) {
RETURN_ERROR(EGL_NO_CONTEXT,EGL_BAD_CONTEXT);
}
- nativeShared = sharedCtxPtr->nativeType();
}
EGLNativeContextType globalSharedContext = dpy->getGlobalSharedContext();
@@ -815,7 +816,7 @@ EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void) {
if(dpy && ctx.Ptr()){
// This double check is required because a context might still be current after it is destroyed - in which case
// its handle should be invalid, that is EGL_NO_CONTEXT should be returned even though the context is current
- EGLContext c = (EGLContext)ctx->getHndl();
+ EGLContext c = (EGLContext)SafePointerFromUInt(ctx->getHndl());
if(dpy->getContext(c).Ptr())
{
return c;
@@ -839,7 +840,7 @@ EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw) {
// current after it is destroyed - in which case its handle should
// be invalid, that is EGL_NO_SURFACE should be returned even
// though the surface is current.
- EGLSurface s = (EGLSurface)surface->getHndl();
+ EGLSurface s = (EGLSurface)SafePointerFromUInt(surface->getHndl());
surface = dpy->getSurface(s);
if(surface.Ptr())
{
@@ -858,7 +859,9 @@ EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void) {
EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void) {
EGLenum api = eglQueryAPI();
eglBindAPI(EGL_OPENGL_ES_API);
- return eglWaitClient();
+ EGLBoolean ret = eglWaitClient();
+ eglBindAPI(api);
+ return ret;
}
EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine) {
@@ -1012,7 +1015,6 @@ EglImage *attachEGLImage(unsigned int imageId)
void detachEGLImage(unsigned int imageId)
{
ThreadInfo* thread = getThreadInfo();
- EglDisplay* dpy = static_cast<EglDisplay*>(thread->eglDisplay);
ContextPtr ctx = thread->eglContext;
if (ctx.Ptr()) {
ctx->detachImage(imageId);
@@ -1020,7 +1022,7 @@ void detachEGLImage(unsigned int imageId)
}
-EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
+EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list)
{
VALIDATE_DISPLAY(display);
VALIDATE_CONTEXT(context);
@@ -1033,13 +1035,13 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum ta
ThreadInfo* thread = getThreadInfo();
ShareGroupPtr sg = thread->shareGroup;
if (sg.Ptr() != NULL) {
- unsigned int globalTexName = sg->getGlobalName(TEXTURE, (uintptr_t)buffer);
+ unsigned int globalTexName = sg->getGlobalName(TEXTURE, SafeUIntFromPointer(buffer));
if (!globalTexName) return EGL_NO_IMAGE_KHR;
ImagePtr img( new EglImage() );
if (img.Ptr() != NULL) {
- ObjectDataPtr objData = sg->getObjectData(TEXTURE, (uintptr_t)buffer);
+ ObjectDataPtr objData = sg->getObjectData(TEXTURE, SafeUIntFromPointer(buffer));
if (!objData.Ptr()) return EGL_NO_IMAGE_KHR;
TextureData *texData = (TextureData *)objData.Ptr();
@@ -1057,7 +1059,7 @@ EGLImageKHR eglCreateImageKHR(EGLDisplay display, EGLContext context, EGLenum ta
}
-EGLBoolean eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image)
+EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR(EGLDisplay display, EGLImageKHR image)
{
VALIDATE_DISPLAY(display);
return dpy->destroyImageKHR(image) ? EGL_TRUE:EGL_FALSE;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglSurface.h b/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
index d65f480..ba28ae8 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
+++ b/emulator/opengl/host/libs/Translator/EGL/EglSurface.h
@@ -16,14 +16,15 @@
#ifndef EGL_SURFACE_H
#define EGL_SURFACE_H
+#include <map>
+
#include <EGL/egl.h>
#include <EGL/eglinternalplatform.h>
-#include <map>
-#include <GLcommon/SmartPtr.h>
+#include "emugl/common/smart_ptr.h"
#include "EglConfig.h"
class EglSurface;
-typedef SmartPtr<EglSurface> SurfacePtr;
+typedef emugl::SmartPtr<EglSurface> SurfacePtr;
class EglDisplay;
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp
index 1b403f2..6481774 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglThreadInfo.cpp
@@ -16,26 +16,33 @@
#include "EglThreadInfo.h"
#include "EglOsApi.h"
-EglThreadInfo::EglThreadInfo():m_err(EGL_SUCCESS),m_api(EGL_OPENGL_ES_API) {}
+#include "emugl/common/lazy_instance.h"
+#include "emugl/common/thread_store.h"
-#include <cutils/threads.h>
+namespace {
-static thread_store_t s_tls = THREAD_STORE_INITIALIZER;
-
-static void tlsDestruct(void *ptr)
-{
- if (ptr) {
- EglThreadInfo *ti = (EglThreadInfo *)ptr;
- delete ti;
+class EglThreadInfoStore : public emugl::ThreadStore {
+public:
+ EglThreadInfoStore() : emugl::ThreadStore(&destructor) {}
+private:
+ static void destructor(void* value) {
+ delete static_cast<EglThreadInfo*>(value);
}
-}
+};
+
+} // namespace
+
+EglThreadInfo::EglThreadInfo() :
+ m_err(EGL_SUCCESS), m_api(EGL_OPENGL_ES_API) {}
+
+static emugl::LazyInstance<EglThreadInfoStore> s_tls = LAZY_INSTANCE_INIT;
EglThreadInfo* EglThreadInfo::get(void)
{
- EglThreadInfo *ti = (EglThreadInfo *)thread_store_get(&s_tls);
+ EglThreadInfo *ti = static_cast<EglThreadInfo*>(s_tls->get());
if (!ti) {
ti = new EglThreadInfo();
- thread_store_set(&s_tls, ti, tlsDestruct);
+ s_tls->set(ti);
}
return ti;
}
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp b/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
index 460c0b6..5b48fcb 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglWindowsApi.cpp
@@ -20,8 +20,7 @@
#include <stdio.h>
#define IS_TRUE(a) \
- if(a != true) return false;
-
+ if(a != true) return NULL;
struct DisplayInfo{
DisplayInfo():dc(NULL),hwnd(NULL),isPixelFormatSet(false){};
@@ -48,9 +47,7 @@ static TlsData *getTLS() {
class WinDisplay{
public:
- typedef enum {
- DEFAULT_DISPLAY = 0
- };
+ enum { DEFAULT_DISPLAY = 0 };
WinDisplay(){};
DisplayInfo& getInfo(int configurationIndex){ return getTLS()->m_map[configurationIndex];}
HDC getDC(int configId){return getTLS()->m_map[configId].dc;}
@@ -193,7 +190,8 @@ HWND createDummyWindow(){
wcx.lpszClassName = "DummyWin"; // name of window class
wcx.hIconSm = (HICON) NULL; // small class icon
- ATOM winClass = RegisterClassEx(&wcx);
+ RegisterClassEx(&wcx);
+
HWND hwnd = CreateWindowEx(WS_EX_CLIENTEDGE,
"DummyWin",
"Dummy",
@@ -340,7 +338,7 @@ EglConfig* pixelFormatToConfig(EGLNativeInternalDisplayType display,int renderab
EGLint transparentType,samples;
EGLint tRed,tGreen,tBlue;
EGLint pMaxWidth,pMaxHeight,pMaxPixels;
- EGLint configId,level;
+ EGLint level;
EGLint window,bitmap,pbuffer,transparent;
HDC dpy = getDummyDC(display,WinDisplay::DEFAULT_DISPLAY);
@@ -416,10 +414,10 @@ void queryConfigs(EGLNativeInternalDisplayType display,int renderableType,Config
initPixelFormat(dpy);
//quering num of formats
- int nFormats = DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
+ int maxFormat = DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
//inserting rest of formats
- for(iPixelFormat;iPixelFormat < nFormats; iPixelFormat++) {
+ for(;iPixelFormat <= maxFormat; iPixelFormat++) {
DescribePixelFormat(dpy, iPixelFormat,sizeof(PIXELFORMATDESCRIPTOR), &pfd);
EglConfig* pConfig = pixelFormatToConfig(display,renderableType,&pfd,iPixelFormat);
if(pConfig) listOut.push_back(pConfig);
@@ -497,7 +495,7 @@ EGLNativeSurfaceType createPbufferSurface(EGLNativeInternalDisplayType display,E
if(!s_wglExtProcs->wglCreatePbufferARB) return NULL;
EGLNativePbufferType pb = s_wglExtProcs->wglCreatePbufferARB(dpy,cfg->nativeId(),width,height,pbAttribs);
if(!pb) {
- DWORD err = GetLastError();
+ GetLastError();
return NULL;
}
return new SrfcInfo(pb);
@@ -507,7 +505,7 @@ bool releasePbuffer(EGLNativeInternalDisplayType display,EGLNativeSurfaceType pb
if (!pb) return false;
if(!s_wglExtProcs->wglReleasePbufferDCARB || !s_wglExtProcs->wglDestroyPbufferARB) return false;
if(!s_wglExtProcs->wglReleasePbufferDCARB(pb->getPbuffer(),pb->getDC()) || !s_wglExtProcs->wglDestroyPbufferARB(pb->getPbuffer())){
- DWORD err = GetLastError();
+ GetLastError();
return false;
}
return true;
@@ -539,7 +537,7 @@ EGLNativeContextType createContext(EGLNativeInternalDisplayType display,EglConfi
bool destroyContext(EGLNativeInternalDisplayType dpy,EGLNativeContextType ctx) {
if(!wglDeleteContext(ctx)) {
- DWORD err = GetLastError();
+ GetLastError();
return false;
}
return true;
@@ -566,7 +564,7 @@ bool makeCurrent(EGLNativeInternalDisplayType display,EglSurface* read,EglSurfac
void swapBuffers(EGLNativeInternalDisplayType display,EGLNativeSurfaceType srfc){
if(srfc && !SwapBuffers(srfc->getDC())) {
- DWORD err = GetLastError();
+ GetLastError();
}
}
diff --git a/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp b/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
index 129f244..41cf8c4 100644
--- a/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/EglX11Api.cpp
@@ -14,10 +14,11 @@
* limitations under the License.
*/
#include "EglOsApi.h"
+#include "emugl/common/mutex.h"
+
#include <string.h>
#include <X11/Xlib.h>
#include <GL/glx.h>
-#include <utils/threads.h>
class ErrorHandler{
@@ -29,7 +30,7 @@ int getLastError(){ return s_lastErrorCode;};
private:
static int s_lastErrorCode;
int (*m_oldErrorHandler) (Display *, XErrorEvent *);
-static android::Mutex s_lock;
+static emugl::Mutex s_lock;
static int errorHandlerProc(EGLNativeDisplayType dpy,XErrorEvent* event);
};
@@ -50,17 +51,17 @@ private:
};
int ErrorHandler::s_lastErrorCode = 0;
-android::Mutex ErrorHandler::s_lock;
+emugl::Mutex ErrorHandler::s_lock;
ErrorHandler::ErrorHandler(EGLNativeDisplayType dpy){
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
XSync(dpy,False);
s_lastErrorCode = 0;
m_oldErrorHandler = XSetErrorHandler(errorHandlerProc);
}
ErrorHandler::~ErrorHandler(){
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
XSetErrorHandler(m_oldErrorHandler);
s_lastErrorCode = 0;
}
@@ -71,7 +72,7 @@ int ErrorHandler::errorHandlerProc(EGLNativeDisplayType dpy,XErrorEvent* event){
}
#define IS_SUCCESS(a) \
- if(a != Success) return false;
+ if(a != Success) return 0;
namespace EglOS {
@@ -193,7 +194,7 @@ bool validNativePixmap(EGLNativeDisplayType dpy,EGLNativeSurfaceType pix) {
int tmp;
unsigned int utmp;
ErrorHandler handler(dpy);
- if(!XGetGeometry(dpy,pix ? pix->srfc() : NULL,&root,&tmp,&tmp,&utmp,&utmp,&utmp,&utmp)) return false;
+ if(!XGetGeometry(dpy,pix ? pix->srfc() : 0,&root,&tmp,&tmp,&utmp,&utmp,&utmp,&utmp)) return false;
return handler.getLastError() == 0;
}
@@ -260,7 +261,7 @@ bool makeCurrent(EGLNativeDisplayType dpy,EglSurface* read,EglSurface* draw,EGLN
bool retval = false;
if (!ctx && !read && !draw) {
// unbind
- retval = glXMakeContextCurrent(dpy, NULL, NULL, NULL);
+ retval = glXMakeContextCurrent(dpy, 0, 0, NULL);
}
else if (ctx && read && draw) {
retval = glXMakeContextCurrent(dpy,draw->native()->srfc(),read->native()->srfc(),ctx);
diff --git a/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp b/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
index 4f5d75f..1571b3a 100644
--- a/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
+++ b/emulator/opengl/host/libs/Translator/EGL/ThreadInfo.cpp
@@ -14,16 +14,47 @@
* limitations under the License.
*/
-#include <stdio.h>
#include "ThreadInfo.h"
-//#define TRACE_THREADINFO
-#ifdef TRACE_THREADINFO
+#include "emugl/common/lazy_instance.h"
+#include "emugl/common/thread_store.h"
+
+#include <stdio.h>
+
+// Set TRACE_THREADINFO to 1 to debug creation/destruction of ThreadInfo
+// instances.
+#define TRACE_THREADINFO 0
+
+#if TRACE_THREADINFO
#define LOG_THREADINFO(x...) fprintf(stderr, x)
#else
#define LOG_THREADINFO(x...)
#endif
+namespace {
+
+class ThreadInfoStore : public ::emugl::ThreadStore {
+public:
+ ThreadInfoStore() : ::emugl::ThreadStore(&destructor) {}
+
+ size_t getInstanceCount() const { return mNumInstances; }
+
+private:
+ static void destructor(void* value) {
+ LOG_THREADINFO("%s: EFL %p (%d instances)\n", __FUNCTION__,
+ value, mNumInstances);
+ delete static_cast<ThreadInfo*>(value);
+ mNumInstances--;
+ }
+
+ static size_t mNumInstances;
+};
+
+size_t ThreadInfoStore::mNumInstances = 0;
+
+} // namespace
+
+
void ThreadInfo::updateInfo(ContextPtr eglCtx,
EglDisplay* dpy,
GLEScontext* glesCtx,
@@ -37,27 +68,16 @@ void ThreadInfo::updateInfo(ContextPtr eglCtx,
objManager = manager;
}
-#include <cutils/threads.h>
-static thread_store_t s_tls = THREAD_STORE_INITIALIZER;
-static int active_instance = 0;
-static void tlsDestruct(void *ptr)
-{
- active_instance--;
- LOG_THREADINFO("tlsDestruct EGL %lx %d\n", (long)ptr, active_instance);
- if (ptr) {
- ThreadInfo *ti = (ThreadInfo *)ptr;
- delete ti;
- }
-}
+static ::emugl::LazyInstance<ThreadInfoStore> s_tls = LAZY_INSTANCE_INIT;
ThreadInfo *getThreadInfo()
{
- ThreadInfo *ti = (ThreadInfo *)thread_store_get(&s_tls);
+ ThreadInfo *ti = static_cast<ThreadInfo*>(s_tls->get());
if (!ti) {
ti = new ThreadInfo();
- thread_store_set(&s_tls, ti, tlsDestruct);
- active_instance++;
- LOG_THREADINFO("getThreadInfo EGL %lx %d\n", (long)ti, active_instance);
+ s_tls->set(ti);
+ LOG_THREADINFO("%s: EGL %p (%d instances)\n", __FUNCTION__,
+ ti, (int)ThreadInfoStore::getInstanceCount());
}
return ti;
}
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk b/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk
index 9aa74a7..c5e7e6d 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/Android.mk
@@ -18,11 +18,14 @@ $(call emugl-end-module)
### GLES_CM host implementation, 64-bit ########################
-$(call emugl-begin-host-shared-library,lib64GLES_CM_translator)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-shared-library,lib64GLES_CM_translator)
-$(call emugl-import,lib64GLcommon)
+ $(call emugl-import,lib64GLcommon)
-LOCAL_LDLIBS += -m64
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ LOCAL_CFLAGS += -fPIC
+ LOCAL_LDLIBS += -m64
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp
index af5c0d8..66adefb 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.cpp
@@ -51,7 +51,7 @@ GLDispatch::GLDispatch():m_isLoaded(false){};
void GLDispatch::dispatchFuncs() {
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
if(m_isLoaded)
return;
LOAD_GL_FUNC(glActiveTexture);
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h
index 9dc320f..ae8c9f8 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLDispatch.h
@@ -17,7 +17,7 @@
#define GLDISPATCHH
#include <GLES/gl.h>
-#include <utils/threads.h>
+#include "emugl/common/mutex.h"
#define GLAPIENTRY GL_APIENTRY
@@ -151,8 +151,8 @@ public:
void (GLAPIENTRY *glVertexPointer) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
void (GLAPIENTRY *glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
private:
- bool m_isLoaded;
- android::Mutex m_lock;
+ bool m_isLoaded;
+ emugl::Mutex m_lock;
};
#endif
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
index ecf51bb..6476c02 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.cpp
@@ -23,7 +23,7 @@
#include <GLES/glext.h>
void GLEScmContext::init() {
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
if(!m_initialized) {
s_glDispatch.dispatchFuncs(GLES_1_1);
GLEScontext::init();
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
index 1785877..fbb7023 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmContext.h
@@ -23,7 +23,6 @@
#include <map>
#include <vector>
#include <string>
-#include <utils/threads.h>
typedef std::map<GLfloat,std::vector<int> > PointSizeIndices;
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
index 3ae271f..dd74750 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -582,7 +582,7 @@ GL_API void GL_APIENTRY glDrawElements( GLenum mode, GLsizei count, GLenum type
GLESConversionArrays tmpArrs;
if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo
const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER));
- indices = buf+reinterpret_cast<uintptr_t>(elementsIndices);
+ indices = buf + SafeUIntFromPointer(elementsIndices);
}
ctx->setupArraysPointers(tmpArrs,0,count,type,indices,false);
@@ -699,8 +699,6 @@ GL_API void GL_APIENTRY glGetBooleanv( GLenum pname, GLboolean *params) {
return;
}
- GLint i;
-
switch(pname)
{
case GL_FRAMEBUFFER_BINDING_OES:
@@ -745,7 +743,6 @@ GL_API void GL_APIENTRY glGetBufferParameteriv( GLenum target, GLenum pname, GL
GET_CTX()
SET_ERROR_IF(!(GLEScmValidate::bufferTarget(target) && GLEScmValidate::bufferParam(pname)),GL_INVALID_ENUM);
SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
- bool ret = true;
switch(pname) {
case GL_BUFFER_SIZE:
ctx->getBufferSize(target,params);
@@ -787,7 +784,6 @@ GL_API void GL_APIENTRY glGetFixedv( GLenum pname, GLfixed *params) {
size_t nParams = glParamSize(pname);
GLfloat fParams[16];
- GLint i;
switch(pname)
{
@@ -994,9 +990,9 @@ GL_API void GL_APIENTRY glGetPointerv( GLenum pname, void **params) {
if(p) {
if(p->isVBO())
{
- *params = (void*)(p->getBufferOffset());
+ *params = SafePointerFromUInt(p->getBufferOffset());
}else{
- *params = const_cast<void *>( p->getArrayData());
+ *params = const_cast<void *>(p->getArrayData());
}
} else {
ctx->setGLerror(GL_INVALID_ENUM);
@@ -1652,7 +1648,7 @@ GL_API void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglImageOE
{
GET_CTX();
SET_ERROR_IF(!GLEScmValidate::textureTargetLimited(target),GL_INVALID_ENUM);
- unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
+ unsigned int imagehndl = SafeUIntFromPointer(image);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
if (img) {
// Create the texture object in the underlying EGL implementation,
@@ -1688,7 +1684,7 @@ GL_API void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target, GL
{
GET_CTX();
SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
- unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
+ unsigned int imagehndl = SafeUIntFromPointer(image);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
SET_ERROR_IF(!img,GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
@@ -2231,13 +2227,15 @@ void glDrawTexOES (T x, T y, T z, T width, T height) {
int numClipPlanes;
- GLint viewport[4];
+ GLint viewport[4] = {};
z = (z>1 ? 1 : (z<0 ? 0 : z));
- T vertices[4*3] = {x , y, z,
- x , y+height, z,
- x+width, y+height, z,
- x+width, y, z};
+ T vertices[4*3] = {
+ x , y, z,
+ x , static_cast<T>(y+height), z,
+ static_cast<T>(x+width), static_cast<T>(y+height), z,
+ static_cast<T>(x+width), y, z
+ };
GLfloat texels[ctx->getMaxTexUnits()][4*2];
memset((void*)texels, 0, ctx->getMaxTexUnits()*4*2*sizeof(GLfloat));
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk b/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk
index f4845f7..438334a 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/Android.mk
@@ -18,10 +18,12 @@ $(call emugl-end-module)
### GLES_V2 host implementation, 64-bit ##############################
-$(call emugl-begin-host-shared-library,lib64GLES_V2_translator)
-$(call emugl-import, lib64GLcommon)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-shared-library,lib64GLES_V2_translator)
+ $(call emugl-import, lib64GLcommon)
-LOCAL_LDLIBS += -m64
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ LOCAL_LDLIBS += -m64
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
index 1457cec..f8f674b 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.cpp
@@ -15,11 +15,10 @@
*/
#include "GLESv2Context.h"
-
-
+#include <string.h>
void GLESv2Context::init() {
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
if(!m_initialized) {
s_glDispatch.dispatchFuncs(GLES_2_0);
GLEScontext::init();
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
index 75af864..7e71177 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Context.h
@@ -20,7 +20,6 @@
#include <GLcommon/GLDispatch.h>
#include <GLcommon/GLEScontext.h>
#include <GLcommon/objectNameManager.h>
-#include <utils/threads.h>
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
index 7ae9427..fe64f6f 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Imp.cpp
@@ -593,7 +593,7 @@ GL_APICALL void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, GLenum t
const GLvoid* indices = elementsIndices;
if(ctx->isBindedBuffer(GL_ELEMENT_ARRAY_BUFFER)) { // if vbo is binded take the indices from the vbo
const unsigned char* buf = static_cast<unsigned char *>(ctx->getBindedBuffer(GL_ELEMENT_ARRAY_BUFFER));
- indices = buf+reinterpret_cast<uintptr_t>(elementsIndices);
+ indices = buf + SafeUIntFromPointer(elementsIndices);
}
GLESConversionArrays tmpArrs;
@@ -867,7 +867,6 @@ GL_APICALL void GL_APIENTRY glGetBufferParameteriv(GLenum target, GLenum pname,
GET_CTX();
SET_ERROR_IF(!(GLESv2Validate::bufferTarget(target) && GLESv2Validate::bufferParam(pname)),GL_INVALID_ENUM);
SET_ERROR_IF(!ctx->isBindedBuffer(target),GL_INVALID_OPERATION);
- bool ret = true;
switch(pname) {
case GL_BUFFER_SIZE:
ctx->getBufferSize(target,params);
@@ -941,11 +940,19 @@ GL_APICALL void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat* params){
}
GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params){
+ int destroyCtx = 0;
GET_CTX();
+ if (!ctx) {
+ ctx = createGLESContext();
+ if (ctx)
+ destroyCtx = 1;
+ }
if (ctx->glGetIntegerv(pname,params))
{
- return;
+ if (destroyCtx)
+ deleteGLESContext(ctx);
+ return;
}
bool es2 = ctx->getCaps()->GL_ARB_ES2_COMPATIBILITY;
@@ -1031,6 +1038,8 @@ GL_APICALL void GL_APIENTRY glGetIntegerv(GLenum pname, GLint* params){
default:
ctx->dispatcher().glGetIntegerv(pname,params);
}
+ if (destroyCtx)
+ deleteGLESContext(ctx);
}
GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv(GLenum target, GLenum attachment, GLenum pname, GLint* params){
@@ -2006,7 +2015,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES(GLenum target, GLeglIma
{
GET_CTX();
SET_ERROR_IF(!GLESv2Validate::textureTargetLimited(target),GL_INVALID_ENUM);
- unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
+ unsigned int imagehndl = SafeUIntFromPointer(image);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
if (img) {
// Create the texture object in the underlying EGL implementation,
@@ -2042,7 +2051,7 @@ GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES(GLenum target
{
GET_CTX();
SET_ERROR_IF(target != GL_RENDERBUFFER_OES,GL_INVALID_ENUM);
- unsigned int imagehndl = ToTargetCompatibleHandle((uintptr_t)image);
+ unsigned int imagehndl = SafeUIntFromPointer(image);
EglImage *img = s_eglIface->eglAttachEGLImage(imagehndl);
SET_ERROR_IF(!img,GL_INVALID_VALUE);
SET_ERROR_IF(!ctx->shareGroup().Ptr(),GL_INVALID_OPERATION);
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
index 53d1314..3f00428 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/GLESv2Validate.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
#include "GLESv2Validate.h"
+#include <string.h>
bool GLESv2Validate::blendEquationMode(GLenum mode){
return mode == GL_FUNC_ADD ||
diff --git a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
index a80326d..940538a 100644
--- a/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_V2/ShaderParser.cpp
@@ -15,6 +15,7 @@
*/
#include "ShaderParser.h"
+#include <stdlib.h>
#include <string.h>
ShaderParser::ShaderParser():ObjectData(SHADER_DATA),
@@ -223,8 +224,7 @@ void ShaderParser::parseOmitPrecision(){
SEMICOLON
} statementState = PRECISION;
const char *precision = NULL;
- const char *delimiter = NULL;
-
+
enum {
PARSE_NONE,
PARSE_IN_C_COMMENT,
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk b/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
index 1236566..b215329 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
+++ b/emulator/opengl/host/libs/Translator/GLcommon/Android.mk
@@ -41,21 +41,23 @@ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
$(call emugl-export,LDLIBS,$(host_common_LDLIBS))
$(call emugl-export,LDFLAGS,$(host_common_LDFLAGS))
$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared)
-$(call emugl-export,STATIC_LIBRARIES, libcutils libutils liblog)
+$(call emugl-export,STATIC_LIBRARIES, libemugl_common)
$(call emugl-end-module)
### EGL host implementation, 64-bit ################
-
-$(call emugl-begin-host-static-library,lib64GLcommon)
-
-$(call emugl-import,lib64OpenglOsUtils)
-translator_path := $(LOCAL_PATH)/..
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-$(call emugl-export,LDLIBS,$(host_common_LDLIBS))
-$(call emugl-export,LDFLAGS,$(host_common_LDFLAGS))
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared)
-$(call emugl-export,STATIC_LIBRARIES, lib64cutils lib64utils lib64log)
-
-$(call emugl-end-module)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64GLcommon)
+
+ $(call emugl-import,lib64OpenglOsUtils)
+ translator_path := $(LOCAL_PATH)/..
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ LOCAL_CFLAGS += -fPIC
+ $(call emugl-export,LDLIBS,$(host_common_LDLIBS))
+ $(call emugl-export,LDFLAGS,$(host_common_LDFLAGS))
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/../include $(EMUGL_PATH)/shared)
+ $(call emugl-export,STATIC_LIBRARIES, lib64emugl_common)
+
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
index abed760..7b217fd 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/GLDispatch.cpp
@@ -45,29 +45,30 @@ static GL_FUNC_PTR getGLFuncAddress(const char *funcName) {
return ret;
}
-#define LOAD_GL_FUNC(name) { void * funcAddrs = NULL; \
- if(name == NULL){ \
- funcAddrs = (void *)getGLFuncAddress(#name); \
- if(funcAddrs){ \
- *(void**)(&name) = funcAddrs; \
- } else { \
- fprintf(stderr,"could not load func %s\n",#name); \
- *(void**)(&name) = (void *)dummy_##name; \
- } \
- } \
- }
+#define LOAD_GL_FUNC(name) do { \
+ if (!name) { \
+ void* funcAddress = (void *)getGLFuncAddress(#name); \
+ if (funcAddress) { \
+ name = (__typeof__(name))(funcAddress); \
+ } else { \
+ fprintf(stderr, "Could not load func %s\n", #name); \
+ name = (__typeof__(name))(dummy_##name); \
+ } \
+ } \
+ } while (0)
-#define LOAD_GLEXT_FUNC(name) { void * funcAddrs = NULL; \
- if(name == NULL){ \
- funcAddrs = (void *)getGLFuncAddress(#name); \
- if(funcAddrs) \
- *(void**)(&name) = funcAddrs; \
- } \
- }
+#define LOAD_GLEXT_FUNC(name) do { \
+ if (!name) { \
+ void* funcAddress = (void *)getGLFuncAddress(#name); \
+ if (funcAddress) { \
+ name = (__typeof__(name))(funcAddress); \
+ } \
+ } \
+ } while (0)
/* initializing static GLDispatch members*/
-android::Mutex GLDispatch::s_lock;
+emugl::Mutex GLDispatch::s_lock;
void (GLAPIENTRY *GLDispatch::glActiveTexture)(GLenum) = NULL;
void (GLAPIENTRY *GLDispatch::glBindBuffer)(GLenum,GLuint) = NULL;
void (GLAPIENTRY *GLDispatch::glBindTexture)(GLenum, GLuint) = NULL;
@@ -298,7 +299,7 @@ GLDispatch::GLDispatch():m_isLoaded(false){};
void GLDispatch::dispatchFuncs(GLESVersion version){
- android::Mutex::Autolock mutex(s_lock);
+ emugl::Mutex::AutoLock mutex(s_lock);
if(m_isLoaded)
return;
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp b/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
index 387eb2d..ba3edbe 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/GLEScontext.cpp
@@ -23,6 +23,7 @@
#include <GLcommon/TextureUtils.h>
#include <GLcommon/FramebufferData.h>
#include <strings.h>
+#include <string.h>
//decleration
static void convertFixedDirectLoop(const char* dataIn,unsigned int strideIn,void* dataOut,unsigned int nBytes,unsigned int strideOut,int attribSize);
@@ -84,7 +85,7 @@ void GLESConversionArrays::operator++(){
}
GLDispatch GLEScontext::s_glDispatch;
-android::Mutex GLEScontext::s_lock;
+emugl::Mutex GLEScontext::s_lock;
std::string* GLEScontext::s_glExtensions= NULL;
std::string GLEScontext::s_glVendor;
std::string GLEScontext::s_glRenderer;
@@ -191,7 +192,7 @@ GLEScontext::~GLEScontext() {
const GLvoid* GLEScontext::setPointer(GLenum arrType,GLint size,GLenum type,GLsizei stride,const GLvoid* data,bool normalize) {
GLuint bufferName = m_arrayBuffer;
if(bufferName) {
- unsigned int offset = ToTargetCompatibleHandle((uintptr_t)data);
+ unsigned int offset = SafeUIntFromPointer(data);
GLESbuffer* vbo = static_cast<GLESbuffer*>(m_shareGroup->getObjectData(VERTEXBUFFER,bufferName).Ptr());
m_map[arrType]->setBuffer(size,type,stride,vbo,bufferName,offset,normalize);
return static_cast<const unsigned char*>(vbo->getData()) + offset;
@@ -329,10 +330,8 @@ void GLEScontext::convertDirectVBO(GLESConversionArrays& cArrs,GLint first,GLsiz
RangeList ranges;
RangeList conversions;
GLushort* indices = NULL;
- GLenum type = p->getType();
int attribSize = p->getSize();
int stride = p->getStride()?p->getStride():sizeof(GLfixed)*attribSize;
- unsigned int size = p->getStride()?p->getStride()*count:attribSize*count*sizeof(GLfixed);
char* data = (char*)p->getBufferData() + (first*stride);
if(p->bufferNeedConversion()) {
@@ -388,7 +387,6 @@ void GLEScontext::convertIndirectVBO(GLESConversionArrays& cArrs,GLsizei count,G
RangeList ranges;
RangeList conversions;
GLushort* conversionIndices = NULL;
- GLenum type = p->getType();
int attribSize = p->getSize();
int stride = p->getStride()?p->getStride():sizeof(GLfixed)*attribSize;
char* data = static_cast<char*>(p->getBufferData());
@@ -679,6 +677,10 @@ bool GLEScontext::glGetIntegerv(GLenum pname, GLint *params)
case GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES:
*params = GL_RGBA;
break;
+
+ case GL_MAX_TEXTURE_SIZE:
+ *params = getMaxTexSize();
+ break;
default:
return false;
}
diff --git a/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp b/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp
index cfea855..3612211 100644
--- a/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp
+++ b/emulator/opengl/host/libs/Translator/GLcommon/objectNameManager.cpp
@@ -18,12 +18,11 @@
#include <GLcommon/GLEScontext.h>
-NameSpace::NameSpace(NamedObjectType p_type, GlobalNameSpace *globalNameSpace) :
+NameSpace::NameSpace(NamedObjectType p_type,
+ GlobalNameSpace *globalNameSpace) :
m_nextName(0),
m_type(p_type),
- m_globalNameSpace(globalNameSpace)
-{
-}
+ m_globalNameSpace(globalNameSpace) {}
NameSpace::~NameSpace()
{
@@ -35,14 +34,16 @@ NameSpace::~NameSpace()
}
ObjectLocalName
-NameSpace::genName(ObjectLocalName p_localName, bool genGlobal, bool genLocal)
+NameSpace::genName(ObjectLocalName p_localName,
+ bool genGlobal, bool genLocal)
{
-
ObjectLocalName localName = p_localName;
if (genLocal) {
do {
localName = ++m_nextName;
- } while( localName == 0 || m_localToGlobalMap.find(localName) != m_localToGlobalMap.end() );
+ } while(localName == 0 ||
+ m_localToGlobalMap.find(localName) !=
+ m_localToGlobalMap.end() );
}
if (genGlobal) {
@@ -114,15 +115,9 @@ NameSpace::replaceGlobalName(ObjectLocalName p_localName, unsigned int p_globalN
}
-GlobalNameSpace::GlobalNameSpace()
-{
- mutex_init(&m_lock);
-}
+GlobalNameSpace::GlobalNameSpace() : m_lock() {}
-GlobalNameSpace::~GlobalNameSpace()
-{
- mutex_destroy(&m_lock);
-}
+GlobalNameSpace::~GlobalNameSpace() {}
unsigned int
GlobalNameSpace::genName(NamedObjectType p_type)
@@ -130,7 +125,7 @@ GlobalNameSpace::genName(NamedObjectType p_type)
if ( p_type >= NUM_OBJECT_TYPES ) return 0;
unsigned int name = 0;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
switch (p_type) {
case VERTEXBUFFER:
GLEScontext::dispatcher().glGenBuffers(1,&name);
@@ -148,7 +143,6 @@ GlobalNameSpace::genName(NamedObjectType p_type)
default:
name = 0;
}
- mutex_unlock(&m_lock);
return name;
}
@@ -160,11 +154,8 @@ GlobalNameSpace::deleteName(NamedObjectType p_type, unsigned int p_name)
typedef std::pair<NamedObjectType, ObjectLocalName> ObjectIDPair;
typedef std::map<ObjectIDPair, ObjectDataPtr> ObjectDataMap;
-ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace)
-{
- mutex_init(&m_lock);
-
- for (int i=0; i<NUM_OBJECT_TYPES; i++) {
+ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace) : m_lock() {
+ for (int i=0; i < NUM_OBJECT_TYPES; i++) {
m_nameSpace[i] = new NameSpace((NamedObjectType)i, globalNameSpace);
}
@@ -173,27 +164,24 @@ ShareGroup::ShareGroup(GlobalNameSpace *globalNameSpace)
ShareGroup::~ShareGroup()
{
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
for (int t = 0; t < NUM_OBJECT_TYPES; t++) {
delete m_nameSpace[t];
}
- ObjectDataMap *map = (ObjectDataMap *)m_objectsData;
- if (map) delete map;
-
- mutex_unlock(&m_lock);
- mutex_destroy(&m_lock);
+ delete (ObjectDataMap *)m_objectsData;
}
ObjectLocalName
-ShareGroup::genName(NamedObjectType p_type, ObjectLocalName p_localName, bool genLocal)
+ShareGroup::genName(NamedObjectType p_type,
+ ObjectLocalName p_localName,
+ bool genLocal)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- ObjectLocalName localName = m_nameSpace[p_type]->genName(p_localName,true,genLocal);
- mutex_unlock(&m_lock);
-
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ObjectLocalName localName =
+ m_nameSpace[p_type]->genName(p_localName, true, genLocal);
return localName;
}
@@ -202,35 +190,28 @@ ShareGroup::genGlobalName(NamedObjectType p_type)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- unsigned int name = m_nameSpace[p_type]->genGlobalName();
- mutex_unlock(&m_lock);
-
- return name;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return m_nameSpace[p_type]->genGlobalName();
}
unsigned int
-ShareGroup::getGlobalName(NamedObjectType p_type, ObjectLocalName p_localName)
+ShareGroup::getGlobalName(NamedObjectType p_type,
+ ObjectLocalName p_localName)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- unsigned int globalName = m_nameSpace[p_type]->getGlobalName(p_localName);
- mutex_unlock(&m_lock);
-
- return globalName;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return m_nameSpace[p_type]->getGlobalName(p_localName);
}
ObjectLocalName
-ShareGroup::getLocalName(NamedObjectType p_type, unsigned int p_globalName)
+ShareGroup::getLocalName(NamedObjectType p_type,
+ unsigned int p_globalName)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- ObjectLocalName localName = m_nameSpace[p_type]->getLocalName(p_globalName);
- mutex_unlock(&m_lock);
-
- return localName;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return m_nameSpace[p_type]->getLocalName(p_globalName);
}
void
@@ -238,13 +219,12 @@ ShareGroup::deleteName(NamedObjectType p_type, ObjectLocalName p_localName)
{
if (p_type >= NUM_OBJECT_TYPES) return;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
m_nameSpace[p_type]->deleteName(p_localName);
ObjectDataMap *map = (ObjectDataMap *)m_objectsData;
if (map) {
map->erase( ObjectIDPair(p_type, p_localName) );
}
- mutex_unlock(&m_lock);
}
bool
@@ -252,29 +232,29 @@ ShareGroup::isObject(NamedObjectType p_type, ObjectLocalName p_localName)
{
if (p_type >= NUM_OBJECT_TYPES) return 0;
- mutex_lock(&m_lock);
- bool exist = m_nameSpace[p_type]->isObject(p_localName);
- mutex_unlock(&m_lock);
-
- return exist;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return m_nameSpace[p_type]->isObject(p_localName);
}
void
-ShareGroup::replaceGlobalName(NamedObjectType p_type, ObjectLocalName p_localName, unsigned int p_globalName)
+ShareGroup::replaceGlobalName(NamedObjectType p_type,
+ ObjectLocalName p_localName,
+ unsigned int p_globalName)
{
if (p_type >= NUM_OBJECT_TYPES) return;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
m_nameSpace[p_type]->replaceGlobalName(p_localName, p_globalName);
- mutex_unlock(&m_lock);
}
void
-ShareGroup::setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, ObjectDataPtr data)
+ShareGroup::setObjectData(NamedObjectType p_type,
+ ObjectLocalName p_localName,
+ ObjectDataPtr data)
{
if (p_type >= NUM_OBJECT_TYPES) return;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ObjectDataMap *map = (ObjectDataMap *)m_objectsData;
if (!map) {
@@ -284,45 +264,36 @@ ShareGroup::setObjectData(NamedObjectType p_type, ObjectLocalName p_localName, O
ObjectIDPair id( p_type, p_localName );
map->insert( std::pair<ObjectIDPair, ObjectDataPtr>(id, data) );
-
- mutex_unlock(&m_lock);
}
ObjectDataPtr
-ShareGroup::getObjectData(NamedObjectType p_type, ObjectLocalName p_localName)
+ShareGroup::getObjectData(NamedObjectType p_type,
+ ObjectLocalName p_localName)
{
ObjectDataPtr ret;
if (p_type >= NUM_OBJECT_TYPES) return ret;
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ObjectDataMap *map = (ObjectDataMap *)m_objectsData;
if (map) {
- ObjectDataMap::iterator i = map->find( ObjectIDPair(p_type, p_localName) );
+ ObjectDataMap::iterator i =
+ map->find( ObjectIDPair(p_type, p_localName) );
if (i != map->end()) ret = (*i).second;
}
-
- mutex_unlock(&m_lock);
-
return ret;
}
ObjectNameManager::ObjectNameManager(GlobalNameSpace *globalNameSpace) :
- m_globalNameSpace(globalNameSpace)
-{
- mutex_init(&m_lock);
-}
+ m_lock(), m_globalNameSpace(globalNameSpace) {}
-ObjectNameManager::~ObjectNameManager()
-{
- mutex_destroy(&m_lock);
-}
+ObjectNameManager::~ObjectNameManager() {}
ShareGroupPtr
ObjectNameManager::createShareGroup(void *p_groupName)
{
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ShareGroupPtr shareGroupReturn;
@@ -334,19 +305,19 @@ ObjectNameManager::createShareGroup(void *p_groupName)
//
// Group does not exist, create new group
//
- shareGroupReturn = ShareGroupPtr( new ShareGroup(m_globalNameSpace) );
- m_groups.insert( std::pair<void *, ShareGroupPtr>(p_groupName, shareGroupReturn) );
+ shareGroupReturn = ShareGroupPtr(new ShareGroup(m_globalNameSpace));
+ m_groups.insert(
+ std::pair<void*, ShareGroupPtr>(
+ p_groupName, shareGroupReturn));
}
- mutex_unlock(&m_lock);
-
return shareGroupReturn;
}
ShareGroupPtr
ObjectNameManager::getShareGroup(void *p_groupName)
{
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ShareGroupPtr shareGroupReturn(NULL);
@@ -354,58 +325,45 @@ ObjectNameManager::getShareGroup(void *p_groupName)
if (s != m_groups.end()) {
shareGroupReturn = (*s).second;
}
- mutex_unlock(&m_lock);
return shareGroupReturn;
}
ShareGroupPtr
-ObjectNameManager::attachShareGroup(void *p_groupName, void *p_existingGroupName)
+ObjectNameManager::attachShareGroup(void *p_groupName,
+ void *p_existingGroupName)
{
- mutex_lock(&m_lock);
-
- ShareGroupPtr shareGroupReturn;
+ emugl::Mutex::AutoLock _lock(m_lock);
ShareGroupsMap::iterator s( m_groups.find(p_existingGroupName) );
if (s == m_groups.end()) {
// ShareGroup did not found !!!
- mutex_unlock(&m_lock);
return ShareGroupPtr(NULL);
}
- shareGroupReturn = (*s).second;
-
- if (m_groups.find(p_groupName) == m_groups.end())
- {
- m_groups.insert( std::pair<void *, ShareGroupPtr>(p_groupName, shareGroupReturn) );
+ ShareGroupPtr shareGroupReturn((*s).second);
+ if (m_groups.find(p_groupName) == m_groups.end()) {
+ m_groups.insert(
+ std::pair<void*, ShareGroupPtr>(
+ p_groupName, shareGroupReturn));
}
-
- mutex_unlock(&m_lock);
-
return shareGroupReturn;
}
void
ObjectNameManager::deleteShareGroup(void *p_groupName)
{
- mutex_lock(&m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ShareGroupsMap::iterator s( m_groups.find(p_groupName) );
if (s != m_groups.end()) {
m_groups.erase(s);
}
-
- mutex_unlock(&m_lock);
}
void *ObjectNameManager::getGlobalContext()
{
- void *ret = NULL;
-
- mutex_lock(&m_lock);
- if (m_groups.size() > 0) ret = (*m_groups.begin()).first;
- mutex_unlock(&m_lock);
-
- return ret;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return (m_groups.size() > 0) ? (*m_groups.begin()).first : NULL;
}
diff --git a/emulator/opengl/host/libs/Translator/include/ETC1/etc1.h b/emulator/opengl/host/libs/Translator/include/ETC1/etc1.h
new file mode 100644
index 0000000..0d38905
--- /dev/null
+++ b/emulator/opengl/host/libs/Translator/include/ETC1/etc1.h
@@ -0,0 +1,106 @@
+// Copyright 2009 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef __etc1_h__
+#define __etc1_h__
+
+#define ETC1_ENCODED_BLOCK_SIZE 8
+#define ETC1_DECODED_BLOCK_SIZE 48
+
+#ifndef ETC1_RGB8_OES
+#define ETC1_RGB8_OES 0x8D64
+#endif
+
+typedef unsigned char etc1_byte;
+typedef int etc1_bool;
+typedef unsigned int etc1_uint32;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Encode a block of pixels.
+//
+// pIn is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
+// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
+// value of pixel (x, y).
+//
+// validPixelMask is a 16-bit mask where bit (1 << (x + y * 4)) indicates whether
+// the corresponding (x,y) pixel is valid. Invalid pixel color values are ignored when compressing.
+//
+// pOut is an ETC1 compressed version of the data.
+
+void etc1_encode_block(const etc1_byte* pIn, etc1_uint32 validPixelMask, etc1_byte* pOut);
+
+// Decode a block of pixels.
+//
+// pIn is an ETC1 compressed version of the data.
+//
+// pOut is a pointer to a ETC_DECODED_BLOCK_SIZE array of bytes that represent a
+// 4 x 4 square of 3-byte pixels in form R, G, B. Byte (3 * (x + 4 * y) is the R
+// value of pixel (x, y).
+
+void etc1_decode_block(const etc1_byte* pIn, etc1_byte* pOut);
+
+// Return the size of the encoded image data (does not include size of PKM header).
+
+etc1_uint32 etc1_get_encoded_data_size(etc1_uint32 width, etc1_uint32 height);
+
+// Encode an entire image.
+// pIn - pointer to the image data. Formatted such that
+// pixel (x,y) is at pIn + pixelSize * x + stride * y;
+// pOut - pointer to encoded data. Must be large enough to store entire encoded image.
+// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
+// returns non-zero if there is an error.
+
+int etc1_encode_image(const etc1_byte* pIn, etc1_uint32 width, etc1_uint32 height,
+ etc1_uint32 pixelSize, etc1_uint32 stride, etc1_byte* pOut);
+
+// Decode an entire image.
+// pIn - pointer to encoded data.
+// pOut - pointer to the image data. Will be written such that
+// pixel (x,y) is at pIn + pixelSize * x + stride * y. Must be
+// large enough to store entire image.
+// pixelSize can be 2 or 3. 2 is an GL_UNSIGNED_SHORT_5_6_5 image, 3 is a GL_BYTE RGB image.
+// returns non-zero if there is an error.
+
+int etc1_decode_image(const etc1_byte* pIn, etc1_byte* pOut,
+ etc1_uint32 width, etc1_uint32 height,
+ etc1_uint32 pixelSize, etc1_uint32 stride);
+
+// Size of a PKM header, in bytes.
+
+#define ETC_PKM_HEADER_SIZE 16
+
+// Format a PKM header
+
+void etc1_pkm_format_header(etc1_byte* pHeader, etc1_uint32 width, etc1_uint32 height);
+
+// Check if a PKM header is correctly formatted.
+
+etc1_bool etc1_pkm_is_valid(const etc1_byte* pHeader);
+
+// Read the image width from a PKM header
+
+etc1_uint32 etc1_pkm_get_width(const etc1_byte* pHeader);
+
+// Read the image height from a PKM header
+
+etc1_uint32 etc1_pkm_get_height(const etc1_byte* pHeader);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
index de7d563..18a989c 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLDispatch.h
@@ -18,7 +18,7 @@
#include <GLES/gl.h>
#include <GLES2/gl2.h>
-#include <utils/threads.h>
+#include "emugl/common/mutex.h"
#include "gldefs.h"
#include "GLutils.h"
@@ -260,8 +260,8 @@ public:
static void (GL_APIENTRY *glShaderSource)(GLuint shader, GLsizei count, const GLchar** string, const GLint* length);
private:
- bool m_isLoaded;
- static android::Mutex s_lock;
+ bool m_isLoaded;
+ static emugl::Mutex s_lock;
};
#endif
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h
index 3353ec1..38429d1 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLESbuffer.h
@@ -43,5 +43,5 @@ private:
bool m_wasBound;
};
-typedef SmartPtr<GLESbuffer> GLESbufferPtr;
+typedef emugl::SmartPtr<GLESbuffer> GLESbufferPtr;
#endif
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
index 20509fc..5aed0ad 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLEScontext.h
@@ -20,7 +20,7 @@
#include "GLDispatch.h"
#include "GLESpointer.h"
#include "objectNameManager.h"
-#include <utils/threads.h>
+#include "emugl/common/mutex.h"
#include <string>
typedef std::map<GLenum,GLESpointer*> ArraysMap;
@@ -187,7 +187,7 @@ protected:
void initCapsLocked(const GLubyte * extensionString);
virtual void initExtensionString() =0;
- static android::Mutex s_lock;
+ static emugl::Mutex s_lock;
static GLDispatch s_glDispatch;
bool m_initialized;
unsigned int m_activeTexture;
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h b/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
index 2aed646..974b9be 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/GLutils.h
@@ -16,36 +16,37 @@
#ifndef GL_UTILS_H
#define GL_UTILS_H
-#include <inttypes.h>
#include <assert.h>
+#include <inttypes.h>
-typedef enum{
- GLES_1_1 = 1,
- GLES_2_0 = 2,
- MAX_GLES_VERSION //Must be last
- }GLESVersion;
+typedef enum {
+ GLES_1_1 = 1,
+ GLES_2_0 = 2,
+ MAX_GLES_VERSION //Must be last
+} GLESVersion;
template <class T>
void swap(T& x,T& y) {
T temp;
- temp=x;
- x=y;
- y=temp;
+ temp = x;
+ x = y;
+ y = temp;
}
bool isPowerOf2(int num);
-inline
-unsigned int ToTargetCompatibleHandle(uintptr_t hostHandle)
-{
- // The host and target handles can have different sizes (e.g. 32-bit
- // target handle for ARM, and 64-bit host handle on x86_64).
- // This function checks that the input host handle value can be
- // converted into a target handle one without losing any bits.
- //
- unsigned int targetHandle = (unsigned int)hostHandle;
- assert(sizeof(targetHandle) == sizeof(hostHandle) || targetHandle == hostHandle);
- return targetHandle;
+// <EGL/egl.h> defines many types as 'void*' while they're really
+// implemented as unsigned integers. These convenience template functions
+// help casting between them safely without generating compiler warnings.
+inline void* SafePointerFromUInt(unsigned int handle) {
+ return (void*)(uintptr_t)(handle);
+}
+
+inline unsigned int SafeUIntFromPointer(const void* ptr) {
+ // Assertion error if the pointer contains a value that does not fit
+ // in an unsigned integer!
+ assert((uintptr_t)(ptr) == (unsigned int)(uintptr_t)(ptr));
+ return (unsigned int)(uintptr_t)(ptr);
}
#endif
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h b/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h
deleted file mode 100644
index 8ac93fb..0000000
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/SmartPtr.h
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
-* Copyright (C) 2011 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __SMART_PTR_H
-#define __SMART_PTR_H
-
-#include <cutils/threads.h>
-#include <cutils/atomic.h>
-
-template <class T, bool threadSafe = false>
-class SmartPtr
-{
-public:
- explicit SmartPtr(T* ptr = (T*)NULL) {
- if (threadSafe) {
- m_lock = new mutex_t;
- mutex_init(m_lock);
- }
- else m_lock = NULL;
-
- m_ptr = ptr;
- if (ptr)
- m_pRefCount = new int32_t(1);
- else
- m_pRefCount = NULL;
- }
-
- SmartPtr<T,threadSafe>(const SmartPtr<T,false>& rhs) {
- if (threadSafe) {
- m_lock = new mutex_t;
- mutex_init(m_lock);
- }
- else m_lock = NULL;
-
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- }
-
- SmartPtr<T,threadSafe>(SmartPtr<T,true>& rhs) {
- if (threadSafe) {
- m_lock = new mutex_t;
- mutex_init(m_lock);
- }
- else m_lock = NULL;
-
- if (rhs.m_lock) mutex_lock(rhs.m_lock);
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- if (rhs.m_lock) mutex_unlock(rhs.m_lock);
- }
-
- ~SmartPtr() {
- if (m_lock) mutex_lock(m_lock);
- release();
- if (m_lock)
- {
- mutex_unlock(m_lock);
- mutex_destroy(m_lock);
- delete m_lock;
- }
- }
-
- T* Ptr() const {
- return m_ptr;
- }
-
- const T* constPtr() const
- {
- return m_ptr;
- }
-
- T* operator->() const {
- return m_ptr;
- }
-
- T& operator*() const {
- return *m_ptr;
- }
-
- // This gives STL lists something to compare.
- bool operator <(const SmartPtr<T>& t1) const {
- return m_ptr < t1.m_ptr;
- }
-
- SmartPtr<T,threadSafe>& operator=(const SmartPtr<T,false>& rhs)
- {
- if (m_ptr == rhs.m_ptr)
- return *this;
-
- if (m_lock) mutex_lock(m_lock);
- release();
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- if (m_lock) mutex_unlock(m_lock);
-
- return *this;
- }
-
- SmartPtr<T,threadSafe>& operator=(SmartPtr<T,true>& rhs)
- {
- if (m_ptr == rhs.m_ptr)
- return *this;
-
- if (m_lock) mutex_lock(m_lock);
- release();
- if (rhs.m_lock) mutex_lock(rhs.m_lock);
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- if (rhs.m_lock) mutex_unlock(rhs.m_lock);
- if (m_lock) mutex_unlock(m_lock);
-
- return *this;
- }
-
-private:
- int32_t *m_pRefCount;
- mutex_t *m_lock;
- T* m_ptr;
-
- // Increment the reference count on this pointer by 1.
- int use() {
- if (!m_pRefCount) return 0;
- return android_atomic_inc(m_pRefCount) + 1;
- }
-
- // Decrement the reference count on the pointer by 1.
- // If the reference count goes to (or below) 0, the pointer is deleted.
- int release() {
- if (!m_pRefCount) return 0;
-
- int iVal = android_atomic_dec(m_pRefCount);
- if (iVal > 1)
- return iVal - 1;
-
- delete m_pRefCount;
- m_pRefCount = NULL;
-
- if (m_ptr) {
- delete m_ptr;
- m_ptr = NULL;
- }
- return 0;
- }
-
-};
-
-#endif // of __SMART_PTR_H
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h b/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
index 3c5e15a..e0d1bfb 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/TranslatorIfaces.h
@@ -74,8 +74,8 @@ struct EglImage
unsigned int border;
};
-typedef SmartPtr<EglImage> ImagePtr;
-typedef std::map< unsigned int, ImagePtr> ImagesHndlMap;
+typedef emugl::SmartPtr<EglImage> ImagePtr;
+typedef std::map< unsigned int, ImagePtr> ImagesHndlMap;
class GLEScontext;
diff --git a/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h b/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h
index 605fd29..4d4d038 100644
--- a/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h
+++ b/emulator/opengl/host/libs/Translator/include/GLcommon/objectNameManager.h
@@ -16,9 +16,9 @@
#ifndef _OBJECT_NAME_MANAGER_H
#define _OBJECT_NAME_MANAGER_H
-#include <cutils/threads.h>
#include <map>
-#include "SmartPtr.h"
+#include "emugl/common/mutex.h"
+#include "emugl/common/smart_ptr.h"
enum NamedObjectType {
VERTEXBUFFER = 0,
@@ -47,7 +47,7 @@ public:
private:
ObjectDataType m_dataType;
};
-typedef SmartPtr<ObjectData> ObjectDataPtr;
+typedef emugl::SmartPtr<ObjectData> ObjectDataPtr;
typedef unsigned long long ObjectLocalName;
typedef std::map<ObjectLocalName, unsigned int> NamesMap;
@@ -129,7 +129,7 @@ public:
void deleteName(NamedObjectType p_type, unsigned int p_name);
private:
- mutex_t m_lock;
+ emugl::Mutex m_lock;
};
//
@@ -143,7 +143,7 @@ private:
class ShareGroup
{
friend class ObjectNameManager;
- friend class SmartPtr<ShareGroup>; // to allow destructing when ShareGroupPtr refcount reaches zero
+ friend class emugl::SmartPtr<ShareGroup>; // to allow destructing when ShareGroupPtr refcount reaches zero
public:
@@ -204,12 +204,12 @@ private:
~ShareGroup();
private:
- mutex_t m_lock;
+ emugl::Mutex m_lock;
NameSpace *m_nameSpace[NUM_OBJECT_TYPES];
void *m_objectsData;
};
-typedef SmartPtr<ShareGroup> ShareGroupPtr;
+typedef emugl::SmartPtr<ShareGroup> ShareGroupPtr;
typedef std::multimap<void *, ShareGroupPtr> ShareGroupsMap;
//
@@ -262,7 +262,7 @@ public:
private:
ShareGroupsMap m_groups;
- mutex_t m_lock;
+ emugl::Mutex m_lock;
GlobalNameSpace *m_globalNameSpace;
};
diff --git a/emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h b/emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h
new file mode 100644
index 0000000..c9e6f17
--- /dev/null
+++ b/emulator/opengl/host/libs/Translator/include/KHR/khrplatform.h
@@ -0,0 +1,282 @@
+#ifndef __khrplatform_h_
+#define __khrplatform_h_
+
+/*
+** Copyright (c) 2008-2009 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be included
+** in all copies or substantial portions of the Materials.
+**
+** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+/* Khronos platform-specific types and definitions.
+ *
+ * $Revision: 23298 $ on $Date: 2013-09-30 17:07:13 -0700 (Mon, 30 Sep 2013) $
+ *
+ * Adopters may modify this file to suit their platform. Adopters are
+ * encouraged to submit platform specific modifications to the Khronos
+ * group so that they can be included in future versions of this file.
+ * Please submit changes by sending them to the public Khronos Bugzilla
+ * (http://khronos.org/bugzilla) by filing a bug against product
+ * "Khronos (general)" component "Registry".
+ *
+ * A predefined template which fills in some of the bug fields can be
+ * reached using http://tinyurl.com/khrplatform-h-bugreport, but you
+ * must create a Bugzilla login first.
+ *
+ *
+ * See the Implementer's Guidelines for information about where this file
+ * should be located on your system and for more details of its use:
+ * http://www.khronos.org/registry/implementers_guide.pdf
+ *
+ * This file should be included as
+ * #include <KHR/khrplatform.h>
+ * by Khronos client API header files that use its types and defines.
+ *
+ * The types in khrplatform.h should only be used to define API-specific types.
+ *
+ * Types defined in khrplatform.h:
+ * khronos_int8_t signed 8 bit
+ * khronos_uint8_t unsigned 8 bit
+ * khronos_int16_t signed 16 bit
+ * khronos_uint16_t unsigned 16 bit
+ * khronos_int32_t signed 32 bit
+ * khronos_uint32_t unsigned 32 bit
+ * khronos_int64_t signed 64 bit
+ * khronos_uint64_t unsigned 64 bit
+ * khronos_intptr_t signed same number of bits as a pointer
+ * khronos_uintptr_t unsigned same number of bits as a pointer
+ * khronos_ssize_t signed size
+ * khronos_usize_t unsigned size
+ * khronos_float_t signed 32 bit floating point
+ * khronos_time_ns_t unsigned 64 bit time in nanoseconds
+ * khronos_utime_nanoseconds_t unsigned time interval or absolute time in
+ * nanoseconds
+ * khronos_stime_nanoseconds_t signed time interval in nanoseconds
+ * khronos_boolean_enum_t enumerated boolean type. This should
+ * only be used as a base type when a client API's boolean type is
+ * an enum. Client APIs which use an integer or other type for
+ * booleans cannot use this as the base type for their boolean.
+ *
+ * Tokens defined in khrplatform.h:
+ *
+ * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
+ *
+ * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
+ * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
+ *
+ * Calling convention macros defined in this file:
+ * KHRONOS_APICALL
+ * KHRONOS_APIENTRY
+ * KHRONOS_APIATTRIBUTES
+ *
+ * These may be used in function prototypes as:
+ *
+ * KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
+ * int arg1,
+ * int arg2) KHRONOS_APIATTRIBUTES;
+ */
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APICALL
+ *-------------------------------------------------------------------------
+ * This precedes the return type of the function in the function prototype.
+ */
+#if defined(_WIN32) && !defined(__SCITECH_SNAP__)
+# define KHRONOS_APICALL __declspec(dllimport)
+#elif defined (__SYMBIAN32__)
+# define KHRONOS_APICALL IMPORT_C
+#else
+# define KHRONOS_APICALL
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIENTRY
+ *-------------------------------------------------------------------------
+ * This follows the return type of the function and precedes the function
+ * name in the function prototype.
+ */
+#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
+ /* Win32 but not WinCE */
+# define KHRONOS_APIENTRY __stdcall
+#else
+# define KHRONOS_APIENTRY
+#endif
+
+/*-------------------------------------------------------------------------
+ * Definition of KHRONOS_APIATTRIBUTES
+ *-------------------------------------------------------------------------
+ * This follows the closing parenthesis of the function prototype arguments.
+ */
+#if defined (__ARMCC_2__)
+#define KHRONOS_APIATTRIBUTES __softfp
+#else
+#define KHRONOS_APIATTRIBUTES
+#endif
+
+/*-------------------------------------------------------------------------
+ * basic type definitions
+ *-----------------------------------------------------------------------*/
+#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
+
+
+/*
+ * Using <stdint.h>
+ */
+#include <stdint.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__VMS ) || defined(__sgi)
+
+/*
+ * Using <inttypes.h>
+ */
+#include <inttypes.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
+
+/*
+ * Win32
+ */
+typedef __int32 khronos_int32_t;
+typedef unsigned __int32 khronos_uint32_t;
+typedef __int64 khronos_int64_t;
+typedef unsigned __int64 khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif defined(__sun__) || defined(__digital__)
+
+/*
+ * Sun or Digital
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#if defined(__arch64__) || defined(_LP64)
+typedef long int khronos_int64_t;
+typedef unsigned long int khronos_uint64_t;
+#else
+typedef long long int khronos_int64_t;
+typedef unsigned long long int khronos_uint64_t;
+#endif /* __arch64__ */
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#elif 0
+
+/*
+ * Hypothetical platform with no float or int64 support
+ */
+typedef int khronos_int32_t;
+typedef unsigned int khronos_uint32_t;
+#define KHRONOS_SUPPORT_INT64 0
+#define KHRONOS_SUPPORT_FLOAT 0
+
+#else
+
+/*
+ * Generic fallback
+ */
+#include <stdint.h>
+typedef int32_t khronos_int32_t;
+typedef uint32_t khronos_uint32_t;
+typedef int64_t khronos_int64_t;
+typedef uint64_t khronos_uint64_t;
+#define KHRONOS_SUPPORT_INT64 1
+#define KHRONOS_SUPPORT_FLOAT 1
+
+#endif
+
+
+/*
+ * Types that are (so far) the same on all platforms
+ */
+typedef signed char khronos_int8_t;
+typedef unsigned char khronos_uint8_t;
+typedef signed short int khronos_int16_t;
+typedef unsigned short int khronos_uint16_t;
+
+/*
+ * Types that differ between LLP64 and LP64 architectures - in LLP64,
+ * pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
+ * to be the only LLP64 architecture in current use.
+ */
+#ifdef _WIN64
+typedef signed long long int khronos_intptr_t;
+typedef unsigned long long int khronos_uintptr_t;
+typedef signed long long int khronos_ssize_t;
+typedef unsigned long long int khronos_usize_t;
+#else
+typedef signed long int khronos_intptr_t;
+typedef unsigned long int khronos_uintptr_t;
+typedef signed long int khronos_ssize_t;
+typedef unsigned long int khronos_usize_t;
+#endif
+
+#if KHRONOS_SUPPORT_FLOAT
+/*
+ * Float type
+ */
+typedef float khronos_float_t;
+#endif
+
+#if KHRONOS_SUPPORT_INT64
+/* Time types
+ *
+ * These types can be used to represent a time interval in nanoseconds or
+ * an absolute Unadjusted System Time. Unadjusted System Time is the number
+ * of nanoseconds since some arbitrary system event (e.g. since the last
+ * time the system booted). The Unadjusted System Time is an unsigned
+ * 64 bit value that wraps back to 0 every 584 years. Time intervals
+ * may be either signed or unsigned.
+ */
+typedef khronos_uint64_t khronos_utime_nanoseconds_t;
+typedef khronos_int64_t khronos_stime_nanoseconds_t;
+#endif
+
+/*
+ * Dummy value used to pad enum types to 32 bits.
+ */
+#ifndef KHRONOS_MAX_ENUM
+#define KHRONOS_MAX_ENUM 0x7FFFFFFF
+#endif
+
+/*
+ * Enumerated boolean type
+ *
+ * Values other than zero should be considered to be true. Therefore
+ * comparisons should not be made against KHRONOS_TRUE.
+ */
+typedef enum {
+ KHRONOS_FALSE = 0,
+ KHRONOS_TRUE = 1,
+ KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
+} khronos_boolean_enum_t;
+
+#endif /* __khrplatform_h_ */
diff --git a/emulator/opengl/host/libs/libOpenglRender/Android.mk b/emulator/opengl/host/libs/libOpenglRender/Android.mk
index 1d923b4..787ae83 100644
--- a/emulator/opengl/host/libs/libOpenglRender/Android.mk
+++ b/emulator/opengl/host/libs/libOpenglRender/Android.mk
@@ -54,7 +54,7 @@ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
# use Translator's egl/gles headers
LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include
-LOCAL_STATIC_LIBRARIES += libutils liblog
+LOCAL_STATIC_LIBRARIES += libemugl_common
$(call emugl-export,CFLAGS,$(host_common_CFLAGS))
@@ -62,22 +62,24 @@ $(call emugl-end-module)
### host libOpenglRender, 64-bit #########################################
-$(call emugl-begin-host-shared-library,lib64OpenglRender)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-shared-library,lib64OpenglRender)
-$(call emugl-import,lib64GLESv1_dec lib64GLESv2_dec lib64_renderControl_dec lib64OpenglCodecCommon lib64OpenglOsUtils)
+ $(call emugl-import,lib64GLESv1_dec lib64GLESv2_dec lib64_renderControl_dec lib64OpenglCodecCommon lib64OpenglOsUtils)
-#LOCAL_LDFLAGS += -m64 # adding -m64 here doesn't work, because it somehow appear BEFORE -m32 in command-line.
-LOCAL_LDLIBS += $(host_common_LDLIBS) -m64 # Put -m64 it in LOCAL_LDLIBS instead.
+ #LOCAL_LDFLAGS += -m64 # adding -m64 here doesn't work, because it somehow appear BEFORE -m32 in command-line.
+ LOCAL_LDLIBS += $(host_common_LDLIBS) -m64 # Put -m64 it in LOCAL_LDLIBS instead.
-LOCAL_SRC_FILES := $(host_common_SRC_FILES)
-$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include)
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ LOCAL_SRC_FILES := $(host_common_SRC_FILES)
+ $(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include)
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-# use Translator's egl/gles headers
-LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include
+ # use Translator's egl/gles headers
+ LOCAL_C_INCLUDES += $(EMUGL_PATH)/host/libs/Translator/include
-LOCAL_STATIC_LIBRARIES += lib64utils lib64log
+ LOCAL_STATIC_LIBRARIES += lib64emugl_common
-$(call emugl-export,CFLAGS,$(host_common_CFLAGS) -m64)
+ $(call emugl-export,CFLAGS,$(host_common_CFLAGS) -m64)
-$(call emugl-end-module)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
index 46c5acf..e612294 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
@@ -18,6 +18,7 @@
#include "EGLDispatch.h"
#include "GLDispatch.h"
#include "ThreadInfo.h"
+#include "GLcommon/GLutils.h"
#ifdef WITH_GLES2
#include "GL2Dispatch.h"
#endif
@@ -92,17 +93,19 @@ ColorBuffer *ColorBuffer::create(int p_width, int p_height,
cb->m_internalFormat = texInternalFormat;
if (fb->getCaps().has_eglimage_texture_2d) {
- cb->m_eglImage = s_egl.eglCreateImageKHR(fb->getDisplay(),
- s_egl.eglGetCurrentContext(),
- EGL_GL_TEXTURE_2D_KHR,
- (EGLClientBuffer)cb->m_tex,
- NULL);
-
- cb->m_blitEGLImage = s_egl.eglCreateImageKHR(fb->getDisplay(),
- s_egl.eglGetCurrentContext(),
- EGL_GL_TEXTURE_2D_KHR,
- (EGLClientBuffer)cb->m_blitTex,
- NULL);
+ cb->m_eglImage = s_egl.eglCreateImageKHR(
+ fb->getDisplay(),
+ s_egl.eglGetCurrentContext(),
+ EGL_GL_TEXTURE_2D_KHR,
+ (EGLClientBuffer)SafePointerFromUInt(cb->m_tex),
+ NULL);
+
+ cb->m_blitEGLImage = s_egl.eglCreateImageKHR(
+ fb->getDisplay(),
+ s_egl.eglGetCurrentContext(),
+ EGL_GL_TEXTURE_2D_KHR,
+ (EGLClientBuffer)SafePointerFromUInt(cb->m_blitTex),
+ NULL);
}
fb->unbind_locked();
@@ -201,7 +204,7 @@ bool ColorBuffer::blitFromCurrentReadBuffer()
// save current viewport and match it to the current
// colorbuffer size
//
- GLint vport[4];
+ GLint vport[4] = {};
s_gl.glGetIntegerv(GL_VIEWPORT, vport);
s_gl.glViewport(0, 0, m_width, m_height);
@@ -295,6 +298,7 @@ bool ColorBuffer::bind_fbo()
GL_TEXTURE_2D, m_tex, 0);
GLenum status = s_gl.glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES);
if (status != GL_FRAMEBUFFER_COMPLETE_OES) {
+ ERR("ColorBuffer::bind_fbo: FBO not complete: %#x\n", status);
s_gl.glBindFramebufferOES(GL_FRAMEBUFFER_OES, 0);
s_gl.glDeleteFramebuffersOES(1, &m_fbo);
m_fbo = 0;
diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h
index 883162b..9a919c3 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h
+++ b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.h
@@ -19,7 +19,7 @@
#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <GLES/gl.h>
-#include <SmartPtr.h>
+#include "emugl/common/smart_ptr.h"
class ColorBuffer
{
@@ -55,6 +55,6 @@ private:
GLenum m_internalFormat;
};
-typedef SmartPtr<ColorBuffer> ColorBufferPtr;
+typedef emugl::SmartPtr<ColorBuffer> ColorBufferPtr;
#endif
diff --git a/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp b/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp
index ca7351e..08c71e8 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/FBConfig.cpp
@@ -67,7 +67,6 @@ InitConfigStatus FBConfig::initConfigList(FrameBuffer *fb)
return ret;
}
- const FrameBufferCaps &caps = fb->getCaps();
EGLDisplay dpy = fb->getDisplay();
if (dpy == EGL_NO_DISPLAY) {
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
index cfadf12..e7a7960 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.cpp
@@ -393,7 +393,7 @@ FrameBuffer::~FrameBuffer()
void FrameBuffer::setPostCallback(OnPostFn onPost, void* onPostContext)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_onPost = onPost;
m_onPostContext = onPostContext;
if (m_onPost && !m_fbImage) {
@@ -490,7 +490,7 @@ HandleType FrameBuffer::genHandle()
HandleType FrameBuffer::createColorBuffer(int p_width, int p_height,
GLenum p_internalFormat)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
HandleType ret = 0;
ColorBufferPtr cb( ColorBuffer::create(p_width, p_height, p_internalFormat) );
@@ -505,7 +505,7 @@ HandleType FrameBuffer::createColorBuffer(int p_width, int p_height,
HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share,
bool p_isGL2)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
HandleType ret = 0;
RenderContextPtr share(NULL);
@@ -527,7 +527,7 @@ HandleType FrameBuffer::createRenderContext(int p_config, HandleType p_share,
HandleType FrameBuffer::createWindowSurface(int p_config, int p_width, int p_height)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
HandleType ret = 0;
WindowSurfacePtr win( WindowSurface::create(p_config, p_width, p_height) );
@@ -541,32 +541,35 @@ HandleType FrameBuffer::createWindowSurface(int p_config, int p_width, int p_hei
void FrameBuffer::DestroyRenderContext(HandleType p_context)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_contexts.erase(p_context);
}
void FrameBuffer::DestroyWindowSurface(HandleType p_surface)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
m_windows.erase(p_surface);
}
-void FrameBuffer::openColorBuffer(HandleType p_colorbuffer)
+int FrameBuffer::openColorBuffer(HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) {
// bad colorbuffer handle
- return;
+ ERR("FB: openColorBuffer cb handle %#x not found\n", p_colorbuffer);
+ return -1;
}
(*c).second.refcount++;
+ return 0;
}
void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c(m_colorbuffers.find(p_colorbuffer));
if (c == m_colorbuffers.end()) {
+ ERR("FB: closeColorBuffer cb handle %#x not found\n", p_colorbuffer);
// bad colorbuffer handle
return;
}
@@ -577,10 +580,11 @@ void FrameBuffer::closeColorBuffer(HandleType p_colorbuffer)
bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
WindowSurfaceMap::iterator w( m_windows.find(p_surface) );
if (w == m_windows.end()) {
+ ERR("FB::flushWindowSurfaceColorBuffer: window handle %#x not found\n", p_surface);
// bad surface handle
return false;
}
@@ -591,16 +595,18 @@ bool FrameBuffer::flushWindowSurfaceColorBuffer(HandleType p_surface)
bool FrameBuffer::setWindowSurfaceColorBuffer(HandleType p_surface,
HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
WindowSurfaceMap::iterator w( m_windows.find(p_surface) );
if (w == m_windows.end()) {
// bad surface handle
+ ERR("%s: bad window surface handle %#x\n", __FUNCTION__, p_surface);
return false;
}
ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) );
if (c == m_colorbuffers.end()) {
+ ERR("%s: bad color buffer handle %#x\n", __FUNCTION__, p_colorbuffer);
// bad colorbuffer handle
return false;
}
@@ -614,7 +620,7 @@ bool FrameBuffer::updateColorBuffer(HandleType p_colorbuffer,
int x, int y, int width, int height,
GLenum format, GLenum type, void *pixels)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) );
if (c == m_colorbuffers.end()) {
@@ -629,7 +635,7 @@ bool FrameBuffer::updateColorBuffer(HandleType p_colorbuffer,
bool FrameBuffer::bindColorBufferToTexture(HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) );
if (c == m_colorbuffers.end()) {
@@ -642,7 +648,7 @@ bool FrameBuffer::bindColorBufferToTexture(HandleType p_colorbuffer)
bool FrameBuffer::bindColorBufferToRenderbuffer(HandleType p_colorbuffer)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
ColorBufferMap::iterator c( m_colorbuffers.find(p_colorbuffer) );
if (c == m_colorbuffers.end()) {
@@ -657,7 +663,7 @@ bool FrameBuffer::bindContext(HandleType p_context,
HandleType p_drawSurface,
HandleType p_readSurface)
{
- android::Mutex::Autolock mutex(m_lock);
+ emugl::Mutex::AutoLock mutex(m_lock);
WindowSurfacePtr draw(NULL), read(NULL);
RenderContextPtr ctx(NULL);
diff --git a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
index de0b71c..f8683b2 100644
--- a/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
+++ b/emulator/opengl/host/libs/libOpenglRender/FrameBuffer.h
@@ -20,7 +20,8 @@
#include "ColorBuffer.h"
#include "RenderContext.h"
#include "WindowSurface.h"
-#include <utils/threads.h>
+#include "emugl/common/mutex.h"
+
#include <map>
#include <EGL/egl.h>
#include <stdint.h>
@@ -72,7 +73,7 @@ public:
HandleType createColorBuffer(int p_width, int p_height, GLenum p_internalFormat);
void DestroyRenderContext(HandleType p_context);
void DestroyWindowSurface(HandleType p_surface);
- void openColorBuffer(HandleType p_colorbuffer);
+ int openColorBuffer(HandleType p_colorbuffer);
void closeColorBuffer(HandleType p_colorbuffer);
bool bindContext(HandleType p_context, HandleType p_drawSurface, HandleType p_readSurface);
@@ -111,7 +112,7 @@ private:
int m_y;
int m_width;
int m_height;
- android::Mutex m_lock;
+ emugl::Mutex m_lock;
FBNativeWindowType m_nativeWindow;
FrameBufferCaps m_caps;
EGLDisplay m_eglDisplay;
diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderContext.h b/emulator/opengl/host/libs/libOpenglRender/RenderContext.h
index 9cbb5fc..80ac43f 100644
--- a/emulator/opengl/host/libs/libOpenglRender/RenderContext.h
+++ b/emulator/opengl/host/libs/libOpenglRender/RenderContext.h
@@ -16,12 +16,12 @@
#ifndef _LIBRENDER_RENDERCONTEXT_H
#define _LIBRENDER_RENDERCONTEXT_H
-#include "SmartPtr.h"
+#include "emugl/common/smart_ptr.h"
#include <EGL/egl.h>
#include "GLDecoderContextData.h"
class RenderContext;
-typedef SmartPtr<RenderContext> RenderContextPtr;
+typedef emugl::SmartPtr<RenderContext> RenderContextPtr;
class RenderContext
{
diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp
index 6a15138..83ba9c5 100644
--- a/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/RenderControl.cpp
@@ -215,13 +215,20 @@ static uint32_t rcCreateColorBuffer(uint32_t width,
return fb->createColorBuffer(width, height, internalFormat);
}
-static void rcOpenColorBuffer(uint32_t colorbuffer)
+static int rcOpenColorBuffer2(uint32_t colorbuffer)
{
FrameBuffer *fb = FrameBuffer::getFB();
if (!fb) {
- return;
+ return -1;
}
- fb->openColorBuffer( colorbuffer );
+ return fb->openColorBuffer( colorbuffer );
+}
+
+// Deprecated, kept for compatibility with old system images only.
+// Use rcOpenColorBuffer2 instead.
+static void rcOpenColorBuffer(uint32_t colorbuffer)
+{
+ (void) rcOpenColorBuffer2(colorbuffer);
}
static void rcCloseColorBuffer(uint32_t colorbuffer)
@@ -359,4 +366,5 @@ void initRenderControlContext(renderControl_decoder_context_t *dec)
dec->set_rcColorBufferCacheFlush(rcColorBufferCacheFlush);
dec->set_rcReadColorBuffer(rcReadColorBuffer);
dec->set_rcUpdateColorBuffer(rcUpdateColorBuffer);
+ dec->set_rcOpenColorBuffer2(rcOpenColorBuffer2);
}
diff --git a/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp b/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp
index 1b2c0fe..9ae2a43 100644
--- a/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp
@@ -94,7 +94,7 @@ int RenderThread::Main()
stats_totalBytes += readBuf.validData();
long long dt = GetCurrentTimeMS() - stats_t0;
if (dt > 1000) {
- float dts = (float)dt / 1000.0f;
+ //float dts = (float)dt / 1000.0f;
//printf("Used Bandwidth %5.3f MB/s\n", ((float)stats_totalBytes / dts) / (1024.0f*1024.0f));
stats_totalBytes = 0;
stats_t0 = GetCurrentTimeMS();
diff --git a/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp b/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp
index 566ca40..5337009 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/ThreadInfo.cpp
@@ -15,17 +15,28 @@
*/
#include "ThreadInfo.h"
-#include <cutils/threads.h>
+#include "emugl/common/lazy_instance.h"
+#include "emugl/common/thread_store.h"
-static thread_store_t s_tls = THREAD_STORE_INITIALIZER;
+namespace {
+
+class ThreadInfoStore : public ::emugl::ThreadStore {
+public:
+ ThreadInfoStore() : ::emugl::ThreadStore(NULL) {}
+};
+
+} // namespace
+
+static ::emugl::LazyInstance<ThreadInfoStore> s_tls = LAZY_INSTANCE_INIT;
RenderThreadInfo::RenderThreadInfo() {
- thread_store_set(&s_tls, this, NULL);
+ s_tls->set(this);
}
RenderThreadInfo::~RenderThreadInfo() {
+ s_tls->set(NULL);
}
RenderThreadInfo* RenderThreadInfo::get() {
- return (RenderThreadInfo*)thread_store_get(&s_tls);
+ return static_cast<RenderThreadInfo*>(s_tls->get());
}
diff --git a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp
index 9c32ff8..bdda01a 100644
--- a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp
@@ -58,9 +58,6 @@ WindowSurface *WindowSurface::create(int p_config, int p_width, int p_height)
}
win->m_fbconf = fbconf;
- FrameBuffer *fb = FrameBuffer::getFB();
- const FrameBufferCaps &caps = fb->getCaps();
-
//
// Create a pbuffer to be used as the egl surface
// for that window.
@@ -209,8 +206,6 @@ bool WindowSurface::resizePbuffer(unsigned int p_width, unsigned int p_height)
m_eglSurface = NULL;
}
- const FrameBufferCaps &caps = fb->getCaps();
-
//
// Create pbuffer surface.
//
diff --git a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h
index e9f1f7d..fe35a94 100644
--- a/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h
+++ b/emulator/opengl/host/libs/libOpenglRender/WindowSurface.h
@@ -19,7 +19,7 @@
#include "ColorBuffer.h"
#include "RenderContext.h"
#include "FBConfig.h"
-#include "SmartPtr.h"
+#include "emugl/common/smart_ptr.h"
#include "FixedBuffer.h"
#include <EGL/egl.h>
#include <GLES/gl.h>
@@ -66,6 +66,6 @@ private:
const FBConfig *m_fbconf;
};
-typedef SmartPtr<WindowSurface> WindowSurfacePtr;
+typedef emugl::SmartPtr<WindowSurface> WindowSurfacePtr;
#endif
diff --git a/emulator/opengl/host/libs/renderControl_dec/Android.mk b/emulator/opengl/host/libs/renderControl_dec/Android.mk
index 1063532..4a97a93 100644
--- a/emulator/opengl/host/libs/renderControl_dec/Android.mk
+++ b/emulator/opengl/host/libs/renderControl_dec/Android.mk
@@ -10,10 +10,12 @@ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
$(call emugl-end-module)
### host library, 64-bit ####################################
-$(call emugl-begin-host-static-library,lib64_renderControl_dec)
-$(call emugl-import,lib64OpenglCodecCommon)
-$(call emugl-gen-decoder,$(LOCAL_PATH),renderControl)
-# For renderControl_types.h
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-$(call emugl-export,CFLAGS,-m64)
-$(call emugl-end-module)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64_renderControl_dec)
+ $(call emugl-import,lib64OpenglCodecCommon)
+ $(call emugl-gen-decoder,$(LOCAL_PATH),renderControl)
+ # For renderControl_types.h
+ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ $(call emugl-export,CFLAGS,-m64)
+ $(call emugl-end-module)
+endif \ No newline at end of file
diff --git a/emulator/opengl/host/libs/renderControl_dec/renderControl.in b/emulator/opengl/host/libs/renderControl_dec/renderControl.in
index 8281fd9..55539f9 100644
--- a/emulator/opengl/host/libs/renderControl_dec/renderControl.in
+++ b/emulator/opengl/host/libs/renderControl_dec/renderControl.in
@@ -23,3 +23,4 @@ GL_ENTRY(void, rcBindRenderbuffer, uint32_t colorBuffer)
GL_ENTRY(EGLint, rcColorBufferCacheFlush, uint32_t colorbuffer, EGLint postCount,int forRead)
GL_ENTRY(void, rcReadColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
GL_ENTRY(int, rcUpdateColorBuffer, uint32_t colorbuffer, GLint x, GLint y, GLint width, GLint height, GLenum format, GLenum type, void *pixels)
+GL_ENTRY(int, rcOpenColorBuffer2, uint32_t colorbuffer)
diff --git a/emulator/opengl/host/renderer/main.cpp b/emulator/opengl/host/renderer/main.cpp
index d2e3f72..2c3f8e2 100644
--- a/emulator/opengl/host/renderer/main.cpp
+++ b/emulator/opengl/host/renderer/main.cpp
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
int winY = 0;
int winWidth = 320;
int winHeight = 480;
- FBNativeWindowType windowId = NULL;
+ FBNativeWindowType windowId = 0;
int iWindowId = 0;
//
diff --git a/emulator/opengl/host/tools/emugen/Android.mk b/emulator/opengl/host/tools/emugen/Android.mk
index ad9ab06..e2f3939 100644
--- a/emulator/opengl/host/tools/emugen/Android.mk
+++ b/emulator/opengl/host/tools/emugen/Android.mk
@@ -1,15 +1,35 @@
-ifneq ($(HOST_OS),windows)
+# Determine if the emugen build needs to be builts from
+# sources.
+EMUGL_BUILD_EMUGEN :=
+ifeq (true,$(BUILD_STANDALONE_EMULATOR))
+ # The emulator's standalone build system can build host Linux
+ # binaries even when it targets Windows by setting
+ # LOCAL_HOST_BUILD to true, so rebuild from sources.
+ EMUGL_BUILD_EMUGEN := true
+else
+ ifneq ($(HOST_OS),windows)
+ # The platform build can only build emugen when targetting
+ # the same host sytem.
+ EMUGL_BUILD_EMUGEN := true
+ endif
+endif
LOCAL_PATH:=$(call my-dir)
+ifeq (true,$(EMUGL_BUILD_EMUGEN))
+
$(call emugl-begin-host-executable,emugen)
- LOCAL_SRC_FILES := \
- ApiGen.cpp \
- EntryPoint.cpp \
- main.cpp \
- strUtils.cpp \
- TypeFactory.cpp
+LOCAL_SRC_FILES := \
+ ApiGen.cpp \
+ EntryPoint.cpp \
+ main.cpp \
+ strUtils.cpp \
+ TypeFactory.cpp \
+
+ifeq (true,$(BUILD_STANDALONE_EMULATOR))
+LOCAL_HOST_BUILD := true
+endif
$(call emugl-end-module)
@@ -17,7 +37,7 @@ $(call emugl-end-module)
# protocol encoders/ decoders. This variable is used by other emugl modules.
EMUGL_EMUGEN := $(LOCAL_BUILT_MODULE)
-else # windows build
+else # windows platform build
# on windows use the build host emugen executable
# (that will be the linux exeutable when using mingw build)
diff --git a/emulator/opengl/host/tools/emugen/ApiGen.cpp b/emulator/opengl/host/tools/emugen/ApiGen.cpp
index 6964862..2e4c8d1 100644
--- a/emulator/opengl/host/tools/emugen/ApiGen.cpp
+++ b/emulator/opengl/host/tools/emugen/ApiGen.cpp
@@ -420,8 +420,8 @@ static void writeVarEncodingExpression(Var& var, FILE* fp)
if (!var.isVoid()) {
fprintf(fp, "\t\tmemcpy(ptr, &%s, %u); ptr += %u;\n",
varname,
- (uint) var.type()->bytes(),
- (uint) var.type()->bytes());
+ (unsigned) var.type()->bytes(),
+ (unsigned) var.type()->bytes());
}
}
}
@@ -645,7 +645,7 @@ int ApiGen::genEncoderImpl(const std::string &filename)
fprintf(fp, "\t return NULL;\n");
} else if (e->retval().type()->name() != "void") {
fprintf(fp, "\n\t%s retval;\n", e->retval().type()->name().c_str());
- fprintf(fp, "\tstream->readback(&retval, %u);\n",(uint) e->retval().type()->bytes());
+ fprintf(fp, "\tstream->readback(&retval, %u);\n",(unsigned) e->retval().type()->bytes());
fprintf(fp, "\treturn retval;\n");
}
fprintf(fp, "}\n\n");
@@ -776,12 +776,10 @@ int ApiGen::genDecoderImpl(const std::string &filename)
\tchar lastCall[256] = {0}; \n\
#endif \n\
\twhile ((len - pos >= 8) && !unknownOpcode) { \n\
-\t\tvoid *params[%u]; \n\
\t\tint opcode = *(int *)ptr; \n\
\t\tunsigned int packetLen = *(int *)(ptr + 4);\n\
\t\tif (len - pos < packetLen) return pos; \n\
-\t\tswitch(opcode) {\n",
- (uint) m_maxEntryPointsParams);
+\t\tswitch(opcode) {\n");
for (size_t f = 0; f < n; f++) {
enum Pass_t { PASS_TmpBuffAlloc = 0, PASS_MemAlloc, PASS_DebugPrint, PASS_FunctionCall, PASS_Epilog, PASS_LAST };
@@ -823,7 +821,8 @@ int ApiGen::genDecoderImpl(const std::string &filename)
}
} else if (pass == PASS_DebugPrint) {
fprintf(fp, "#ifdef DEBUG_PRINTOUT\n");
- fprintf(fp, "\t\t\tfprintf(stderr,\"%s: %s(%s)\\n\"", m_basename.c_str(), e->name().c_str(), printString.c_str());
+ fprintf(fp, "\t\t\tfprintf(stderr,\"%s(%%p): %s(%s)\\n\", stream",
+ m_basename.c_str(), e->name().c_str(), printString.c_str());
if (e->vars().size() > 0 && !e->vars()[0].isVoid()) fprintf(fp, ",");
}
@@ -845,9 +844,9 @@ int ApiGen::genDecoderImpl(const std::string &filename)
if (v->pointerDir() == Var::POINTER_IN || v->pointerDir() == Var::POINTER_INOUT) {
if (pass == PASS_MemAlloc && v->pointerDir() == Var::POINTER_INOUT) {
fprintf(fp, "\t\t\tsize_t tmpPtr%uSize = (size_t)*(unsigned int *)(ptr + %s);\n",
- (uint) j, varoffset.c_str());
+ (unsigned) j, varoffset.c_str());
fprintf(fp, "unsigned char *tmpPtr%u = (ptr + %s + 4);\n",
- (uint) j, varoffset.c_str());
+ (unsigned) j, varoffset.c_str());
}
if (pass == PASS_FunctionCall) {
if (v->nullAllowed()) {
@@ -866,30 +865,33 @@ int ApiGen::genDecoderImpl(const std::string &filename)
} else { // out pointer;
if (pass == PASS_TmpBuffAlloc) {
fprintf(fp, "\t\t\tsize_t tmpPtr%uSize = (size_t)*(unsigned int *)(ptr + %s);\n",
- (uint) j, varoffset.c_str());
+ (unsigned) j, varoffset.c_str());
if (!totalTmpBuffExist) {
- fprintf(fp, "\t\t\tsize_t totalTmpSize = tmpPtr%uSize;\n", (uint)j);
+ fprintf(fp, "\t\t\tsize_t totalTmpSize = tmpPtr%uSize;\n", (unsigned)j);
} else {
- fprintf(fp, "\t\t\ttotalTmpSize += tmpPtr%uSize;\n", (uint)j);
+ fprintf(fp, "\t\t\ttotalTmpSize += tmpPtr%uSize;\n", (unsigned)j);
}
tmpBufOffset[j] = totalTmpBuffOffset;
char tmpPtrName[16];
- sprintf(tmpPtrName," + tmpPtr%uSize", (uint)j);
+ sprintf(tmpPtrName," + tmpPtr%uSize", (unsigned)j);
totalTmpBuffOffset += std::string(tmpPtrName);
totalTmpBuffExist = true;
} else if (pass == PASS_MemAlloc) {
fprintf(fp, "\t\t\tunsigned char *tmpPtr%u = &tmpBuf[%s];\n",
- (uint)j, tmpBufOffset[j].c_str());
+ (unsigned)j, tmpBufOffset[j].c_str());
+ fprintf(fp, "\t\t\tmemset(tmpPtr%u, 0, %s);\n",
+ (unsigned)j,
+ toString(v->type()->bytes()).c_str());
} else if (pass == PASS_FunctionCall) {
if (v->nullAllowed()) {
fprintf(fp, "tmpPtr%uSize == 0 ? NULL : (%s)(tmpPtr%u)",
- (uint) j, v->type()->name().c_str(), (uint) j);
+ (unsigned) j, v->type()->name().c_str(), (unsigned) j);
} else {
- fprintf(fp, "(%s)(tmpPtr%u)", v->type()->name().c_str(), (uint) j);
+ fprintf(fp, "(%s)(tmpPtr%u)", v->type()->name().c_str(), (unsigned) j);
}
} else if (pass == PASS_DebugPrint) {
fprintf(fp, "(%s)(tmpPtr%u), *(unsigned int *)(ptr + %s)",
- v->type()->name().c_str(), (uint) j,
+ v->type()->name().c_str(), (unsigned) j,
varoffset.c_str());
}
varoffset += " + 4";
@@ -939,7 +941,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
fprintf(fp, "\t\t} //switch\n");
if (strstr(m_basename.c_str(), "gl")) {
fprintf(fp, "#ifdef CHECK_GL_ERROR\n");
- fprintf(fp, "\tint err = this->glGetError();\n");
+ fprintf(fp, "\tint err = lastCall[0] ? this->glGetError() : GL_NO_ERROR;\n");
fprintf(fp, "\tif (err) fprintf(stderr, \"%s Error: 0x%%X in %%s\\n\", err, lastCall);\n", m_basename.c_str());
fprintf(fp, "#endif\n");
}
@@ -1036,7 +1038,7 @@ int ApiGen::setGlobalAttribute(const std::string & line, size_t lc)
if (token == "base_opcode") {
std::string str = getNextToken(line, pos, &last, WHITESPACE);
if (str.size() == 0) {
- fprintf(stderr, "line %u: missing value for base_opcode\n", (uint) lc);
+ fprintf(stderr, "line %u: missing value for base_opcode\n", (unsigned) lc);
} else {
setBaseOpcode(atoi(str.c_str()));
}
diff --git a/emulator/opengl/host/tools/emugen/ApiGen.h b/emulator/opengl/host/tools/emugen/ApiGen.h
index 1627ef6..8ba18af 100644
--- a/emulator/opengl/host/tools/emugen/ApiGen.h
+++ b/emulator/opengl/host/tools/emugen/ApiGen.h
@@ -54,6 +54,8 @@ public:
case WRAPPER_SIDE:
retval = "wrapper";
break;
+ default:
+ retval = "unknown";
}
return retval;
}
diff --git a/emulator/opengl/host/tools/emugen/getopt.c b/emulator/opengl/host/tools/emugen/getopt.c
new file mode 100644
index 0000000..3523538
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/getopt.c
@@ -0,0 +1,76 @@
+#include "getopt.h"
+
+#include <stdio.h>
+#include <string.h>
+
+#define _getprogname() nargv[0]
+
+int opterr = 1;
+int optind = 1;
+int optopt = 0;
+char* optarg;
+
+int getopt(int argc, char* const argv[], const char* ostr) {
+ static const char kEmpty[] = "";
+ static const char* place = kEmpty;
+ if (!*place) {
+ if (optind >= argc)
+ return -1;
+
+ const char* arg = argv[optind];
+ if (arg[0] != '-') {
+ // Not an option.
+ return -1;
+ }
+ if (arg[1] == '-' && !arg[2]) {
+ // '--' -> end of options.
+ return -1;
+ }
+ if (!arg[1]) {
+ // Single '-', If the program wants it, treat it as an option.
+ // Otherwise, it's the end of options.
+ if (!strchr(ostr, '-')) {
+ return -1;
+ }
+ optopt = '-';
+ place = arg + 1;
+ } else {
+ optopt = arg[1];
+ place = arg + 2;
+ }
+ };
+
+ char* oindex = strchr(ostr, optopt);
+ if (!oindex) {
+ // Unsupported option.
+ (void)fprintf(stderr, "%s: illegal option -- %c\n", argv[0]);
+ return '?';
+ }
+ if (oindex[1] != ':') {
+ // No argument needed.
+ optarg = NULL;
+ if (!*place)
+ optind++;
+ return optopt;
+ }
+
+ // This option needs an argument. Either after the option character,
+ // or the argument that follows.
+ if (*place) {
+ optarg = (char *)place;
+ } else if (argc > ++optind) {
+ optarg = (char *)argv[optind];
+ } else if (oindex[2] == ':') {
+ // Optional argument is missing.
+ place = kEmpty;
+ optarg = NULL;
+ return optopt;
+ } else {
+ // Missing argument.
+ place = kEmpty;
+ (void)fprintf(stderr, "%s: option requires an argument --%c\n",
+ argv[0], optopt);
+ return ':';
+ }
+ return optopt;
+}
diff --git a/emulator/opengl/host/tools/emugen/getopt.h b/emulator/opengl/host/tools/emugen/getopt.h
new file mode 100644
index 0000000..cc04850
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/getopt.h
@@ -0,0 +1,18 @@
+#ifndef GETOPT_H
+#define GETOPT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int optind;
+extern char* optarg;
+extern int optopt;
+
+int getopt(int argc, char* const argv[], const char* ostr);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // GETOPT_H
diff --git a/emulator/opengl/host/tools/emugen/main.cpp b/emulator/opengl/host/tools/emugen/main.cpp
index 96377f2..c0c24e9 100644
--- a/emulator/opengl/host/tools/emugen/main.cpp
+++ b/emulator/opengl/host/tools/emugen/main.cpp
@@ -20,6 +20,7 @@
#include "strUtils.h"
#include "ApiGen.h"
#include "TypeFactory.h"
+#include "getopt.h"
const std::string SPEC_EXTENSION = std::string(".in");
const std::string ATTRIB_EXTENSION = std::string(".attrib");
diff --git a/emulator/opengl/sdl.mk b/emulator/opengl/sdl.mk
new file mode 100644
index 0000000..a85ed58
--- /dev/null
+++ b/emulator/opengl/sdl.mk
@@ -0,0 +1,25 @@
+# This contains common definitions used to define a host module to
+# link SDL with the EmuGL test programs.
+
+ifeq ($(BUILD_STANDALONE_EMULATOR),true)
+
+# When using the emulator standalone build, inherit the values from the
+# Makefile that included us.
+EMUGL_SDL_CFLAGS := $(SDL_CFLAGS)
+EMUGL_SDL_LDLIBS := $(SDL_LDLIBS)
+EMUGL_SDL_STATIC_LIBRARIES := emulator_libSDL emulator_libSDLmain
+
+else # BUILD_STANDALONE_EMULATOR != true
+
+# Otherwise, use the prebuilt libraries that come with the platform.
+
+EMUGL_SDL_CONFIG ?= prebuilts/tools/$(HOST_PREBUILT_TAG)/sdl/bin/sdl-config
+EMUGL_SDL_CFLAGS := $(shell $(EMUGL_SDL_CONFIG) --cflags)
+EMUGL_SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(EMUGL_SDL_CONFIG) --static-libs))
+EMUGL_SDL_STATIC_LIBRARIES := libSDL libSDLmain
+
+ifeq ($(HOST_OS),windows)
+EMUGL_SDL_LDLIBS += -lws2_32
+endif
+
+endif # BUILD_STANDALONE_EMULATOR != true
diff --git a/emulator/opengl/shared/OpenglCodecCommon/Android.mk b/emulator/opengl/shared/OpenglCodecCommon/Android.mk
index 5deb1f7..83090d8 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/Android.mk
+++ b/emulator/opengl/shared/OpenglCodecCommon/Android.mk
@@ -24,19 +24,21 @@ endif
$(call emugl-begin-host-static-library,libOpenglCodecCommon)
LOCAL_SRC_FILES := $(host_commonSources)
-
-$(call emugl-export,STATIC_LIBRARIES,libcutils)
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+$(call emugl-import, libemugl_common)
+$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include/libOpenglRender $(LOCAL_PATH))
+$(call emugl-export,LDLIBS,-lstdc++)
$(call emugl-end-module)
### OpenglCodecCommon host, 64-bit #########################################
-$(call emugl-begin-host-static-library,lib64OpenglCodecCommon)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64OpenglCodecCommon)
-LOCAL_SRC_FILES := $(host_commonSources)
-
-$(call emugl-export,STATIC_LIBRARIES,lib64cutils)
-$(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
-$(call emugl-export,CFLAGS,-m64)
-$(call emugl-end-module)
+ LOCAL_SRC_FILES := $(host_commonSources)
+ $(call emugl-import, lib64emugl_common)
+ $(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/host/include/libOpenglRender $(LOCAL_PATH))
+ $(call emugl-export,CFLAGS,-m64 -fPIC)
+ $(call emugl-export,LDLIBS,-lstdc++)
+ $(call emugl-end-module)
+endif
diff --git a/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h b/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
index 6f41fd7..4cad61f 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
+++ b/emulator/opengl/shared/OpenglCodecCommon/ErrorLog.h
@@ -16,22 +16,12 @@
#ifndef _ERROR_LOG_H_
#define _ERROR_LOG_H_
-#if (HAVE_ANDROID_OS == 1)
-# include <cutils/log.h>
-# define ERR(...) ALOGE(__VA_ARGS__)
-# ifdef EMUGL_DEBUG
-# define DBG(...) ALOGD(__VA_ARGS__)
-# else
-# define DBG(...) ((void)0)
-# endif
+#include <stdio.h>
+#define ERR(...) fprintf(stderr, __VA_ARGS__)
+#ifdef EMUGL_DEBUG
+# define DBG(...) fprintf(stderr, __VA_ARGS__)
#else
-# include <stdio.h>
-# define ERR(...) fprintf(stderr, __VA_ARGS__)
-# ifdef EMUGL_DEBUG
-# define DBG(...) fprintf(stderr, __VA_ARGS__)
-# else
-# define DBG(...) ((void)0)
-# endif
+# define DBG(...) ((void)0)
#endif
-#endif
+#endif // _ERROR_LOG_H_
diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp b/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp
index 9795490..b02131c 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp
+++ b/emulator/opengl/shared/OpenglCodecCommon/GLClientState.cpp
@@ -19,7 +19,6 @@
#include <stdlib.h>
#include <string.h>
#include "glUtils.h"
-#include <cutils/log.h>
#ifndef MAX
#define MAX(a, b) ((a) < (b) ? (b) : (a))
diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h b/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h
index 23785ae..d5b5189 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h
+++ b/emulator/opengl/shared/OpenglCodecCommon/GLDecoderContextData.h
@@ -53,12 +53,12 @@ public:
void storePointerData(unsigned int loc, void *data, size_t len) {
- assert(loc < m_nLocations);
+ assert(loc < (unsigned)m_nLocations);
m_pointerData[loc].alloc(len);
memcpy(m_pointerData[loc].ptr(), data, len);
}
void *pointerData(unsigned int loc) {
- assert(loc < m_nLocations);
+ assert(loc < (unsigned)m_nLocations);
return m_pointerData[loc].ptr();
}
private:
diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp b/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
index c7da37a..59f7b97 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
+++ b/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.cpp
@@ -16,23 +16,22 @@
#include "GLSharedGroup.h"
-/**** KeyedVector utilities ****/
-
-template <typename T>
-static void clearObjectMap(android::DefaultKeyedVector<GLuint, T>& v) {
- for (size_t i = 0; i < v.size(); i++)
- delete v.valueAt(i);
- v.clear();
-}
+#include <string.h>
/**** BufferData ****/
BufferData::BufferData() : m_size(0) {};
+
BufferData::BufferData(GLsizeiptr size, void * data) : m_size(size)
{
- void * buffer = NULL;
- if (size>0) buffer = m_fixedBuffer.alloc(size);
- if (data) memcpy(buffer, data, size);
+ void* buffer = NULL;
+
+ if (size > 0) {
+ buffer = m_fixedBuffer.alloc(size);
+ if (data) {
+ memcpy(buffer, data, size);
+ }
+ }
}
/**** ProgramData ****/
@@ -204,9 +203,7 @@ bool ProgramData::attachShader(GLuint shader)
return false;
}
}
- // AKA m_shaders.push_back(), but that has an ambiguous call to insertAt()
- // due to the default parameters. This is the desired insertAt() overload.
- m_shaders.insertAt(shader, m_shaders.size(), 1);
+ m_shaders.append(shader);
return true;
}
@@ -215,7 +212,7 @@ bool ProgramData::detachShader(GLuint shader)
size_t n = m_shaders.size();
for (size_t i = 0; i < n; i++) {
if (m_shaders[i] == shader) {
- m_shaders.removeAt(i);
+ m_shaders.remove(i);
return true;
}
}
@@ -225,49 +222,32 @@ bool ProgramData::detachShader(GLuint shader)
/***** GLSharedGroup ****/
GLSharedGroup::GLSharedGroup() :
- m_buffers(android::DefaultKeyedVector<GLuint, BufferData*>(NULL)),
- m_programs(android::DefaultKeyedVector<GLuint, ProgramData*>(NULL)),
- m_shaders(android::DefaultKeyedVector<GLuint, ShaderData*>(NULL))
-{
-}
+ m_buffers(), m_programs(), m_shaders() {}
-GLSharedGroup::~GLSharedGroup()
-{
- m_buffers.clear();
- m_programs.clear();
- clearObjectMap(m_buffers);
- clearObjectMap(m_programs);
- clearObjectMap(m_shaders);
-}
+GLSharedGroup::~GLSharedGroup() {}
BufferData * GLSharedGroup::getBufferData(GLuint bufferId)
{
- android::AutoMutex _lock(m_lock);
- return m_buffers.valueFor(bufferId);
+ emugl::Mutex::AutoLock _lock(m_lock);
+ return m_buffers.get(bufferId);
}
void GLSharedGroup::addBufferData(GLuint bufferId, GLsizeiptr size, void * data)
{
- android::AutoMutex _lock(m_lock);
- m_buffers.add(bufferId, new BufferData(size, data));
+ emugl::Mutex::AutoLock _lock(m_lock);
+ m_buffers.set(bufferId, new BufferData(size, data));
}
void GLSharedGroup::updateBufferData(GLuint bufferId, GLsizeiptr size, void * data)
{
- android::AutoMutex _lock(m_lock);
- ssize_t idx = m_buffers.indexOfKey(bufferId);
- if (idx >= 0) {
- delete m_buffers.valueAt(idx);
- m_buffers.editValueAt(idx) = new BufferData(size, data);
- } else {
- m_buffers.add(bufferId, new BufferData(size, data));
- }
+ emugl::Mutex::AutoLock _lock(m_lock);
+ m_buffers.set(bufferId, new BufferData(size, data));
}
GLenum GLSharedGroup::subUpdateBufferData(GLuint bufferId, GLintptr offset, GLsizeiptr size, void * data)
{
- android::AutoMutex _lock(m_lock);
- BufferData * buf = m_buffers.valueFor(bufferId);
+ emugl::Mutex::AutoLock _lock(m_lock);
+ BufferData * buf = m_buffers.get(bufferId);
if ((!buf) || (buf->m_size < offset+size) || (offset < 0) || (size<0)) return GL_INVALID_VALUE;
//it's safe to update now
@@ -277,215 +257,197 @@ GLenum GLSharedGroup::subUpdateBufferData(GLuint bufferId, GLintptr offset, GLsi
void GLSharedGroup::deleteBufferData(GLuint bufferId)
{
- android::AutoMutex _lock(m_lock);
- ssize_t idx = m_buffers.indexOfKey(bufferId);
- if (idx >= 0) {
- delete m_buffers.valueAt(idx);
- m_buffers.removeItemsAt(idx);
- }
+ emugl::Mutex::AutoLock _lock(m_lock);
+ (void) m_buffers.remove(bufferId);
}
void GLSharedGroup::addProgramData(GLuint program)
{
- android::AutoMutex _lock(m_lock);
- ProgramData *pData = m_programs.valueFor(program);
- if (pData)
- {
- m_programs.removeItem(program);
- delete pData;
- }
-
- m_programs.add(program,new ProgramData());
+ emugl::Mutex::AutoLock _lock(m_lock);
+ m_programs.set(program, new ProgramData());
}
void GLSharedGroup::initProgramData(GLuint program, GLuint numIndexes)
{
- android::AutoMutex _lock(m_lock);
- ProgramData *pData = m_programs.valueFor(program);
- if (pData)
- {
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData *pData = m_programs.get(program);
+ if (pData) {
pData->initProgramData(numIndexes);
}
}
bool GLSharedGroup::isProgramInitialized(GLuint program)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
- if (pData)
- {
- return pData->isInitialized();
- }
- return false;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
+ return pData && pData->isInitialized();
}
void GLSharedGroup::deleteProgramData(GLuint program)
{
- android::AutoMutex _lock(m_lock);
- ProgramData *pData = m_programs.valueFor(program);
- if (pData)
- delete pData;
- m_programs.removeItem(program);
+ emugl::Mutex::AutoLock _lock(m_lock);
+ m_programs.remove(program);
}
void GLSharedGroup::attachShader(GLuint program, GLuint shader)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* programData = m_programs.valueFor(program);
- ssize_t idx = m_shaders.indexOfKey(shader);
- if (programData && idx >= 0) {
- if (programData->attachShader(shader)) {
- refShaderDataLocked(idx);
- }
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* programData = m_programs.get(program);
+ if (programData && programData->attachShader(shader)) {
+ refShaderDataLocked(shader);
}
}
void GLSharedGroup::detachShader(GLuint program, GLuint shader)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* programData = m_programs.valueFor(program);
- ssize_t idx = m_shaders.indexOfKey(shader);
- if (programData && idx >= 0) {
- if (programData->detachShader(shader)) {
- unrefShaderDataLocked(idx);
- }
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* programData = m_programs.get(program);
+ if (programData && programData->detachShader(shader)) {
+ unrefShaderDataLocked(shader);
}
}
-void GLSharedGroup::setProgramIndexInfo(GLuint program, GLuint index, GLint base, GLint size, GLenum type, const char* name)
+void GLSharedGroup::setProgramIndexInfo(GLuint program,
+ GLuint index,
+ GLint base,
+ GLint size,
+ GLenum type,
+ const char* name)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
- if (pData)
- {
- pData->setIndexInfo(index,base,size,type);
-
- if (type == GL_SAMPLER_2D) {
- size_t n = pData->getNumShaders();
- for (size_t i = 0; i < n; i++) {
- GLuint shaderId = pData->getShader(i);
- ShaderData* shader = m_shaders.valueFor(shaderId);
- if (!shader) continue;
- ShaderData::StringList::iterator nameIter = shader->samplerExternalNames.begin();
- ShaderData::StringList::iterator nameEnd = shader->samplerExternalNames.end();
- while (nameIter != nameEnd) {
- if (*nameIter == name) {
- pData->setIndexFlags(index, ProgramData::INDEX_FLAG_SAMPLER_EXTERNAL);
- break;
- }
- ++nameIter;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
+ if (!pData) {
+ return;
+ }
+ pData->setIndexInfo(index,base,size,type);
+
+ if (type == GL_SAMPLER_2D) {
+ size_t n = pData->getNumShaders();
+ for (size_t i = 0; i < n; i++) {
+ GLuint shaderId = pData->getShader(i);
+ ShaderData* shader = m_shaders.get(shaderId);
+ if (!shader) continue;
+#if 0 // TODO(digit): Understand why samplerExternalNames is always empty?
+ ShaderData::StringList::iterator nameIter =
+ shader->samplerExternalNames.begin();
+ ShaderData::StringList::iterator nameEnd =
+ shader->samplerExternalNames.end();
+ while (nameIter != nameEnd) {
+ if (*nameIter == name) {
+ pData->setIndexFlags(
+ index,
+ ProgramData::INDEX_FLAG_SAMPLER_EXTERNAL);
+ break;
}
+ ++nameIter;
}
+#endif
}
}
}
+
GLenum GLSharedGroup::getProgramUniformType(GLuint program, GLint location)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
- GLenum type=0;
- if (pData)
- {
- type = pData->getTypeForLocation(location);
- }
- return type;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
+ return pData ? pData->getTypeForLocation(location) : 0;
}
bool GLSharedGroup::isProgram(GLuint program)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
- return (pData!=NULL);
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
+ return (pData != NULL);
}
void GLSharedGroup::setupLocationShiftWAR(GLuint program)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
if (pData) pData->setupLocationShiftWAR();
}
-GLint GLSharedGroup::locationWARHostToApp(GLuint program, GLint hostLoc, GLint arrIndex)
+GLint GLSharedGroup::locationWARHostToApp(GLuint program,
+ GLint hostLoc,
+ GLint arrIndex)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
- if (pData) return pData->locationWARHostToApp(hostLoc, arrIndex);
- else return hostLoc;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
+ return pData ? pData->locationWARHostToApp(hostLoc, arrIndex) : hostLoc;
}
GLint GLSharedGroup::locationWARAppToHost(GLuint program, GLint appLoc)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
- if (pData) return pData->locationWARAppToHost(appLoc);
- else return appLoc;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
+ return pData ? pData->locationWARAppToHost(appLoc) : appLoc;
}
bool GLSharedGroup::needUniformLocationWAR(GLuint program)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
- if (pData) return pData->needUniformLocationWAR();
- return false;
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
+ return pData ? pData->needUniformLocationWAR() : false;
}
-GLint GLSharedGroup::getNextSamplerUniform(GLuint program, GLint index, GLint* val, GLenum* target) const
+GLint GLSharedGroup::getNextSamplerUniform(GLuint program,
+ GLint index,
+ GLint* val,
+ GLenum* target) const
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
return pData ? pData->getNextSamplerUniform(index, val, target) : -1;
}
-bool GLSharedGroup::setSamplerUniform(GLuint program, GLint appLoc, GLint val, GLenum* target)
+bool GLSharedGroup::setSamplerUniform(GLuint program,
+ GLint appLoc,
+ GLint val,
+ GLenum* target)
{
- android::AutoMutex _lock(m_lock);
- ProgramData* pData = m_programs.valueFor(program);
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ProgramData* pData = m_programs.get(program);
return pData ? pData->setSamplerUniform(appLoc, val, target) : false;
}
bool GLSharedGroup::addShaderData(GLuint shader)
{
- android::AutoMutex _lock(m_lock);
+ emugl::Mutex::AutoLock _lock(m_lock);
ShaderData* data = new ShaderData;
- if (data) {
- if (m_shaders.add(shader, data) < 0) {
- delete data;
- data = NULL;
- }
- data->refcount = 1;
- }
- return data != NULL;
+ data->refcount = 1;
+ m_shaders.set(shader, data);
+ return true;
}
ShaderData* GLSharedGroup::getShaderData(GLuint shader)
{
- android::AutoMutex _lock(m_lock);
- return m_shaders.valueFor(shader);
+ emugl::Mutex::AutoLock _lock(m_lock);
+ ShaderData* data = m_shaders.get(shader);
+ if (data) {
+ data->refcount++;
+ }
+ return data;
}
void GLSharedGroup::unrefShaderData(GLuint shader)
{
- android::AutoMutex _lock(m_lock);
- ssize_t idx = m_shaders.indexOfKey(shader);
- if (idx >= 0) {
- unrefShaderDataLocked(idx);
- }
+ emugl::Mutex::AutoLock _lock(m_lock);
+ unrefShaderDataLocked(shader);
}
-void GLSharedGroup::refShaderDataLocked(ssize_t shaderIdx)
+void GLSharedGroup::refShaderDataLocked(GLuint shader)
{
- assert(shaderIdx >= 0 && shaderIdx <= m_shaders.size());
- ShaderData* data = m_shaders.valueAt(shaderIdx);
- data->refcount++;
+ ShaderData* data = m_shaders.get(shader);
+ if (data) {
+ data->refcount++;
+ }
}
-void GLSharedGroup::unrefShaderDataLocked(ssize_t shaderIdx)
+void GLSharedGroup::unrefShaderDataLocked(GLuint shader)
{
- assert(shaderIdx >= 0 && shaderIdx <= m_shaders.size());
- ShaderData* data = m_shaders.valueAt(shaderIdx);
- if (--data->refcount == 0) {
- delete data;
- m_shaders.removeItemsAt(shaderIdx);
+ ShaderData* data = m_shaders.get(shader);
+ if (data && --data->refcount == 0) {
+ m_shaders.remove(shader);
}
}
diff --git a/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h b/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h
index 61b8f00..f111f99 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h
+++ b/emulator/opengl/shared/OpenglCodecCommon/GLSharedGroup.h
@@ -16,6 +16,11 @@
#ifndef _GL_SHARED_GROUP_H_
#define _GL_SHARED_GROUP_H_
+#include "emugl/common/id_to_object_map.h"
+#include "emugl/common/mutex.h"
+#include "emugl/common/pod_vector.h"
+#include "emugl/common/smart_ptr.h"
+
#define GL_API
#ifndef ANDROID
#define GL_APIENTRY
@@ -30,18 +35,13 @@
#include <stdio.h>
#include <stdlib.h>
#include "ErrorLog.h"
-#include <utils/KeyedVector.h>
-#include <utils/List.h>
-#include <utils/String8.h>
-#include <utils/threads.h>
#include "FixedBuffer.h"
-#include "SmartPtr.h"
struct BufferData {
BufferData();
BufferData(GLsizeiptr size, void * data);
GLsizeiptr m_size;
- FixedBuffer m_fixedBuffer;
+ FixedBuffer m_fixedBuffer;
};
class ProgramData {
@@ -61,7 +61,7 @@ private:
bool m_initialized;
bool m_locShiftWAR;
- android::Vector<GLuint> m_shaders;
+ emugl::PodVector<GLuint> m_shaders;
public:
enum {
@@ -92,20 +92,22 @@ public:
};
struct ShaderData {
+#if 0 // TODO(digit): Undertand why this is never used?
typedef android::List<android::String8> StringList;
StringList samplerExternalNames;
+#endif
int refcount;
};
class GLSharedGroup {
private:
- android::DefaultKeyedVector<GLuint, BufferData*> m_buffers;
- android::DefaultKeyedVector<GLuint, ProgramData*> m_programs;
- android::DefaultKeyedVector<GLuint, ShaderData*> m_shaders;
- mutable android::Mutex m_lock;
+ emugl::IdToObjectMap<BufferData> m_buffers;
+ emugl::IdToObjectMap<ProgramData> m_programs;
+ emugl::IdToObjectMap<ShaderData> m_shaders;
+ mutable emugl::Mutex m_lock;
- void refShaderDataLocked(ssize_t shaderIdx);
- void unrefShaderDataLocked(ssize_t shaderIdx);
+ void refShaderDataLocked(GLuint shader);
+ void unrefShaderDataLocked(GLuint shader);
public:
GLSharedGroup();
@@ -138,6 +140,6 @@ public:
void unrefShaderData(GLuint shader);
};
-typedef SmartPtr<GLSharedGroup> GLSharedGroupPtr;
+typedef emugl::SmartPtr<GLSharedGroup> GLSharedGroupPtr;
#endif //_GL_SHARED_GROUP_H_
diff --git a/emulator/opengl/shared/OpenglCodecCommon/SmartPtr.h b/emulator/opengl/shared/OpenglCodecCommon/SmartPtr.h
deleted file mode 100644
index 4bdfbe4..0000000
--- a/emulator/opengl/shared/OpenglCodecCommon/SmartPtr.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
-* Copyright (C) 2011 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-#ifndef __SMART_PTR_H
-#define __SMART_PTR_H
-
-#include <cutils/threads.h>
-#include <cutils/atomic.h>
-
-template <class T, bool threadSafe = false>
-class SmartPtr
-{
-public:
- explicit SmartPtr(T* ptr = (T*)NULL) {
- if (threadSafe) {
- m_lock = new mutex_t;
- mutex_init(m_lock);
- }
- else m_lock = NULL;
-
- m_ptr = ptr;
- if (ptr)
- m_pRefCount = new int32_t(1);
- else
- m_pRefCount = NULL;
- }
-
- SmartPtr<T,threadSafe>(const SmartPtr<T,false>& rhs) {
- if (threadSafe) {
- m_lock = new mutex_t;
- mutex_init(m_lock);
- }
- else m_lock = NULL;
-
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- }
-
- SmartPtr<T,threadSafe>(SmartPtr<T,true>& rhs) {
- if (threadSafe) {
- m_lock = new mutex_t;
- mutex_init(m_lock);
- }
- else m_lock = NULL;
-
- if (rhs.m_lock) mutex_lock(rhs.m_lock);
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- if (rhs.m_lock) mutex_unlock(rhs.m_lock);
- }
-
- ~SmartPtr() {
- if (m_lock) mutex_lock(m_lock);
- release();
- if (m_lock)
- {
- mutex_unlock(m_lock);
- mutex_destroy(m_lock);
- delete m_lock;
- }
- }
-
- T* Ptr() const {
- return m_ptr;
- }
-
- const T* constPtr() const
- {
- return m_ptr;
- }
-
- T* operator->() const {
- return m_ptr;
- }
-
- T& operator*() const {
- return *m_ptr;
- }
-
- operator void*() const {
- return (void *)m_ptr;
- }
-
- // This gives STL lists something to compare.
- bool operator <(const SmartPtr<T>& t1) const {
- return m_ptr < t1.m_ptr;
- }
-
- SmartPtr<T,threadSafe>& operator=(const SmartPtr<T,false>& rhs)
- {
- if (m_ptr == rhs.m_ptr)
- return *this;
-
- if (m_lock) mutex_lock(m_lock);
- release();
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- if (m_lock) mutex_unlock(m_lock);
-
- return *this;
- }
-
- SmartPtr<T,threadSafe>& operator=(SmartPtr<T,true>& rhs)
- {
- if (m_ptr == rhs.m_ptr)
- return *this;
-
- if (m_lock) mutex_lock(m_lock);
- release();
- if (rhs.m_lock) mutex_lock(rhs.m_lock);
- m_pRefCount = rhs.m_pRefCount;
- m_ptr = rhs.m_ptr;
- use();
- if (rhs.m_lock) mutex_unlock(rhs.m_lock);
- if (m_lock) mutex_unlock(m_lock);
-
- return *this;
- }
-
-private:
- int32_t *m_pRefCount;
- mutex_t *m_lock;
- T* m_ptr;
-
- // Increment the reference count on this pointer by 1.
- int use() {
- if (!m_pRefCount) return 0;
- return android_atomic_inc(m_pRefCount) + 1;
- }
-
- // Decrement the reference count on the pointer by 1.
- // If the reference count goes to (or below) 0, the pointer is deleted.
- int release() {
- if (!m_pRefCount) return 0;
-
- int iVal = android_atomic_dec(m_pRefCount);
- if (iVal > 1)
- return iVal - 1;
-
- delete m_pRefCount;
- m_pRefCount = NULL;
-
- if (m_ptr) {
- delete m_ptr;
- m_ptr = NULL;
- }
- return 0;
- }
-
-};
-
-#endif // of __SMART_PTR_H
diff --git a/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp b/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp
index f7a2314..726d359 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp
+++ b/emulator/opengl/shared/OpenglCodecCommon/SocketStream.cpp
@@ -14,7 +14,6 @@
* limitations under the License.
*/
#include "SocketStream.h"
-#include <cutils/sockets.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -53,6 +52,7 @@ SocketStream::~SocketStream()
#else
::close(m_sock);
#endif
+ m_sock = -1;
}
if (m_buf != NULL) {
free(m_buf);
@@ -112,7 +112,6 @@ int SocketStream::writeFully(const void* buffer, size_t size)
const unsigned char *SocketStream::readFully(void *buf, size_t len)
{
- const unsigned char* ret = NULL;
if (!valid()) return NULL;
if (!buf) {
return NULL; // do not allow NULL buf in that implementation
@@ -140,7 +139,7 @@ const unsigned char *SocketStream::read( void *buf, size_t *inout_len)
int n;
do {
- n = recv(buf, *inout_len);
+ n = this->recv(buf, *inout_len);
} while( n < 0 && errno == EINTR );
if (n > 0) {
diff --git a/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp b/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp
index 8a6e56e..ba355ab 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp
+++ b/emulator/opengl/shared/OpenglCodecCommon/TcpStream.cpp
@@ -14,7 +14,8 @@
* limitations under the License.
*/
#include "TcpStream.h"
-#include <cutils/sockets.h>
+#include "emugl/common/sockets.h"
+
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -30,77 +31,48 @@
#define LISTEN_BACKLOG 4
-TcpStream::TcpStream(size_t bufSize) :
- SocketStream(bufSize)
-{
-}
+TcpStream::TcpStream(size_t bufSize) : SocketStream(bufSize) {}
TcpStream::TcpStream(int sock, size_t bufSize) :
- SocketStream(sock, bufSize)
-{
+ SocketStream(sock, bufSize) {
// disable Nagle algorithm to improve bandwidth of small
// packets which are quite common in our implementation.
-#ifdef _WIN32
- DWORD flag;
-#else
- int flag;
-#endif
- flag = 1;
- setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, (const char*)&flag, sizeof(flag) );
+ emugl::socketTcpDisableNagle(sock);
}
-int TcpStream::listen(char addrstr[MAX_ADDRSTR_LEN])
-{
- m_sock = socket_loopback_server(0, SOCK_STREAM);
+int TcpStream::listen(char addrstr[MAX_ADDRSTR_LEN]) {
+ m_sock = emugl::socketTcpLoopbackServer(0, SOCK_STREAM);
if (!valid())
return int(ERR_INVALID_SOCKET);
- /* get the actual port number assigned by the system */
- struct sockaddr_in addr;
- socklen_t addrLen = sizeof(addr);
- memset(&addr, 0, sizeof(addr));
- if (getsockname(m_sock, (struct sockaddr*)&addr, &addrLen) < 0) {
- close(m_sock);
+ int port = emugl::socketGetPort(m_sock);
+ if (port < 0) {
+ ::close(m_sock);
return int(ERR_INVALID_SOCKET);
}
- snprintf(addrstr, MAX_ADDRSTR_LEN - 1, "%hu", ntohs(addr.sin_port));
+
+ snprintf(addrstr, MAX_ADDRSTR_LEN - 1, "%hu", port);
addrstr[MAX_ADDRSTR_LEN-1] = '\0';
return 0;
}
-SocketStream * TcpStream::accept()
-{
- int clientSock = -1;
-
- while (true) {
- struct sockaddr_in addr;
- socklen_t len = sizeof(addr);
- clientSock = ::accept(m_sock, (sockaddr *)&addr, &len);
-
- if (clientSock < 0 && errno == EINTR) {
- continue;
- }
- break;
- }
+SocketStream * TcpStream::accept() {
+ int clientSock = emugl::socketAccept(m_sock);
+ if (clientSock < 0)
+ return NULL;
- TcpStream *clientStream = NULL;
-
- if (clientSock >= 0) {
- clientStream = new TcpStream(clientSock, m_bufsize);
- }
- return clientStream;
+ return new TcpStream(clientSock, m_bufsize);
}
-int TcpStream::connect(const char* addr)
-{
+int TcpStream::connect(const char* addr) {
int port = atoi(addr);
- return connect("127.0.0.1",port);
+ m_sock = emugl::socketTcpLoopbackClient(port, SOCK_STREAM);
+ return valid() ? 0 : -1;
}
int TcpStream::connect(const char* hostname, unsigned short port)
{
- m_sock = socket_network_client(hostname, port, SOCK_STREAM);
- if (!valid()) return -1;
- return 0;
+ m_sock = emugl::socketTcpClient(hostname, port, SOCK_STREAM);
+ return valid() ? 0 : -1;
}
diff --git a/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp b/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp
index b2eef6d..7b2f67d 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp
+++ b/emulator/opengl/shared/OpenglCodecCommon/UnixStream.cpp
@@ -14,7 +14,9 @@
* limitations under the License.
*/
#include "UnixStream.h"
-#include <cutils/sockets.h>
+
+#include "emugl/common/sockets.h"
+
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@@ -92,7 +94,7 @@ int UnixStream::listen(char addrstr[MAX_ADDRSTR_LEN])
return -1;
}
- m_sock = socket_local_server(addrstr, ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM);
+ m_sock = emugl::socketLocalServer(addrstr, SOCK_STREAM);
if (!valid()) return int(ERR_INVALID_SOCKET);
return 0;
@@ -123,7 +125,7 @@ SocketStream * UnixStream::accept()
int UnixStream::connect(const char* addr)
{
- m_sock = socket_local_client(addr, ANDROID_SOCKET_NAMESPACE_FILESYSTEM, SOCK_STREAM);
+ m_sock = emugl::socketLocalClient(addr, SOCK_STREAM);
if (!valid()) return -1;
return 0;
diff --git a/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp b/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp
index 76907a0..dcfb0c0 100644
--- a/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp
+++ b/emulator/opengl/shared/OpenglCodecCommon/Win32PipeStream.cpp
@@ -193,8 +193,6 @@ int Win32PipeStream::commitBuffer(size_t size)
const unsigned char *Win32PipeStream::readFully(void *buf, size_t len)
{
- const unsigned char* ret = NULL;
-
if (m_pipe == INVALID_HANDLE_VALUE)
return NULL;
diff --git a/emulator/opengl/shared/OpenglOsUtils/Android.mk b/emulator/opengl/shared/OpenglOsUtils/Android.mk
index 8a6c18b..f9673fc 100644
--- a/emulator/opengl/shared/OpenglOsUtils/Android.mk
+++ b/emulator/opengl/shared/OpenglOsUtils/Android.mk
@@ -10,6 +10,7 @@ LOCAL_PATH := $(call my-dir)
host_common_SRC_FILES := osDynLibrary.cpp
host_common_LDLIBS :=
+host_common_INCLUDES := $(LOCAL_PATH)
ifeq ($(HOST_OS),windows)
host_common_SRC_FILES += \
@@ -29,15 +30,19 @@ endif
### 32-bit host library ####
$(call emugl-begin-host-static-library,libOpenglOsUtils)
- $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
+ $(call emugl-export,C_INCLUDES,$(host_common_INCLUDES))
LOCAL_SRC_FILES = $(host_common_SRC_FILES)
$(call emugl-export,LDLIBS,$(host_common_LDLIBS))
+ $(call emugl-import,libemugl_common)
$(call emugl-end-module)
### 64-bit host library ####
-$(call emugl-begin-host-static-library,lib64OpenglOsUtils)
- $(call emugl-export,C_INCLUDES,$(LOCAL_PATH))
- LOCAL_SRC_FILES = $(host_common_SRC_FILES)
- $(call emugl-export,LDLIBS,$(host_common_LDLIBS))
- $(call emugl-export,CFLAGS,-m64)
-$(call emugl-end-module)
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64OpenglOsUtils)
+ $(call emugl-export,C_INCLUDES,$(host_common_INCLUDES))
+ LOCAL_SRC_FILES = $(host_common_SRC_FILES)
+ $(call emugl-export,LDLIBS,$(host_common_LDLIBS))
+ $(call emugl-import,lib64emugl_common)
+ $(call emugl-export,CFLAGS,-m64 -fPIC)
+ $(call emugl-end-module)
+endif
diff --git a/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp b/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp
index d8879eb..ef2bebc 100644
--- a/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp
+++ b/emulator/opengl/shared/OpenglOsUtils/osThreadUnix.cpp
@@ -15,6 +15,10 @@
*/
#include "osThread.h"
+#include "emugl/common/thread_store.h"
+
+#include <stdint.h>
+
namespace osUtils {
Thread::Thread() :
@@ -55,9 +59,8 @@ Thread::wait(int *exitStatus)
return false;
}
- long long int ret=(long long int)retval;
if (exitStatus) {
- *exitStatus = (int)ret;
+ *exitStatus = (int)(uintptr_t)retval;
}
return true;
}
@@ -87,7 +90,8 @@ Thread::thread_main(void *p_arg)
self->m_exitStatus = ret;
pthread_mutex_unlock(&self->m_lock);
- return (void*)ret;
+ ::emugl::ThreadStore::OnThreadExit();
+ return (void*)(uintptr_t)ret;
}
} // of namespace osUtils
diff --git a/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp b/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp
index 2d563f8..1a30b97 100644
--- a/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp
+++ b/emulator/opengl/shared/OpenglOsUtils/osThreadWin.cpp
@@ -15,6 +15,8 @@
*/
#include "osThread.h"
+#include "emugl/common/thread_store.h"
+
namespace osUtils {
Thread::Thread() :
@@ -95,6 +97,7 @@ Thread::thread_main(void *p_arg)
Thread *self = (Thread *)p_arg;
int ret = self->Main();
self->m_isRunning = false;
+ ::emugl::ThreadStore::OnThreadExit();
return ret;
}
diff --git a/emulator/opengl/shared/emugl/common/Android.mk b/emulator/opengl/shared/emugl/common/Android.mk
new file mode 100644
index 0000000..58dd6da
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/Android.mk
@@ -0,0 +1,54 @@
+# This build script corresponds to a library containing many definitions
+# common to both the guest and the host. They relate to
+#
+LOCAL_PATH := $(call my-dir)
+
+### emugl_common host library ###########################################
+
+commonSources := \
+ id_to_object_map.cpp \
+ lazy_instance.cpp \
+ pod_vector.cpp \
+ smart_ptr.cpp \
+ sockets.cpp \
+ thread_store.cpp \
+
+host_commonSources := $(commonSources)
+
+$(call emugl-begin-host-static-library,libemugl_common)
+LOCAL_SRC_FILES := $(host_commonSources)
+$(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/shared)
+$(call emugl-export,LDLIBS,-lstdc++)
+$(call emugl-end-module)
+
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-static-library,lib64emugl_common)
+ LOCAL_SRC_FILES := $(host_commonSources)
+ $(call emugl-export,CFLAGS,-m64 -fPIC)
+ $(call emugl-export,C_INCLUDES,$(EMUGL_PATH)/shared)
+ $(call emugl-export,LDLIBS,-lstdc++)
+ $(call emugl-end-module)
+endif
+
+
+### emugl_common_unittests ##############################################
+
+host_commonSources := \
+ id_to_object_map_unittest.cpp \
+ lazy_instance_unittest.cpp \
+ pod_vector_unittest.cpp \
+ mutex_unittest.cpp \
+ smart_ptr_unittest.cpp \
+ thread_store_unittest.cpp \
+
+$(call emugl-begin-host-executable,emugl_common_host_unittests)
+LOCAL_SRC_FILES := $(host_commonSources)
+$(call emugl-import,libemugl_common libemugl_gtest)
+$(call emugl-end-module)
+
+ifdef EMUGL_BUILD_64BITS
+ $(call emugl-begin-host64-executable,emugl64_common_host_unittests)
+ LOCAL_SRC_FILES := $(host_commonSources)
+ $(call emugl-import,lib64emugl_common lib64emugl_gtest)
+ $(call emugl-end-module)
+endif
diff --git a/emulator/opengl/shared/emugl/common/id_to_object_map.cpp b/emulator/opengl/shared/emugl/common/id_to_object_map.cpp
new file mode 100644
index 0000000..597c9eb
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/id_to_object_map.cpp
@@ -0,0 +1,236 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/id_to_object_map.h"
+
+#include <stdlib.h>
+
+namespace emugl {
+
+namespace {
+
+typedef IdToObjectMapBase::KeyType KeyType;
+
+enum {
+ kMinShift = 3,
+ kMaxShift = 31,
+ kMinCapacity = (1 << kMinShift),
+ kLoadScale = 1024,
+ kMinLoad = kLoadScale/4, // 25% minimum load.
+ kMaxLoad = kLoadScale*3/4, // 75% maximum load.
+
+ kInvalidKey = IdToObjectMapBase::kMaxId + 1U,
+ kTombstone = IdToObjectMapBase::kMaxId + 2U,
+};
+
+// Return a number that indicates if the current |capacity| is appropriate
+// to hold |size| items in our map.
+// -1 -> the capacity is too small and needs to be increased.
+// 0 -> the capacity is ok.
+// +1 -> the capacity is too large and needs to be decreased.
+int capacityCompare(size_t shift, size_t size) {
+ size_t capacity = 1U << shift;
+ // Essentially, one can rewrite:
+ // load < minLoad
+ // as:
+ // size / capacity < minLoad
+ // capacity * minLoad > size
+ if (capacity * kMinLoad > size * kLoadScale)
+ return +1;
+
+ // Similarly, one can rewrite:
+ // load > maxLoad
+ // as:
+ // size / capacity > maxLoad
+ // capacity * maxLoad < size
+ if (capacity * kMaxLoad < size * kLoadScale)
+ return -1;
+
+ return 0;
+}
+
+size_t probeKeys(const KeyType* keys, size_t shift, KeyType key) {
+ static const int kPrimes[] = {
+ 1, /* For 1 << 0 */
+ 2,
+ 3,
+ 7,
+ 13,
+ 31,
+ 61,
+ 127,
+ 251,
+ 509,
+ 1021,
+ 2039,
+ 4093,
+ 8191,
+ 16381,
+ 32749,
+ 65521, /* For 1 << 16 */
+ 131071,
+ 262139,
+ 524287,
+ 1048573,
+ 2097143,
+ 4194301,
+ 8388593,
+ 16777213,
+ 33554393,
+ 67108859,
+ 134217689,
+ 268435399,
+ 536870909,
+ 1073741789,
+ 2147483647 /* For 1 << 31 */
+ };
+
+ size_t slot = key % kPrimes[shift];
+ size_t step = 0;
+ for (;;) {
+ KeyType k = keys[slot];
+ if (k == kInvalidKey || k == kTombstone || k == key)
+ return slot;
+
+ step += 1;
+ slot = (slot + step) & (1U << shift);
+ }
+}
+
+} // namespace
+
+IdToObjectMapBase::IdToObjectMapBase() :
+ mCount(0), mShift(kMinShift) {
+ size_t capacity = 1U << mShift;
+ mKeys = static_cast<KeyType*>(::calloc(sizeof(mKeys[0]), capacity));
+ mValues = static_cast<void**>(::calloc(sizeof(mValues[0]), capacity));
+ for (size_t n = 0; n < capacity; ++n) {
+ mKeys[n] = kInvalidKey;
+ }
+}
+
+IdToObjectMapBase::~IdToObjectMapBase() {
+ mShift = 0;
+ mCount = 0;
+ ::free(mKeys);
+ ::free(mValues);
+}
+
+bool IdToObjectMapBase::contains(KeyType key) const {
+ size_t slot = probeKeys(mKeys, mShift, key);
+ switch (mKeys[slot]) {
+ case kInvalidKey:
+ case kTombstone:
+ return false;
+ default:
+ ;
+ }
+ return true;
+}
+
+bool IdToObjectMapBase::find(KeyType key, void** value) const {
+ size_t slot = probeKeys(mKeys, mShift, key);
+ if (!isValidKey(mKeys[slot])) {
+ *value = NULL;
+ return false;
+ }
+ *value = mValues[slot];
+ return true;
+}
+
+void* IdToObjectMapBase::set(KeyType key, void* value) {
+ if (!value)
+ return remove(key);
+
+ size_t slot = probeKeys(mKeys, mShift, key);
+ void* result;
+ if (isValidKey(mKeys[slot])) {
+ result = mValues[slot];
+ mValues[slot] = value;
+ } else {
+ mKeys[slot] = key;
+ mValues[slot] = value;
+ result = NULL;
+ mCount++;
+ resize(mCount);
+ }
+ return result;
+}
+
+void* IdToObjectMapBase::remove(KeyType key) {
+ size_t slot = probeKeys(mKeys, mShift, key);
+ if (!isValidKey(mKeys[slot]))
+ return NULL;
+
+ void* result = mValues[slot];
+ mValues[slot] = NULL;
+ mKeys[slot] = kTombstone;
+ mCount--;
+ return result;
+}
+
+void IdToObjectMapBase::resize(size_t newSize) {
+ int ret = capacityCompare(mShift, newSize);
+ if (!ret)
+ return;
+
+ size_t oldCapacity = 1U << mShift;
+ size_t newShift = mShift;
+
+ if (ret < 0) {
+ // Capacity is too small and must be increased.
+ do {
+ if (newShift == kMaxShift)
+ break;
+ ++newShift;
+ } while (capacityCompare(newShift, newSize) < 0);
+ } else {
+ // Capacity is too large and must be decreased.
+ do {
+ if (newShift == kMinShift)
+ break;
+ newShift--;
+ } while (capacityCompare(newShift, newSize) > 0);
+ }
+ if (newShift == mShift)
+ return;
+
+ // Allocate new arrays.
+ size_t newCapacity = 1U << newShift;
+ KeyType* newKeys = static_cast<KeyType*>(
+ ::calloc(sizeof(newKeys[0]), newCapacity));
+ void** newValues = static_cast<void**>(
+ ::calloc(sizeof(newValues[0]), newCapacity));
+ for (size_t n = 0; n < newCapacity; ++n)
+ newKeys[n] = kInvalidKey;
+
+ // Copy old entries into new arrays.
+ for (size_t n = 0; n < oldCapacity; ++n) {
+ KeyType key = mKeys[n];
+ if (isValidKey(key)) {
+ size_t newSlot = probeKeys(newKeys, newShift, key);
+ newKeys[newSlot] = key;
+ newValues[newSlot] = mValues[n];
+ }
+ }
+
+ // Swap arrays, and get rid of old ones.
+ ::free(mKeys);
+ ::free(mValues);
+ mKeys = newKeys;
+ mValues = newValues;
+ mShift = newShift;
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/id_to_object_map.h b/emulator/opengl/shared/emugl/common/id_to_object_map.h
new file mode 100644
index 0000000..e3d0a81
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/id_to_object_map.h
@@ -0,0 +1,176 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef EMUGL_COMMON_ID_TO_OBJECT_MAP_H
+#define EMUGL_COMMON_ID_TO_OBJECT_MAP_H
+
+#include <stddef.h>
+
+namespace emugl {
+
+// Base implementation class for IdToObjectMap template.
+// Used to reduce template-instanciated code generation.
+class IdToObjectMapBase {
+public:
+ // The type of keys in this map.
+ typedef unsigned KeyType;
+
+ // Values higher than kMaxId cannot be used as map keys.
+ enum {
+ kMaxId = 0xfffffffdU,
+ };
+
+ static inline bool isValidKey(KeyType key) {
+ return key <= kMaxId;
+ }
+
+protected:
+ IdToObjectMapBase();
+
+ ~IdToObjectMapBase();
+
+ void clear();
+
+ // Return size
+ inline size_t size() const { return mCount; }
+
+ inline size_t capacity() const { return 1U << mShift; }
+
+ // Return true iff the map contains a given key.
+ bool contains(KeyType key) const;
+
+ // Find a value associated with a given |key| in the map.
+ // On success, return true and sets |*value| to the value/pointer,
+ // which is _still_ owned by the map.
+ // On failure, return false and sets |*value| to NULL.
+ bool find(KeyType key, void** value) const;
+
+ // Associate a value with a given |key| in the map.
+ // Return the old value for the key, if any. Caller is responsible
+ // for freeing it.
+ void* set(KeyType key, void* value);
+
+ // Remove the value associated with a given |key|.
+ // Return the old value, if any. Caller is responsible for
+ // freeing it.
+ void* remove(KeyType key);
+
+ size_t mCount;
+ size_t mShift;
+ KeyType* mKeys;
+ void** mValues;
+
+private:
+ // Resize the map if needed to ensure it can hold at least |newSize|
+ // entries.
+ void resize(size_t newSize);
+};
+
+// A templated data container that acts as a dictionary mapping unsigned
+// integer keys to heap-allocated objects of type T. The dictionary
+// owns the objects associated with its keys, and automatically destroys
+// them when it is destroyed, or during replacement or removal.
+template <class T>
+class IdToObjectMap : public IdToObjectMapBase {
+public:
+ // Initialize an empty instance.
+ IdToObjectMap() : IdToObjectMapBase() {}
+
+ // Destroy this instance.
+ ~IdToObjectMap() {
+ clear();
+ }
+
+ // Return the number of items in this map.
+ inline size_t size() const { return IdToObjectMapBase::size(); }
+
+ // Return true iff the map is empty.
+ inline bool empty() const { return !IdToObjectMapBase::size(); }
+
+ // Remove all items from the map.
+ void clear();
+
+ // Returns true iff the dictionary contains a value for |key|.
+ inline bool contains(KeyType key) const {
+ return IdToObjectMapBase::contains(key);
+ }
+
+ // Find the value corresponding to |key| in this map.
+ // On success, return true, and sets |*value| to point to the
+ // value (still owned by the instance). On failure, return false.
+ inline bool find(KeyType key, T** value) const {
+ return IdToObjectMapBase::find(key, reinterpret_cast<void**>(value));
+ }
+
+ // Return the value associated with a given |key|, or NULL if it is
+ // not in the map. Result is still owned by the map.
+ inline T* get(KeyType key) const {
+ T* result = NULL;
+ this->find(key, &result);
+ return result;
+ }
+
+ // Associate |value| with a given |key|. Returns true if a previous
+ // value was replaced, and false if this is the first time a value
+ // was associated with the given key. IMPORTANT: This transfers
+ // ownership of |value| to the map instance. In case of replacement,
+ // the old value is automatically destroyed. Using NULL as the value
+ // is equivalent to calling remove().
+ bool set(KeyType key, T* value);
+
+ // Remove any value associated with |key|.
+ // Return true iff a value was associated with the key and destroyed
+ // by this function, false if there was no value associated with the
+ // key (or if it was NULL).
+ bool remove(KeyType key);
+};
+
+template <class T>
+void IdToObjectMap<T>::clear() {
+ size_t n = capacity();
+ while (n > 0) {
+ --n;
+ if (!isValidKey(mKeys[n]))
+ continue;
+
+ delete static_cast<T*>(mValues[n]);
+ mValues[n] = NULL;
+ mKeys[n] = kMaxId + 1U;
+ }
+ mCount = 0;
+}
+
+template <class T>
+bool IdToObjectMap<T>::set(KeyType key, T* value) {
+ T* oldValue = static_cast<T*>(IdToObjectMapBase::set(key, value));
+ if (!oldValue) {
+ return false;
+ }
+ delete oldValue;
+ return true;
+}
+
+template <class T>
+bool IdToObjectMap<T>::remove(KeyType key) {
+ T* oldValue = static_cast<T*>(IdToObjectMapBase::remove(key));
+ if (!oldValue)
+ return false;
+ delete oldValue;
+ return true;
+}
+
+} // namespace emugl
+
+
+#endif // EMUGL_COMMON_ID_TO_OBJECT_MAP_H
diff --git a/emulator/opengl/shared/emugl/common/id_to_object_map_unittest.cpp b/emulator/opengl/shared/emugl/common/id_to_object_map_unittest.cpp
new file mode 100644
index 0000000..50740be
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/id_to_object_map_unittest.cpp
@@ -0,0 +1,116 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/id_to_object_map.h"
+
+#include <gtest/gtest.h>
+
+namespace emugl {
+
+namespace {
+
+typedef IdToObjectMapBase::KeyType KeyType;
+
+class Foo {
+public:
+ Foo() : mVal(0) {}
+ Foo(int val) : mVal(val) {}
+ ~Foo() {}
+ int val() const { return mVal; }
+ void setVal(int val) { mVal = val; }
+private:
+ int mVal;
+};
+
+} // namespace
+
+TEST(IdToObjectMap, Empty) {
+ IdToObjectMap<Foo> map;
+ EXPECT_TRUE(map.empty());
+ EXPECT_EQ(0U, map.size());
+}
+
+TEST(IdToObjectMap, SetIntegerRange) {
+ IdToObjectMap<Foo> map;
+ KeyType kMax = 10000;
+
+ // Add all items in the map.
+ for (KeyType n = 0; n < kMax; ++n) {
+ EXPECT_FALSE(map.set(n, new Foo(n))) << "For key " << n;
+ }
+
+ // Check final size.
+ EXPECT_EQ(static_cast<size_t>(kMax), map.size());
+
+ // Find all items in the map.
+ for (KeyType n = 0; n < kMax; ++n) {
+ EXPECT_TRUE(map.contains(n)) << "For key " << n;
+ Foo* foo = NULL;
+ EXPECT_TRUE(map.find(n, &foo)) << "For key " << n;
+ if (foo) {
+ EXPECT_EQ(static_cast<int>(n), foo->val()) << "For key " << n;
+ }
+ }
+}
+
+TEST(IdToObjectMap, RemoveAll) {
+ IdToObjectMap<Foo> map;
+ KeyType kMax = 10000;
+
+ // Add all items in the map.
+ for (KeyType n = 0; n < kMax; ++n) {
+ EXPECT_FALSE(map.set(n, new Foo(n))) << "For key " << n;
+ }
+
+ EXPECT_EQ(static_cast<size_t>(kMax), map.size());
+
+ for (KeyType n = 0; n < kMax; ++n) {
+ EXPECT_TRUE(map.remove(n)) << "For key " << n;
+ }
+ EXPECT_EQ(0U, map.size());
+}
+
+TEST(IdToObjectMap, RemoveOdd) {
+ IdToObjectMap<Foo> map;
+ KeyType kMax = 10000;
+
+ // Add all items in the map.
+ for (KeyType n = 0; n < kMax; ++n) {
+ EXPECT_FALSE(map.set(n, new Foo(n))) << "For key " << n;
+ }
+
+ EXPECT_EQ(static_cast<size_t>(kMax), map.size());
+
+ for (KeyType n = 0; n < kMax; ++n) {
+ if (n & 1) {
+ EXPECT_TRUE(map.remove(n)) << "For key " << n;
+ }
+ }
+ EXPECT_EQ(static_cast<size_t>(kMax / 2), map.size());
+
+ for (KeyType n = 0; n < kMax; ++n) {
+ if (n & 1) {
+ EXPECT_FALSE(map.contains(n)) << "For key " << n;
+ } else {
+ EXPECT_TRUE(map.contains(n)) << "For key " << n;
+ Foo* foo = NULL;
+ EXPECT_TRUE(map.find(n, &foo)) << "For key " << n;
+ if (foo) {
+ EXPECT_EQ(static_cast<int>(n), foo->val());
+ }
+ }
+ }
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/lazy_instance.cpp b/emulator/opengl/shared/emugl/common/lazy_instance.cpp
new file mode 100644
index 0000000..ee715fa
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/lazy_instance.cpp
@@ -0,0 +1,101 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/lazy_instance.h"
+
+#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN 1
+# include <windows.h>
+#else
+# include <sched.h>
+#endif
+
+namespace emugl {
+namespace internal {
+
+typedef LazyInstanceState::AtomicType AtomicType;
+
+#if defined(__GNUC__)
+static inline void compilerBarrier() {
+ __asm__ __volatile__ ("" : : : "memory");
+}
+#else
+#error "Your compiler is not supported"
+#endif
+
+#if defined(__i386__) || defined(__x86_64__)
+# define acquireBarrier() compilerBarrier()
+# define releaseBarrier() compilerBarrier()
+#else
+# error "Your CPU is not supported"
+#endif
+
+static inline AtomicType loadAcquire(AtomicType volatile* ptr) {
+ AtomicType ret = *ptr;
+ acquireBarrier();
+ return ret;
+}
+
+static inline void storeRelease(AtomicType volatile* ptr, AtomicType value) {
+ releaseBarrier();
+ *ptr = value;
+}
+
+static int atomicCompareAndSwap(AtomicType volatile* ptr,
+ int expected,
+ int value) {
+#ifdef _WIN32
+ return InterlockedCompareExchange(ptr, value, expected);
+#elif defined(__GNUC__)
+ return __sync_val_compare_and_swap(ptr, expected, value);
+#else
+#error "Your compiler is not supported"
+#endif
+}
+
+static void yieldThread() {
+#ifdef _WIN32
+ ::Sleep(0);
+#else
+ sched_yield();
+#endif
+}
+
+bool LazyInstanceState::inInitState() {
+ return loadAcquire(&mState) == STATE_INIT;
+}
+
+bool LazyInstanceState::needConstruction() {
+ AtomicType state = loadAcquire(&mState);
+ if (mState == STATE_DONE)
+ return false;
+
+ state = atomicCompareAndSwap(&mState, STATE_INIT, STATE_CONSTRUCTING);
+ if (state == STATE_INIT)
+ return true;
+
+ do {
+ yieldThread();
+ state = loadAcquire(&mState);
+ } while (state != STATE_DONE);
+
+ return false;
+}
+
+void LazyInstanceState::doneConstructing() {
+ storeRelease(&mState, STATE_DONE);
+}
+
+} // namespace internal
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/lazy_instance.h b/emulator/opengl/shared/emugl/common/lazy_instance.h
new file mode 100644
index 0000000..6641c93
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/lazy_instance.h
@@ -0,0 +1,156 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef EMUGL_COMMON_LAZY_INSTANCE_H
+#define EMUGL_COMMON_LAZY_INSTANCE_H
+
+#include <new>
+
+#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN 1
+# include <windows.h>
+#endif
+
+namespace emugl {
+namespace internal {
+
+// A LazyInstance is a helper template that can be used to perform
+// thread-safe lazy initialization of static C++ objects without forcing
+// the generation of C++ static constructors in the final executable.
+//
+// In a nutshell, you can replace a statement like:
+//
+// static Foo gFoo;
+//
+// With:
+//
+// static LazyInstance<Foo> gFoo = LAZY_INSTANCE_INIT;
+//
+// In the first case, a hidden static C++ constructor is embedded in the
+// final executable, and executed at *load* *time* to call the Foo::Foo
+// constructor on the gFoo object.
+//
+// On the second case, gFoo will only be initialized lazily, i.e. the first
+// time any code actually tries to access the variable.
+//
+// Note that access is slightly different, i.e.:
+//
+// gFoo.get() returns a reference to the lazy-initialized object.
+// gFoo.ptr() returns a pointer to it.
+// gFoo->Something() is equivalent to doing gFoo.ptr()->Something().
+//
+// 'gFoo' is stored in the .bss section and this doesn't use heap allocation.
+// This class can only be used to perform lazy initialization through the
+// class' default constructor. For more specialized cases, you will have
+// to create a derived class, e.g.:
+//
+// class FoorWithDefaultParams : public Foo {
+// public:
+// FooWithDefaultParams() : Foo(<default-parameters>) {}
+// };
+//
+// LazyInstance<FooWithDefaultParams> gFoo = LAZY_INSTANCE_INIT;
+//
+// The implementation of LazyInstance relies on atomic operations and
+// POD-struct class definitions, i.e. one that doesn't have any constructor,
+// destructor, virtual members, or private ones, and that can be
+// zero-initialized at link time.
+//
+// You can also use LazyInstance<> instances as static local variables,
+// e.g.:
+//
+// Foo* getFooSingleton() {
+// static LazyInstance<Foo> sFoo = LAZY_INSTANCE_INIT;
+// return sFoo.ptr();
+// }
+//
+// This is useful on Windows which doesn't support thread-safe lazy
+// initialization of static C++ local variables, or when the code is
+// compiled with -fno-threadsafe-statics.
+//
+// This class is heavily inspired by Chromium's implementation of the
+// same-named class (see $CHROMIUM/src/base/lazy_instance.h).
+
+// Atomic state variable type. Used to ensure to synchronize concurrent
+// initialization and access without incurring the full cost of a mutex
+// lock/unlock.
+struct LazyInstanceState {
+ enum {
+ STATE_INIT = 0,
+ STATE_CONSTRUCTING = 1,
+ STATE_DONE = 2,
+ };
+
+ bool inInitState();
+ bool needConstruction();
+ void doneConstructing();
+
+#ifdef _WIN32
+ typedef LONG volatile AtomicType;
+#else
+ typedef int volatile AtomicType;
+#endif
+
+ volatile AtomicType mState;
+};
+
+#define LAZY_INSTANCE_STATE_INIT \
+ { ::emugl::internal::LazyInstanceState::STATE_INIT }
+
+} // namespace internal
+
+// LazyInstance template definition, see comment above for usage
+// instructions. It is crucial to make this a POD-struct compatible
+// type [1].
+//
+// [1] http://en.wikipedia.org/wiki/Plain_Old_Data_Structures
+//
+template <class T>
+struct LazyInstance {
+ bool hasInstance() const { return !mState.inInitState(); }
+
+ T& get() const { return *ptr(); }
+
+ T* ptr() const;
+
+ const T* operator->() const { return ptr(); }
+
+ T* operator->() { return ptr(); }
+
+ T& operator*() { return get(); }
+
+ // Really private, do not use.
+ union {
+ mutable internal::LazyInstanceState mState;
+ double mPadding;
+ };
+ mutable char mStorage[sizeof(T)];
+};
+
+// Initialization value, must resolve to all-0 to ensure the object
+// instance is actually placed in the .bss
+#define LAZY_INSTANCE_INIT { { LAZY_INSTANCE_STATE_INIT }, { 0 } }
+
+template <class T>
+T* LazyInstance<T>::ptr() const {
+ if (mState.needConstruction()) {
+ new (mStorage) T();
+ mState.doneConstructing();
+ }
+ return reinterpret_cast<T*>(mStorage);
+}
+
+} // namespace emugl
+
+#endif // EMUGL_COMMON_LAZY_INSTANCE_H
diff --git a/emulator/opengl/shared/emugl/common/lazy_instance_unittest.cpp b/emulator/opengl/shared/emugl/common/lazy_instance_unittest.cpp
new file mode 100644
index 0000000..824845f
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/lazy_instance_unittest.cpp
@@ -0,0 +1,146 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/lazy_instance.h"
+
+#include "emugl/common/mutex.h"
+#include "emugl/common/testing/test_thread.h"
+
+#include <gtest/gtest.h>
+
+namespace emugl {
+
+namespace {
+
+class Foo {
+public:
+ Foo() : mValue(42) {}
+ int get() const { return mValue; }
+ void set(int value) { mValue = value; }
+ ~Foo() { mValue = 13; }
+private:
+ int mValue;
+};
+
+class StaticCounter {
+public:
+ StaticCounter() {
+ Mutex::AutoLock lock(mMutex);
+ mCounter++;
+ }
+
+ int getValue() const {
+ Mutex::AutoLock lock(mMutex);
+ return mCounter;
+ }
+
+private:
+ static Mutex mMutex;
+ static int mCounter;
+};
+
+// NOTE: This introduces a static C++ constructor for this object file,
+// but that's ok because a LazyInstance<Mutex> should not be used to
+// test the behaviour of LazyInstance :-)
+Mutex StaticCounter::mMutex;
+int StaticCounter::mCounter = 0;
+
+} // namespace
+
+TEST(LazyInstance, HasInstance) {
+ LazyInstance<Foo> foo_instance = LAZY_INSTANCE_INIT;
+ EXPECT_FALSE(foo_instance.hasInstance());
+ EXPECT_FALSE(foo_instance.hasInstance());
+ foo_instance.ptr();
+ EXPECT_TRUE(foo_instance.hasInstance());
+}
+
+TEST(LazyInstance, Simple) {
+ LazyInstance<Foo> foo_instance = LAZY_INSTANCE_INIT;
+ Foo* foo1 = foo_instance.ptr();
+ EXPECT_TRUE(foo1);
+ EXPECT_EQ(42, foo_instance->get());
+ foo1->set(10);
+ EXPECT_EQ(10, foo_instance->get());
+ EXPECT_EQ(foo1, foo_instance.ptr());
+}
+
+// For the following test, launch 1000 threads that each try to get
+// the instance pointer of a lazy instance. Then verify that they're all
+// the same value.
+//
+// The lazy instance has a special constructor that will increment a
+// global counter. This allows us to ensure that it is only called once.
+//
+
+namespace {
+
+// The following is the shared structure between all threads.
+struct MultiState {
+ MultiState(LazyInstance<StaticCounter>* staticCounter) :
+ mMutex(), mStaticCounter(staticCounter), mCount(0) {}
+
+ enum {
+ kMaxThreads = 1000,
+ };
+
+ Mutex mMutex;
+ LazyInstance<StaticCounter>* mStaticCounter;
+ size_t mCount;
+ void* mValues[kMaxThreads];
+ TestThread* mThreads[kMaxThreads];
+};
+
+// The thread function for the test below.
+static void* threadFunc(void* param) {
+ MultiState* state = static_cast<MultiState*>(param);
+ Mutex::AutoLock lock(state->mMutex);
+ if (state->mCount < MultiState::kMaxThreads) {
+ state->mValues[state->mCount++] = state->mStaticCounter->ptr();
+ }
+ return NULL;
+}
+
+} // namespace
+
+TEST(LazyInstance, MultipleThreads) {
+ LazyInstance<StaticCounter> counter_instance = LAZY_INSTANCE_INIT;
+ MultiState state(&counter_instance);
+ const size_t kNumThreads = MultiState::kMaxThreads;
+
+ // Create all threads.
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ state.mThreads[n] = new TestThread(threadFunc, &state);
+ }
+
+ // Wait for their completion.
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ state.mThreads[n]->join();
+ }
+
+ // Now check that the constructor was only called once.
+ EXPECT_EQ(1, counter_instance->getValue());
+
+ // Now compare all the store values, they should be the same.
+ StaticCounter* expectedValue = counter_instance.ptr();
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ EXPECT_EQ(expectedValue, state.mValues[n]) << "For thread " << n;
+ }
+
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ delete state.mThreads[n];
+ }
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/mutex.h b/emulator/opengl/shared/emugl/common/mutex.h
new file mode 100644
index 0000000..c6cdcf2
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/mutex.h
@@ -0,0 +1,92 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef EMUGL_MUTEX_H
+#define EMUGL_MUTEX_H
+
+#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN 1
+# include <windows.h>
+#else
+# include <pthread.h>
+#endif
+
+namespace emugl {
+
+// Simple wrapper class for mutexes.
+class Mutex {
+public:
+ // Constructor.
+ Mutex() {
+#ifdef _WIN32
+ ::InitializeCriticalSection(&mLock);
+#else
+ ::pthread_mutex_init(&mLock, NULL);
+#endif
+ }
+
+ // Destructor.
+ ~Mutex() {
+#ifdef _WIN32
+ ::DeleteCriticalSection(&mLock);
+#else
+ ::pthread_mutex_destroy(&mLock);
+#endif
+ }
+
+ // Acquire the mutex.
+ void lock() {
+#ifdef _WIN32
+ ::EnterCriticalSection(&mLock);
+#else
+ ::pthread_mutex_lock(&mLock);
+#endif
+ }
+
+ // Release the mutex.
+ void unlock() {
+#ifdef _WIN32
+ ::LeaveCriticalSection(&mLock);
+#else
+ ::pthread_mutex_unlock(&mLock);
+#endif
+ }
+
+ // Helper class to lock / unlock a mutex automatically on scope
+ // entry and exit.
+ class AutoLock {
+ public:
+ AutoLock(Mutex& mutex) : mMutex(&mutex) {
+ mMutex->lock();
+ }
+
+ ~AutoLock() {
+ mMutex->unlock();
+ }
+ private:
+ Mutex* mMutex;
+ };
+
+private:
+#ifdef _WIN32
+ CRITICAL_SECTION mLock;
+#else
+ pthread_mutex_t mLock;
+#endif
+
+};
+
+} // namespace emugl
+
+#endif // EMUGL_MUTEX_H
diff --git a/emulator/opengl/shared/emugl/common/mutex_unittest.cpp b/emulator/opengl/shared/emugl/common/mutex_unittest.cpp
new file mode 100644
index 0000000..e952d75
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/mutex_unittest.cpp
@@ -0,0 +1,108 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/mutex.h"
+
+#include "emugl/common/testing/test_thread.h"
+
+#include <gtest/gtest.h>
+
+namespace emugl {
+
+// Check that construction and destruction doesn't crash.
+TEST(Mutex, ConstructionDestruction) {
+ Mutex lock;
+}
+
+// Check that a simple lock + unlock works.
+TEST(Mutex, LockUnlock) {
+ Mutex lock;
+ lock.lock();
+ lock.unlock();
+}
+
+// Check that AutoLock compiles and doesn't crash.
+TEST(Mutex, AutoLock) {
+ Mutex mutex;
+ Mutex::AutoLock lock(mutex);
+}
+
+// Wrapper class for threads. Does not use emugl::Thread intentionally.
+// Common data type used by the following tests below.
+struct ThreadParams {
+ ThreadParams() : mutex(), counter(0) {}
+
+ Mutex mutex;
+ int counter;
+};
+
+// This thread function uses Mutex::lock/unlock to synchronize a counter
+// increment operation.
+static void* threadFunction(void* param) {
+ ThreadParams* p = static_cast<ThreadParams*>(param);
+
+ p->mutex.lock();
+ p->counter++;
+ p->mutex.unlock();
+ return NULL;
+}
+
+TEST(Mutex, Synchronization) {
+ const size_t kNumThreads = 2000;
+ TestThread* threads[kNumThreads];
+ ThreadParams p;
+
+ // Create and launch all threads.
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ threads[n] = new TestThread(threadFunction, &p);
+ }
+
+ // Wait until their completion.
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ threads[n]->join();
+ delete threads[n];
+ }
+
+ EXPECT_EQ(static_cast<int>(kNumThreads), p.counter);
+}
+
+// This thread function uses a Mutex::AutoLock to protect the counter.
+static void* threadAutoLockFunction(void* param) {
+ ThreadParams* p = static_cast<ThreadParams*>(param);
+
+ Mutex::AutoLock lock(p->mutex);
+ p->counter++;
+ return NULL;
+}
+
+TEST(Mutex, AutoLockSynchronization) {
+ const size_t kNumThreads = 2000;
+ TestThread* threads[kNumThreads];
+ ThreadParams p;
+
+ // Create and launch all threads.
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ threads[n] = new TestThread(threadAutoLockFunction, &p);
+ }
+
+ // Wait until their completion.
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ threads[n]->join();
+ delete threads[n];
+ }
+
+ EXPECT_EQ(static_cast<int>(kNumThreads), p.counter);
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/pod_vector.cpp b/emulator/opengl/shared/emugl/common/pod_vector.cpp
new file mode 100644
index 0000000..c8ec3a6
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/pod_vector.cpp
@@ -0,0 +1,150 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/pod_vector.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+#define USE_MALLOC_USABLE_SIZE 0
+
+namespace emugl {
+
+static inline void swapPointers(char** p1, char** p2) {
+ char* tmp = *p1;
+ *p1 = *p2;
+ *p2 = tmp;
+}
+
+PodVectorBase::PodVectorBase(const PodVectorBase& other) {
+ initFrom(other.begin(), other.byteSize());
+}
+
+PodVectorBase& PodVectorBase::operator=(const PodVectorBase& other) {
+ initFrom(other.begin(), other.byteSize());
+ return *this;
+}
+
+PodVectorBase::~PodVectorBase() {
+ if (mBegin) {
+ // Sanity.
+ ::memset(mBegin, 0xee, byteSize());
+ ::free(mBegin);
+ mBegin = NULL;
+ mEnd = NULL;
+ mLimit = NULL;
+ }
+}
+
+void PodVectorBase::initFrom(const void* from, size_t fromLen) {
+ if (!fromLen || !from) {
+ mBegin = NULL;
+ mEnd = NULL;
+ mLimit = NULL;
+ } else {
+ mBegin = static_cast<char*>(::malloc(fromLen));
+ mEnd = mLimit = mBegin + fromLen;
+ ::memcpy(mBegin, from, fromLen);
+ }
+}
+
+void PodVectorBase::assignFrom(const PodVectorBase& other) {
+ resize(other.byteSize(), 1U);
+ ::memmove(begin(), other.begin(), byteSize());
+}
+
+void PodVectorBase::resize(size_t newSize, size_t itemSize) {
+ const size_t kMaxSize = maxItemCapacity(itemSize);
+ size_t oldCapacity = itemCapacity(itemSize);
+ const size_t kMinCapacity = 256 / itemSize;
+
+ if (newSize < oldCapacity) {
+ // Only shrink if the new size is really small.
+ if (newSize < oldCapacity / 2 && oldCapacity > kMinCapacity) {
+ reserve(newSize, itemSize);
+ }
+ } else if (newSize > oldCapacity) {
+ size_t newCapacity = oldCapacity;
+ while (newCapacity < newSize) {
+ size_t newCapacity2 = newCapacity + (newCapacity >> 2) + 8;
+ if (newCapacity2 < newCapacity || newCapacity > kMaxSize) {
+ newCapacity = kMaxSize;
+ } else {
+ newCapacity = newCapacity2;
+ }
+ }
+ reserve(newCapacity, itemSize);
+ }
+ mEnd = mBegin + newSize * itemSize;
+}
+
+void PodVectorBase::reserve(size_t newSize, size_t itemSize) {
+ if (newSize == 0) {
+ ::free(mBegin);
+ mBegin = NULL;
+ mEnd = NULL;
+ mLimit = NULL;
+ return;
+ }
+
+ size_t oldByteSize = byteSize();
+ size_t newByteCapacity = newSize * itemSize;
+ char* newBegin = static_cast<char*>(::realloc(mBegin, newByteCapacity));
+ mBegin = newBegin;
+ mEnd = newBegin + oldByteSize;
+#if USE_MALLOC_USABLE_SIZE
+ size_t usableSize = malloc_usable_size(mBegin);
+ if (usableSize > newByteCapacity) {
+ newByteCapacity = usableSize - (usableSize % itemSize);
+ }
+#endif
+ mLimit = newBegin + newByteCapacity;
+ // Sanity.
+ if (newByteCapacity > oldByteSize) {
+ ::memset(mBegin + oldByteSize, 0, newByteCapacity - oldByteSize);
+ }
+}
+
+void PodVectorBase::removeAt(size_t itemPos, size_t itemSize) {
+ size_t count = itemCount(itemSize);
+ if (itemPos < count) {
+ size_t pos = itemPos * itemSize;
+ ::memmove(mBegin + pos,
+ mBegin + pos + itemSize,
+ byteSize() - pos - itemSize);
+ resize(count - 1U, itemSize);
+ }
+}
+
+void* PodVectorBase::insertAt(size_t itemPos, size_t itemSize) {
+ size_t count = this->itemCount(itemSize);
+ resize(count + 1, itemSize);
+ size_t pos = itemPos * itemSize;
+ if (itemPos < count) {
+ ::memmove(mBegin + pos + itemSize,
+ mBegin + pos,
+ count * itemSize - pos);
+ // Sanity to avoid copying pointers and other bad stuff.
+ ::memset(mBegin + pos, 0, itemSize);
+ }
+ return mBegin + pos;
+}
+
+void PodVectorBase::swapAll(PodVectorBase* other) {
+ swapPointers(&mBegin, &other->mBegin);
+ swapPointers(&mEnd, &other->mEnd);
+ swapPointers(&mLimit, &other->mLimit);
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/pod_vector.h b/emulator/opengl/shared/emugl/common/pod_vector.h
new file mode 100644
index 0000000..c4e184b
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/pod_vector.h
@@ -0,0 +1,265 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef EMUGL_COMMON_POD_VECTOR_H
+#define EMUGL_COMMON_POD_VECTOR_H
+
+
+#include <stddef.h>
+
+#ifndef __STDC_LIMIT_MACROS
+#define __STDC_LIMIT_MACROS 1
+#endif
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS 1
+#endif
+#include <stdint.h>
+
+#ifndef SIZE_MAX
+#error "You must define __STDC_LIMIT_MACROS before including <stddint.h>"
+#endif
+
+namespace emugl {
+
+// A PodVector is a templated vector-like type that is used to store
+// POD-struct compatible items only. This allows the implementation to
+// use ::memmove() to move items, and also malloc_usable_size() to
+// determine the best capacity.
+//
+// std::vector<> is capable of doing this in theory, using horrible
+// templating tricks that make error messages very difficult to
+// understand.
+//
+// Note that a PodVector can be used to store items that contain pointers,
+// as long as these do not point to items in the same container.
+//
+// The PodVector provides methods that also follow the std::vector<>
+// conventions, i.e. push_back() is an alias for append().
+//
+
+// NOTE: This is a re-implementation of
+// external/qemu/android/base/containers/PodVector.h for emugl.
+
+// PodVectorBase is a base, non-templated, implementation class that all
+// PodVector instances derive from. This is used to reduce template
+// specialization. Do not use directly, i..e it's an implementation detail.
+class PodVectorBase {
+protected:
+ PodVectorBase() : mBegin(NULL), mEnd(NULL), mLimit(NULL) {}
+ explicit PodVectorBase(const PodVectorBase& other);
+ PodVectorBase& operator=(const PodVectorBase& other);
+ ~PodVectorBase();
+
+ bool empty() const { return mEnd == mBegin; }
+
+ size_t byteSize() const { return mEnd - mBegin; }
+
+ size_t byteCapacity() const { return mLimit - mBegin; }
+
+ void* begin() { return mBegin; }
+ const void* begin() const { return mBegin; }
+ void* end() { return mEnd; }
+ const void* end() const { return mEnd; }
+
+ void* itemAt(size_t pos, size_t itemSize) {
+ return mBegin + pos * itemSize;
+ }
+
+ const void* itemAt(size_t pos, size_t itemSize) const {
+ return mBegin + pos * itemSize;
+ }
+
+ void assignFrom(const PodVectorBase& other);
+
+ inline size_t itemCount(size_t itemSize) const {
+ return byteSize() / itemSize;
+ }
+
+ inline size_t itemCapacity(size_t itemSize) const {
+ return byteCapacity() / itemSize;
+ }
+
+ inline size_t maxItemCapacity(size_t itemSize) const {
+ return SIZE_MAX / itemSize;
+ }
+
+ void resize(size_t newSize, size_t itemSize);
+ void reserve(size_t newSize, size_t itemSize);
+
+ void removeAt(size_t index, size_t itemSize);
+ void* insertAt(size_t index, size_t itemSize);
+ void swapAll(PodVectorBase* other);
+
+ char* mBegin;
+ char* mEnd;
+ char* mLimit;
+
+private:
+ void initFrom(const void* from, size_t fromLen);
+};
+
+
+// A PodVector<T> holds a vector (dynamically resizable array) or items
+// that must be POD-struct compatible (i.e. they cannot have constructors,
+// destructors, or virtual members). This allows the implementation to be
+// small, fast and efficient, memory-wise.
+//
+// If you want to implement a vector of C++ objects, consider using
+// std::vector<> instead, but keep in mind that this implies a non-trivial
+// cost when appending, inserting, removing items in the collection.
+//
+template <typename T>
+class PodVector : public PodVectorBase {
+public:
+ // Default constructor for an empty PodVector<T>
+ PodVector() : PodVectorBase() {}
+
+ // Copy constructor. This copies all items from |other| into
+ // the new instance with ::memmove().
+ PodVector(const PodVector& other) : PodVectorBase(other) {}
+
+ // Assignment operator.
+ PodVector& operator=(const PodVector& other) {
+ this->assignFrom(other);
+ return *this;
+ }
+
+ // Destructor, this simply releases the internal storage block that
+ // holds all the items, but doesn't touch them otherwise.
+ ~PodVector() {}
+
+ // Return true iff the PodVector<T> instance is empty, i.e. does not
+ // have any items.
+ bool empty() const { return PodVectorBase::empty(); }
+
+ // Return the number of items in the current PodVector<T> instance.
+ size_t size() const { return PodVectorBase::itemCount(sizeof(T)); }
+
+ // Return the current capacity in the current PodVector<T> instance.
+ // Do not use directly, except if you know what you're doing. Try to
+ // use resize() or reserve() instead.
+ size_t capacity() const {
+ return PodVectorBase::itemCapacity(sizeof(T));
+ }
+
+ // Return the maximum capacity of any PodVector<T> instance.
+ static inline size_t maxCapacity() { return SIZE_MAX / sizeof(T); }
+
+ // Resize the vector to ensure it can hold |newSize|
+ // items. This may or may not call reserve() under the hood.
+ // It's a fatal error to try to resize above maxCapacity().
+ void resize(size_t newSize) {
+ PodVectorBase::resize(newSize, sizeof(T));
+ }
+
+ // Resize the vector's storage array to ensure that it can hold at
+ // least |newSize| items. It's a fatal error to try to resize above
+ // maxCapacity().
+ void reserve(size_t newSize) {
+ PodVectorBase::reserve(newSize, sizeof(T));
+ }
+
+ // Return a pointer to the first item in the vector. This is only
+ // valid until the next call to any function that changes the size
+ // or capacity of the vector. Can be NULL if the vector is empty.
+ T* begin() {
+ return reinterpret_cast<T*>(PodVectorBase::begin());
+ }
+
+ // Return a constant pointer to the first item in the vector. This is
+ // only valid until the next call to any function that changes the
+ // size of capacity of the vector.
+ const T* begin() const {
+ return reinterpret_cast<T*>(PodVectorBase::begin());
+ }
+
+ // Return a pointer past the last item in the vector. I.e. if the
+ // result is not NULL, then |result - 1| points to the last item.
+ // Can be NULL if the vector is empty.
+ T* end() {
+ return reinterpret_cast<T*>(PodVectorBase::end());
+ }
+
+ // Return a constant pointer past the last item in the vector. I.e. if
+ // the result is not NULL, then |result - 1| points to the last item.
+ // Can be NULL if the vector is empty.
+ const T* end() const {
+ return reinterpret_cast<T*>(PodVectorBase::end());
+ }
+
+ // Returns a reference to the item a position |index| in the vector.
+ // It may be a fatal error to access an out-of-bounds position.
+ T& operator[](size_t index) {
+ return *reinterpret_cast<T*>(
+ PodVectorBase::itemAt(index, sizeof(T)));
+ }
+
+ const T& operator[](size_t index) const {
+ return *reinterpret_cast<const T*>(
+ PodVectorBase::itemAt(index, sizeof(T)));
+ }
+
+ // Increase the vector's size by 1, then move all items past a given
+ // position to the right. Return the position of the insertion point
+ // to let the caller copy the content it desires there. It's preferrable
+ // to use insert() directly, which will do the item copy for you.
+ T* emplace(size_t index) {
+ return reinterpret_cast<T*>(
+ PodVectorBase::insertAt(index, sizeof(T)));
+ }
+
+ // Insert an item at a given position. |index| is the insertion position
+ // which must be between 0 and size() included, or a fatal error may
+ // occur. |item| is a reference to an item to copy into the array,
+ // byte-by-byte.
+ void insert(size_t index, const T& item) {
+ *(this->emplace(index)) = item;
+ }
+
+ // Prepend an item at the start of a vector. This moves all vector items
+ // to the right, and is thus costly. |item| is a reference to an item
+ // to copy to the start of the vector.
+ void prepend(const T& item) {
+ *(this->emplace(0U)) = item;
+ }
+
+ // Append an item at the end of a vector. Specialized version of insert()
+ // which always uses size() as the insertion position.
+ void append(const T& item) {
+ *(this->emplace(this->size())) = item;
+ }
+
+ // Remove the item at a given position. |index| is the position of the
+ // item to delete. It must be between 0 and size(), included, or
+ // a fatal error may occur. Deleting the item at position size()
+ // doesn't do anything.
+ void remove(size_t index) {
+ PodVectorBase::removeAt(index, sizeof(T));
+ }
+
+ void swap(PodVector* other) {
+ PodVectorBase::swapAll(other);
+ }
+
+ // Compatibility methods for std::vector<>
+ void push_back(const T& item) { append(item); }
+ void pop() { remove(0U); }
+
+ typedef T* iterator;
+ typedef const T* const_iterator;
+};
+
+} // namespace emugl
+
+#endif // EMUGL_COMMON_POD_VECTOR_H
diff --git a/emulator/opengl/shared/emugl/common/pod_vector_unittest.cpp b/emulator/opengl/shared/emugl/common/pod_vector_unittest.cpp
new file mode 100644
index 0000000..9ce509a
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/pod_vector_unittest.cpp
@@ -0,0 +1,127 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/pod_vector.h"
+
+#include <gtest/gtest.h>
+
+namespace emugl {
+
+static int hashIndex(size_t n) {
+ return static_cast<int>(((n >> 14) * 13773) + (n * 51));
+}
+
+TEST(PodVector, Empty) {
+ PodVector<int> v;
+ EXPECT_TRUE(v.empty());
+ EXPECT_EQ(0U, v.size());
+}
+
+TEST(PodVector, AppendOneItem) {
+ PodVector<int> v;
+ v.append(10234);
+ EXPECT_FALSE(v.empty());
+ EXPECT_EQ(1U, v.size());
+ EXPECT_EQ(10234, v[0]);
+}
+
+TEST(PodVector, AppendLotsOfItems) {
+ PodVector<int> v;
+ const size_t kMaxCount = 10000;
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ v.append(hashIndex(n));
+ }
+ EXPECT_EQ(kMaxCount, v.size());
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ EXPECT_EQ(hashIndex(n), v[n]) << "At index " << n;
+ }
+}
+
+TEST(PodVector, RemoveFrontItems) {
+ PodVector<int> v;
+ const size_t kMaxCount = 100;
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ v.append(hashIndex(n));
+ }
+ EXPECT_EQ(kMaxCount, v.size());
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ EXPECT_EQ(hashIndex(n), v[0]) << "At index " << n;
+ v.remove(0U);
+ EXPECT_EQ(kMaxCount - n - 1U, v.size()) << "At index " << n;
+ }
+}
+
+TEST(PodVector, PrependItems) {
+ PodVector<int> v;
+ const size_t kMaxCount = 100;
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ v.prepend(hashIndex(n));
+ }
+ EXPECT_EQ(kMaxCount, v.size());
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ EXPECT_EQ(hashIndex(kMaxCount - n - 1), v[n]) << "At index " << n;
+ }
+}
+
+TEST(PodVector, ResizeExpands) {
+ PodVector<int> v;
+ const size_t kMaxCount = 100;
+ const size_t kMaxCount2 = 10000;
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ v.append(hashIndex(n));
+ }
+ EXPECT_EQ(kMaxCount, v.size());
+ v.resize(kMaxCount2);
+ EXPECT_EQ(kMaxCount2, v.size());
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ EXPECT_EQ(hashIndex(n), v[n]) << "At index " << n;
+ }
+}
+
+TEST(PodVector, ResizeTruncates) {
+ PodVector<int> v;
+ const size_t kMaxCount = 10000;
+ const size_t kMaxCount2 = 10;
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ v.append(hashIndex(n));
+ }
+ EXPECT_EQ(kMaxCount, v.size());
+ v.resize(kMaxCount2);
+ EXPECT_EQ(kMaxCount2, v.size());
+ for (size_t n = 0; n < kMaxCount2; ++n) {
+ EXPECT_EQ(hashIndex(n), v[n]) << "At index " << n;
+ }
+}
+
+
+TEST(PodVector, AssignmentOperator) {
+ PodVector<int> v1;
+ const size_t kMaxCount = 10000;
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ v1.append(hashIndex(n));
+ }
+ EXPECT_EQ(kMaxCount, v1.size());
+
+ PodVector<int> v2;
+ v2 = v1;
+
+ v1.reserve(0);
+
+ EXPECT_EQ(kMaxCount, v2.size());
+ for (size_t n = 0; n < kMaxCount; ++n) {
+ EXPECT_EQ(hashIndex(n), v2[n]) << "At index " << n;
+ }
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/scoped_pointer_vector.h b/emulator/opengl/shared/emugl/common/scoped_pointer_vector.h
new file mode 100644
index 0000000..3d263e9
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/scoped_pointer_vector.h
@@ -0,0 +1,27 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef EMUGL_COMMON_SCOPED_POINTER_VECTOR_H
+#define EMUGL_COMMON_SCOPED_POINTER_VECTOR_H
+
+namespace emugl {
+
+template <class T>
+class ScopedPointerVector {
+ ScopedPointerVector
+};
+
+} // namespace emugl
+
+#endif // EMUGL_COMMON_SCOPED_POINTER_VECTOR_H
diff --git a/emulator/opengl/shared/emugl/common/smart_ptr.cpp b/emulator/opengl/shared/emugl/common/smart_ptr.cpp
new file mode 100644
index 0000000..703487d
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/smart_ptr.cpp
@@ -0,0 +1,113 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/smart_ptr.h"
+
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
+namespace emugl {
+
+// Thread-safe atomic reference-counting type.
+class RefCount {
+public:
+ RefCount() : mCount(1) {}
+ ~RefCount() {}
+
+ // Technically not thread-safe, use only for testing.
+ int count() const { return (int)mCount; }
+
+ void increment() {
+#ifdef _WIN32
+ InterlockedIncrement(&mCount);
+#else
+ __sync_fetch_and_add(&mCount, 1);
+#endif
+ }
+
+ bool decrement() {
+#ifdef _WIN32
+ return InterlockedDecrement(&mCount) == 0;
+#else
+ return __sync_add_and_fetch(&mCount, -1) == 0;
+#endif
+ }
+
+private:
+#ifdef _WIN32
+ LONG mCount;
+#else
+ int mCount;
+#endif
+};
+
+
+// SmartPtrBase implementation.
+
+SmartPtrBase::SmartPtrBase(void* ptr) : mPtr(ptr), mRefCount(NULL) {
+ if (mPtr)
+ mRefCount = new RefCount();
+}
+
+
+SmartPtrBase::SmartPtrBase(const SmartPtrBase& other)
+ : mPtr(other.mPtr), mRefCount(other.mRefCount) {
+ if (mRefCount)
+ mRefCount->increment();
+}
+
+
+int SmartPtrBase::getRefCount() const {
+ return mRefCount ? mRefCount->count() : 0;
+}
+
+
+void SmartPtrBase::addRef() {
+ if (mRefCount)
+ mRefCount->increment();
+}
+
+
+void* SmartPtrBase::copyFrom(const SmartPtrBase& other) {
+ void* old_ptr = release();
+
+ mPtr = other.mPtr;
+ mRefCount = other.mRefCount;
+ if (mRefCount)
+ mRefCount->increment();
+
+ return old_ptr;
+}
+
+
+void* SmartPtrBase::release() {
+ void* old_ptr = mPtr;
+ RefCount* old_refcount = mRefCount;
+
+ if (old_refcount) {
+ mPtr = NULL;
+ mRefCount = NULL;
+
+ if (old_refcount->decrement()) {
+ delete old_refcount;
+ return old_ptr;
+ }
+ }
+
+ return NULL;
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/smart_ptr.h b/emulator/opengl/shared/emugl/common/smart_ptr.h
new file mode 100644
index 0000000..73efdd6
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/smart_ptr.h
@@ -0,0 +1,150 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+#ifndef EMUGL_SMART_PTR_H
+#define EMUGL_SMART_PTR_H
+
+#include <stddef.h>
+
+namespace emugl {
+
+// Hidden atomic ref-counting implementation.
+class RefCount;
+
+// Base class for all templated SmartPtr<> instances. Reduces
+// template expansion and code. Consider this to be an implementation
+// detail of SmartPtr<>, so don't rely on anything here.
+class SmartPtrBase {
+public:
+ // Defrault constructor.
+ SmartPtrBase() : mPtr(NULL), mRefCount(NULL) {}
+
+ // Normal constructor. This takes ownership of |ptr|, though only
+ // template instances are capable of destroying the object.
+ explicit SmartPtrBase(void* ptr);
+
+ // Copy-constructor, this increments the reference count.
+ SmartPtrBase(const SmartPtrBase& other);
+
+ // Assignment operator, also increments the reference count.
+ SmartPtrBase& operator=(const SmartPtrBase& other);
+
+ // Nothing happens in this destructor, the real work must be performed
+ // in subclasses.
+ ~SmartPtrBase() {}
+
+
+ // Used to enable 'if (smart_ptr) { ... }' properly.
+ operator void*() const {
+ return mPtr;
+ }
+
+ // Return internal reference count value, only use for unit testing.
+ int getRefCount() const;
+
+protected:
+ // Used internally to increment the reference count.
+ void addRef();
+
+ // Copy the |other| into this instance, returns the old pointer value
+ // if it needs to be destroyed by the caller, or NULL otherwise.
+ void* copyFrom(const SmartPtrBase& other);
+
+ // Used internally to decrement the reference count, if it reaches 0,
+ // returns the pointer to be destroyed, NULL otherwise.
+ void* release();
+
+ void* mPtr;
+ RefCount* mRefCount;
+};
+
+
+// The real template class to be used for smart pointers.
+// Typical uses:
+//
+// SmartPtr<Foo> ptr(new Foo()); // takes ownership.
+// SmartPtr<Foo> ptr2; // empty pointer.
+// ptr2 = ptr; // copies pointer + increment reference count.
+// Foo* obj = ptr.Ptr(); // access pointed object.
+// ptr->DoStuff(); // operate directly on pointed object.
+// (*ptr)->DoStuff(); // same here.
+//
+// On scope exit, the internal reference count is decremented and the
+// object is deleted automatically when it reaches 0, indicating that
+// there are no more owners.
+//
+// IMPORTANT: You need to be sure that only one 'chain' of smart pointers
+// own a given object. I.e. the following is incorrect:
+//
+// Foo* foo = new Foo(); // create new instance.
+// SmartPtr<Foo> ptr(foo); // |ptr| takes ownership of |foo|.
+// SmartPtr<Foo> ptr2(foo); // |ptr2| takes also ownership of |foo|.
+//
+// The problem is that |ptr| and |ptr2| don't know anything about each
+// other, and will not share the same reference count. Once a smart pointer
+// owns an object, only use other smart pointers that are copy-constructed
+// or assigned with the initial one to keep everything consistent.
+template <class T>
+class SmartPtr : public emugl::SmartPtrBase {
+public:
+ // Default constructor. The instance holds a NULL pointer.
+ SmartPtr() : SmartPtrBase() {}
+
+ // Regular constructor, takes ownership of |ptr|.
+ explicit SmartPtr(T* ptr) : SmartPtrBase(ptr) {}
+
+ // Copy-constructor, |this| and |other| will share the same internal
+ // reference count, which is incremented by 1.
+ SmartPtr(const SmartPtr& other)
+ : SmartPtrBase(reinterpret_cast<const SmartPtrBase&>(other)) {}
+
+ // Assignment operator, same semantics as copy-constructor.
+ SmartPtr& operator=(const SmartPtr& other) {
+ void* old_ptr = copyFrom(static_cast<const SmartPtrBase&>(other));
+ if (old_ptr)
+ delete reinterpret_cast<T*>(old_ptr);
+ return *this;
+ }
+
+ // Destructor, decrements reference count and destroys the object
+ // if it reaches 0 (indicating this was the last owning smart pointer).
+ ~SmartPtr() {
+ void* ptr = release();
+ if (ptr)
+ delete reinterpret_cast<T*>(ptr);
+ }
+
+ // Return owned object instance, or NULL.
+ T* Ptr() const {
+ return reinterpret_cast<T*>(mPtr);
+ }
+
+ // Return owned object instance, or NULL
+ const T* constPtr() const {
+ return reinterpret_cast<const T*>(mPtr);
+ }
+
+ // Operate directly on owned object.
+ T* operator->() const {
+ return Ptr();
+ }
+
+ // Return reference to owned object.
+ T& operator*() const {
+ return *Ptr();
+ }
+};
+
+} // namespace emugl
+
+#endif // EMUGL_SMART_PTR_H
diff --git a/emulator/opengl/shared/emugl/common/smart_ptr_unittest.cpp b/emulator/opengl/shared/emugl/common/smart_ptr_unittest.cpp
new file mode 100644
index 0000000..db9e5f2
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/smart_ptr_unittest.cpp
@@ -0,0 +1,140 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/smart_ptr.h"
+
+#include <gtest/gtest.h>
+
+namespace emugl {
+
+// This Test sub-class is used to track allocations and deallocations of
+// the MyTestClass instances that are created through newInstance().
+// See below for typical usage.
+class SmartPtrTest : public testing::Test {
+public:
+ SmartPtrTest() : mNewCount(0), mDeleteCount(0), mDoCount(0) {}
+
+ ~SmartPtrTest() {
+ mNewCount = 0;
+ mDoCount = 0;
+ mDeleteCount = 0;
+ }
+
+ class MyClass;
+
+ MyClass* newInstance() {
+ return new MyClass(this);
+ }
+
+ class MyClass {
+ public:
+ MyClass(SmartPtrTest* test) : mTest(test) {
+ mTest->mNewCount++;
+ }
+
+ void doStuff() {
+ mTest->mDoCount++;
+ }
+
+ ~MyClass() {
+ mTest->mDeleteCount++;
+ }
+ private:
+ SmartPtrTest* mTest;
+ };
+
+ int mNewCount;
+ int mDeleteCount;
+ int mDoCount;
+};
+
+
+TEST_F(SmartPtrTest, Empty) {
+ SmartPtr<MyClass> ptr;
+ EXPECT_FALSE(ptr.Ptr());
+
+ EXPECT_EQ(0, mNewCount);
+ EXPECT_EQ(0, mDeleteCount);
+ EXPECT_EQ(0, mDoCount);
+}
+
+
+TEST_F(SmartPtrTest, SingleRef) {
+ MyClass* obj = newInstance();
+ EXPECT_EQ(1, mNewCount);
+
+ {
+ SmartPtr<MyClass> ptr(obj);
+ EXPECT_EQ(obj, ptr.Ptr());
+
+ EXPECT_EQ(1, mNewCount);
+ EXPECT_EQ(0, mDeleteCount);
+ EXPECT_EQ(0, mDoCount);
+ }
+ // Check that the object was deleted.
+ EXPECT_EQ(1, mDeleteCount);
+}
+
+
+TEST_F(SmartPtrTest, CopyConstructor) {
+ MyClass* obj = newInstance();
+ EXPECT_EQ(1, mNewCount);
+
+ {
+ SmartPtr<MyClass> ptr1(obj);
+ {
+ SmartPtr<MyClass> ptr2(ptr1);
+ EXPECT_EQ(2, ptr1.getRefCount());
+ EXPECT_EQ(2, ptr2.getRefCount());
+ EXPECT_EQ(1, mNewCount);
+ EXPECT_EQ(0, mDeleteCount);
+ EXPECT_EQ(0, mDoCount);
+ }
+ EXPECT_EQ(1, mNewCount);
+ EXPECT_EQ(0, mDeleteCount);
+ EXPECT_EQ(0, mDoCount);
+ }
+ EXPECT_EQ(1, mNewCount);
+ EXPECT_EQ(1, mDeleteCount);
+ EXPECT_EQ(0, mDoCount);
+}
+
+
+TEST_F(SmartPtrTest, AssignmentOperator) {
+ SmartPtr<MyClass> ptr1(newInstance());
+ SmartPtr<MyClass> ptr2(newInstance());
+ EXPECT_EQ(2, mNewCount);
+ EXPECT_EQ(0, mDeleteCount);
+ EXPECT_EQ(0, mDoCount);
+
+ ptr2 = ptr1;
+ EXPECT_EQ(2, mNewCount);
+ EXPECT_EQ(1, mDeleteCount);
+
+ EXPECT_EQ(ptr1.Ptr(), ptr2.Ptr());
+ EXPECT_EQ(2, ptr1.getRefCount());
+ EXPECT_EQ(2, ptr2.getRefCount());
+}
+
+
+TEST_F(SmartPtrTest, ArrowOperator) {
+ SmartPtr<MyClass> ptr(newInstance());
+ ptr->doStuff();
+ EXPECT_EQ(1, mDoCount);
+
+ (*ptr).doStuff();
+ EXPECT_EQ(2, mDoCount);
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/sockets.cpp b/emulator/opengl/shared/emugl/common/sockets.cpp
new file mode 100644
index 0000000..2a13d72
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/sockets.cpp
@@ -0,0 +1,222 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/sockets.h"
+
+#include <errno.h>
+
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/un.h>
+#include <sys/stat.h>
+#endif
+
+#include <stddef.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+
+namespace emugl {
+
+namespace {
+
+static void socketSetReuseAddress(int s) {
+#ifdef _WIN32
+ // The default behaviour on Windows is equivalent to SO_REUSEADDR
+ // so we don't need to set this option. Moreover, one should never
+ // set this option with WinSock because it's badly implemented and
+ // generates a huge security issue. See:
+ // http://msdn.microsoft.com/en-us/library/windows/desktop/ms740621(v=vs.85).aspx
+#else
+ int val = 1;
+ setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &val, sizeof(val));
+#endif
+}
+
+// Helper union to store a socket address.
+struct SockAddr {
+ socklen_t len;
+ union {
+ sockaddr generic;
+ sockaddr_in inet;
+#ifndef _WIN32
+ sockaddr_un local;
+#endif
+ };
+
+ int getFamily() const { return generic.sa_family; }
+
+ void initEmpty() {
+ ::memset(this, 0, sizeof(*this));
+ this->len = static_cast<socklen_t>(sizeof(*this));
+ }
+
+ int initFromInet(uint32_t ip_address, int port) {
+ if (port < 0 || port >= 65536)
+ return -EINVAL;
+
+ ::memset(this, 0, sizeof(*this));
+ this->inet.sin_family = AF_INET;
+ this->inet.sin_port = htons(port);
+ this->inet.sin_addr.s_addr = htonl(ip_address);
+ this->len = sizeof(this->inet);
+ return 0;
+ }
+
+ int initFromLocalhost(int port) {
+ return initFromInet(0x7f000001, port);
+ }
+
+#ifndef _WIN32
+ // Initialize the SockAddr from a Unix path. Returns 0 on success,
+ // or -errno code on failure.
+ int initFromUnixPath(const char* path) {
+ if (!path || !path[0])
+ return -EINVAL;
+
+ size_t pathLen = ::strlen(path);
+ if (pathLen >= sizeof(local.sun_path))
+ return -E2BIG;
+
+ ::memset(this, 0, sizeof(*this));
+ this->local.sun_family = AF_LOCAL;
+ ::memcpy(this->local.sun_path, path, pathLen + 1U);
+ this->len = pathLen + offsetof(sockaddr_un, sun_path);
+ return 0;
+ }
+#endif
+};
+
+int socketBindInternal(const SockAddr* addr, int socketType) {
+ int s = ::socket(addr->getFamily(), socketType, 0);
+ if (s < 0)
+ return -errno;
+
+ // Bind to the socket.
+ if (::bind(s, &addr->generic, addr->len) < 0 ||
+ ::listen(s, 5) < 0) {
+ int ret = -errno;
+ ::close(s);
+ return ret;
+ }
+
+ socketSetReuseAddress(s);
+ return s;
+}
+
+int socketConnectInternal(const SockAddr* addr, int socketType) {
+ int s = ::socket(addr->getFamily(), socketType, 0);
+ if (s < 0)
+ return -errno;
+
+ int ret;
+ do {
+ ret = ::connect(s, &addr->generic, addr->len);
+ } while (ret < 0 && errno == EINTR);
+
+ if (ret < 0) {
+ ret = -errno;
+ ::close(s);
+ return ret;
+ }
+
+ return s;
+}
+
+} // namespace
+
+void socketTcpDisableNagle(int s) {
+ // disable Nagle algorithm to improve bandwidth of small
+ // packets which are quite common in our implementation.
+#ifdef _WIN32
+ DWORD flag;
+#else
+ int flag;
+#endif
+ flag = 1;
+ setsockopt(s, IPPROTO_TCP, TCP_NODELAY,
+ (const char*)&flag, sizeof(flag));
+}
+
+int socketGetPort(int s) {
+ SockAddr addr;
+ addr.initEmpty();
+ if (getsockname(s, &addr.generic, &addr.len) < 0) {
+ return -errno;
+ }
+ switch (addr.generic.sa_family) {
+ case AF_INET:
+ return ntohs(addr.inet.sin_port);
+ default:
+ ;
+ }
+ return -EINVAL;
+}
+
+#ifndef _WIN32
+int socketLocalServer(const char* path, int socketType) {
+ SockAddr addr;
+ int ret = addr.initFromUnixPath(path);
+ if (ret < 0) {
+ return ret;
+ }
+ return socketBindInternal(&addr, socketType);
+}
+
+int socketLocalClient(const char* path, int socketType) {
+ SockAddr addr;
+ int ret = addr.initFromUnixPath(path);
+ if (ret < 0) {
+ return ret;
+ }
+ return socketConnectInternal(&addr, socketType);
+}
+#endif // !_WIN32
+
+int socketTcpLoopbackServer(int port, int socketType) {
+ SockAddr addr;
+ int ret = addr.initFromLocalhost(port);
+ if (ret < 0) {
+ return ret;
+ }
+ return socketBindInternal(&addr, socketType);
+}
+
+int socketTcpLoopbackClient(int port, int socketType) {
+ SockAddr addr;
+ int ret = addr.initFromLocalhost(port);
+ if (ret < 0) {
+ return ret;
+ }
+ return socketConnectInternal(&addr, socketType);
+}
+
+int socketTcpClient(const char* hostname, int port, int socketType) {
+ // TODO(digit): Implement this.
+ return -ENOSYS;
+}
+
+int socketAccept(int serverSocket) {
+ int ret;
+ do {
+ ret = ::accept(serverSocket, NULL, NULL);
+ } while (ret < 0 && errno == EINTR);
+ return ret;
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/sockets.h b/emulator/opengl/shared/emugl/common/sockets.h
new file mode 100644
index 0000000..11e7ac7
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/sockets.h
@@ -0,0 +1,57 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef EMUGL_COMMON_SOCKETS_H
+#define EMUGL_COMMON_SOCKETS_H
+
+// A set of helper functions used to deal with sockets in a portable way.
+
+namespace emugl {
+
+// Disable Nagle's algorithm for socket descriptor |s|. This assumes
+// that |s| is a TCP socket descriptor.
+void socketTcpDisableNagle(int s);
+
+// Return the port associated with a given IP or IPv6 socket,
+// or -errno code on failure.
+int socketGetPort(int s);
+
+// Bind to a local/Unix path, and return its socket descriptor on success,
+// or -errno code on failure.
+int socketLocalServer(const char* path, int socketType);
+
+// Connect to a Unix local path, and return a new socket descriptor
+// on success, or -errno code on failure.
+int socketLocalClient(const char* path, int socketType);
+
+// Bind to a localhost TCP socket, and return its socket descriptor on
+// success, or -errno code on failure.
+int socketTcpLoopbackServer(int port, int socketType);
+
+// Connect to a localhost TCP port, and return a new socket descriptor on
+// success, or -errno code on failure.
+int socketTcpLoopbackClient(int port, int socketType);
+
+// Connect to a TCP host, and return a new socket descriptor on
+// success, or -errno code on failure.
+int socketTcpClient(const char* hostname, int port, int socketType);
+
+// Accept a new connection. |serverSocket| must be a bound server socket
+// descriptor. Returns new socket descriptor on success, or -errno code
+// on failure.
+int socketAccept(int serverSocket);
+
+} // namespace emugl
+
+#endif // EMUGL_COMMON_SOCKETS_H
diff --git a/emulator/opengl/shared/emugl/common/testing/test_thread.h b/emulator/opengl/shared/emugl/common/testing/test_thread.h
new file mode 100644
index 0000000..2d758b3
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/testing/test_thread.h
@@ -0,0 +1,78 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef EMUGL_COMMON_TESTING_TEST_THREAD_H
+#define EMUGL_COMMON_TESTING_TEST_THREAD_H
+
+#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN 1
+# include <windows.h>
+#else
+# include <pthread.h>
+#endif
+
+namespace emugl {
+
+// Very basic platform thread wrapper that only uses a tiny stack.
+// This shall only be used during unit testing, and allows test code
+// to not depend on the implementation of emugl::Thread.
+class TestThread {
+public:
+ // Main thread function type.
+ typedef void* (ThreadFunction)(void* param);
+
+ // Constructor actually launches a new platform thread.
+ TestThread(ThreadFunction* func, void* funcParam) {
+#ifdef _WIN32
+ mThread = CreateThread(NULL,
+ 16384,
+ (DWORD WINAPI (*)(void*))func,
+ funcParam,
+ NULL,
+ NULL);
+#else
+ pthread_attr_t attr;
+ pthread_attr_init(&attr);
+ pthread_attr_setstacksize(&attr, 16384);
+ pthread_create(&mThread, &attr, func, funcParam);
+ pthread_attr_destroy(&attr);
+#endif
+ }
+
+ ~TestThread() {
+#ifdef _WIN32
+ CloseHandle(mThread);
+#endif
+ }
+
+ void join() {
+#ifdef _WIN32
+ WaitForSingleObject(mThread, INFINITE);
+#else
+ void* ret = NULL;
+ pthread_join(mThread, &ret);
+#endif
+ }
+
+private:
+#ifdef _WIN32
+ HANDLE mThread;
+#else
+ pthread_t mThread;
+#endif
+};
+
+} // namespace emugl
+
+#endif // EMUGL_COMMON_TESTING_TEST_THREAD_H
diff --git a/emulator/opengl/shared/emugl/common/thread_store.cpp b/emulator/opengl/shared/emugl/common/thread_store.cpp
new file mode 100644
index 0000000..ea64c6f
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/thread_store.cpp
@@ -0,0 +1,242 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/thread_store.h"
+
+#ifdef _WIN32
+#include "emugl/common/lazy_instance.h"
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+// Set to 1 to print debug messages.
+#define DEBUG_THREAD_STORE 0
+
+#if DEBUG_THREAD_STORE
+# define D(...) do { printf("%s:%d: ", __FUNCTION__, __LINE__); printf(__VA_ARGS__); fflush(stdout); } while (0)
+#else
+# define D(...) ((void)0)
+#endif
+
+namespace emugl {
+
+#ifdef _WIN32
+
+namespace {
+
+// The ThreadStore implementation on Windows is very tricky, because
+// TlsAlloc() doesn't allow one to provide a destructor function. As
+// such threads are expected to destroy all TLS values explicitely.
+//
+// To solve this issue, this source file provides a static method called
+// ThreadStore::OnThreadExit() that must be called when a thread exits,
+// which will cleanup all values for the current thread.
+//
+// But this forces us to track thread-specific values ourselves.
+
+// Maximum amount of thread-specific slots supported by this implementation.
+enum {
+ kMaxTlsSlots = 64
+};
+
+// TlsSlotArray is a thread-specific array of values. Instances will
+// be stored in a Win32 TLS value controlled by a single master TLS
+// key.
+//
+typedef void* TlsSlotArray[kMaxTlsSlots];
+
+// Global state shared by all threads
+class GlobalState {
+public:
+ GlobalState() {
+ D("Entering\n");
+ mMasterTls = TlsAlloc();
+ D("Master TLS = %d\n", (int)mMasterTls);
+ InitializeCriticalSection(&mSection);
+ mLastIndex = 0;
+ ::memset(mDestructors, 0, sizeof(mDestructors));
+ D("Exiting\n");
+ }
+
+ // Register a new TLS key, or return -1 on error (too many keys).
+ // |destroy| is the destructor function for the key.
+ int registerKey(ThreadStore::Destructor* destroy) {
+ D("Entering destroy=%p\n", destroy);
+ int ret = -1;
+ EnterCriticalSection(&mSection);
+ if (mLastIndex < kMaxTlsSlots) {
+ ret = mLastIndex++;
+ mDestructors[ret] = destroy;
+ }
+ LeaveCriticalSection(&mSection);
+ D("Exiting newKey=%d\n", ret);
+ return ret;
+ }
+
+ void unregisterKey(int key) {
+ D("key=%d\n", key);
+ if (key < 0 || key >= kMaxTlsSlots) {
+ D("Invalid key\n");
+ return;
+ }
+
+ // Note: keys are not reusable, but remove the destructor to avoid
+ // crashes in leaveCurrentThread() when it points to a function that
+ // is going to be unloaded from the process' address space.
+ EnterCriticalSection(&mSection);
+ mDestructors[key] = NULL;
+ LeaveCriticalSection(&mSection);
+ D("Exiting\n");
+ }
+
+ // Get the current thread-local value for a given |key|.
+ void* getValue(int key) const {
+ D("Entering key=%d\n", key);
+ if (key < 0 || key >= kMaxTlsSlots) {
+ D("Invalid key, result=NULL\n");
+ return NULL;
+ }
+
+ TlsSlotArray* array = getArray();
+ void* ret = (*array)[key];
+ D("Exiting keyValue=%p\n", ret);
+ return ret;
+ }
+
+ // Set the current thread-local |value| for a given |key|.
+ void setValue(int key, void* value) {
+ D("Entering key=%d\n",key);
+ if (key < 0 || key >= kMaxTlsSlots) {
+ D("Invalid key, returning\n");
+ return;
+ }
+
+ TlsSlotArray* array = getArray();
+ (*array)[key] = value;
+ D("Exiting\n");
+ }
+
+ // Call this when a thread exits to destroy all its thread-local values.
+ void leaveCurrentThread() {
+ D("Entering\n");
+ TlsSlotArray* array =
+ reinterpret_cast<TlsSlotArray*>(TlsGetValue(mMasterTls));
+ if (!array) {
+ D("Exiting, no thread-local data in this thread\n");
+ return;
+ }
+
+ for (size_t n = 0; n < kMaxTlsSlots; ++n) {
+ void* value = array[n];
+ if (value) {
+ (*array)[n] = NULL;
+ // NOTE: In theory, a destructor could reset the slot to
+ // a new value, and we would have to loop in this function
+ // in interesting ways. In practice, ignore the issue.
+ EnterCriticalSection(&mSection);
+ ThreadStore::Destructor* destroy = mDestructors[n];
+ LeaveCriticalSection(&mSection);
+ if (destroy) {
+ D("Calling destructor %p for key=%d, with value=%p\n",
+ destroy, (int)n, value);
+ (*destroy)(value);
+ }
+ }
+ }
+ TlsSetValue(mMasterTls, NULL);
+ ::free(array);
+ D("Exiting\n");
+ }
+
+private:
+ // Return the thread-local array of TLS slots for the current thread.
+ // Cannot return NULL.
+ TlsSlotArray* getArray() const {
+ D("Entering\n");
+ TlsSlotArray* array =
+ reinterpret_cast<TlsSlotArray*>(TlsGetValue(mMasterTls));
+ if (!array) {
+ array = reinterpret_cast<TlsSlotArray*>(
+ ::calloc(sizeof(*array), 1));
+ TlsSetValue(mMasterTls, array);
+ D("Allocated new array at %p\n", array);
+ } else {
+ D("Retrieved array at %p\n", array);
+ }
+ return array;
+ }
+
+ DWORD mMasterTls;
+ CRITICAL_SECTION mSection;
+ int mLastIndex;
+ ThreadStore::Destructor* mDestructors[kMaxTlsSlots];
+};
+
+LazyInstance<GlobalState> gGlobalState = LAZY_INSTANCE_INIT;
+
+} // namespace
+
+ThreadStore::ThreadStore(Destructor* destroy) {
+ D("Entering this=%p destroy=%p\n", this, destroy);
+ mKey = gGlobalState->registerKey(destroy);
+ D("Exiting this=%p key=%d\n", this, mKey);
+}
+
+ThreadStore::~ThreadStore() {
+ D("Entering this=%p\n", this);
+ GlobalState* state = gGlobalState.ptr();
+ state->unregisterKey(mKey);
+ D("Exiting this=%p\n", this);
+}
+
+void* ThreadStore::get() const {
+ D("Entering this=%p\n", this);
+ void* ret = gGlobalState->getValue(mKey);
+ D("Exiting this=%p value=%p\n", this, ret);
+ return ret;
+}
+
+void ThreadStore::set(void* value) {
+ D("Entering this=%p value=%p\n", this, value);
+ gGlobalState->setValue(mKey, value);
+ D("Exiting this=%p\n", this);
+}
+
+// static
+void ThreadStore::OnThreadExit() {
+ gGlobalState->leaveCurrentThread();
+}
+
+#else // !_WIN32
+
+ThreadStore::ThreadStore(Destructor* destroy) {
+ int ret = pthread_key_create(&mKey, destroy);
+ if (ret != 0) {
+ fprintf(stderr,
+ "Could not create thread store key: %s\n",
+ strerror(ret));
+ exit(1);
+ }
+}
+
+ThreadStore::~ThreadStore() {
+ pthread_key_delete(mKey);
+}
+
+#endif // !_WIN32
+
+} // namespace emugl
diff --git a/emulator/opengl/shared/emugl/common/thread_store.h b/emulator/opengl/shared/emugl/common/thread_store.h
new file mode 100644
index 0000000..5fd08bd
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/thread_store.h
@@ -0,0 +1,110 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#ifndef EMUGL_COMMON_THREAD_STORE_H
+#define EMUGL_COMMON_THREAD_STORE_H
+
+#ifdef _WIN32
+# define WIN32_LEAN_AND_MEAN 1
+# include <windows.h>
+#else
+# include <pthread.h>
+#endif
+
+namespace emugl {
+
+// A class to model storage of thread-specific values, that can be
+// destroyed on thread exit.
+//
+// Note that on Windows, a thread must call OnThreadExit() explicitly
+// here to ensure that the values are probably discarded. This is an
+// unfortunate requirement of the Win32 API, which doesn't support
+// destructors at all.
+//
+// There are various hacks on the web to try to achieve this automatically
+// (e.g. [1]) but they rely on using the Microsoft build tools,
+// which doesn't work for us.
+//
+// Note another important issue with ThreadStore instances: if you create
+// one instance in a shared library, you need to make sure that it is
+// always destroyed before the library is unloaded. Otherwise, future
+// thread exit will likely crash, due to calling a destructor function
+// that is no longer in the process' address space.
+//
+// Finally, destroying an instance does _not_ free the corresponding values,
+// because doing so properly requires coordinating all participating threads,
+// which is impossible to achieve in the most general case. Thus, consider
+// that thread-local values are always leaked on library unload, or on
+// program exit.
+//
+// [1] http://stackoverflow.com/questions/14538159/about-tls-callback-in-windows
+
+class ThreadStore {
+public:
+ // Type of a function used to destroy a thread-specific value that
+ // was previously assigned by calling set().
+ typedef void (Destructor)(void* value);
+
+ // Initialize instance so that is hold keys that must be destroyed
+ // on thread exit by calling |destroy|.
+ explicit ThreadStore(Destructor* destroy);
+
+ // NOTE: Destructor don't free the thread-local values, but are required
+ // to avoid crashes (see note above).
+ ~ThreadStore();
+
+ // Retrieve current thread-specific value from store.
+#ifdef _WIN32
+ void* get() const;
+#else
+ inline void* get() const {
+ return pthread_getspecific(mKey);
+ }
+#endif
+
+ // Set the new thread-specific value.
+#ifdef _WIN32
+ void set(void* value);
+#else
+ inline void set(void* value) {
+ pthread_setspecific(mKey, value);
+ }
+#endif
+
+#ifdef _WIN32
+ // Each thread should call this function on exit to ensure that
+ // all corresponding TLS values are properly freed.
+ static void OnThreadExit();
+#else
+ // Nothing to do on Posix.
+ static inline void OnThreadExit() {}
+#endif
+
+private:
+ // Ensure you can't create an empty ThreadStore instance, or simply
+ // copy it in any way.
+ ThreadStore();
+ ThreadStore(const ThreadStore&);
+ ThreadStore& operator=(const ThreadStore&);
+
+#ifdef _WIN32
+ int mKey;
+#else
+ pthread_key_t mKey;
+#endif
+};
+
+} // namespace emugl
+
+#endif // EMUGL_COMMON_THREAD_STORE_H
diff --git a/emulator/opengl/shared/emugl/common/thread_store_unittest.cpp b/emulator/opengl/shared/emugl/common/thread_store_unittest.cpp
new file mode 100644
index 0000000..6b5dddb
--- /dev/null
+++ b/emulator/opengl/shared/emugl/common/thread_store_unittest.cpp
@@ -0,0 +1,146 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+#include "emugl/common/thread_store.h"
+
+#include "emugl/common/mutex.h"
+#include "emugl/common/testing/test_thread.h"
+
+#include <gtest/gtest.h>
+
+namespace emugl {
+
+namespace {
+
+// Helper class used to count instance creation and destruction.
+class StaticCounter {
+public:
+ enum {
+ kMaxInstances = 1000,
+ };
+
+ StaticCounter() {
+ Mutex::AutoLock lock(mMutex);
+ if (mCreationCount < kMaxInstances)
+ mInstances[mCreationCount] = this;
+ mCreationCount++;
+ }
+
+ ~StaticCounter() {
+ Mutex::AutoLock lock(mMutex);
+ mDestructionCount++;
+ }
+
+ static void reset() {
+ Mutex::AutoLock lock(mMutex);
+ mCreationCount = 0;
+ mDestructionCount = 0;
+ }
+
+ static size_t getCreationCount() {
+ Mutex::AutoLock lock(mMutex);
+ return mCreationCount;
+ }
+
+ static size_t getDestructionCount() {
+ Mutex::AutoLock lock(mMutex);
+ return mDestructionCount;
+ }
+
+ static void freeAll() {
+ for (size_t n = 0; n < kMaxInstances; ++n)
+ delete mInstances[n];
+ }
+
+private:
+ static Mutex mMutex;
+ static size_t mCreationCount;
+ static size_t mDestructionCount;
+ static StaticCounter* mInstances[kMaxInstances];
+};
+
+Mutex StaticCounter::mMutex;
+size_t StaticCounter::mCreationCount = 0;
+size_t StaticCounter::mDestructionCount = 0;
+StaticCounter* StaticCounter::mInstances[kMaxInstances];
+
+} // namespace
+
+// Just check that we can create a new ThreadStore with an empty
+// destructor, and use it in the current thread.
+TEST(ThreadStore, MainThreadWithoutDestructor) {
+ ThreadStore store(NULL);
+ static int x = 42;
+ store.set(&x);
+ EXPECT_EQ(&x, store.get());
+}
+
+// The following test checks that exiting a thread correctly deletes
+// any thread-local value stored in it.
+static void simplyDestroy(void* value) {
+ delete (StaticCounter*) value;
+}
+
+static void* simpleThreadFunc(void* param) {
+ ThreadStore* store = static_cast<ThreadStore*>(param);
+ store->set(new StaticCounter());
+ ThreadStore::OnThreadExit();
+ return NULL;
+}
+
+TEST(ThreadStore, ThreadsWithDestructor) {
+ ThreadStore store(simplyDestroy);
+ const size_t kNumThreads = 1000;
+ TestThread* threads[kNumThreads];
+ StaticCounter::reset();
+
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ threads[n] = new TestThread(&simpleThreadFunc, &store);
+ }
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ threads[n]->join();
+ }
+
+ EXPECT_EQ(kNumThreads, StaticCounter::getCreationCount());
+ EXPECT_EQ(kNumThreads, StaticCounter::getDestructionCount());
+
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ delete threads[n];
+ }
+}
+
+TEST(ThreadStore, ThreadsWithoutDestructor) {
+ ThreadStore store(NULL);
+ const size_t kNumThreads = 1000;
+ TestThread* threads[kNumThreads];
+ StaticCounter::reset();
+
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ threads[n] = new TestThread(&simpleThreadFunc, &store);
+ }
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ threads[n]->join();
+ }
+
+ EXPECT_EQ(kNumThreads, StaticCounter::getCreationCount());
+ EXPECT_EQ(0U, StaticCounter::getDestructionCount());
+
+ StaticCounter::freeAll();
+
+ for (size_t n = 0; n < kNumThreads; ++n) {
+ delete threads[n];
+ }
+}
+
+} // namespace emugl
diff --git a/emulator/opengl/tests/emulator_test_renderer/Android.mk b/emulator/opengl/tests/emulator_test_renderer/Android.mk
index 9c4cfdd..d585513 100644
--- a/emulator/opengl/tests/emulator_test_renderer/Android.mk
+++ b/emulator/opengl/tests/emulator_test_renderer/Android.mk
@@ -5,17 +5,8 @@ $(call emugl-import,libOpenglRender event_injector)
LOCAL_SRC_FILES := main.cpp
-PREBUILT := $(HOST_PREBUILT_TAG)
-LOCAL_SDL_CONFIG ?= prebuilts/tools/$(PREBUILT)/sdl/bin/sdl-config
-LOCAL_SDL_CFLAGS := $(shell $(LOCAL_SDL_CONFIG) --cflags)
-LOCAL_SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(LOCAL_SDL_CONFIG) --static-libs))
-
-LOCAL_CFLAGS += $(LOCAL_SDL_CFLAGS) -g -O0
-LOCAL_LDLIBS += $(LOCAL_SDL_LDLIBS)
-
-ifeq ($(HOST_OS),windows)
-LOCAL_LDLIBS += -lws2_32
-endif
+LOCAL_CFLAGS += $(EMUGL_SDL_CFLAGS) -g -O0
+LOCAL_LDLIBS += $(EMUGL_SDL_LDLIBS)
LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
diff --git a/emulator/opengl/tests/event_injector/sockets.c b/emulator/opengl/tests/event_injector/sockets.c
index a2cc334..33df32b 100644
--- a/emulator/opengl/tests/event_injector/sockets.c
+++ b/emulator/opengl/tests/event_injector/sockets.c
@@ -24,10 +24,6 @@
#include <stdlib.h>
#include <string.h>
#include <limits.h>
-//#include "android/utils/path.h"
-//#include "android/utils/debug.h"
-//#include "android/utils/misc.h"
-//#include "android/utils/system.h"
#define D(...) ((void)0)
diff --git a/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk b/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk
index a66207e..1f25a33 100644
--- a/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk
+++ b/emulator/opengl/tests/translator_tests/GLES_CM/Android.mk
@@ -3,28 +3,23 @@ LOCAL_PATH:= $(call my-dir)
$(call emugl-begin-host-executable,triangleCM)
$(call emugl-import,libEGL_translator libGLES_CM_translator)
-PREBUILT := $(HOST_PREBUILT_TAG)
-LOCAL_SDL_CONFIG ?= prebuilts/tools/$(PREBUILT)/sdl/bin/sdl-config
-LOCAL_SDL_CFLAGS := $(shell $(LOCAL_SDL_CONFIG) --cflags)
-LOCAL_SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(LOCAL_SDL_CONFIG) --static-libs))
-
ifeq ($(HOST_OS),darwin)
# SDK 10.6+ deprecates __dyld_func_lookup required by dlcompat_init_func
# in SDL_dlcompat.o this module depends. Instruct linker to resolved it at runtime.
OSX_VERSION_MAJOR := $(shell echo $(mac_sdk_version) | cut -d . -f 2)
OSX_VERSION_MAJOR_GREATER_THAN_OR_EQUAL_TO_6 := $(shell [ $(OSX_VERSION_MAJOR) -ge 6 ] && echo true)
ifeq ($(OSX_VERSION_MAJOR_GREATER_THAN_OR_EQUAL_TO_6),true)
- LOCAL_SDL_LDLIBS += -Wl,-undefined,dynamic_lookup
+ LOCAL_LDLIBS += -Wl,-undefined,dynamic_lookup
endif
endif
LOCAL_SRC_FILES:= \
triangleCM.cpp
-LOCAL_CFLAGS += $(LOCAL_SDL_CFLAGS) -g -O0
-LOCAL_LDLIBS += $(LOCAL_SDL_LDLIBS)
+LOCAL_CFLAGS += $(EMUGL_SDL_CFLAGS) -g -O0
+LOCAL_LDLIBS += $(EMUGL_SDL_LDLIBS) -lstdc++
-LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
+LOCAL_STATIC_LIBRARIES += $(EMUGL_SDL_STATIC_LIBRARIES)
ifeq ($(HOST_OS),darwin)
$(call emugl-import,libMac_view)
diff --git a/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp b/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp
index 7547cd0..0e86166 100644
--- a/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp
+++ b/emulator/opengl/tests/translator_tests/GLES_CM/triangleCM.cpp
@@ -148,13 +148,10 @@ int main(int argc, char **argv)
bool useCopy = false;
bool useSubCopy = false;
- int c;
- extern char *optarg;
-
#ifdef _WIN32
HWND windowId = NULL;
#elif __linux__
- Window windowId = NULL;
+ Window windowId = 0;
#elif __APPLE__
void* windowId = NULL;
#endif
@@ -282,17 +279,17 @@ int main(int argc, char **argv)
#define MIN_T 0
GLbyte byteVertices[] = { -1,-1,0, // Position
- 255,0,0,255, // Color
+ (GLbyte)255,0,0,(GLbyte)255, // Color
MIN_T, MIN_T, // texture
12, //point size
1,-1,0,
- 0,255,0,255,
+ 0,(GLbyte)255,0,(GLbyte)255,
MAX_T,MIN_T,
47,
0,1,0,
- 0,0,255,255,
+ 0,0,(GLbyte)255,(GLbyte)255,
MID_T, MAX_T,
14
};
diff --git a/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk b/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk
index e72da96..10b3b0c 100644
--- a/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk
+++ b/emulator/opengl/tests/translator_tests/GLES_V2/Android.mk
@@ -3,18 +3,13 @@ LOCAL_PATH:= $(call my-dir)
$(call emugl-begin-host-executable,triangleV2)
$(call emugl-import,libEGL_translator libGLES_V2_translator)
-PREBUILT := $(HOST_PREBUILT_TAG)
-LOCAL_SDL_CONFIG ?= prebuilts/tools/$(PREBUILT)/sdl/bin/sdl-config
-LOCAL_SDL_CFLAGS := $(shell $(LOCAL_SDL_CONFIG) --cflags)
-LOCAL_SDL_LDLIBS := $(filter-out %.a %.lib,$(shell $(LOCAL_SDL_CONFIG) --static-libs))
-
LOCAL_SRC_FILES:= \
triangleV2.cpp
-LOCAL_CFLAGS += $(LOCAL_SDL_CFLAGS) -g -O0
-LOCAL_LDLIBS += $(LOCAL_SDL_LDLIBS)
+LOCAL_CFLAGS += $(EMUGL_SDL_CFLAGS) -g -O0
+LOCAL_LDLIBS += $(EMUGL_SDL_LDLIBS) -lstdc++
-LOCAL_STATIC_LIBRARIES += libSDL libSDLmain
+LOCAL_STATIC_LIBRARIES += $(EMUGL_SDL_STATIC_LIBRARIES)
ifeq ($(HOST_OS),darwin)
# SDK 10.6+ deprecates __dyld_func_lookup required by dlcompat_init_func
@@ -28,4 +23,3 @@ ifeq ($(HOST_OS),darwin)
endif
$(call emugl-end-module)
-
diff --git a/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp b/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp
index 59535c5..3a8ff0f 100644
--- a/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp
+++ b/emulator/opengl/tests/translator_tests/GLES_V2/triangleV2.cpp
@@ -313,20 +313,6 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int n
int main(int argc, char **argv)
#endif
{
- GLuint ui32Vbo = 0; // Vertex buffer object handle
- GLuint ui32IndexVbo;
- GLuint ui32Texture;
-
- int nframes = 100;
- bool immidateMode = false;
- bool useIndices = false;
- bool useTexture = true;
- bool useCompTexture = false;
- bool useFixed = true;
- bool usePoints = false;
- bool useCopy = false;
- bool useSubCopy = false;
-
#ifdef _WIN32
int argc;
char **argv = parseCmdLine(lpCmdLine, &argc);
@@ -372,7 +358,7 @@ int main(int argc, char **argv)
#ifdef _WIN32
HWND windowId = NULL;
#elif __linux__
- Window windowId = NULL;
+ Window windowId = 0;
#elif __APPLE__
void* windowId = NULL;
#endif
diff --git a/emulator/opengl/tests/ut_renderer/Android.mk b/emulator/opengl/tests/ut_renderer/Android.mk
index fe8e7ac..91608b2 100644
--- a/emulator/opengl/tests/ut_renderer/Android.mk
+++ b/emulator/opengl/tests/ut_renderer/Android.mk
@@ -3,7 +3,7 @@ LOCAL_PATH:=$(call my-dir)
ifeq ($(HOST_OS), linux)
$(call emugl-begin-host-executable,ut_renderer)
-$(call emugl-import,libut_rendercontrol_dec libGLESv1_dec libGLESv2_dec libEGL_host_wrapper)
+$(call emugl-import,libut_rendercontrol_dec libGLESv1_dec libGLESv2_dec libEGL_host_wrapper libOpenglRender)
LOCAL_SRC_FILES := ut_renderer.cpp \
RenderingThread.cpp \
diff --git a/emulator/opengl/tests/ut_renderer/Renderer.cpp b/emulator/opengl/tests/ut_renderer/Renderer.cpp
index 22afadb..1102014 100644
--- a/emulator/opengl/tests/ut_renderer/Renderer.cpp
+++ b/emulator/opengl/tests/ut_renderer/Renderer.cpp
@@ -56,7 +56,7 @@ Renderer::Renderer()
int Renderer::createSurface(RenderingThread *thread, const ClientHandle & handle)
{
- android::Mutex::Autolock(this->m_mutex);
+ emugl::Mutex::AutoLock(this->m_mutex);
assert(m_surfaces.find(handle) == m_surfaces.end());
if (handle.handle == 0) {
@@ -75,7 +75,7 @@ int Renderer::createSurface(RenderingThread *thread, const ClientHandle & handle
int Renderer::destroySurface(RenderingThread *thread, const ClientHandle &handle)
{
- android::Mutex::Autolock(this->m_mutex);
+ emugl::Mutex::AutoLock(this->m_mutex);
SurfaceMap::iterator i = m_surfaces.find(handle);
if (i == m_surfaces.end()) {
@@ -90,7 +90,7 @@ int Renderer::destroySurface(RenderingThread *thread, const ClientHandle &handle
int Renderer::createContext(RenderingThread *thread, const ClientHandle &handle, ClientHandle shareCtx, int version)
{
- android::Mutex::Autolock(this->m_mutex);
+ emugl::Mutex::AutoLock(this->m_mutex);
assert(m_ctxs.find(handle) == m_ctxs.end());
RendererContext *shared = NULL;
@@ -115,7 +115,7 @@ int Renderer::createContext(RenderingThread *thread, const ClientHandle &handle,
int Renderer::destroyContext(RenderingThread *thread, const ClientHandle &handle)
{
- android::Mutex::Autolock(this->m_mutex);
+ emugl::Mutex::AutoLock(this->m_mutex);
ContextMap::iterator i = m_ctxs.find(handle);
if (i == m_ctxs.end()) {
@@ -133,7 +133,7 @@ int Renderer::makeCurrent(RenderingThread *thread,
const ClientHandle &readSurface,
const ClientHandle & ctx)
{
- android::Mutex::Autolock(this->m_mutex);
+ emugl::Mutex::AutoLock(this->m_mutex);
RendererContext *currentContext = thread->currentContext();
@@ -172,7 +172,7 @@ int Renderer::makeCurrent(RenderingThread *thread,
int Renderer::swapBuffers(RenderingThread *thread,
const ClientHandle &surface)
{
- android::Mutex::Autolock(this->m_mutex);
+ emugl::Mutex::AutoLock(this->m_mutex);
SurfaceMap::iterator s = m_surfaces.find(surface);
if (s == m_surfaces.end()) {
diff --git a/emulator/opengl/tests/ut_renderer/Renderer.h b/emulator/opengl/tests/ut_renderer/Renderer.h
index cdf10b6..81f4077 100644
--- a/emulator/opengl/tests/ut_renderer/Renderer.h
+++ b/emulator/opengl/tests/ut_renderer/Renderer.h
@@ -19,7 +19,7 @@
#include "RendererSurface.h"
#include "RendererContext.h"
#include "NativeWindowing.h"
-#include <utils/threads.h>
+#include "emugl/common/mutex.h"
class RenderingThread;
@@ -57,6 +57,6 @@ private:
NativeWindowing *m_nw;
EGLDisplay m_dpy;
- android::Mutex m_mutex; // single global mutex for the renderer class;
+ emugl::Mutex m_mutex; // single global mutex for the renderer class;
};
#endif
diff --git a/emulator/qtools/Android.mk b/emulator/qtools/Android.mk
deleted file mode 100644
index 8b2c25b..0000000
--- a/emulator/qtools/Android.mk
+++ /dev/null
@@ -1,157 +0,0 @@
-#
-# Copyright 2006 The Android Open Source Project
-#
-# Java method trace dump tool
-#
-
-LOCAL_PATH:= $(call my-dir)
-
-common_includes := external/qemu/include external/qemu
-common_cflags := -O0 -g
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := post_trace.cpp trace_reader.cpp decoder.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := post_trace
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := read_trace.cpp trace_reader.cpp decoder.cpp armdis.cpp \
- thumbdis.cpp opcode.cpp read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := read_trace
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := check_trace.cpp trace_reader.cpp decoder.cpp \
- opcode.cpp read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := check_trace
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := bb_dump.cpp trace_reader.cpp decoder.cpp \
- read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := bb_dump
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := bb2sym.cpp trace_reader.cpp decoder.cpp \
- read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := bb2sym
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := profile_trace.cpp trace_reader.cpp decoder.cpp \
- opcode.cpp read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := profile_trace
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := bbprof.cpp trace_reader.cpp decoder.cpp armdis.cpp \
- thumbdis.cpp opcode.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := bbprof
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := q2g.cpp trace_reader.cpp decoder.cpp \
- opcode.cpp read_elf.cpp parse_options.cpp gtrace.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := q2g
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := q2dm.cpp trace_reader.cpp decoder.cpp armdis.cpp \
- thumbdis.cpp opcode.cpp read_elf.cpp parse_options.cpp dmtrace.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := q2dm
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := coverage.cpp trace_reader.cpp decoder.cpp armdis.cpp \
- thumbdis.cpp opcode.cpp read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := coverage
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := stack_dump.cpp trace_reader.cpp decoder.cpp armdis.cpp \
- thumbdis.cpp opcode.cpp read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := stack_dump
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := check_stack.cpp trace_reader.cpp decoder.cpp armdis.cpp \
- thumbdis.cpp opcode.cpp read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := check_stack
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := hist_trace.cpp trace_reader.cpp decoder.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := hist_trace
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := read_addr.cpp trace_reader.cpp decoder.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := read_addr
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := read_pid.cpp trace_reader.cpp decoder.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := read_pid
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := exc_dump.cpp trace_reader.cpp decoder.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := exc_dump
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := read_method.cpp trace_reader.cpp decoder.cpp \
- read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := read_method
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := profile_pid.cpp trace_reader.cpp decoder.cpp \
- read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := profile_pid
-include $(BUILD_HOST_EXECUTABLE)
-
-include $(CLEAR_VARS)
-LOCAL_SRC_FILES := dump_regions.cpp trace_reader.cpp decoder.cpp \
- read_elf.cpp parse_options.cpp
-LOCAL_C_INCLUDES += $(common_includes)
-LOCAL_CFLAGS += $(common_cflags)
-LOCAL_MODULE := dump_regions
-include $(BUILD_HOST_EXECUTABLE)
diff --git a/emulator/qtools/armdis.cpp b/emulator/qtools/armdis.cpp
deleted file mode 100644
index 1f35867..0000000
--- a/emulator/qtools/armdis.cpp
+++ /dev/null
@@ -1,905 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#include <stdio.h>
-#include <string.h>
-#include "armdis.h"
-#include "opcode.h"
-
-static const char *cond_names[] = {
- "eq",
- "ne",
- "cs",
- "cc",
- "mi",
- "pl",
- "vs",
- "vc",
- "hi",
- "ls",
- "ge",
- "lt",
- "gt",
- "le",
- "",
- "RESERVED"
-};
-
-// Indexed by the shift type (bits 6-5)
-static const char *shift_names[] = {
- "LSL",
- "LSR",
- "ASR",
- "ROR"
-};
-
-static const char* cond_to_str(int cond) {
- return cond_names[cond];
-}
-
-char *Arm::disasm(uint32_t addr, uint32_t insn, char *result)
-{
- static char buf[80];
- char *ptr;
-
- ptr = result ? result : buf;
- Opcode opcode = decode(insn);
- switch (opcode) {
- case OP_INVALID:
- sprintf(ptr, "Invalid");
- return ptr;
- case OP_UNDEFINED:
- sprintf(ptr, "Undefined");
- return ptr;
- case OP_ADC:
- case OP_ADD:
- case OP_AND:
- case OP_BIC:
- case OP_CMN:
- case OP_CMP:
- case OP_EOR:
- case OP_MOV:
- case OP_MVN:
- case OP_ORR:
- case OP_RSB:
- case OP_RSC:
- case OP_SBC:
- case OP_SUB:
- case OP_TEQ:
- case OP_TST:
- return disasm_alu(opcode, insn, ptr);
- case OP_B:
- case OP_BL:
- return disasm_branch(addr, opcode, insn, ptr);
- case OP_BKPT:
- return disasm_bkpt(insn, ptr);
- case OP_BLX:
- // not supported yet
- break;
- case OP_BX:
- return disasm_bx(insn, ptr);
- case OP_CDP:
- sprintf(ptr, "cdp");
- return ptr;
- case OP_CLZ:
- return disasm_clz(insn, ptr);
- case OP_LDC:
- sprintf(ptr, "ldc");
- return ptr;
- case OP_LDM:
- case OP_STM:
- return disasm_memblock(opcode, insn, ptr);
- case OP_LDR:
- case OP_LDRB:
- case OP_LDRBT:
- case OP_LDRT:
- case OP_STR:
- case OP_STRB:
- case OP_STRBT:
- case OP_STRT:
- return disasm_mem(insn, ptr);
- case OP_LDRH:
- case OP_LDRSB:
- case OP_LDRSH:
- case OP_STRH:
- return disasm_memhalf(insn, ptr);
- case OP_MCR:
- case OP_MRC:
- return disasm_mcr(opcode, insn, ptr);
- case OP_MLA:
- return disasm_mla(opcode, insn, ptr);
- case OP_MRS:
- return disasm_mrs(insn, ptr);
- case OP_MSR:
- return disasm_msr(insn, ptr);
- case OP_MUL:
- return disasm_mul(opcode, insn, ptr);
- case OP_PLD:
- return disasm_pld(insn, ptr);
- case OP_STC:
- sprintf(ptr, "stc");
- return ptr;
- case OP_SWI:
- return disasm_swi(insn, ptr);
- case OP_SWP:
- case OP_SWPB:
- return disasm_swp(opcode, insn, ptr);
- case OP_UMLAL:
- case OP_UMULL:
- case OP_SMLAL:
- case OP_SMULL:
- return disasm_umlal(opcode, insn, ptr);
- default:
- sprintf(ptr, "Error");
- return ptr;
- }
- return NULL;
-}
-
-char *Arm::disasm_alu(Opcode opcode, uint32_t insn, char *ptr)
-{
- static const uint8_t kNoOperand1 = 1;
- static const uint8_t kNoDest = 2;
- static const uint8_t kNoSbit = 4;
-
- char rn_str[20];
- char rd_str[20];
- uint8_t flags = 0;
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t is_immed = (insn >> 25) & 0x1;
- uint8_t bit_s = (insn >> 20) & 1;
- uint8_t rn = (insn >> 16) & 0xf;
- uint8_t rd = (insn >> 12) & 0xf;
- uint8_t immed = insn & 0xff;
-
- const char *opname = opcode_names[opcode];
- switch (opcode) {
- case OP_CMN:
- case OP_CMP:
- case OP_TEQ:
- case OP_TST:
- flags = kNoDest | kNoSbit;
- break;
- case OP_MOV:
- case OP_MVN:
- flags = kNoOperand1;
- break;
- default:
- break;
- }
-
- // The "mov" instruction ignores the first operand (rn).
- rn_str[0] = 0;
- if ((flags & kNoOperand1) == 0) {
- sprintf(rn_str, "r%d, ", rn);
- }
-
- // The following instructions do not write the result register (rd):
- // tst, teq, cmp, cmn.
- rd_str[0] = 0;
- if ((flags & kNoDest) == 0) {
- sprintf(rd_str, "r%d, ", rd);
- }
-
- const char *sbit_str = "";
- if (bit_s && !(flags & kNoSbit))
- sbit_str = "s";
-
- if (is_immed) {
- sprintf(ptr, "%s%s%s\t%s%s#%u ; 0x%x",
- opname, cond_to_str(cond), sbit_str, rd_str, rn_str, immed, immed);
- return ptr;
- }
-
- uint8_t shift_is_reg = (insn >> 4) & 1;
- uint8_t rotate = (insn >> 8) & 0xf;
- uint8_t rm = insn & 0xf;
- uint8_t shift_type = (insn >> 5) & 0x3;
- uint8_t rs = (insn >> 8) & 0xf;
- uint8_t shift_amount = (insn >> 7) & 0x1f;
- uint32_t rotated_val = immed;
- uint8_t rotate2 = rotate << 1;
- rotated_val = (rotated_val >> rotate2) | (rotated_val << (32 - rotate2));
-
- if (!shift_is_reg && shift_type == 0 && shift_amount == 0) {
- sprintf(ptr, "%s%s%s\t%s%sr%d",
- opname, cond_to_str(cond), sbit_str, rd_str, rn_str, rm);
- return ptr;
- }
-
- const char *shift_name = shift_names[shift_type];
- if (shift_is_reg) {
- sprintf(ptr, "%s%s%s\t%s%sr%d, %s r%d",
- opname, cond_to_str(cond), sbit_str, rd_str, rn_str, rm,
- shift_name, rs);
- return ptr;
- }
- if (shift_amount == 0) {
- if (shift_type == 3) {
- sprintf(ptr, "%s%s%s\t%s%sr%d, RRX",
- opname, cond_to_str(cond), sbit_str, rd_str, rn_str, rm);
- return ptr;
- }
- shift_amount = 32;
- }
- sprintf(ptr, "%s%s%s\t%s%sr%d, %s #%u",
- opname, cond_to_str(cond), sbit_str, rd_str, rn_str, rm,
- shift_name, shift_amount);
- return ptr;
-}
-
-char *Arm::disasm_branch(uint32_t addr, Opcode opcode, uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint32_t offset = insn & 0xffffff;
- // Sign-extend the 24-bit offset
- if ((offset >> 23) & 1)
- offset |= 0xff000000;
-
- // Pre-compute the left-shift and the prefetch offset
- offset <<= 2;
- offset += 8;
- addr += offset;
- const char *opname = opcode_names[opcode];
- sprintf(ptr, "%s%s\t0x%x", opname, cond_to_str(cond), addr);
- return ptr;
-}
-
-char *Arm::disasm_bx(uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t rn = insn & 0xf;
- sprintf(ptr, "bx%s\tr%d", cond_to_str(cond), rn);
- return ptr;
-}
-
-char *Arm::disasm_bkpt(uint32_t insn, char *ptr)
-{
- uint32_t immed = (((insn >> 8) & 0xfff) << 4) | (insn & 0xf);
- sprintf(ptr, "bkpt\t#%d", immed);
- return ptr;
-}
-
-char *Arm::disasm_clz(uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t rd = (insn >> 12) & 0xf;
- uint8_t rm = insn & 0xf;
- sprintf(ptr, "clz%s\tr%d, r%d", cond_to_str(cond), rd, rm);
- return ptr;
-}
-
-char *Arm::disasm_memblock(Opcode opcode, uint32_t insn, char *ptr)
-{
- char tmp_reg[10], tmp_list[80];
-
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t write_back = (insn >> 21) & 0x1;
- uint8_t bit_s = (insn >> 22) & 0x1;
- uint8_t is_up = (insn >> 23) & 0x1;
- uint8_t is_pre = (insn >> 24) & 0x1;
- uint8_t rn = (insn >> 16) & 0xf;
- uint16_t reg_list = insn & 0xffff;
-
- const char *opname = opcode_names[opcode];
-
- const char *bang = "";
- if (write_back)
- bang = "!";
-
- const char *carret = "";
- if (bit_s)
- carret = "^";
-
- const char *comma = "";
- tmp_list[0] = 0;
- for (int ii = 0; ii < 16; ++ii) {
- if (reg_list & (1 << ii)) {
- sprintf(tmp_reg, "%sr%d", comma, ii);
- strcat(tmp_list, tmp_reg);
- comma = ",";
- }
- }
-
- const char *addr_mode = "";
- if (is_pre) {
- if (is_up) {
- addr_mode = "ib";
- } else {
- addr_mode = "db";
- }
- } else {
- if (is_up) {
- addr_mode = "ia";
- } else {
- addr_mode = "da";
- }
- }
-
- sprintf(ptr, "%s%s%s\tr%d%s, {%s}%s",
- opname, cond_to_str(cond), addr_mode, rn, bang, tmp_list, carret);
- return ptr;
-}
-
-char *Arm::disasm_mem(uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t is_reg = (insn >> 25) & 0x1;
- uint8_t is_load = (insn >> 20) & 0x1;
- uint8_t write_back = (insn >> 21) & 0x1;
- uint8_t is_byte = (insn >> 22) & 0x1;
- uint8_t is_up = (insn >> 23) & 0x1;
- uint8_t is_pre = (insn >> 24) & 0x1;
- uint8_t rn = (insn >> 16) & 0xf;
- uint8_t rd = (insn >> 12) & 0xf;
- uint16_t offset = insn & 0xfff;
-
- const char *opname = "ldr";
- if (!is_load)
- opname = "str";
-
- const char *bang = "";
- if (write_back)
- bang = "!";
-
- const char *minus = "";
- if (is_up == 0)
- minus = "-";
-
- const char *byte = "";
- if (is_byte)
- byte = "b";
-
- if (is_reg == 0) {
- if (is_pre) {
- if (offset == 0) {
- sprintf(ptr, "%s%s%s\tr%d, [r%d]",
- opname, cond_to_str(cond), byte, rd, rn);
- } else {
- sprintf(ptr, "%s%s%s\tr%d, [r%d, #%s%u]%s",
- opname, cond_to_str(cond), byte, rd, rn, minus, offset, bang);
- }
- } else {
- const char *transfer = "";
- if (write_back)
- transfer = "t";
- sprintf(ptr, "%s%s%s%s\tr%d, [r%d], #%s%u",
- opname, cond_to_str(cond), byte, transfer, rd, rn, minus, offset);
- }
- return ptr;
- }
-
- uint8_t rm = insn & 0xf;
- uint8_t shift_type = (insn >> 5) & 0x3;
- uint8_t shift_amount = (insn >> 7) & 0x1f;
-
- const char *shift_name = shift_names[shift_type];
-
- if (is_pre) {
- if (shift_amount == 0) {
- if (shift_type == 0) {
- sprintf(ptr, "%s%s%s\tr%d, [r%d, %sr%d]%s",
- opname, cond_to_str(cond), byte, rd, rn, minus, rm, bang);
- return ptr;
- }
- if (shift_type == 3) {
- sprintf(ptr, "%s%s%s\tr%d, [r%d, %sr%d, RRX]%s",
- opname, cond_to_str(cond), byte, rd, rn, minus, rm, bang);
- return ptr;
- }
- shift_amount = 32;
- }
- sprintf(ptr, "%s%s%s\tr%d, [r%d, %sr%d, %s #%u]%s",
- opname, cond_to_str(cond), byte, rd, rn, minus, rm,
- shift_name, shift_amount, bang);
- return ptr;
- }
-
- const char *transfer = "";
- if (write_back)
- transfer = "t";
-
- if (shift_amount == 0) {
- if (shift_type == 0) {
- sprintf(ptr, "%s%s%s%s\tr%d, [r%d], %sr%d",
- opname, cond_to_str(cond), byte, transfer, rd, rn, minus, rm);
- return ptr;
- }
- if (shift_type == 3) {
- sprintf(ptr, "%s%s%s%s\tr%d, [r%d], %sr%d, RRX",
- opname, cond_to_str(cond), byte, transfer, rd, rn, minus, rm);
- return ptr;
- }
- shift_amount = 32;
- }
-
- sprintf(ptr, "%s%s%s%s\tr%d, [r%d], %sr%d, %s #%u",
- opname, cond_to_str(cond), byte, transfer, rd, rn, minus, rm,
- shift_name, shift_amount);
- return ptr;
-}
-
-char *Arm::disasm_memhalf(uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t is_load = (insn >> 20) & 0x1;
- uint8_t write_back = (insn >> 21) & 0x1;
- uint8_t is_immed = (insn >> 22) & 0x1;
- uint8_t is_up = (insn >> 23) & 0x1;
- uint8_t is_pre = (insn >> 24) & 0x1;
- uint8_t rn = (insn >> 16) & 0xf;
- uint8_t rd = (insn >> 12) & 0xf;
- uint8_t bits_65 = (insn >> 5) & 0x3;
- uint8_t rm = insn & 0xf;
- uint8_t offset = (((insn >> 8) & 0xf) << 4) | (insn & 0xf);
-
- const char *opname = "ldr";
- if (is_load == 0)
- opname = "str";
-
- const char *width = "";
- if (bits_65 == 1)
- width = "h";
- else if (bits_65 == 2)
- width = "sb";
- else
- width = "sh";
-
- const char *bang = "";
- if (write_back)
- bang = "!";
- const char *minus = "";
- if (is_up == 0)
- minus = "-";
-
- if (is_immed) {
- if (is_pre) {
- if (offset == 0) {
- sprintf(ptr, "%s%sh\tr%d, [r%d]", opname, cond_to_str(cond), rd, rn);
- } else {
- sprintf(ptr, "%s%sh\tr%d, [r%d, #%s%u]%s",
- opname, cond_to_str(cond), rd, rn, minus, offset, bang);
- }
- } else {
- sprintf(ptr, "%s%sh\tr%d, [r%d], #%s%u",
- opname, cond_to_str(cond), rd, rn, minus, offset);
- }
- return ptr;
- }
-
- if (is_pre) {
- sprintf(ptr, "%s%sh\tr%d, [r%d, %sr%d]%s",
- opname, cond_to_str(cond), rd, rn, minus, rm, bang);
- } else {
- sprintf(ptr, "%s%sh\tr%d, [r%d], %sr%d",
- opname, cond_to_str(cond), rd, rn, minus, rm);
- }
- return ptr;
-}
-
-char *Arm::disasm_mcr(Opcode opcode, uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t crn = (insn >> 16) & 0xf;
- uint8_t crd = (insn >> 12) & 0xf;
- uint8_t cpnum = (insn >> 8) & 0xf;
- uint8_t opcode2 = (insn >> 5) & 0x7;
- uint8_t crm = insn & 0xf;
-
- const char *opname = opcode_names[opcode];
- sprintf(ptr, "%s%s\t%d, 0, r%d, cr%d, cr%d, {%d}",
- opname, cond_to_str(cond), cpnum, crd, crn, crm, opcode2);
- return ptr;
-}
-
-char *Arm::disasm_mla(Opcode opcode, uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t rd = (insn >> 16) & 0xf;
- uint8_t rn = (insn >> 12) & 0xf;
- uint8_t rs = (insn >> 8) & 0xf;
- uint8_t rm = insn & 0xf;
- uint8_t bit_s = (insn >> 20) & 1;
-
- const char *opname = opcode_names[opcode];
- sprintf(ptr, "%s%s%s\tr%d, r%d, r%d, r%d",
- opname, cond_to_str(cond), bit_s ? "s" : "", rd, rm, rs, rn);
- return ptr;
-}
-
-char *Arm::disasm_umlal(Opcode opcode, uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t rdhi = (insn >> 16) & 0xf;
- uint8_t rdlo = (insn >> 12) & 0xf;
- uint8_t rs = (insn >> 8) & 0xf;
- uint8_t rm = insn & 0xf;
- uint8_t bit_s = (insn >> 20) & 1;
-
- const char *opname = opcode_names[opcode];
- sprintf(ptr, "%s%s%s\tr%d, r%d, r%d, r%d",
- opname, cond_to_str(cond), bit_s ? "s" : "", rdlo, rdhi, rm, rs);
- return ptr;
-}
-
-char *Arm::disasm_mul(Opcode opcode, uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t rd = (insn >> 16) & 0xf;
- uint8_t rs = (insn >> 8) & 0xf;
- uint8_t rm = insn & 0xf;
- uint8_t bit_s = (insn >> 20) & 1;
-
- const char *opname = opcode_names[opcode];
- sprintf(ptr, "%s%s%s\tr%d, r%d, r%d",
- opname, cond_to_str(cond), bit_s ? "s" : "", rd, rm, rs);
- return ptr;
-}
-
-char *Arm::disasm_mrs(uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t rd = (insn >> 12) & 0xf;
- uint8_t ps = (insn >> 22) & 1;
-
- sprintf(ptr, "mrs%s\tr%d, %s", cond_to_str(cond), rd, ps ? "spsr" : "cpsr");
- return ptr;
-}
-
-char *Arm::disasm_msr(uint32_t insn, char *ptr)
-{
- char flags[8];
- int flag_index = 0;
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t is_immed = (insn >> 25) & 0x1;
- uint8_t pd = (insn >> 22) & 1;
- uint8_t mask = (insn >> 16) & 0xf;
-
- if (mask & 1)
- flags[flag_index++] = 'c';
- if (mask & 2)
- flags[flag_index++] = 'x';
- if (mask & 4)
- flags[flag_index++] = 's';
- if (mask & 8)
- flags[flag_index++] = 'f';
- flags[flag_index] = 0;
-
- if (is_immed) {
- uint32_t immed = insn & 0xff;
- uint8_t rotate = (insn >> 8) & 0xf;
- uint8_t rotate2 = rotate << 1;
- uint32_t rotated_val = (immed >> rotate2) | (immed << (32 - rotate2));
- sprintf(ptr, "msr%s\t%s_%s, #0x%x",
- cond_to_str(cond), pd ? "spsr" : "cpsr", flags, rotated_val);
- return ptr;
- }
-
- uint8_t rm = insn & 0xf;
-
- sprintf(ptr, "msr%s\t%s_%s, r%d",
- cond_to_str(cond), pd ? "spsr" : "cpsr", flags, rm);
- return ptr;
-}
-
-char *Arm::disasm_pld(uint32_t insn, char *ptr)
-{
- uint8_t is_reg = (insn >> 25) & 0x1;
- uint8_t is_up = (insn >> 23) & 0x1;
- uint8_t rn = (insn >> 16) & 0xf;
-
- const char *minus = "";
- if (is_up == 0)
- minus = "-";
-
- if (is_reg) {
- uint8_t rm = insn & 0xf;
- sprintf(ptr, "pld\t[r%d, %sr%d]", rn, minus, rm);
- return ptr;
- }
-
- uint16_t offset = insn & 0xfff;
- if (offset == 0) {
- sprintf(ptr, "pld\t[r%d]", rn);
- } else {
- sprintf(ptr, "pld\t[r%d, #%s%u]", rn, minus, offset);
- }
- return ptr;
-}
-
-char *Arm::disasm_swi(uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint32_t sysnum = insn & 0x00ffffff;
-
- sprintf(ptr, "swi%s 0x%x", cond_to_str(cond), sysnum);
- return ptr;
-}
-
-char *Arm::disasm_swp(Opcode opcode, uint32_t insn, char *ptr)
-{
- uint8_t cond = (insn >> 28) & 0xf;
- uint8_t rn = (insn >> 16) & 0xf;
- uint8_t rd = (insn >> 12) & 0xf;
- uint8_t rm = insn & 0xf;
-
- const char *opname = opcode_names[opcode];
- sprintf(ptr, "%s%s\tr%d, r%d, [r%d]", opname, cond_to_str(cond), rd, rm, rn);
- return ptr;
-}
-
-Opcode Arm::decode(uint32_t insn) {
- uint32_t bits27_26 = (insn >> 26) & 0x3;
- switch (bits27_26) {
- case 0x0:
- return decode00(insn);
- case 0x1:
- return decode01(insn);
- case 0x2:
- return decode10(insn);
- case 0x3:
- return decode11(insn);
- }
- return OP_INVALID;
-}
-
-Opcode Arm::decode00(uint32_t insn) {
- uint8_t bit25 = (insn >> 25) & 0x1;
- uint8_t bit4 = (insn >> 4) & 0x1;
- if (bit25 == 0 && bit4 == 1) {
- if ((insn & 0x0ffffff0) == 0x012fff10) {
- // Bx instruction
- return OP_BX;
- }
- if ((insn & 0x0ff000f0) == 0x01600010) {
- // Clz instruction
- return OP_CLZ;
- }
- if ((insn & 0xfff000f0) == 0xe1200070) {
- // Bkpt instruction
- return OP_BKPT;
- }
- uint32_t bits7_4 = (insn >> 4) & 0xf;
- if (bits7_4 == 0x9) {
- if ((insn & 0x0ff00ff0) == 0x01000090) {
- // Swp instruction
- uint8_t bit22 = (insn >> 22) & 0x1;
- if (bit22)
- return OP_SWPB;
- return OP_SWP;
- }
- // One of the multiply instructions
- return decode_mul(insn);
- }
-
- uint8_t bit7 = (insn >> 7) & 0x1;
- if (bit7 == 1) {
- // One of the load/store halfword/byte instructions
- return decode_ldrh(insn);
- }
- }
-
- // One of the data processing instructions
- return decode_alu(insn);
-}
-
-Opcode Arm::decode01(uint32_t insn) {
- uint8_t is_reg = (insn >> 25) & 0x1;
- uint8_t bit4 = (insn >> 4) & 0x1;
- if (is_reg == 1 && bit4 == 1)
- return OP_UNDEFINED;
- uint8_t is_load = (insn >> 20) & 0x1;
- uint8_t is_byte = (insn >> 22) & 0x1;
- if ((insn & 0xfd70f000) == 0xf550f000) {
- // Pre-load
- return OP_PLD;
- }
- if (is_load) {
- if (is_byte) {
- // Load byte
- return OP_LDRB;
- }
- // Load word
- return OP_LDR;
- }
- if (is_byte) {
- // Store byte
- return OP_STRB;
- }
- // Store word
- return OP_STR;
-}
-
-Opcode Arm::decode10(uint32_t insn) {
- uint8_t bit25 = (insn >> 25) & 0x1;
- if (bit25 == 0) {
- // LDM/STM
- uint8_t is_load = (insn >> 20) & 0x1;
- if (is_load)
- return OP_LDM;
- return OP_STM;
- }
- // Branch or Branch with link
- uint8_t is_link = (insn >> 24) & 1;
- uint32_t offset = insn & 0xffffff;
-
- // Sign-extend the 24-bit offset
- if ((offset >> 23) & 1)
- offset |= 0xff000000;
-
- // Pre-compute the left-shift and the prefetch offset
- offset <<= 2;
- offset += 8;
- if (is_link == 0)
- return OP_B;
- return OP_BL;
-}
-
-Opcode Arm::decode11(uint32_t insn) {
- uint8_t bit25 = (insn >> 25) & 0x1;
- if (bit25 == 0) {
- // LDC, SDC
- uint8_t is_load = (insn >> 20) & 0x1;
- if (is_load) {
- // LDC
- return OP_LDC;
- }
- // STC
- return OP_STC;
- }
-
- uint8_t bit24 = (insn >> 24) & 0x1;
- if (bit24 == 0x1) {
- // SWI
- return OP_SWI;
- }
-
- uint8_t bit4 = (insn >> 4) & 0x1;
- uint8_t cpnum = (insn >> 8) & 0xf;
-
- if (cpnum == 15) {
- // Special case for coprocessor 15
- uint8_t opcode = (insn >> 21) & 0x7;
- if (bit4 == 0 || opcode != 0) {
- // This is an unexpected bit pattern. Create an undefined
- // instruction in case this is ever executed.
- return OP_UNDEFINED;
- }
-
- // MRC, MCR
- uint8_t is_mrc = (insn >> 20) & 0x1;
- if (is_mrc)
- return OP_MRC;
- return OP_MCR;
- }
-
- if (bit4 == 0) {
- // CDP
- return OP_CDP;
- }
- // MRC, MCR
- uint8_t is_mrc = (insn >> 20) & 0x1;
- if (is_mrc)
- return OP_MRC;
- return OP_MCR;
-}
-
-Opcode Arm::decode_mul(uint32_t insn) {
- uint8_t bit24 = (insn >> 24) & 0x1;
- if (bit24 != 0) {
- // This is an unexpected bit pattern. Create an undefined
- // instruction in case this is ever executed.
- return OP_UNDEFINED;
- }
- uint8_t bit23 = (insn >> 23) & 0x1;
- uint8_t bit22_U = (insn >> 22) & 0x1;
- uint8_t bit21_A = (insn >> 21) & 0x1;
- if (bit23 == 0) {
- // 32-bit multiply
- if (bit22_U != 0) {
- // This is an unexpected bit pattern. Create an undefined
- // instruction in case this is ever executed.
- return OP_UNDEFINED;
- }
- if (bit21_A == 0)
- return OP_MUL;
- return OP_MLA;
- }
- // 64-bit multiply
- if (bit22_U == 0) {
- // Unsigned multiply long
- if (bit21_A == 0)
- return OP_UMULL;
- return OP_UMLAL;
- }
- // Signed multiply long
- if (bit21_A == 0)
- return OP_SMULL;
- return OP_SMLAL;
-}
-
-Opcode Arm::decode_ldrh(uint32_t insn) {
- uint8_t is_load = (insn >> 20) & 0x1;
- uint8_t bits_65 = (insn >> 5) & 0x3;
- if (is_load) {
- if (bits_65 == 0x1) {
- // Load unsigned halfword
- return OP_LDRH;
- } else if (bits_65 == 0x2) {
- // Load signed byte
- return OP_LDRSB;
- }
- // Signed halfword
- if (bits_65 != 0x3) {
- // This is an unexpected bit pattern. Create an undefined
- // instruction in case this is ever executed.
- return OP_UNDEFINED;
- }
- // Load signed halfword
- return OP_LDRSH;
- }
- // Store halfword
- if (bits_65 != 0x1) {
- // This is an unexpected bit pattern. Create an undefined
- // instruction in case this is ever executed.
- return OP_UNDEFINED;
- }
- // Store halfword
- return OP_STRH;
-}
-
-Opcode Arm::decode_alu(uint32_t insn) {
- uint8_t is_immed = (insn >> 25) & 0x1;
- uint8_t opcode = (insn >> 21) & 0xf;
- uint8_t bit_s = (insn >> 20) & 1;
- uint8_t shift_is_reg = (insn >> 4) & 1;
- uint8_t bit7 = (insn >> 7) & 1;
- if (!is_immed && shift_is_reg && (bit7 != 0)) {
- // This is an unexpected bit pattern. Create an undefined
- // instruction in case this is ever executed.
- return OP_UNDEFINED;
- }
- switch (opcode) {
- case 0x0:
- return OP_AND;
- case 0x1:
- return OP_EOR;
- case 0x2:
- return OP_SUB;
- case 0x3:
- return OP_RSB;
- case 0x4:
- return OP_ADD;
- case 0x5:
- return OP_ADC;
- case 0x6:
- return OP_SBC;
- case 0x7:
- return OP_RSC;
- case 0x8:
- if (bit_s)
- return OP_TST;
- return OP_MRS;
- case 0x9:
- if (bit_s)
- return OP_TEQ;
- return OP_MSR;
- case 0xa:
- if (bit_s)
- return OP_CMP;
- return OP_MRS;
- case 0xb:
- if (bit_s)
- return OP_CMN;
- return OP_MSR;
- case 0xc:
- return OP_ORR;
- case 0xd:
- return OP_MOV;
- case 0xe:
- return OP_BIC;
- case 0xf:
- return OP_MVN;
- }
- // Unreachable
- return OP_INVALID;
-}
diff --git a/emulator/qtools/armdis.h b/emulator/qtools/armdis.h
deleted file mode 100644
index 230f833..0000000
--- a/emulator/qtools/armdis.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef ARMDIS_H
-#define ARMDIS_H
-
-#include <inttypes.h>
-#include "opcode.h"
-
-class Arm {
- public:
- static char *disasm(uint32_t addr, uint32_t insn, char *buffer);
- static Opcode decode(uint32_t insn);
-
- private:
- static Opcode decode00(uint32_t insn);
- static Opcode decode01(uint32_t insn);
- static Opcode decode10(uint32_t insn);
- static Opcode decode11(uint32_t insn);
- static Opcode decode_mul(uint32_t insn);
- static Opcode decode_ldrh(uint32_t insn);
- static Opcode decode_alu(uint32_t insn);
-
- static char *disasm_alu(Opcode opcode, uint32_t insn, char *ptr);
- static char *disasm_branch(uint32_t addr, Opcode opcode, uint32_t insn, char *ptr);
- static char *disasm_bx(uint32_t insn, char *ptr);
- static char *disasm_bkpt(uint32_t insn, char *ptr);
- static char *disasm_clz(uint32_t insn, char *ptr);
- static char *disasm_memblock(Opcode opcode, uint32_t insn, char *ptr);
- static char *disasm_mem(uint32_t insn, char *ptr);
- static char *disasm_memhalf(uint32_t insn, char *ptr);
- static char *disasm_mcr(Opcode opcode, uint32_t insn, char *ptr);
- static char *disasm_mla(Opcode opcode, uint32_t insn, char *ptr);
- static char *disasm_umlal(Opcode opcode, uint32_t insn, char *ptr);
- static char *disasm_mul(Opcode opcode, uint32_t insn, char *ptr);
- static char *disasm_mrs(uint32_t insn, char *ptr);
- static char *disasm_msr(uint32_t insn, char *ptr);
- static char *disasm_pld(uint32_t insn, char *ptr);
- static char *disasm_swi(uint32_t insn, char *ptr);
- static char *disasm_swp(Opcode opcode, uint32_t insn, char *ptr);
-};
-
-extern char *disasm_insn_thumb(uint32_t pc, uint32_t insn1, uint32_t insn2, char *result);
-extern Opcode decode_insn_thumb(uint32_t given);
-
-#endif /* ARMDIS_H */
diff --git a/emulator/qtools/bb2sym.cpp b/emulator/qtools/bb2sym.cpp
deleted file mode 100644
index 8a18b67..0000000
--- a/emulator/qtools/bb2sym.cpp
+++ /dev/null
@@ -1,140 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <assert.h>
-#include "trace_reader.h"
-#include "parse_options.h"
-
-typedef TraceReader<> TraceReaderType;
-
-#include "parse_options-inl.h"
-
-struct MyStaticRec {
- StaticRec bb;
- symbol_type *sym;
- MyStaticRec *inner; // pointer to an inner basic block
- int is_thumb;
-};
-
-MyStaticRec **assign_inner_blocks(int num_blocks, MyStaticRec *blocks);
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_file elf_file\n", program);
- OptionsUsage();
-}
-
-// This function is called from quicksort to compare addresses of basic
-// blocks.
-int cmp_inc_addr(const void *a, const void *b) {
- MyStaticRec *bb1, *bb2;
-
- bb1 = *(MyStaticRec**)a;
- bb2 = *(MyStaticRec**)b;
- if (bb1->bb.bb_addr < bb2->bb.bb_addr)
- return -1;
- if (bb1->bb.bb_addr > bb2->bb.bb_addr)
- return 1;
- return bb1->bb.bb_num - bb2->bb.bb_num;
-}
-
-int main(int argc, char **argv) {
- uint32_t insns[kMaxInsnPerBB];
-
- // Parse the options
- ParseOptions(argc, argv);
- if (argc - optind != 2) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[optind++];
- char *elf_file = argv[optind++];
- TraceReader<> *trace = new TraceReader<>;
- trace->Open(trace_filename);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
-
- TraceHeader *header = trace->GetHeader();
- uint32_t num_static_bb = header->num_static_bb;
-
- // Allocate space for all of the static blocks
- MyStaticRec *blocks = new MyStaticRec[num_static_bb];
-
- // Read in all the static blocks
- for (uint32_t ii = 0; ii < num_static_bb; ++ii) {
- trace->ReadStatic(&blocks[ii].bb);
- blocks[ii].is_thumb = blocks[ii].bb.bb_addr & 1;
- blocks[ii].bb.bb_addr &= ~1;
- blocks[ii].sym = NULL;
- blocks[ii].inner = NULL;
- trace->ReadStaticInsns(blocks[ii].bb.num_insns, insns);
- }
-
- MyStaticRec **sorted = assign_inner_blocks(num_static_bb, blocks);
-
- while (1) {
- symbol_type *sym;
- BBEvent event;
- BBEvent ignored;
-
- if (GetNextValidEvent(trace, &event, &ignored, &sym))
- break;
-
- uint64_t bb_num = event.bb_num;
- blocks[bb_num].sym = sym;
- }
-
- printf("# bb num_insns bb_addr file symbol\n");
- for (uint32_t ii = 0; ii < num_static_bb; ++ii) {
- if (sorted[ii]->bb.bb_addr == 0 || sorted[ii]->bb.num_insns == 0
- || sorted[ii]->sym == NULL)
- continue;
-
- printf("%8lld %3d 0x%08x %s %s\n",
- sorted[ii]->bb.bb_num, sorted[ii]->bb.num_insns,
- sorted[ii]->bb.bb_addr, sorted[ii]->sym->region->path,
- sorted[ii]->sym->name);
- }
- return 0;
-}
-
-// Find the basic blocks that are subsets of other basic blocks.
-MyStaticRec **assign_inner_blocks(int num_blocks, MyStaticRec *blocks)
-{
- int ii;
- uint32_t addr_end, addr_diff;
-
- // Create a list of pointers to the basic blocks that we can sort.
- MyStaticRec **sorted = new MyStaticRec*[num_blocks];
- for (ii = 0; ii < num_blocks; ++ii) {
- sorted[ii] = &blocks[ii];
- }
-
- // Sort the basic blocks into increasing address order
- qsort(sorted, num_blocks, sizeof(MyStaticRec*), cmp_inc_addr);
-
- // Create pointers to inner blocks and break up the enclosing block
- // so that there is no overlap.
- for (ii = 0; ii < num_blocks - 1; ++ii) {
- int num_bytes;
- if (sorted[ii]->is_thumb)
- num_bytes = sorted[ii]->bb.num_insns << 1;
- else
- num_bytes = sorted[ii]->bb.num_insns << 2;
- addr_end = sorted[ii]->bb.bb_addr + num_bytes;
- if (addr_end > sorted[ii + 1]->bb.bb_addr) {
- sorted[ii]->inner = sorted[ii + 1];
- addr_diff = sorted[ii + 1]->bb.bb_addr - sorted[ii]->bb.bb_addr;
- uint32_t num_insns;
- if (sorted[ii]->is_thumb)
- num_insns = addr_diff >> 1;
- else
- num_insns = addr_diff >> 2;
- sorted[ii]->bb.num_insns = num_insns;
- }
- }
-
- return sorted;
-}
diff --git a/emulator/qtools/bb_dump.cpp b/emulator/qtools/bb_dump.cpp
deleted file mode 100644
index de241fb..0000000
--- a/emulator/qtools/bb_dump.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <assert.h>
-#include "trace_reader.h"
-#include "parse_options.h"
-
-typedef TraceReader<> TraceReaderType;
-
-#include "parse_options-inl.h"
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_file elf_file\n", program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv) {
- // Parse the options
- ParseOptions(argc, argv);
- if (argc - optind != 2) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[optind++];
- char *elf_file = argv[optind++];
- TraceReader<> *trace = new TraceReader<>;
- trace->Open(trace_filename);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
-
- printf("# time bb pid num_insns bb_addr\n");
- while (1) {
- symbol_type *sym;
- BBEvent event;
- BBEvent ignored;
-
- if (GetNextValidEvent(trace, &event, &ignored, &sym))
- break;
- printf("%7lld %4lld %5d %3d 0x%08x %s\n",
- event.time, event.bb_num, event.pid, event.num_insns,
- event.bb_addr, sym->name);
- }
- return 0;
-}
diff --git a/emulator/qtools/bbprof.cpp b/emulator/qtools/bbprof.cpp
deleted file mode 100644
index 36d0941..0000000
--- a/emulator/qtools/bbprof.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include "trace_reader.h"
-#include "armdis.h"
-
-struct MyStaticRec {
- StaticRec bb;
- uint32_t *insns;
- uint32_t *cycles; // number of cycles for each insn
- uint32_t elapsed; // number of cycles for basic block
- int freq; // execution frequency
- MyStaticRec *inner; // pointer to an inner basic block
- int is_thumb;
-};
-
-MyStaticRec **assign_inner_blocks(int num_blocks, MyStaticRec *blocks);
-
-// This function is called from quicksort to compare addresses of basic
-// blocks.
-int cmp_inc_addr(const void *a, const void *b) {
- MyStaticRec *bb1, *bb2;
-
- bb1 = *(MyStaticRec**)a;
- bb2 = *(MyStaticRec**)b;
- if (bb1->bb.bb_addr < bb2->bb.bb_addr)
- return -1;
- if (bb1->bb.bb_addr > bb2->bb.bb_addr)
- return 1;
- return bb1->bb.bb_num - bb2->bb.bb_num;
-}
-
-// This function is called from quicksort to compare the elapsed time
-// of basic blocks.
-int cmp_dec_elapsed(const void *a, const void *b) {
- MyStaticRec *bb1, *bb2;
-
- bb1 = *(MyStaticRec**)a;
- bb2 = *(MyStaticRec**)b;
- if (bb1->elapsed < bb2->elapsed)
- return 1;
- if (bb1->elapsed > bb2->elapsed)
- return -1;
- return bb1->bb.bb_num - bb2->bb.bb_num;
-}
-
-// This function is called from quicksort to compare frequencies of
-// basic blocks.
-int cmp_dec_freq(const void *a, const void *b) {
- MyStaticRec *bb1, *bb2;
-
- bb1 = *(MyStaticRec**)a;
- bb2 = *(MyStaticRec**)b;
- if (bb1->freq < bb2->freq)
- return 1;
- if (bb1->freq > bb2->freq)
- return -1;
- return bb1->bb.bb_num - bb2->bb.bb_num;
-}
-
-int main(int argc, char **argv)
-{
- if (argc != 2) {
- fprintf(stderr, "Usage: %s trace_file\n", argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[1];
- TraceReaderBase *trace = new TraceReaderBase;
- trace->Open(trace_filename);
- TraceHeader *header = trace->GetHeader();
- uint32_t num_static_bb = header->num_static_bb;
-
- // Allocate space for all of the static blocks
- MyStaticRec *blocks = new MyStaticRec[num_static_bb];
-
- // Read in all the static blocks
- for (uint32_t ii = 0; ii < num_static_bb; ++ii) {
- trace->ReadStatic(&blocks[ii].bb);
- blocks[ii].is_thumb = blocks[ii].bb.bb_addr & 1;
- blocks[ii].bb.bb_addr &= ~1;
- uint32_t num_insns = blocks[ii].bb.num_insns;
- blocks[ii].insns = new uint32_t[num_insns];
- blocks[ii].cycles = new uint32_t[num_insns];
- memset(blocks[ii].cycles, 0, num_insns * sizeof(uint32_t));
- trace->ReadStaticInsns(num_insns, blocks[ii].insns);
- blocks[ii].elapsed = 0;
- blocks[ii].freq = 0;
- blocks[ii].inner = NULL;
- }
-
- MyStaticRec **sorted = assign_inner_blocks(num_static_bb, blocks);
-
- uint32_t prev_time = 0;
- uint32_t elapsed = 0;
- uint32_t dummy;
- uint32_t *cycle_ptr = &dummy;
- uint32_t *bb_elapsed_ptr = &dummy;
- while (1) {
- BBEvent event;
-
- if (trace->ReadBB(&event))
- break;
- // Assign frequencies to each basic block
- uint64_t bb_num = event.bb_num;
- int num_insns = event.num_insns;
- blocks[bb_num].freq += 1;
- for (MyStaticRec *bptr = blocks[bb_num].inner; bptr; bptr = bptr->inner)
- bptr->freq += 1;
-
- // Assign simulation time to each instruction
- for (MyStaticRec *bptr = &blocks[bb_num]; bptr; bptr = bptr->inner) {
- uint32_t bb_num_insns = bptr->bb.num_insns;
- for (uint32_t ii = 0; num_insns && ii < bb_num_insns; ++ii, --num_insns) {
- uint32_t sim_time = trace->ReadInsnTime(event.time);
- elapsed = sim_time - prev_time;
- prev_time = sim_time;
-
- // Attribute the elapsed time to the previous instruction and
- // basic block.
- *cycle_ptr += elapsed;
- *bb_elapsed_ptr += elapsed;
- cycle_ptr = &bptr->cycles[ii];
- bb_elapsed_ptr = &bptr->elapsed;
- }
- }
- }
- *cycle_ptr += 1;
- *bb_elapsed_ptr += 1;
-
- // Sort the basic blocks into decreasing elapsed time
- qsort(sorted, num_static_bb, sizeof(MyStaticRec*), cmp_dec_elapsed);
-
- char spaces[80];
- memset(spaces, ' ', 79);
- spaces[79] = 0;
- for (uint32_t ii = 0; ii < num_static_bb; ++ii) {
- printf("bb %lld addr: 0x%x, insns: %d freq: %u elapsed: %u\n",
- sorted[ii]->bb.bb_num, sorted[ii]->bb.bb_addr,
- sorted[ii]->bb.num_insns, sorted[ii]->freq,
- sorted[ii]->elapsed);
- int num_insns = sorted[ii]->bb.num_insns;
- uint32_t addr = sorted[ii]->bb.bb_addr;
- for (int jj = 0; jj < num_insns; ++jj) {
- uint32_t elapsed = sorted[ii]->cycles[jj];
- uint32_t insn = sorted[ii]->insns[jj];
- if (insn_is_thumb(insn)) {
- insn = insn_unwrap_thumb(insn);
-
- // thumb_pair is true if this is the first of a pair of
- // thumb instructions (BL or BLX).
- bool thumb_pair = ((insn & 0xf800) == 0xf000);
-
- // Get the next thumb instruction (if any) because we may need
- // it for the case where insn is BL or BLX.
- uint32_t insn2 = 0;
- if (thumb_pair && (jj + 1 < num_insns)) {
- insn2 = sorted[ii]->insns[jj + 1];
- insn2 = insn_unwrap_thumb(insn2);
- jj += 1;
- }
- char *disasm = disasm_insn_thumb(addr, insn, insn2, NULL);
- if (thumb_pair) {
- printf(" %4u %08x %04x %04x %s\n", elapsed, addr, insn,
- insn2, disasm);
- addr += 2;
- } else {
- printf(" %4u %08x %04x %s\n", elapsed, addr, insn,
- disasm);
- }
- addr += 2;
- } else {
- char *disasm = Arm::disasm(addr, insn, NULL);
- printf(" %4u %08x %08x %s\n", elapsed, addr, insn, disasm);
- addr += 4;
- }
- }
- }
-
- delete[] sorted;
- return 0;
-}
-
-// Find the basic blocks that are subsets of other basic blocks.
-MyStaticRec **assign_inner_blocks(int num_blocks, MyStaticRec *blocks)
-{
- int ii;
- uint32_t addr_end, addr_diff;
-
- // Create a list of pointers to the basic blocks that we can sort.
- MyStaticRec **sorted = new MyStaticRec*[num_blocks];
- for (ii = 0; ii < num_blocks; ++ii) {
- sorted[ii] = &blocks[ii];
- }
-
- // Sort the basic blocks into increasing address order
- qsort(sorted, num_blocks, sizeof(MyStaticRec*), cmp_inc_addr);
-
- // Create pointers to inner blocks and break up the enclosing block
- // so that there is no overlap.
- for (ii = 0; ii < num_blocks - 1; ++ii) {
- int num_bytes;
- if (sorted[ii]->is_thumb)
- num_bytes = sorted[ii]->bb.num_insns << 1;
- else
- num_bytes = sorted[ii]->bb.num_insns << 2;
- addr_end = sorted[ii]->bb.bb_addr + num_bytes;
- if (addr_end > sorted[ii + 1]->bb.bb_addr) {
- sorted[ii]->inner = sorted[ii + 1];
- addr_diff = sorted[ii + 1]->bb.bb_addr - sorted[ii]->bb.bb_addr;
- uint32_t num_insns;
- if (sorted[ii]->is_thumb)
- num_insns = addr_diff >> 1;
- else
- num_insns = addr_diff >> 2;
- sorted[ii]->bb.num_insns = num_insns;
- }
- }
-
- return sorted;
-}
diff --git a/emulator/qtools/bitvector.h b/emulator/qtools/bitvector.h
deleted file mode 100644
index d3f5cf1..0000000
--- a/emulator/qtools/bitvector.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef BITVECTOR_H
-#define BITVECTOR_H
-
-#include <inttypes.h>
-#include <assert.h>
-
-class Bitvector {
- public:
- explicit Bitvector(int num_bits) {
- num_bits_ = num_bits;
-
- // Round up to a multiple of 32
- num_bits = (num_bits + 31) & ~31;
- vector_ = new uint32_t[num_bits >> 5];
- }
- ~Bitvector() {
- delete[] vector_;
- }
-
- void SetBit(int bitnum) {
- assert(bitnum < num_bits_);
- vector_[bitnum >> 5] |= 1 << (bitnum & 31);
- }
- void ClearBit(int bitnum) {
- assert(bitnum < num_bits_);
- vector_[bitnum >> 5] &= ~(1 << (bitnum & 31));
- }
- bool GetBit(int bitnum) {
- assert(bitnum < num_bits_);
- return (vector_[bitnum >> 5] >> (bitnum & 31)) & 1;
- }
-
- private:
- int num_bits_;
- uint32_t *vector_;
-};
-
-#endif // BITVECTOR_H
diff --git a/emulator/qtools/callstack.h b/emulator/qtools/callstack.h
deleted file mode 100644
index 8982330..0000000
--- a/emulator/qtools/callstack.h
+++ /dev/null
@@ -1,775 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef CALL_STACK_H
-#define CALL_STACK_H
-
-#include "opcode.h"
-#include "armdis.h"
-
-class CallStackBase {
- public:
- int getId() { return mId; }
- void setId(int id) { mId = id; }
-
- private:
- int mId;
-};
-
-// Define a template class for the stack frame. The template parameter
-// SYM is the symbol_type from the TraceReader<> template class. To
-// use the CallStack class, the user derives a subclass of StackFrame
-// and defines push() and pop() methods. This derived class is then
-// passed as a template parameter to CallStack.
-template <class SYM>
-class StackFrame {
- public:
-
- virtual ~StackFrame() {};
-
- virtual void push(int stackLevel, uint64_t time, CallStackBase *base) {};
- virtual void pop(int stackLevel, uint64_t time, CallStackBase *base) {};
-
- typedef SYM symbol_type;
- static const uint32_t kCausedException = 0x01;
- static const uint32_t kInterpreted = 0x02;
- static const uint32_t kStartNative = 0x04;
- static const uint32_t kPopBarrier = (kCausedException | kInterpreted
- | kStartNative);
-
- symbol_type *function; // the symbol for the function we entered
- uint32_t addr; // return address when this function returns
- uint32_t flags;
- uint32_t time; // for debugging when a problem occurred
- uint32_t global_time; // for debugging when a problem occurred
-};
-
-template <class FRAME, class BASE = CallStackBase>
-class CallStack : public BASE {
-public:
- typedef FRAME frame_type;
- typedef typename FRAME::symbol_type symbol_type;
- typedef typename FRAME::symbol_type::region_type region_type;
- typedef BASE base_type;
-
- CallStack(int id, int numFrames, TraceReaderType *trace);
- ~CallStack();
-
- void updateStack(BBEvent *event, symbol_type *function);
- void popAll(uint64_t time);
- void threadStart(uint64_t time);
- void threadStop(uint64_t time);
-
- // Set to true if you don't want to see any Java methods ever
- void setNativeOnly(bool nativeOnly) {
- mNativeOnly = nativeOnly;
- }
-
- int getStackLevel() { return mTop; }
-
- uint64_t getGlobalTime(uint64_t time) { return time + mSkippedTime; }
- void showStack(FILE *stream);
-
- int mNumFrames;
- FRAME *mFrames;
- int mTop; // index of the next stack frame to write
-
-private:
- enum Action { NONE, PUSH, POP, NATIVE_PUSH };
-
- Action getAction(BBEvent *event, symbol_type *function);
- void doMethodAction(BBEvent *event, symbol_type *function);
- void doMethodPop(BBEvent *event, uint32_t addr, const uint32_t flags);
- void doSimplePush(symbol_type *function, uint32_t addr,
- uint64_t time, int flags);
- void doSimplePop(uint64_t time);
- void doPush(BBEvent *event, symbol_type *function);
- void doPop(BBEvent *event, symbol_type *function, Action methodAction);
-
- TraceReaderType *mTrace;
-
- // This is a global switch that disables Java methods from appearing
- // on the stack.
- bool mNativeOnly;
-
- // This keeps track of whether native frames are currently allowed on the
- // stack.
- bool mAllowNativeFrames;
-
- symbol_type mDummyFunction;
- region_type mDummyRegion;
-
- symbol_type *mPrevFunction;
- BBEvent mPrevEvent;
-
- symbol_type *mUserFunction;
- BBEvent mUserEvent; // the previous user-mode event
-
- uint64_t mSkippedTime;
- uint64_t mLastRunTime;
-
- static MethodRec sCurrentMethod;
- static MethodRec sNextMethod;
-};
-
-template<class FRAME, class BASE>
-MethodRec CallStack<FRAME, BASE>::sCurrentMethod;
-template<class FRAME, class BASE>
-MethodRec CallStack<FRAME, BASE>::sNextMethod;
-
-template<class FRAME, class BASE>
-CallStack<FRAME, BASE>::CallStack(int id, int numFrames, TraceReaderType *trace)
-{
- mNativeOnly = false;
- mTrace = trace;
- BASE::setId(id);
- mNumFrames = numFrames;
- mFrames = new FRAME[mNumFrames];
- mTop = 0;
- mAllowNativeFrames = true;
-
- memset(&mDummyFunction, 0, sizeof(symbol_type));
- memset(&mDummyRegion, 0, sizeof(region_type));
- mDummyFunction.region = &mDummyRegion;
- mPrevFunction = &mDummyFunction;
- memset(&mPrevEvent, 0, sizeof(BBEvent));
- mUserFunction = &mDummyFunction;
- memset(&mUserEvent, 0, sizeof(BBEvent));
- mSkippedTime = 0;
- mLastRunTime = 0;
-
- // Read the first two methods from the trace if we haven't already read
- // from the method trace yet.
- if (sCurrentMethod.time == 0) {
- if (mTrace->ReadMethod(&sCurrentMethod)) {
- sCurrentMethod.time = ~0ull;
- sNextMethod.time = ~0ull;
- }
- if (sNextMethod.time != ~0ull && mTrace->ReadMethod(&sNextMethod)) {
- sNextMethod.time = ~0ull;
- }
- }
-}
-
-template<class FRAME, class BASE>
-CallStack<FRAME, BASE>::~CallStack()
-{
- delete mFrames;
-}
-
-template<class FRAME, class BASE>
-void
-CallStack<FRAME, BASE>::updateStack(BBEvent *event, symbol_type *function)
-{
- if (mNativeOnly) {
- // If this is an interpreted function, then use the native VM function
- // instead.
- if (function->vm_sym != NULL)
- function = function->vm_sym;
- } else {
- doMethodAction(event, function);
- }
-
- Action action = getAction(event, function);
-
- // Allow native frames if we are executing in the kernel.
- if (!mAllowNativeFrames
- && (function->region->flags & region_type::kIsKernelRegion) == 0) {
- action = NONE;
- }
-
- if (function->vm_sym != NULL) {
- function = function->vm_sym;
- function->vm_sym = NULL;
- }
- if (action == PUSH) {
- doPush(event, function);
- } else if (action == POP) {
- doPop(event, function, NONE);
- }
-
-#if 0
- // Pop off native functions before pushing or popping Java methods.
- if (action == POP && mPrevFunction->vm_sym == NULL) {
- // Pop off the previous function first.
- doPop(event, function, NONE);
- if (methodAction == POP) {
- doPop(event, function, POP);
- } else if (methodAction == PUSH) {
- doPush(event, function);
- }
- } else {
- if (methodAction != NONE) {
- // If the method trace has a push or pop, then do it.
- action = methodAction;
- } else if (function->vm_sym != NULL) {
- // This function is a Java method. Don't push or pop the
- // Java method without a corresponding method trace record.
- action = NONE;
- }
- if (action == POP) {
- doPop(event, function, methodAction);
- } else if (action == PUSH) {
- doPush(event, function);
- }
- }
-#endif
-
- // If the stack is now empty, then push the current function.
- if (mTop == 0) {
- uint64_t time = event->time - mSkippedTime;
- int flags = 0;
- if (function->vm_sym != NULL) {
- flags = FRAME::kInterpreted;
- }
- doSimplePush(function, 0, time, 0);
- }
-
- mPrevFunction = function;
- mPrevEvent = *event;
-}
-
-template<class FRAME, class BASE>
-void
-CallStack<FRAME, BASE>::threadStart(uint64_t time)
-{
- mSkippedTime += time - mLastRunTime;
-}
-
-template<class FRAME, class BASE>
-void
-CallStack<FRAME, BASE>::threadStop(uint64_t time)
-{
- mLastRunTime = time;
-}
-
-template<class FRAME, class BASE>
-typename CallStack<FRAME, BASE>::Action
-CallStack<FRAME, BASE>::getAction(BBEvent *event, symbol_type *function)
-{
- Action action;
- uint32_t offset;
-
- // Compute the offset from the start of the function to this basic
- // block address.
- offset = event->bb_addr - function->addr - function->region->base_addr;
-
- // Get the previously executed instruction
- Opcode op = OP_INVALID;
- int numInsns = mPrevEvent.num_insns;
- uint32_t insn = 0;
- if (numInsns > 0) {
- insn = mPrevEvent.insns[numInsns - 1];
- if (mPrevEvent.is_thumb) {
- insn = insn_unwrap_thumb(insn);
- op = decode_insn_thumb(insn);
- } else {
- op = Arm::decode(insn);
- }
- }
-
- // The number of bytes in the previous basic block depends on
- // whether the basic block was ARM or THUMB instructions.
- int numBytes;
- if (mPrevEvent.is_thumb) {
- numBytes = numInsns << 1;
- } else {
- numBytes = numInsns << 2;
- }
-
- // If this basic block follows the previous one, then return NONE.
- // If we don't do this, then we may be fooled into thinking this
- // is a POP if the previous block ended with a conditional
- // (non-executed) ldmia instruction. We do this check before
- // checking if we are in a different function because we otherwise
- // we might be fooled into thinking this is a PUSH to a new function
- // when it is really just a fall-thru into a local kernel symbol
- // that just looks like a new function.
- uint32_t prev_end_addr = mPrevEvent.bb_addr + numBytes;
- if (prev_end_addr == event->bb_addr) {
- return NONE;
- }
-
- // If this basic block is in the same function as the last basic block,
- // then just return NONE (but see the exceptions below).
- // Exception 1: if the function calls itself (offset == 0) then we
- // want to push this function.
- // Exception 2: if the function returns to itself, then we want
- // to pop this function. We detect this case by checking if the last
- // instruction in the previous basic block was a load-multiple (ldm)
- // and included r15 as one of the loaded registers.
- if (function == mPrevFunction) {
- if (numInsns > 0) {
- // If this is the beginning of the function and the previous
- // instruction was not a branch, then it's a PUSH.
- if (offset == 0 && op != OP_B && op != OP_THUMB_B)
- return PUSH;
-
- // If the previous instruction was an ldm that loaded r15,
- // then it's a POP.
- if (offset != 0 && ((op == OP_LDM && (insn & 0x8000))
- || (op == OP_THUMB_POP && (insn & 0x100)))) {
- return POP;
- }
- }
-
- return NONE;
- }
-
- // We have to figure out if this new function is a call or a
- // return. We don't necessarily have a complete call stack (since
- // we could have started tracing at any point), so we have to use
- // heuristics. If the address we are jumping to is the beginning
- // of a function, or if the instruction that took us there was
- // either "bl" or "blx" then this is a PUSH. Also, if the
- // function offset is non-zero and the previous instruction is a
- // branch instruction, we will call it a PUSH. This happens in
- // the kernel a lot when there is a branch to an offset from a
- // label. A couple more special cases:
- //
- // - entering a .plt section ("procedure linkage table") is a PUSH,
- // - an exception that jumps into the kernel vector entry point
- // is also a push.
- //
- // If the function offset is non-zero and the previous instruction
- // is a bx or some non-branch instruction, then it's a POP.
- //
- // There's another special case that comes up. The user code
- // might execute an instruction that returns but before the pc
- // starts executing in the caller, a kernel interrupt occurs.
- // But it may be hard to tell if this is a return until after
- // the kernel interrupt code is done and returns to user space.
- // So we save the last user basic block and look at it when
- // we come back into user space.
-
- const uint32_t kIsKernelRegion = region_type::kIsKernelRegion;
-
- if (((mPrevFunction->region->flags & kIsKernelRegion) == 0)
- && (function->region->flags & kIsKernelRegion)) {
- // We just switched into the kernel. Save the previous
- // user-mode basic block and function.
- mUserEvent = mPrevEvent;
- mUserFunction = mPrevFunction;
- } else if ((mPrevFunction->region->flags & kIsKernelRegion)
- && ((function->region->flags & kIsKernelRegion) == 0)) {
- // We just switched from kernel to user mode.
- return POP;
- }
-
- action = PUSH;
- if (offset != 0 && mPrevFunction != &mDummyFunction) {
- // We are jumping into the middle of a function, so this is
- // probably a return, not a function call. But look at the
- // previous instruction first to see if it was a branch-and-link.
-
- // If the previous instruction was not a branch (and not a
- // branch-and-link) then POP; or if it is a "bx" instruction
- // then POP because that is used to return from functions.
- if (!isBranch(op) || op == OP_BX || op == OP_THUMB_BX) {
- action = POP;
- } else if (isBranch(op) && !isBranchLink(op)) {
- // If the previous instruction was a normal branch to a
- // local symbol then don't count it as a push or a pop.
- action = NONE;
- }
-
- if (function->flags & symbol_type::kIsVectorTable)
- action = PUSH;
- }
- return action;
-}
-
-
-template<class FRAME, class BASE>
-void CallStack<FRAME, BASE>::doPush(BBEvent *event, symbol_type *function)
-{
- uint64_t time = event->time - mSkippedTime;
-
- // Check for stack overflow
- if (mTop >= mNumFrames) {
- // Don't show the stack by default because this generates a lot
- // of output and this is seen by users if there is an error when
- // post-processing the trace. But this is useful for debugging.
-#if 0
- showStack(stderr);
-#endif
- fprintf(stderr, "Error: stack overflow (%d frames)\n", mTop);
- exit(1);
- }
-
- // Compute the return address here because we may need to change
- // it if we are popping off a frame for a vector table.
- int numBytes;
- if (mPrevEvent.is_thumb) {
- numBytes = mPrevEvent.num_insns << 1;
- } else {
- numBytes = mPrevEvent.num_insns << 2;
- }
- uint32_t retAddr = mPrevEvent.bb_addr + numBytes;
-
- // If this is a Java method then set the return address to zero.
- // We won't be using it for popping the method and it may lead
- // to false matches when searching the stack.
- if (function->vm_sym != NULL) {
- retAddr = 0;
- }
-
-#if 0
- // For debugging only. Show the stack before entering the kernel
- // exception-handling code.
- if (function->flags & symbol_type::kIsVectorStart) {
- printf("stack before entering exception\n");
- showStack(stderr);
- }
-#endif
-
- // If the top of stack is a vector table, then pop it
- // off before pushing on the new function. Also, change the
- // return address for the new function to the return address
- // from the vector table.
- if (mTop > 0
- && (mFrames[mTop - 1].function->flags & symbol_type::kIsVectorTable)) {
- retAddr = mFrames[mTop - 1].addr;
- doSimplePop(time);
- }
-
- const uint32_t kIsKernelRegion = region_type::kIsKernelRegion;
-
- // The following code handles the case where one function, F1,
- // calls another function, F2, but the before F2 can start
- // executing, it takes a page fault (on the first instruction
- // in F2). The kernel is entered, handles the page fault, and
- // then returns to the called function. The problem is that
- // this looks like a new function call to F2 from the kernel.
- // The following code cleans up the stack by popping the
- // kernel frames back to F1 (but not including F1). The
- // return address for F2 also has to be fixed up to point to
- // F1 instead of the kernel.
- //
- // We detect this case by checking if the previous basic block
- // was in the kernel and the current basic block is not.
- if ((mPrevFunction->region->flags & kIsKernelRegion)
- && ((function->region->flags & kIsKernelRegion) == 0)
- && mTop > 0) {
- // We are switching from kernel mode to user mode.
-#if 0
- // For debugging.
- printf(" doPush(): popping to user mode, bb_addr: 0x%08x\n",
- event->bb_addr);
- showStack(stderr);
-#endif
- do {
- // Pop off the kernel frames until we reach the one that
- // caused the exception.
- doSimplePop(time);
-
- // If the next stack frame is the one that caused an
- // exception then stop popping frames.
- if (mTop > 0
- && (mFrames[mTop - 1].flags & FRAME::kCausedException)) {
- mFrames[mTop - 1].flags &= ~FRAME::kCausedException;
- retAddr = mFrames[mTop].addr;
- break;
- }
- } while (mTop > 0);
-#if 0
- // For debugging
- printf(" doPush() popping to level %d, using retAddr 0x%08x\n",
- mTop, retAddr);
-#endif
- }
-
- // If we are starting an exception handler, then mark the previous
- // stack frame so that we know where to return when the exception
- // handler finishes.
- if ((function->flags & symbol_type::kIsVectorStart) && mTop > 0)
- mFrames[mTop - 1].flags |= FRAME::kCausedException;
-
- // If the function being pushed is a Java method, then mark it on
- // the stack so that we don't pop it off until we get a matching
- // trace record from the method trace file.
- int flags = 0;
- if (function->vm_sym != NULL) {
- flags = FRAME::kInterpreted;
- }
- doSimplePush(function, retAddr, time, flags);
-}
-
-template<class FRAME, class BASE>
-void CallStack<FRAME, BASE>::doSimplePush(symbol_type *function, uint32_t addr,
- uint64_t time, int flags)
-{
- // Check for stack overflow
- if (mTop >= mNumFrames) {
- showStack(stderr);
- fprintf(stderr, "too many stack frames (%d)\n", mTop);
- exit(1);
- }
-
- mFrames[mTop].addr = addr;
- mFrames[mTop].function = function;
- mFrames[mTop].flags = flags;
- mFrames[mTop].time = time;
- mFrames[mTop].global_time = time + mSkippedTime;
-
- mFrames[mTop].push(mTop, time, this);
- mTop += 1;
-}
-
-template<class FRAME, class BASE>
-void CallStack<FRAME, BASE>::doSimplePop(uint64_t time)
-{
- if (mTop <= 0) {
- return;
- }
-
- mTop -= 1;
- mFrames[mTop].pop(mTop, time, this);
-
- if (mNativeOnly)
- return;
-
- // If the stack is empty, then allow more native frames.
- // Otherwise, if we are transitioning from Java to native, then allow
- // more native frames.
- // Otherwise, if we are transitioning from native to Java, then disallow
- // more native frames.
- if (mTop == 0) {
- mAllowNativeFrames = true;
- } else {
- bool newerIsJava = (mFrames[mTop].flags & FRAME::kInterpreted) != 0;
- bool olderIsJava = (mFrames[mTop - 1].flags & FRAME::kInterpreted) != 0;
- if (newerIsJava && !olderIsJava) {
- // We are transitioning from Java to native
- mAllowNativeFrames = true;
- } else if (!newerIsJava && olderIsJava) {
- // We are transitioning from native to Java
- mAllowNativeFrames = false;
- }
- }
-}
-
-template<class FRAME, class BASE>
-void CallStack<FRAME, BASE>::doPop(BBEvent *event, symbol_type *function,
- Action methodAction)
-{
- uint64_t time = event->time - mSkippedTime;
-
- // Search backward on the stack for a matching return address.
- // The most common case is that we pop one stack frame, but
- // sometimes we pop more than one.
- int stackLevel;
- bool allowMethodPop = (methodAction == POP);
- for (stackLevel = mTop - 1; stackLevel >= 0; --stackLevel) {
- if (event->bb_addr == mFrames[stackLevel].addr) {
- // We found a matching return address on the stack.
- break;
- }
-
- // If this stack frame caused an exception, then do not pop
- // this stack frame.
- if (mFrames[stackLevel].flags & FRAME::kPopBarrier) {
- // If this is a Java method, then allow a pop only if we
- // have a matching trace record.
- if (mFrames[stackLevel].flags & FRAME::kInterpreted) {
- if (allowMethodPop) {
- // Allow at most one method pop
- allowMethodPop = false;
- continue;
- }
- }
- stackLevel += 1;
- break;
- }
- }
-
- // If we didn't find a matching return address then search the stack
- // again for a matching function.
- if (stackLevel < 0 || event->bb_addr != mFrames[stackLevel].addr) {
- bool allowMethodPop = (methodAction == POP);
- for (stackLevel = mTop - 1; stackLevel >= 0; --stackLevel) {
- // Compare the function with the one in the stack frame.
- if (function == mFrames[stackLevel].function) {
- // We found a matching function. We want to pop up to but not
- // including this frame. But allow popping this frame if this
- // method called itself and we have a method pop.
- if (allowMethodPop && function == mPrevFunction) {
- // pop this frame
- break;
- }
- // do not pop this frame
- stackLevel += 1;
- break;
- }
-
- // If this stack frame caused an exception, then do not pop
- // this stack frame.
- if (mFrames[stackLevel].flags & FRAME::kPopBarrier) {
- // If this is a Java method, then allow a pop only if we
- // have a matching trace record.
- if (mFrames[stackLevel].flags & FRAME::kInterpreted) {
- if (allowMethodPop) {
- // Allow at most one method pop
- allowMethodPop = false;
- continue;
- }
- }
- stackLevel += 1;
- break;
- }
- }
- if (stackLevel < 0)
- stackLevel = 0;
- }
-
- // Note that if we didn't find a matching stack frame, we will pop
- // the whole stack (unless there is a Java method or exception
- // frame on the stack). This is intentional because we may have
- // started the trace in the middle of an executing program that is
- // returning up the stack and we do not know the whole stack. So
- // the right thing to do is to empty the stack.
-
- // If we are emptying the stack, then add the current function
- // on top. If the current function is the same as the top of
- // stack, then avoid an extraneous pop and push.
- if (stackLevel == 0 && mFrames[0].function == function)
- stackLevel = 1;
-
-#if 0
- // If we are popping off a large number of stack frames, then
- // we might have a bug.
- if (mTop - stackLevel > 7) {
- printf("popping thru level %d\n", stackLevel);
- showStack(stderr);
- }
-#endif
-
- // Pop the stack frames
- for (int ii = mTop - 1; ii >= stackLevel; --ii)
- doSimplePop(time);
-
- // Clear the "caused exception" bit on the current stack frame
- if (mTop > 0) {
- mFrames[mTop - 1].flags &= ~FRAME::kCausedException;
- }
-
- // Also handle the case where F1 calls F2 and F2 returns to
- // F1, but before we can execute any instructions in F1, we
- // switch to the kernel. Then when we return from the kernel
- // we want to pop off F2 from the stack instead of pushing F1
- // on top of F2. To handle this case, we saved the last
- // user-mode basic block when we entered the kernel (in
- // the getAction() function) and now we can check to see if
- // that was a return to F1 instead of a call. We use the
- // getAction() function to determine this.
- const uint32_t kIsKernelRegion = region_type::kIsKernelRegion;
- if ((mPrevFunction->region->flags & kIsKernelRegion)
- && ((function->region->flags & kIsKernelRegion) == 0)) {
- mPrevEvent = mUserEvent;
- mPrevFunction = mUserFunction;
- if (getAction(event, function) == POP) {
- // We may need to pop more than one frame, so just
- // call doPop() again. This won't be an infinite loop
- // here because we changed mPrevEvent to the last
- // user-mode event.
- doPop(event, function, methodAction);
- return;
- }
- }
-}
-
-template<class FRAME, class BASE>
-void CallStack<FRAME, BASE>::popAll(uint64_t time)
-{
- time -= mSkippedTime;
- while (mTop != 0) {
- doSimplePop(time);
- }
-}
-
-template<class FRAME, class BASE>
-void CallStack<FRAME, BASE>::doMethodPop(BBEvent *event, uint32_t addr,
- const uint32_t flags)
-{
- uint64_t time = event->time - mSkippedTime;
-
- // Search the stack from the top down for a frame that contains a
- // matching method.
- int stackLevel;
- for (stackLevel = mTop - 1; stackLevel >= 0; --stackLevel) {
- if (mFrames[stackLevel].flags & flags) {
- // If we are searching for a native method, then don't bother trying
- // to match the address.
- if (flags == FRAME::kStartNative)
- break;
- symbol_type *func = mFrames[stackLevel].function;
- uint32_t methodAddr = func->region->base_addr + func->addr;
- if (methodAddr == addr) {
- break;
- }
- }
- }
-
- // If we found a matching frame then pop the stack up to and including
- // that frame.
- if (stackLevel >= 0) {
- // Pop the stack frames
- for (int ii = mTop - 1; ii >= stackLevel; --ii)
- doSimplePop(time);
- }
-}
-
-template<class FRAME, class BASE>
-void CallStack<FRAME, BASE>::doMethodAction(BBEvent *event, symbol_type *function)
-{
- // If the events get ahead of the method trace, then read ahead until we
- // sync up again. This can happen if there is a pop of a method in the
- // method trace for which we don't have a previous push. Such an unmatched
- // pop can happen because the user can start tracing at any time and so
- // there might already be a stack when we start tracing.
- while (event->time >= sNextMethod.time) {
- sCurrentMethod = sNextMethod;
- if (mTrace->ReadMethod(&sNextMethod)) {
- sNextMethod.time = ~0ull;
- }
- }
-
- if (event->time >= sCurrentMethod.time && event->pid == sCurrentMethod.pid) {
- uint64_t time = event->time - mSkippedTime;
- int flags = sCurrentMethod.flags;
- if (flags == kMethodEnter) {
- doSimplePush(function, 0, time, FRAME::kInterpreted);
- mAllowNativeFrames = false;
- } else if (flags == kNativeEnter) {
- doSimplePush(function, 0, time, FRAME::kStartNative);
- mAllowNativeFrames = true;
- } else if (flags == kMethodExit || flags == kMethodException) {
- doMethodPop(event, sCurrentMethod.addr, FRAME::kInterpreted);
- } else if (flags == kNativeExit || flags == kNativeException) {
- doMethodPop(event, sCurrentMethod.addr, FRAME::kStartNative);
- }
-
- // We found a match, so read the next record. When we get to the end
- // of the trace, we set the time to the maximum value (~0).
- sCurrentMethod = sNextMethod;
- if (sNextMethod.time != ~0ull && mTrace->ReadMethod(&sNextMethod)) {
- sNextMethod.time = ~0ull;
- }
- }
-}
-
-template<class FRAME, class BASE>
-void CallStack<FRAME, BASE>::showStack(FILE *stream)
-{
- fprintf(stream, "mTop: %d skippedTime: %llu\n", mTop, mSkippedTime);
- for (int ii = 0; ii < mTop; ++ii) {
- uint32_t addr = mFrames[ii].function->addr;
- addr += mFrames[ii].function->region->vstart;
- fprintf(stream, " %d: t %d gt %d f %x 0x%08x 0x%08x %s\n",
- ii, mFrames[ii].time, mFrames[ii].global_time,
- mFrames[ii].flags,
- mFrames[ii].addr, addr,
- mFrames[ii].function->name);
- }
-}
-
-#endif /* CALL_STACK_H */
diff --git a/emulator/qtools/check_stack.cpp b/emulator/qtools/check_stack.cpp
deleted file mode 100644
index b4d14d3..0000000
--- a/emulator/qtools/check_stack.cpp
+++ /dev/null
@@ -1,270 +0,0 @@
-// Copyright 2009 The Android Open Source Project
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <assert.h>
-#include "trace_reader.h"
-#include "bitvector.h"
-#include "parse_options.h"
-#include "armdis.h"
-
-typedef TraceReader<> TraceReaderType;
-
-#include "parse_options-inl.h"
-#include "callstack.h"
-
-typedef CallStack<StackFrame<symbol_type> > CallStackType;
-
-void compareStacks(uint64_t time, int pid);
-void dumpStacks(int pid);
-
-static uint64_t debugTime;
-static const int kNumStackFrames = 500;
-static const int kMaxThreads = (32 * 1024);
-CallStackType *eStacks[kMaxThreads];
-
-int numErrors;
-static const int kMaxErrors = 3;
-
-struct frame {
- uint64_t time;
- uint32_t addr;
- const char *name;
- bool isNative;
-
- frame(uint64_t time, uint32_t addr, const char *name, bool isNative) {
- this->time = time;
- this->addr = addr;
- this->name = name;
- this->isNative = isNative;
- }
-};
-
-class Stack {
-public:
- static const int kMaxFrames = 1000;
- int top;
- frame *frames[kMaxFrames];
-
- Stack() {
- top = 0;
- }
-
- void push(frame *pframe);
- frame* pop();
- void dump();
-};
-
-void Stack::push(frame *pframe) {
- if (top == kMaxFrames) {
- fprintf(stderr, "Error: stack overflow\n");
- exit(1);
- }
- frames[top] = pframe;
- top += 1;
-}
-
-frame *Stack::pop() {
- if (top <= 0)
- return NULL;
- top -= 1;
- return frames[top];
-}
-
-Stack *mStacks[kMaxThreads];
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_name elf_file\n",
- program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv)
-{
- ParseOptions(argc, argv);
- if (argc - optind != 2) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *qemu_trace_file = argv[optind++];
- char *elf_file = argv[optind++];
-
- TraceReaderType *etrace = new TraceReaderType;
- etrace->Open(qemu_trace_file);
- etrace->ReadKernelSymbols(elf_file);
- etrace->SetRoot(root);
-
- TraceReaderType *mtrace = new TraceReaderType;
- mtrace->Open(qemu_trace_file);
- mtrace->ReadKernelSymbols(elf_file);
- mtrace->SetRoot(root);
-
- BBEvent event;
- while (1) {
- BBEvent ignored;
- symbol_type *function;
- MethodRec method_record;
- symbol_type *sym;
- TraceReaderType::ProcessState *proc;
- frame *pframe;
-
- if (mtrace->ReadMethodSymbol(&method_record, &sym, &proc))
- break;
-
- if (!IsValidPid(proc->pid))
- continue;
-
- // Get the stack for the current thread
- Stack *mStack = mStacks[proc->pid];
-
- // If the stack does not exist, then allocate a new one.
- if (mStack == NULL) {
- mStack = new Stack();
- mStacks[proc->pid] = mStack;
- }
-
- int flags = method_record.flags;
- if (flags == kMethodEnter || flags == kNativeEnter) {
- pframe = new frame(method_record.time, method_record.addr,
- sym == NULL ? NULL: sym->name,
- method_record.flags == kNativeEnter);
- mStack->push(pframe);
- } else {
- pframe = mStack->pop();
- delete pframe;
- }
-
- do {
- if (GetNextValidEvent(etrace, &event, &ignored, &function))
- break;
- if (event.bb_num == 0)
- break;
-
- // Get the stack for the current thread
- CallStackType *eStack = eStacks[event.pid];
-
- // If the stack does not exist, then allocate a new one.
- if (eStack == NULL) {
- eStack = new CallStackType(event.pid, kNumStackFrames, etrace);
- eStacks[event.pid] = eStack;
- }
- if (debugTime != 0 && event.time >= debugTime)
- printf("time: %llu debug time: %lld\n", event.time, debugTime);
-
- // Update the stack
- eStack->updateStack(&event, function);
- } while (event.time < method_record.time);
-
- compareStacks(event.time, event.pid);
- }
-
- for (int ii = 0; ii < kMaxThreads; ++ii) {
- if (eStacks[ii])
- eStacks[ii]->popAll(event.time);
- }
-
- delete etrace;
- delete mtrace;
- return 0;
-}
-
-void compareStacks(uint64_t time, int pid) {
- CallStackType *eStack = eStacks[pid];
- Stack *mStack = mStacks[pid];
- frame **mFrames = mStack->frames;
- frame *mframe;
-
- int mTop = mStack->top;
- int eTop = eStack->mTop;
- CallStackType::frame_type *eFrames = eStack->mFrames;
-
- // Count the number of non-native methods (ie, Java methods) on the
- // Java method stack
- int numNonNativeMethods = 0;
- for (int ii = 0; ii < mTop; ++ii) {
- if (!mFrames[ii]->isNative) {
- numNonNativeMethods += 1;
- }
- }
-
- // Count the number of Java methods on the native stack
- int numMethods = 0;
- for (int ii = 0; ii < eTop; ++ii) {
- if (eFrames[ii].flags & CallStackType::frame_type::kInterpreted) {
- numMethods += 1;
- }
- }
-
- // Verify that the number of Java methods on both stacks are the same.
- // Allow the native stack to have one less Java method because the
- // native stack might be pushing a native function first.
- if (numNonNativeMethods != numMethods && numNonNativeMethods != numMethods + 1) {
- printf("\nDiff at time %llu pid %d: non-native %d numMethods %d\n",
- time, pid, numNonNativeMethods, numMethods);
- dumpStacks(pid);
- numErrors += 1;
- if (numErrors >= kMaxErrors)
- exit(1);
- }
-
- // Verify that the Java methods on the method stack are the same
- // as the Java methods on the native stack.
- int mIndex = 0;
- for (int ii = 0; ii < eTop; ++ii) {
- // Ignore native functions on the native stack.
- if ((eFrames[ii].flags & CallStackType::frame_type::kInterpreted) == 0)
- continue;
- uint32_t addr = eFrames[ii].function->addr;
- addr += eFrames[ii].function->region->vstart;
- while (mIndex < mTop && mFrames[mIndex]->isNative) {
- mIndex += 1;
- }
- if (mIndex >= mTop)
- break;
- if (addr != mFrames[mIndex]->addr) {
- printf("\nDiff at time %llu pid %d: frame %d\n", time, pid, ii);
- dumpStacks(pid);
- exit(1);
- }
- mIndex += 1;
- }
-}
-
-void dumpStacks(int pid) {
- CallStackType *eStack = eStacks[pid];
- Stack *mStack = mStacks[pid];
- frame *mframe;
-
- int mTop = mStack->top;
- printf("\nJava method stack\n");
- for (int ii = 0; ii < mTop; ii++) {
- mframe = mStack->frames[ii];
- const char *native = mframe->isNative ? "n" : " ";
- printf(" %s %d: %llu 0x%x %s\n",
- native, ii, mframe->time, mframe->addr,
- mframe->name == NULL ? "" : mframe->name);
- }
-
- int eTop = eStack->mTop;
- CallStackType::frame_type *eFrames = eStack->mFrames;
- int mIndex = 0;
- printf("\nNative stack\n");
- for (int ii = 0; ii < eTop; ++ii) {
- uint32_t addr = eFrames[ii].function->addr;
- addr += eFrames[ii].function->region->vstart;
- const char *marker = " ";
- if (eFrames[ii].flags & CallStackType::frame_type::kInterpreted) {
- if (mIndex >= mTop || addr != mStack->frames[mIndex]->addr) {
- marker = "*";
- }
- mIndex += 1;
- }
- printf(" %s %d: %d f %d 0x%08x %s\n",
- marker, ii, eFrames[ii].time, eFrames[ii].flags, addr,
- eFrames[ii].function->name);
- }
-}
diff --git a/emulator/qtools/check_trace.cpp b/emulator/qtools/check_trace.cpp
deleted file mode 100644
index d933a87..0000000
--- a/emulator/qtools/check_trace.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <assert.h>
-#include "trace_reader.h"
-#include "armdis.h"
-#include "parse_options.h"
-
-typedef TraceReader<> TraceReaderType;
-
-#include "parse_options-inl.h"
-
-static const uint32_t kOffsetThreshold = 0x100000;
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_file elf_file\n", program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv) {
- // Parse the options
- ParseOptions(argc, argv);
- if (argc - optind != 2) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[optind++];
- char *elf_file = argv[optind++];
- TraceReader<> *trace = new TraceReader<>;
- trace->Open(trace_filename);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
-
- while (1) {
- symbol_type *sym;
- BBEvent event;
- BBEvent ignored;
-
- if (GetNextValidEvent(trace, &event, &ignored, &sym))
- break;
- if (event.bb_num == 0)
- break;
- //printf("t%llu bb %lld %d\n", event.time, event.bb_num, event.num_insns);
- uint64_t insn_time = trace->ReadInsnTime(event.time);
- if (insn_time != event.time) {
- printf("time: %llu insn time: %llu bb: %llu addr: 0x%x num_insns: %d, pid: %d\n",
- event.time, insn_time, event.bb_num, event.bb_addr,
- event.num_insns, event.pid);
- exit(1);
- }
- for (int ii = 1; ii < event.num_insns; ++ii) {
- trace->ReadInsnTime(event.time);
- }
- }
-
- delete trace;
- return 0;
-}
diff --git a/emulator/qtools/coverage.cpp b/emulator/qtools/coverage.cpp
deleted file mode 100644
index 790f721..0000000
--- a/emulator/qtools/coverage.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include "trace_reader.h"
-#include "parse_options.h"
-#include "opcode.h"
-
-const int kMillion = 1000000;
-const int kMHz = 200 * kMillion;
-
-struct symbol {
- int numCalls; // number of times this function is called
-};
-
-typedef TraceReader<symbol> TraceReaderType;
-
-#include "parse_options-inl.h"
-#include "callstack.h"
-
-class MyFrame : public StackFrame<symbol_type> {
- public:
- void push(int stackLevel, uint64_t time, CallStackBase *base) {
- function->numCalls += 1;
- }
- void pop(int stackLevel, uint64_t time, CallStackBase *base) {
- }
-};
-
-typedef CallStack<MyFrame> CallStackType;
-
-static const int kNumStackFrames = 500;
-static const int kMaxThreads = (32 * 1024);
-CallStackType *stacks[kMaxThreads];
-
-// This comparison function is called from qsort() to sort symbols
-// into decreasing number of calls.
-int cmp_sym_calls(const void *a, const void *b) {
- const symbol_type *syma, *symb;
- uint64_t calls1, calls2;
-
- syma = static_cast<symbol_type const *>(a);
- symb = static_cast<symbol_type const *>(b);
- calls1 = syma->numCalls;
- calls2 = symb->numCalls;
- if (calls1 < calls2)
- return 1;
- if (calls1 == calls2) {
- int cmp = strcmp(syma->name, symb->name);
- if (cmp == 0)
- cmp = strcmp(syma->region->path, symb->region->path);
- return cmp;
- }
- return -1;
-}
-
-// This comparison function is called from qsort() to sort symbols
-// into alphabetical order.
-int cmp_sym_names(const void *a, const void *b) {
- const symbol_type *syma, *symb;
-
- syma = static_cast<symbol_type const *>(a);
- symb = static_cast<symbol_type const *>(b);
- int cmp = strcmp(syma->region->path, symb->region->path);
- if (cmp == 0)
- cmp = strcmp(syma->name, symb->name);
- return cmp;
-}
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_file elf_file\n", program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv)
-{
- ParseOptions(argc, argv);
- if (argc - optind != 2) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[optind++];
- char *elf_file = argv[optind++];
- TraceReader<symbol> *trace = new TraceReader<symbol>;
- trace->Open(trace_filename);
- trace->SetDemangle(demangle);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
-
- BBEvent event;
- while (1) {
- BBEvent ignored;
- symbol_type *function;
-
- if (GetNextValidEvent(trace, &event, &ignored, &function))
- break;
- if (event.bb_num == 0)
- break;
-
- // Get the stack for the current thread
- CallStackType *pStack = stacks[event.pid];
-
- // If the stack does not exist, then allocate a new one.
- if (pStack == NULL) {
- pStack = new CallStackType(event.pid, kNumStackFrames, trace);
- stacks[event.pid] = pStack;
- }
-
- // Update the stack
- pStack->updateStack(&event, function);
- }
-
- for (int ii = 0; ii < kMaxThreads; ++ii) {
- if (stacks[ii])
- stacks[ii]->popAll(event.time);
- }
-
- int nsyms;
- symbol_type *syms = trace->GetSymbols(&nsyms);
-
- // Sort the symbols into decreasing number of calls
- qsort(syms, nsyms, sizeof(symbol_type), cmp_sym_names);
-
- symbol_type *psym = syms;
- for (int ii = 0; ii < nsyms; ++ii, ++psym) {
- // Ignore functions with non-zero calls
- if (psym->numCalls)
- continue;
-
- // Ignore some symbols
- if (strcmp(psym->name, "(end)") == 0)
- continue;
- if (strcmp(psym->name, "(unknown)") == 0)
- continue;
- if (strcmp(psym->name, ".plt") == 0)
- continue;
- const char *ksym = " ";
- if (psym->region->flags & region_type::kIsKernelRegion)
- ksym = "k";
- printf("%s %s %s\n", ksym, psym->name, psym->region->path);
-#if 0
- printf("#%d %5d %s %s %s\n", ii + 1, psym->numCalls, ksym, psym->name,
- psym->region->path);
-#endif
- }
- delete[] syms;
- delete trace;
-
- return 0;
-}
diff --git a/emulator/qtools/decoder.cpp b/emulator/qtools/decoder.cpp
deleted file mode 100644
index ec53181..0000000
--- a/emulator/qtools/decoder.cpp
+++ /dev/null
@@ -1,278 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include "decoder.h"
-#include "trace_common.h"
-
-// This array provides a fast conversion from the initial byte in
-// a varint-encoded object to the length (in bytes) of that object.
-int prefix_to_len[] = {
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
- 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
- 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 9, 9, 17, 17
-};
-
-// This array provides a fast conversion from the initial byte in
-// a varint-encoded object to the initial data bits for that object.
-int prefix_to_data[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
- 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
- 112, 113, 114, 115, 116, 117, 118, 119,
- 120, 121, 122, 123, 124, 125, 126, 127,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
- 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 0, 0, 0, 0
-};
-
-signed char prefix_to_signed_data[] = {
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
- 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
- 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
- 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
- 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
- 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
- 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
- 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
- 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
- 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
- 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
- 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
- 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
- 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
- 0x00, 0x01, 0x02, 0x03, 0xfc, 0xfd, 0xfe, 0xff,
- 0x00, 0x01, 0xfe, 0xff, 0x00, 0xff, 0x00, 0xff,
-};
-
-Decoder::Decoder()
-{
- filename_ = NULL;
- fstream_ = NULL;
- next_ = NULL;
- end_ = NULL;
-}
-
-Decoder::~Decoder()
-{
- Close();
- delete[] filename_;
-}
-
-void Decoder::Close()
-{
- if (fstream_) {
- fclose(fstream_);
- fstream_ = NULL;
- }
-}
-
-void Decoder::Open(char *filename)
-{
- if (filename_ != NULL) {
- delete[] filename_;
- }
- filename_ = new char[strlen(filename) + 1];
- strcpy(filename_, filename);
- fstream_ = fopen(filename_, "r");
- if (fstream_ == NULL) {
- perror(filename_);
- exit(1);
- }
-
- int rval = fread(buf_, 1, kBufSize, fstream_);
- if (rval != kBufSize) {
- if (ferror(fstream_)) {
- perror(filename_);
- exit(1);
- }
- if (!feof(fstream_)) {
- fprintf(stderr, "Unexpected short fread() before eof\n");
- exit(1);
- }
- }
- next_ = buf_;
- end_ = buf_ + rval;
-}
-
-void Decoder::FillBuffer()
-{
- assert(next_ <= end_);
-
- if (end_ - next_ < kDecodingSpace && end_ == &buf_[kBufSize]) {
- // Copy the unused bytes left at the end to the beginning of the
- // buffer.
- int len = end_ - next_;
- if (len > 0)
- memcpy(buf_, next_, len);
-
- // Read enough bytes to fill up the buffer, if possible.
- int nbytes = kBufSize - len;
- int rval = fread(buf_ + len, 1, nbytes, fstream_);
- if (rval < nbytes) {
- if (ferror(fstream_)) {
- perror(filename_);
- exit(1);
- }
- if (!feof(fstream_)) {
- fprintf(stderr, "Unexpected short fread() before eof\n");
- exit(1);
- }
- }
- end_ = &buf_[len + rval];
- next_ = buf_;
- }
-}
-
-void Decoder::Read(char *dest, int len)
-{
- while (len > 0) {
- int nbytes = end_ - next_;
- if (nbytes == 0) {
- FillBuffer();
- nbytes = end_ - next_;
- if (nbytes == 0)
- break;
- }
- if (nbytes > len)
- nbytes = len;
- memcpy(dest, next_, nbytes);
- dest += nbytes;
- len -= nbytes;
- next_ += nbytes;
- }
-}
-
-// Decode a varint-encoded object starting at the current position in
-// the array "buf_" and return the decoded value as a 64-bit integer.
-// A varint-encoded object has an initial prefix that specifies how many
-// data bits follow. If the first bit is zero, for example, then there
-// are 7 data bits that follow. The table below shows the prefix values
-// and corresponding data bits.
-//
-// Prefix Bytes Data bits
-// 0 1 7
-// 10 2 14
-// 110 3 21
-// 1110 4 28
-// 11110 5 35
-// 111110 6 42
-// 11111100 9 64
-// 11111101 reserved
-// 11111110 reserved
-// 11111111 reserved
-int64_t Decoder::Decode(bool is_signed)
-{
- int64_t val64;
-
- if (end_ - next_ < kDecodingSpace)
- FillBuffer();
-
-#if BYTE_ORDER == BIG_ENDIAN
- uint8_t byte0 = *next_;
-
- // Get the number of bytes to decode based on the first byte.
- int len = prefix_to_len[byte0];
-
- if (next_ + len > end_) {
- fprintf(stderr, "%s: decoding past end of file.\n", filename_);
- exit(1);
- }
-
- // Get the first data byte.
- if (is_signed)
- val64 = prefix_to_signed_data[byte0];
- else
- val64 = prefix_to_data[byte0];
-
- next_ += 1;
- for (int ii = 1; ii < len; ++ii) {
- val64 = (val64 << 8) | *next_++;
- }
-#else
- // If we are on a little-endian machine, then use large, unaligned loads.
- uint64_t data = *(reinterpret_cast<uint64_t*>(next_));
- uint8_t byte0 = data;
- data = bswap64(data);
-
- // Get the number of bytes to decode based on the first byte.
- int len = prefix_to_len[byte0];
-
- if (next_ + len > end_) {
- fprintf(stderr, "%s: decoding past end of file.\n", filename_);
- exit(1);
- }
-
- // Get the first data byte.
- if (is_signed)
- val64 = prefix_to_signed_data[byte0];
- else
- val64 = prefix_to_data[byte0];
-
- switch (len) {
- case 1:
- break;
- case 2:
- val64 = (val64 << 8) | ((data >> 48) & 0xffull);
- break;
- case 3:
- val64 = (val64 << 16) | ((data >> 40) & 0xffffull);
- break;
- case 4:
- val64 = (val64 << 24) | ((data >> 32) & 0xffffffull);
- break;
- case 5:
- val64 = (val64 << 32) | ((data >> 24) & 0xffffffffull);
- break;
- case 6:
- val64 = (val64 << 40) | ((data >> 16) & 0xffffffffffull);
- break;
- case 9:
- data = *(reinterpret_cast<uint64_t*>(&next_[1]));
- val64 = bswap64(data);
- break;
- }
- next_ += len;
-#endif
- return val64;
-}
diff --git a/emulator/qtools/decoder.h b/emulator/qtools/decoder.h
deleted file mode 100644
index 44905fd..0000000
--- a/emulator/qtools/decoder.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#include <stdio.h>
-#include <inttypes.h>
-
-class Decoder {
- public:
- Decoder();
- ~Decoder();
-
- void Open(char *filename);
- void Close();
- int64_t Decode(bool is_signed);
- void Read(char *dest, int len);
- bool IsEOF() { return (end_ == next_) && feof(fstream_); }
-
- private:
- static const int kBufSize = 4096;
- static const int kDecodingSpace = 9;
-
- void FillBuffer();
-
- char *filename_;
- FILE *fstream_;
- uint8_t buf_[kBufSize];
- uint8_t *next_;
- uint8_t *end_;
-};
diff --git a/emulator/qtools/dmtrace.cpp b/emulator/qtools/dmtrace.cpp
deleted file mode 100644
index c486c5f..0000000
--- a/emulator/qtools/dmtrace.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <inttypes.h>
-#include <string.h>
-#include <unistd.h>
-#include "dmtrace.h"
-
-static const short kVersion = 2;
-
-const DmTrace::Header DmTrace::header = {
- 0x574f4c53, kVersion, sizeof(DmTrace::Header), 0LL
-};
-
-static char *keyHeader = "*version\n" "2\n" "clock=thread-cpu\n";
-static char *keyThreadHeader = "*threads\n";
-static char *keyFunctionHeader = "*methods\n";
-static char *keyEnd = "*end\n";
-
-DmTrace::DmTrace() {
- fData = NULL;
- fTrace = NULL;
- threads = new std::vector<ThreadRecord*>;
- functions = new std::vector<FunctionRecord*>;
-}
-
-DmTrace::~DmTrace() {
- delete threads;
- delete functions;
-}
-
-void DmTrace::open(const char *dmtrace_file, uint64_t start_time)
-{
- fTrace = fopen(dmtrace_file, "w");
- if (fTrace == NULL) {
- perror(dmtrace_file);
- exit(1);
- }
-
- // Make a temporary file to write the data into.
- char tmpData[32];
- strcpy(tmpData, "/tmp/dmtrace-data-XXXXXX");
- int data_fd = mkstemp(tmpData);
- if (data_fd < 0) {
- perror("Cannot create temporary file");
- exit(1);
- }
-
- // Ensure it goes away on exit.
- unlink(tmpData);
- fData = fdopen(data_fd, "w+");
- if (fData == NULL) {
- perror("Can't make temp data file");
- exit(1);
- }
-
- writeHeader(fData, start_time);
-}
-
-void DmTrace::close()
-{
- if (fTrace == NULL)
- return;
- writeKeyFile(fTrace);
-
- // Take down how much data we wrote to the temp data file.
- long size = ftell(fData);
- // Rewind the data file and append its contents to the trace file.
- rewind(fData);
- char *data = (char *)malloc(size);
- fread(data, size, 1, fData);
- fwrite(data, size, 1, fTrace);
- free(data);
- fclose(fData);
- fclose(fTrace);
-}
-
-/*
- * Write values to the binary data file.
- */
-void DmTrace::write2LE(FILE* fstream, unsigned short val)
-{
- putc(val & 0xff, fstream);
- putc(val >> 8, fstream);
-}
-
-void DmTrace::write4LE(FILE* fstream, unsigned int val)
-{
- putc(val & 0xff, fstream);
- putc((val >> 8) & 0xff, fstream);
- putc((val >> 16) & 0xff, fstream);
- putc((val >> 24) & 0xff, fstream);
-}
-
-void DmTrace::write8LE(FILE* fstream, unsigned long long val)
-{
- putc(val & 0xff, fstream);
- putc((val >> 8) & 0xff, fstream);
- putc((val >> 16) & 0xff, fstream);
- putc((val >> 24) & 0xff, fstream);
- putc((val >> 32) & 0xff, fstream);
- putc((val >> 40) & 0xff, fstream);
- putc((val >> 48) & 0xff, fstream);
- putc((val >> 56) & 0xff, fstream);
-}
-
-void DmTrace::writeHeader(FILE *fstream, uint64_t startTime)
-{
- write4LE(fstream, header.magic);
- write2LE(fstream, header.version);
- write2LE(fstream, header.offset);
- write8LE(fstream, startTime);
-}
-
-void DmTrace::writeDataRecord(FILE *fstream, int threadId,
- unsigned int methodVal,
- unsigned int elapsedTime)
-{
- write2LE(fstream, threadId);
- write4LE(fstream, methodVal);
- write4LE(fstream, elapsedTime);
-}
-
-void DmTrace::addFunctionEntry(int functionId, uint32_t cycle, uint32_t pid)
-{
- writeDataRecord(fData, pid, functionId, cycle);
-}
-
-void DmTrace::addFunctionExit(int functionId, uint32_t cycle, uint32_t pid)
-{
- writeDataRecord(fData, pid, functionId | 1, cycle);
-}
-
-void DmTrace::addFunction(int functionId, const char *name)
-{
- FunctionRecord *rec = new FunctionRecord;
- rec->id = functionId;
- rec->name = name;
- functions->push_back(rec);
-}
-
-void DmTrace::addFunction(int functionId, const char *clazz,
- const char *method, const char *sig)
-{
- // Allocate space for all the strings, plus 2 tab separators plus null byte.
- // We currently don't reclaim this space.
- int len = strlen(clazz) + strlen(method) + strlen(sig) + 3;
- char *name = new char[len];
- sprintf(name, "%s\t%s\t%s", clazz, method, sig);
-
- addFunction(functionId, name);
-}
-
-void DmTrace::parseAndAddFunction(int functionId, const char *name)
-{
- // Parse the "name" string into "class", "method" and "signature".
- // The "name" string should look something like this:
- // name = "java.util.LinkedList.size()I"
- // and it will be parsed into this:
- // clazz = "java.util.LinkedList"
- // method = "size"
- // sig = "()I"
-
- // Find the first parenthesis, the start of the signature.
- char *paren = (char*)strchr(name, '(');
-
- // If not found, then add the original name.
- if (paren == NULL) {
- addFunction(functionId, name);
- return;
- }
-
- // Copy the signature
- int len = strlen(paren) + 1;
- char *sig = new char[len];
- strcpy(sig, paren);
-
- // Zero the parenthesis so that we can search backwards from the signature
- *paren = 0;
-
- // Search for the last period, the start of the method name
- char *dot = (char*)strrchr(name, '.');
-
- // If not found, then add the original name.
- if (dot == NULL || dot == name) {
- delete[] sig;
- *paren = '(';
- addFunction(functionId, name);
- return;
- }
-
- // Copy the method, not including the dot
- len = strlen(dot + 1) + 1;
- char *method = new char[len];
- strcpy(method, dot + 1);
-
- // Zero the dot to delimit the class name
- *dot = 0;
-
- addFunction(functionId, name, method, sig);
-
- // Free the space we allocated.
- delete[] sig;
- delete[] method;
-}
-
-void DmTrace::addThread(int threadId, const char *name)
-{
- ThreadRecord *rec = new ThreadRecord;
- rec->id = threadId;
- rec->name = name;
- threads->push_back(rec);
-}
-
-void DmTrace::updateName(int threadId, const char *name)
-{
- std::vector<ThreadRecord*>::iterator iter;
-
- for (iter = threads->begin(); iter != threads->end(); ++iter) {
- if ((*iter)->id == threadId) {
- (*iter)->name = name;
- return;
- }
- }
-}
-
-void DmTrace::writeKeyFile(FILE *fstream)
-{
- fwrite(keyHeader, strlen(keyHeader), 1, fstream);
- writeThreads(fstream);
- writeFunctions(fstream);
- fwrite(keyEnd, strlen(keyEnd), 1, fstream);
-}
-
-void DmTrace::writeThreads(FILE *fstream)
-{
- std::vector<ThreadRecord*>::iterator iter;
-
- fwrite(keyThreadHeader, strlen(keyThreadHeader), 1, fstream);
- for (iter = threads->begin(); iter != threads->end(); ++iter) {
- fprintf(fstream, "%d\t%s\n", (*iter)->id, (*iter)->name);
- }
-}
-
-void DmTrace::writeFunctions(FILE *fstream)
-{
- std::vector<FunctionRecord*>::iterator iter;
-
- fwrite(keyFunctionHeader, strlen(keyFunctionHeader), 1, fstream);
- for (iter = functions->begin(); iter != functions->end(); ++iter) {
- fprintf(fstream, "0x%x\t%s\n", (*iter)->id, (*iter)->name);
- }
-}
diff --git a/emulator/qtools/dmtrace.h b/emulator/qtools/dmtrace.h
deleted file mode 100644
index 6e20921..0000000
--- a/emulator/qtools/dmtrace.h
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef DMTRACE_H
-#define DMTRACE_H
-
-#include <vector>
-
-class DmTrace {
- public:
- struct Header {
- uint32_t magic;
- uint16_t version;
- uint16_t offset;
- uint64_t date_time;
- };
-
- DmTrace();
- ~DmTrace();
-
- void open(const char *dmtrace_file, uint64_t startTime);
- void close();
- void addFunctionEntry(int methodId, uint32_t cycle, uint32_t pid);
- void addFunctionExit(int methodId, uint32_t cycle, uint32_t pid);
- void addFunction(int functionId, const char *name);
- void addFunction(int functionId, const char *clazz, const char *method,
- const char *sig);
- void parseAndAddFunction(int functionId, const char *name);
- void addThread(int threadId, const char *name);
- void updateName(int threadId, const char *name);
-
- private:
- static const Header header;
-
- struct ThreadRecord {
- int id;
- const char *name;
- };
-
- struct FunctionRecord {
- int id;
- const char *name;
- };
-
- void write2LE(FILE* fstream, unsigned short val);
- void write4LE(FILE* fstream, unsigned int val);
- void write8LE(FILE* fstream, unsigned long long val);
- void writeHeader(FILE *fstream, uint64_t startTime);
- void writeDataRecord(FILE *fstream, int threadId,
- unsigned int methodVal,
- unsigned int elapsedTime);
- void writeKeyFile(FILE *fstream);
- void writeThreads(FILE *fstream);
- void writeFunctions(FILE *fstream);
-
- FILE *fData;
- FILE *fTrace;
- std::vector<ThreadRecord*> *threads;
- std::vector<FunctionRecord*> *functions;
-};
-
-#endif // DMTRACE_H
diff --git a/emulator/qtools/dump_regions.cpp b/emulator/qtools/dump_regions.cpp
deleted file mode 100644
index 57389f9..0000000
--- a/emulator/qtools/dump_regions.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <string.h>
-#include "trace_reader.h"
-#include "parse_options.h"
-
-typedef TraceReader<> TraceReaderType;
-
-#include "parse_options-inl.h"
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_file\n", program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv) {
- // Parse the options
- ParseOptions(argc, argv);
- if (argc - optind != 1) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[optind];
- TraceReader<> *trace = new TraceReader<>;
- trace->Open(trace_filename);
- trace->SetRoot(root);
-
- while (1) {
- BBEvent event, ignored;
- symbol_type *dummy_sym;
-
- if (GetNextValidEvent(trace, &event, &ignored, &dummy_sym))
- break;
- }
-
- int num_procs;
- ProcessState *processes = trace->GetProcesses(&num_procs);
-
- ProcessState *pstate = &processes[0];
- for (int ii = 0; ii < num_procs; ++ii, ++pstate) {
- if (pstate->name == NULL)
- pstate->name = "";
- ProcessState *manager = pstate->addr_manager;
- printf("pid %d regions: %d %s",
- pstate->pid, manager->nregions, pstate->name);
- for (int jj = 1; jj < pstate->argc; ++jj) {
- printf(" %s", pstate->argv[jj]);
- }
- printf("\n");
- trace->DumpRegions(stdout, pstate);
- }
-
- delete trace;
- return 0;
-}
diff --git a/emulator/qtools/exc_dump.cpp b/emulator/qtools/exc_dump.cpp
deleted file mode 100644
index 166586f..0000000
--- a/emulator/qtools/exc_dump.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include "trace_reader_base.h"
-
-int main(int argc, char **argv) {
- if (argc != 2) {
- fprintf(stderr, "Usage: %s trace_file\n", argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[1];
- TraceReaderBase *trace = new TraceReaderBase;
- trace->Open(trace_filename);
-
- while (1) {
- uint64_t time, recnum, bb_num, bb_start_time;
- uint32_t pc, target_pc;
- int num_insns;
-
- if (trace->ReadExc(&time, &pc, &recnum, &target_pc, &bb_num,
- &bb_start_time, &num_insns))
- break;
- printf("time: %lld rec: %llu pc: %08x target: %08x bb: %llu bb_start: %llu insns: %d\n",
- time, recnum, pc, target_pc, bb_num, bb_start_time, num_insns);
- }
- return 0;
-}
diff --git a/emulator/qtools/gtrace.cpp b/emulator/qtools/gtrace.cpp
deleted file mode 100644
index 673d8a4..0000000
--- a/emulator/qtools/gtrace.cpp
+++ /dev/null
@@ -1,152 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include "gtrace.h"
-
-// A buffer of zeros
-static char zeros[Gtrace::kGtraceEntriesPerBlock * sizeof(Gtrace::trace_entry)];
-
-Gtrace::Gtrace() {
- gtrace_file_ = NULL;
- ftrace_ = NULL;
- fnames_ = NULL;
- start_sec_ = 0;
- pdate_ = 0;
- ptime_ = 0;
- num_entries_ = 0;
- blockno_ = 1;
- current_pid_ = 0;
-}
-
-Gtrace::~Gtrace() {
- if (ftrace_) {
- // Extend the trace file to a multiple of 8k. Otherwise gtracepost64
- // complains.
- long pos = ftell(ftrace_);
- long pos_end = (pos + 0x1fff) & ~0x1fff;
- if (pos_end > pos) {
- char ch = 0;
- fseek(ftrace_, pos_end - 1, SEEK_SET);
- fwrite(&ch, 1, 1, ftrace_);
- }
- fclose(ftrace_);
- }
- if (fnames_)
- fclose(fnames_);
-}
-
-void Gtrace::Open(const char *gtrace_file, uint32_t pdate, uint32_t ptime)
-{
- ftrace_ = fopen(gtrace_file, "w");
- if (ftrace_ == NULL) {
- perror(gtrace_file);
- exit(1);
- }
- gtrace_file_ = gtrace_file;
-
- pdate_ = pdate;
- ptime_ = ptime;
- sprintf(gname_file_, "gname_%x_%06x.txt", pdate, ptime);
- fnames_ = fopen(gname_file_, "w");
- if (fnames_ == NULL) {
- perror(gname_file_);
- exit(1);
- }
- fprintf(fnames_, "# File# Proc# Line# Name\n");
-}
-
-void Gtrace::WriteFirstHeader(uint32_t start_sec, uint32_t pid)
-{
- first_header fh;
- current_pid_ = pid;
- start_sec_ = start_sec;
- FillFirstHeader(start_sec, pid, &fh);
- fwrite(&fh, sizeof(fh), 1, ftrace_);
- num_entries_ = 8;
-}
-
-void Gtrace::FillFirstHeader(uint32_t start_sec, uint32_t pid,
- first_header *fh) {
- int cpu = 0;
- int max_files = 16;
- int max_procedures = 12;
-
- fh->common.blockno = 0;
- fh->common.entry_width = 8;
- fh->common.block_tic = kBaseTic;
- fh->common.block_time = start_sec;
- //fh->common.usec_cpu = (start_usec << 8) | (cpu & 0xff);
- fh->common.usec_cpu = cpu & 0xff;
- fh->common.pid = pid;
- fh->common.bug_count = 0;
- fh->common.zero_count = 0;
-
- fh->tic = kBaseTic + 1;
- fh->one = 1;
- fh->tics_per_second = kTicsPerSecond;
- fh->trace_time = start_sec;
- fh->version = 5;
- fh->file_proc = (max_files << 8) | max_procedures;
- fh->pdate = pdate_;
- fh->ptime = ptime_;
-}
-
-void Gtrace::WriteBlockHeader(uint32_t cycle, uint32_t pid)
-{
- int cpu = 0;
- block_header bh;
-
- bh.blockno = blockno_++;
- bh.entry_width = 8;
- bh.block_tic = cycle + kBaseTic;
- bh.block_time = start_sec_ + cycle / kTicsPerSecond;
- //bh.usec_cpu = (start_usec << 8) | (cpu & 0xff);
- bh.usec_cpu = cpu & 0xff;
- bh.pid = pid;
- bh.bug_count = 0;
- bh.zero_count = 0;
- fwrite(&bh, sizeof(bh), 1, ftrace_);
-}
-
-void Gtrace::AddGtraceRecord(int filenum, int procnum, uint32_t cycle, uint32_t pid,
- int is_exit)
-{
- trace_entry entry;
-
- if (current_pid_ != pid) {
- current_pid_ = pid;
-
- // We are switching to a new process id, so pad the current block
- // with zeros.
- int num_zeros = (kGtraceEntriesPerBlock - num_entries_) * sizeof(entry);
- fwrite(zeros, num_zeros, 1, ftrace_);
- WriteBlockHeader(cycle, pid);
- num_entries_ = 4;
- }
-
- // If the current block is full, write out a new block header
- if (num_entries_ == kGtraceEntriesPerBlock) {
- WriteBlockHeader(cycle, pid);
- num_entries_ = 4;
- }
-
- entry.cycle = cycle + kBaseTic;
- entry.event = (filenum << 13) | (procnum << 1) | is_exit;
- fwrite(&entry, sizeof(entry), 1, ftrace_);
- num_entries_ += 1;
-}
-
-void Gtrace::AddProcEntry(int filenum, int procnum, uint32_t cycle, uint32_t pid)
-{
- AddGtraceRecord(filenum, procnum, cycle, pid, 0);
-}
-
-void Gtrace::AddProcExit(int filenum, int procnum, uint32_t cycle, uint32_t pid)
-{
- AddGtraceRecord(filenum, procnum, cycle, pid, 1);
-}
-
-void Gtrace::AddProcedure(int filenum, int procnum, const char *proc_name)
-{
- fprintf(fnames_, "%d %d %d %s\n", filenum, procnum, procnum, proc_name);
-}
diff --git a/emulator/qtools/gtrace.h b/emulator/qtools/gtrace.h
deleted file mode 100644
index 542adc2..0000000
--- a/emulator/qtools/gtrace.h
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef GTRACE_H
-#define GTRACE_H
-
-class Gtrace {
- public:
- static const int kGtraceEntriesPerBlock = 1024;
- static const uint32_t kMillion = 1000000;
- static const uint32_t kTicsPerSecond = 200 * kMillion;
- static const int kBaseTic = 0x1000;
-
- struct trace_entry {
- uint32_t cycle;
- uint32_t event;
- };
-
- struct block_header {
- uint32_t blockno;
- uint32_t entry_width;
- uint32_t block_tic;
- uint32_t block_time;
- uint32_t usec_cpu;
- uint32_t pid;
- uint32_t bug_count;
- uint32_t zero_count;
- };
-
- struct first_header {
- block_header common;
- uint32_t tic;
- uint32_t one;
- uint32_t tics_per_second;
- uint32_t trace_time;
- uint32_t version;
- uint32_t file_proc;
- uint32_t pdate;
- uint32_t ptime;
- };
-
- Gtrace();
- ~Gtrace();
-
- void Open(const char *gtrace_file, uint32_t pdate, uint32_t ptime);
- void WriteFirstHeader(uint32_t start_sec, uint32_t pid);
- void AddProcedure(int filenum, int procnum, const char *proc_name);
- void AddProcEntry(int filenum, int procnum, uint32_t cycle, uint32_t pid);
- void AddProcExit(int filenum, int procnum, uint32_t cycle, uint32_t pid);
-
- private:
- void AddGtraceRecord(int filenum, int procnum, uint32_t cycle, uint32_t pid,
- int is_exit);
- void FillFirstHeader(uint32_t start_sec, uint32_t pid,
- first_header *fh);
- void WriteBlockHeader(uint32_t cycle, uint32_t pid);
-
- const char *gtrace_file_;
- char gname_file_[100];
- FILE *ftrace_;
- FILE *fnames_;
- uint32_t start_sec_;
- uint32_t pdate_;
- uint32_t ptime_;
- int num_entries_;
- int blockno_;
- uint32_t current_pid_;
-};
-
-#endif // GTRACE_H
diff --git a/emulator/qtools/hash_table.h b/emulator/qtools/hash_table.h
deleted file mode 100644
index 4ea9ed5..0000000
--- a/emulator/qtools/hash_table.h
+++ /dev/null
@@ -1,219 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef HASH_TABLE_H
-#define HASH_TABLE_H
-
-#include <string.h>
-#include <inttypes.h>
-
-template<class T>
-class HashTable {
- public:
- HashTable(int size, T default_value = T());
- ~HashTable();
-
- typedef struct entry {
- entry *next;
- char *key;
- T value;
- } entry_type;
-
- typedef T value_type;
-
- void Update(const char *key, T value);
- bool Remove(const char *key);
- T Find(const char *key);
- entry_type* GetFirst();
- entry_type* GetNext();
-
- private:
- uint32_t HashFunction(const char *key);
-
- int size_;
- int mask_;
- T default_value_;
- entry_type **table_;
- int num_entries_;
- int current_index_;
- entry_type *current_ptr_;
-};
-
-template<class T>
-HashTable<T>::HashTable(int size, T default_value)
-{
- int pow2;
-
- // Round up size to a power of two
- for (pow2 = 2; pow2 < size; pow2 <<= 1)
- ; // empty body
-
- size_ = pow2;
- mask_ = pow2 - 1;
- default_value_ = default_value;
-
- // Allocate a table of pointers and initialize them all to NULL.
- table_ = new entry_type*[size_];
- for (int ii = 0; ii < size_; ++ii)
- table_[ii] = NULL;
- num_entries_ = 0;
- current_index_ = 0;
- current_ptr_ = NULL;
-}
-
-template<class T>
-HashTable<T>::~HashTable()
-{
- for (int ii = 0; ii < size_; ++ii) {
- entry_type *ptr, *next;
-
- // Delete all the pointers in the chain at this table position.
- // Save the next pointer before deleting each entry so that we
- // don't dereference part of a deallocated object.
- for (ptr = table_[ii]; ptr; ptr = next) {
- next = ptr->next;
- delete[] ptr->key;
- delete ptr;
- }
- }
- delete[] table_;
-}
-
-// Professor Daniel J. Bernstein's hash function. See
-// http://www.partow.net/programming/hashfunctions/
-template<class T>
-uint32_t HashTable<T>::HashFunction(const char *key)
-{
- uint32_t hash = 5381;
-
- int len = strlen(key);
- for(int ii = 0; ii < len; ++key, ++ii)
- hash = ((hash << 5) + hash) + *key;
-
- return hash;
-}
-
-template<class T>
-void HashTable<T>::Update(const char *key, T value)
-{
- // Hash the key to get the table position
- int len = strlen(key);
- int pos = HashFunction(key) & mask_;
-
- // Search the chain for a matching key
- for (entry_type *ptr = table_[pos]; ptr; ptr = ptr->next) {
- if (strcmp(ptr->key, key) == 0) {
- ptr->value = value;
- return;
- }
- }
-
- // Create a new hash entry and fill in the values
- entry_type *ptr = new entry_type;
-
- // Copy the string
- ptr->key = new char[len + 1];
- strcpy(ptr->key, key);
- ptr->value = value;
-
- // Insert the new entry at the beginning of the list
- ptr->next = table_[pos];
- table_[pos] = ptr;
- num_entries_ += 1;
-}
-
-template<class T>
-bool HashTable<T>::Remove(const char *key)
-{
- // Hash the key to get the table position
- int len = strlen(key);
- int pos = HashFunction(key) & mask_;
-
- // Search the chain for a matching key and keep track of the previous
- // element in the chain.
- entry_type *prev = NULL;
- for (entry_type *ptr = table_[pos]; ptr; prev = ptr, ptr = ptr->next) {
- if (strcmp(ptr->key, key) == 0) {
- if (prev == NULL) {
- table_[pos] = ptr->next;
- } else {
- prev->next = ptr->next;
- }
- delete ptr->key;
- delete ptr;
- return true;
- }
- }
- return false;
-}
-
-template<class T>
-typename HashTable<T>::value_type HashTable<T>::Find(const char *key)
-{
- // Hash the key to get the table position
- int pos = HashFunction(key) & mask_;
-
- // Search the chain for a matching key
- for (entry_type *ptr = table_[pos]; ptr; ptr = ptr->next) {
- if (strcmp(ptr->key, key) == 0)
- return ptr->value;
- }
-
- // If we get here, then we didn't find the key
- return default_value_;
-}
-
-template<class T>
-typename HashTable<T>::entry_type* HashTable<T>::GetFirst()
-{
- // Find the first non-NULL table entry.
- for (current_index_ = 0; current_index_ < size_; ++current_index_) {
- if (table_[current_index_])
- break;
- }
-
- // If there are no table entries, then return NULL.
- if (current_index_ == size_)
- return NULL;
-
- // Remember and return the current element.
- current_ptr_ = table_[current_index_];
- return current_ptr_;
-}
-
-template<class T>
-typename HashTable<T>::entry_type* HashTable<T>::GetNext()
-{
- // If we already iterated part way through the hash table, then continue
- // to the next element.
- if (current_ptr_) {
- current_ptr_ = current_ptr_->next;
-
- // If we are pointing to a valid element, then return it.
- if (current_ptr_)
- return current_ptr_;
-
- // Otherwise, start searching at the next table index.
- current_index_ += 1;
- }
-
- // Find the next non-NULL table entry.
- for (; current_index_ < size_; ++current_index_) {
- if (table_[current_index_])
- break;
- }
-
- // If there are no more non-NULL table entries, then return NULL.
- if (current_index_ == size_) {
- // Reset the current index so that we will start over from the
- // beginning on the next call to GetNext().
- current_index_ = 0;
- return NULL;
- }
-
- // Remember and return the current element.
- current_ptr_ = table_[current_index_];
- return current_ptr_;
-}
-
-
-#endif // HASH_TABLE_H
diff --git a/emulator/qtools/hist_trace.cpp b/emulator/qtools/hist_trace.cpp
deleted file mode 100644
index d2c6a90..0000000
--- a/emulator/qtools/hist_trace.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include "trace_reader.h"
-
-static const int kMaxHistEntries = 256;
-static const int kMaxHistEntries2 = kMaxHistEntries / 2;
-int hist[kMaxHistEntries];
-int underflow, overflow;
-
-int main(int argc, char **argv) {
- if (argc != 2) {
- fprintf(stderr, "Usage: %s trace_file\n", argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[1];
- TraceReaderBase *trace = new TraceReaderBase;
- trace->Open(trace_filename);
-
- uint64_t prev_bb_num = 0;
- uint64_t prev_time = 0;
- int total = 0;
-
- while (1) {
- BBEvent event;
-
- if (trace->ReadBB(&event))
- break;
- int bb_diff = event.bb_num - prev_bb_num;
- //int time_diff = event.time - prev_time;
- //printf("bb_num: %llu prev: %llu, diff: %d\n",
- // event.bb_num, prev_bb_num, bb_diff);
- prev_bb_num = event.bb_num;
- prev_time = event.time;
-
- bb_diff += kMaxHistEntries2;
- if (bb_diff < 0)
- underflow += 1;
- else if (bb_diff >= kMaxHistEntries)
- overflow += 1;
- else
- hist[bb_diff] += 1;
- total += 1;
- }
-
- int sum = 0;
- double sum_per = 0;
- double per = 0;
- for (int ii = 0; ii < kMaxHistEntries; ++ii) {
- if (hist[ii] == 0)
- continue;
- per = 100.0 * hist[ii] / total;
- sum += hist[ii];
- sum_per = 100.0 * sum / total;
- printf(" %4d: %6d %6.2f %6.2f\n", ii - kMaxHistEntries2, hist[ii], per, sum_per);
- }
- per = 100.0 * underflow / total;
- printf("under: %6d %6.2f\n", underflow, per);
- per = 100.0 * overflow / total;
- printf("over: %6d %6.2f\n", overflow, per);
- printf("total: %6d\n", total);
- return 0;
-}
diff --git a/emulator/qtools/opcode.cpp b/emulator/qtools/opcode.cpp
deleted file mode 100644
index 41bef3a..0000000
--- a/emulator/qtools/opcode.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#include <stdio.h>
-#include <inttypes.h>
-#include "opcode.h"
-
-// Note: this array depends on the Opcode enum defined in opcode.h
-uint32_t opcode_flags[] = {
- 0, // OP_INVALID
- 0, // OP_UNDEFINED
- kCatAlu, // OP_ADC
- kCatAlu, // OP_ADD
- kCatAlu, // OP_AND
- kCatBranch, // OP_B
- kCatBranch | kCatBranchLink, // OP_BL
- kCatAlu, // OP_BIC
- 0, // OP_BKPT
- kCatBranch | kCatBranchLink | kCatBranchExch, // OP_BLX
- kCatBranch | kCatBranchExch, // OP_BX
- kCatCoproc, // OP_CDP
- kCatAlu, // OP_CLZ
- kCatAlu, // OP_CMN
- kCatAlu, // OP_CMP
- kCatAlu, // OP_EOR
- kCatCoproc | kCatLoad, // OP_LDC
- kCatLoad | kCatMultiple, // OP_LDM
- kCatLoad | kCatWord, // OP_LDR
- kCatLoad | kCatByte, // OP_LDRB
- kCatLoad | kCatByte, // OP_LDRBT
- kCatLoad | kCatHalf, // OP_LDRH
- kCatLoad | kCatByte | kCatSigned, // OP_LDRSB
- kCatLoad | kCatHalf | kCatSigned, // OP_LDRSH
- kCatLoad | kCatWord, // OP_LDRT
- kCatCoproc, // OP_MCR
- kCatAlu, // OP_MLA
- kCatAlu, // OP_MOV
- kCatCoproc, // OP_MRC
- 0, // OP_MRS
- 0, // OP_MSR
- kCatAlu, // OP_MUL
- kCatAlu, // OP_MVN
- kCatAlu, // OP_ORR
- 0, // OP_PLD
- kCatAlu, // OP_RSB
- kCatAlu, // OP_RSC
- kCatAlu, // OP_SBC
- kCatAlu, // OP_SMLAL
- kCatAlu, // OP_SMULL
- kCatCoproc | kCatStore, // OP_STC
- kCatStore | kCatMultiple, // OP_STM
- kCatStore | kCatWord, // OP_STR
- kCatStore | kCatByte, // OP_STRB
- kCatStore | kCatByte, // OP_STRBT
- kCatStore | kCatHalf, // OP_STRH
- kCatStore | kCatWord, // OP_STRT
- kCatAlu, // OP_SUB
- 0, // OP_SWI
- kCatLoad | kCatStore, // OP_SWP
- kCatLoad | kCatStore | kCatByte, // OP_SWPB
- kCatAlu, // OP_TEQ
- kCatAlu, // OP_TST
- kCatAlu, // OP_UMLAL
- kCatAlu, // OP_UMULL
-
- 0, // OP_THUMB_UNDEFINED,
- kCatAlu, // OP_THUMB_ADC,
- kCatAlu, // OP_THUMB_ADD,
- kCatAlu, // OP_THUMB_AND,
- kCatAlu, // OP_THUMB_ASR,
- kCatBranch, // OP_THUMB_B,
- kCatAlu, // OP_THUMB_BIC,
- 0, // OP_THUMB_BKPT,
- kCatBranch | kCatBranchLink, // OP_THUMB_BL,
- kCatBranch | kCatBranchLink | kCatBranchExch, // OP_THUMB_BLX,
- kCatBranch | kCatBranchExch, // OP_THUMB_BX,
- kCatAlu, // OP_THUMB_CMN,
- kCatAlu, // OP_THUMB_CMP,
- kCatAlu, // OP_THUMB_EOR,
- kCatLoad | kCatMultiple, // OP_THUMB_LDMIA,
- kCatLoad | kCatWord, // OP_THUMB_LDR,
- kCatLoad | kCatByte, // OP_THUMB_LDRB,
- kCatLoad | kCatHalf, // OP_THUMB_LDRH,
- kCatLoad | kCatByte | kCatSigned, // OP_THUMB_LDRSB,
- kCatLoad | kCatHalf | kCatSigned, // OP_THUMB_LDRSH,
- kCatAlu, // OP_THUMB_LSL,
- kCatAlu, // OP_THUMB_LSR,
- kCatAlu, // OP_THUMB_MOV,
- kCatAlu, // OP_THUMB_MUL,
- kCatAlu, // OP_THUMB_MVN,
- kCatAlu, // OP_THUMB_NEG,
- kCatAlu, // OP_THUMB_ORR,
- kCatLoad | kCatMultiple, // OP_THUMB_POP,
- kCatStore | kCatMultiple, // OP_THUMB_PUSH,
- kCatAlu, // OP_THUMB_ROR,
- kCatAlu, // OP_THUMB_SBC,
- kCatStore | kCatMultiple, // OP_THUMB_STMIA,
- kCatStore | kCatWord, // OP_THUMB_STR,
- kCatStore | kCatByte, // OP_THUMB_STRB,
- kCatStore | kCatHalf, // OP_THUMB_STRH,
- kCatAlu, // OP_THUMB_SUB,
- 0, // OP_THUMB_SWI,
- kCatAlu, // OP_THUMB_TST,
-
- 0, // OP_END
-};
-
-const char *opcode_names[] = {
- "invalid",
- "undefined",
- "adc",
- "add",
- "and",
- "b",
- "bl",
- "bic",
- "bkpt",
- "blx",
- "bx",
- "cdp",
- "clz",
- "cmn",
- "cmp",
- "eor",
- "ldc",
- "ldm",
- "ldr",
- "ldrb",
- "ldrbt",
- "ldrh",
- "ldrsb",
- "ldrsh",
- "ldrt",
- "mcr",
- "mla",
- "mov",
- "mrc",
- "mrs",
- "msr",
- "mul",
- "mvn",
- "orr",
- "pld",
- "rsb",
- "rsc",
- "sbc",
- "smlal",
- "smull",
- "stc",
- "stm",
- "str",
- "strb",
- "strbt",
- "strh",
- "strt",
- "sub",
- "swi",
- "swp",
- "swpb",
- "teq",
- "tst",
- "umlal",
- "umull",
-
- "undefined",
- "adc",
- "add",
- "and",
- "asr",
- "b",
- "bic",
- "bkpt",
- "bl",
- "blx",
- "bx",
- "cmn",
- "cmp",
- "eor",
- "ldmia",
- "ldr",
- "ldrb",
- "ldrh",
- "ldrsb",
- "ldrsh",
- "lsl",
- "lsr",
- "mov",
- "mul",
- "mvn",
- "neg",
- "orr",
- "pop",
- "push",
- "ror",
- "sbc",
- "stmia",
- "str",
- "strb",
- "strh",
- "sub",
- "swi",
- "tst",
-
- NULL
-};
diff --git a/emulator/qtools/opcode.h b/emulator/qtools/opcode.h
deleted file mode 100644
index c8b67a6..0000000
--- a/emulator/qtools/opcode.h
+++ /dev/null
@@ -1,166 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef OPCODE_H
-#define OPCODE_H
-
-#include <inttypes.h>
-
-// Note: this list of opcodes must match the list used to initialize
-// the opflags[] array in opcode.cpp.
-enum Opcode {
- OP_INVALID,
- OP_UNDEFINED,
- OP_ADC,
- OP_ADD,
- OP_AND,
- OP_B,
- OP_BL,
- OP_BIC,
- OP_BKPT,
- OP_BLX,
- OP_BX,
- OP_CDP,
- OP_CLZ,
- OP_CMN,
- OP_CMP,
- OP_EOR,
- OP_LDC,
- OP_LDM,
- OP_LDR,
- OP_LDRB,
- OP_LDRBT,
- OP_LDRH,
- OP_LDRSB,
- OP_LDRSH,
- OP_LDRT,
- OP_MCR,
- OP_MLA,
- OP_MOV,
- OP_MRC,
- OP_MRS,
- OP_MSR,
- OP_MUL,
- OP_MVN,
- OP_ORR,
- OP_PLD,
- OP_RSB,
- OP_RSC,
- OP_SBC,
- OP_SMLAL,
- OP_SMULL,
- OP_STC,
- OP_STM,
- OP_STR,
- OP_STRB,
- OP_STRBT,
- OP_STRH,
- OP_STRT,
- OP_SUB,
- OP_SWI,
- OP_SWP,
- OP_SWPB,
- OP_TEQ,
- OP_TST,
- OP_UMLAL,
- OP_UMULL,
-
- // Define thumb opcodes
- OP_THUMB_UNDEFINED,
- OP_THUMB_ADC,
- OP_THUMB_ADD,
- OP_THUMB_AND,
- OP_THUMB_ASR,
- OP_THUMB_B,
- OP_THUMB_BIC,
- OP_THUMB_BKPT,
- OP_THUMB_BL,
- OP_THUMB_BLX,
- OP_THUMB_BX,
- OP_THUMB_CMN,
- OP_THUMB_CMP,
- OP_THUMB_EOR,
- OP_THUMB_LDMIA,
- OP_THUMB_LDR,
- OP_THUMB_LDRB,
- OP_THUMB_LDRH,
- OP_THUMB_LDRSB,
- OP_THUMB_LDRSH,
- OP_THUMB_LSL,
- OP_THUMB_LSR,
- OP_THUMB_MOV,
- OP_THUMB_MUL,
- OP_THUMB_MVN,
- OP_THUMB_NEG,
- OP_THUMB_ORR,
- OP_THUMB_POP,
- OP_THUMB_PUSH,
- OP_THUMB_ROR,
- OP_THUMB_SBC,
- OP_THUMB_STMIA,
- OP_THUMB_STR,
- OP_THUMB_STRB,
- OP_THUMB_STRH,
- OP_THUMB_SUB,
- OP_THUMB_SWI,
- OP_THUMB_TST,
-
- OP_END // must be last
-};
-
-extern uint32_t opcode_flags[];
-extern const char *opcode_names[];
-
-// Define bit flags for the opcode categories
-static const uint32_t kCatByte = 0x0001;
-static const uint32_t kCatHalf = 0x0002;
-static const uint32_t kCatWord = 0x0004;
-static const uint32_t kCatLong = 0x0008;
-static const uint32_t kCatNumBytes = (kCatByte | kCatHalf | kCatWord | kCatLong);
-static const uint32_t kCatMultiple = 0x0010;
-static const uint32_t kCatSigned = 0x0020;
-static const uint32_t kCatLoad = 0x0040;
-static const uint32_t kCatStore = 0x0080;
-static const uint32_t kCatMemoryRef = (kCatLoad | kCatStore);
-static const uint32_t kCatAlu = 0x0100;
-static const uint32_t kCatBranch = 0x0200;
-static const uint32_t kCatBranchLink = 0x0400;
-static const uint32_t kCatBranchExch = 0x0800;
-static const uint32_t kCatCoproc = 0x1000;
-static const uint32_t kCatLoadMultiple = (kCatLoad | kCatMultiple);
-static const uint32_t kCatStoreMultiple = (kCatStore | kCatMultiple);
-
-inline bool isALU(Opcode op) { return (opcode_flags[op] & kCatAlu) != 0; }
-inline bool isBranch(Opcode op) { return (opcode_flags[op] & kCatBranch) != 0; }
-inline bool isBranchLink(Opcode op) {
- return (opcode_flags[op] & kCatBranchLink) != 0;
-}
-inline bool isBranchExch(Opcode op) {
- return (opcode_flags[op] & kCatBranchExch) != 0;
-}
-inline bool isLoad(Opcode op) { return (opcode_flags[op] & kCatLoad) != 0; }
-inline bool isLoadMultiple(Opcode op) {
- return (opcode_flags[op] & kCatLoadMultiple) == kCatLoadMultiple;
-}
-inline bool isStoreMultiple(Opcode op) {
- return (opcode_flags[op] & kCatStoreMultiple) == kCatStoreMultiple;
-}
-inline bool isStore(Opcode op) { return (opcode_flags[op] & kCatStore) != 0; }
-inline bool isSigned(Opcode op) { return (opcode_flags[op] & kCatSigned) != 0; }
-inline bool isMemoryRef(Opcode op) {
- return (opcode_flags[op] & kCatMemoryRef) != 0;
-}
-inline int getAccessSize(Opcode op) { return opcode_flags[op] & kCatNumBytes; }
-inline bool isCoproc(Opcode op) { return (opcode_flags[op] & kCatCoproc) != 0; }
-inline int getNumAccesses(Opcode op, uint32_t binary) {
- extern int num_one_bits[];
- int num_accesses = 0;
- if (opcode_flags[op] & kCatNumBytes)
- num_accesses = 1;
- else if (opcode_flags[op] & kCatMultiple) {
- num_accesses = num_one_bits[(binary >> 8) & 0xff]
- + num_one_bits[binary & 0xff];
- }
- return num_accesses;
-}
-
-#endif // OPCODE_H
diff --git a/emulator/qtools/parse_options-inl.h b/emulator/qtools/parse_options-inl.h
deleted file mode 100644
index beb9df4..0000000
--- a/emulator/qtools/parse_options-inl.h
+++ /dev/null
@@ -1,155 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef PARSE_OPTIONS_INL_H
-#define PARSE_OPTIONS_INL_H
-
-// Define a typedef for TraceReaderType and include "parse_options.h"
-// before including this header file in a C++ source file.
-//
-// For example:
-//
-// struct symbol {
-// int elapsed;
-// };
-//
-// typedef TraceReader<symbol> TraceReaderType;
-
-
-typedef TraceReaderType::symbol_type symbol_type;
-typedef TraceReaderType::region_type region_type;
-typedef TraceReaderType::ProcessState ProcessState;
-
-symbol_type *kernel_sym;
-symbol_type *library_sym;
-
-// Returns true if the given event is included (or not excluded)
-// from the list of valid events specified by the user on the
-// command line.
-inline bool IsValidEvent(BBEvent *event, symbol_type *sym)
-{
- if (include_some_pids && pid_include_vector.GetBit(event->pid) == 0)
- return false;
- if (exclude_some_pids && pid_exclude_vector.GetBit(event->pid))
- return false;
- if (include_some_procedures) {
- if (sym == NULL || included_procedures.Find(sym->name) == 0)
- return false;
- }
- if (exclude_some_procedures) {
- if (sym == NULL || excluded_procedures.Find(sym->name))
- return false;
- }
- return true;
-}
-
-inline bool IsValidPid(int pid) {
- if (include_some_pids && pid_include_vector.GetBit(pid) == 0)
- return false;
- if (exclude_some_pids && pid_exclude_vector.GetBit(pid))
- return false;
- return true;
-}
-
-inline symbol_type *GetSymbol(TraceReaderType *trace, int pid, uint32_t addr,
- uint64_t time)
-{
- symbol_type *sym = trace->LookupFunction(pid, addr, time);
-
- if (lump_kernel && (sym->region->flags & region_type::kIsKernelRegion)) {
- if (kernel_sym == NULL) {
- kernel_sym = sym;
- sym->name = ":kernel";
- } else {
- sym = kernel_sym;
- }
- }
-
- if (lump_libraries && (sym->region->flags & region_type::kIsLibraryRegion)) {
- if (library_sym == NULL) {
- library_sym = sym;
- sym->name = ":libs";
- } else {
- sym = library_sym;
- }
- }
-
- return sym;
-}
-
-inline bool IsIncludedProcedure(symbol_type *sym)
-{
- if (include_kernel_syms && (sym->region->flags & region_type::kIsKernelRegion))
- return true;
- if (include_library_syms && (sym->region->flags & region_type::kIsLibraryRegion))
- return true;
- return included_procedures.Find(sym->name);
-}
-
-inline bool IsExcludedProcedure(symbol_type *sym)
-{
- if (exclude_kernel_syms && (sym->region->flags & region_type::kIsKernelRegion))
- return true;
- if (exclude_library_syms && (sym->region->flags & region_type::kIsLibraryRegion))
- return true;
- return excluded_procedures.Find(sym->name);
-}
-
-// Returns true on end-of-file.
-inline bool GetNextValidEvent(TraceReaderType *trace,
- BBEvent *event,
- BBEvent *first_ignored_event,
- symbol_type **sym_ptr)
-{
- symbol_type *sym = NULL;
- first_ignored_event->time = 0;
- if (trace->ReadBB(event))
- return true;
- bool recheck = true;
- while (recheck) {
- recheck = false;
- if (include_some_pids) {
- while (pid_include_vector.GetBit(event->pid) == 0) {
- if (first_ignored_event->time == 0)
- *first_ignored_event = *event;
- if (trace->ReadBB(event))
- return true;
- }
- } else if (exclude_some_pids) {
- while (pid_exclude_vector.GetBit(event->pid)) {
- if (first_ignored_event->time == 0)
- *first_ignored_event = *event;
- if (trace->ReadBB(event))
- return true;
- }
- }
-
- if (include_some_procedures) {
- sym = GetSymbol(trace, event->pid, event->bb_addr, event->time);
- while (!IsIncludedProcedure(sym)) {
- if (first_ignored_event->time == 0)
- *first_ignored_event = *event;
- if (trace->ReadBB(event))
- return true;
- recheck = true;
- sym = GetSymbol(trace, event->pid, event->bb_addr, event->time);
- }
- } else if (exclude_some_procedures) {
- sym = GetSymbol(trace, event->pid, event->bb_addr, event->time);
- while (IsExcludedProcedure(sym)) {
- if (first_ignored_event->time == 0)
- *first_ignored_event = *event;
- if (trace->ReadBB(event))
- return true;
- recheck = true;
- sym = GetSymbol(trace, event->pid, event->bb_addr, event->time);
- }
- }
- }
- if (sym == NULL)
- sym = GetSymbol(trace, event->pid, event->bb_addr, event->time);
-
- *sym_ptr = sym;
- return false;
-}
-
-#endif // PARSE_OPTIONS_INL_H
diff --git a/emulator/qtools/parse_options.cpp b/emulator/qtools/parse_options.cpp
deleted file mode 100644
index 395e9a1..0000000
--- a/emulator/qtools/parse_options.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <ctype.h>
-#include "bitvector.h"
-#include "parse_options.h"
-#include "hash_table.h"
-
-const char *root = "";
-bool lump_kernel;
-bool lump_libraries;
-Bitvector pid_include_vector(32768);
-Bitvector pid_exclude_vector(32768);
-bool include_some_pids;
-bool exclude_some_pids;
-
-HashTable<int> excluded_procedures(2000);
-HashTable<int> included_procedures(2000);
-bool exclude_some_procedures;
-bool include_some_procedures;
-
-bool exclude_kernel_syms;
-bool exclude_library_syms;
-bool include_kernel_syms;
-bool include_library_syms;
-bool demangle = true;
-
-static const char *OptionsUsageStr =
- " -e :kernel exclude all kernel symbols\n"
- " -e :libs exclude all library symbols\n"
- " -e <func> exclude function <func>\n"
- " -e <pid> exclude process <pid>\n"
- " -i :kernel include all kernel symbols\n"
- " -i :libs include all library symbols\n"
- " -i <func> include function <func>\n"
- " -i <pid> include process <pid>\n"
- " -l :kernel lump all the kernel symbols together\n"
- " -l :libs lump all the library symbols together\n"
- " -m do not demangle C++ symbols (m for 'mangle')\n"
- " -r <root> use <root> as the path for finding ELF executables\n"
- ;
-
-void OptionsUsage()
-{
- fprintf(stderr, "%s", OptionsUsageStr);
-}
-
-void ParseOptions(int argc, char **argv)
-{
- bool err = false;
- while (!err) {
- int opt = getopt(argc, argv, "+e:i:l:mr:");
- if (opt == -1)
- break;
- switch (opt) {
- case 'e':
- if (*optarg == ':') {
- if (strcmp(optarg, ":kernel") == 0)
- exclude_kernel_syms = true;
- else if (strcmp(optarg, ":libs") == 0)
- exclude_library_syms = true;
- else
- err = true;
- excluded_procedures.Update(optarg, 1);
- exclude_some_procedures = true;
- } else if (isdigit(*optarg)) {
- int bitnum = atoi(optarg);
- pid_exclude_vector.SetBit(bitnum);
- exclude_some_pids = true;
- } else {
- excluded_procedures.Update(optarg, 1);
- exclude_some_procedures = true;
- }
- break;
- case 'i':
- if (*optarg == ':') {
- if (strcmp(optarg, ":kernel") == 0)
- include_kernel_syms = true;
- else if (strcmp(optarg, ":libs") == 0)
- include_library_syms = true;
- else
- err = true;
- included_procedures.Update(optarg, 1);
- include_some_procedures = true;
- } else if (isdigit(*optarg)) {
- int bitnum = atoi(optarg);
- pid_include_vector.SetBit(bitnum);
- include_some_pids = true;
- } else {
- included_procedures.Update(optarg, 1);
- include_some_procedures = true;
- }
- break;
- case 'l':
- if (strcmp(optarg, ":kernel") == 0)
- lump_kernel = true;
- else if (strcmp(optarg, ":libs") == 0)
- lump_libraries = true;
- else
- err = true;
- break;
- case 'm':
- demangle = false;
- break;
- case 'r':
- root = optarg;
- break;
- default:
- err = true;
- break;
- }
- }
-
- if (err) {
- Usage(argv[0]);
- exit(1);
- }
-}
diff --git a/emulator/qtools/parse_options.h b/emulator/qtools/parse_options.h
deleted file mode 100644
index aacbb9e..0000000
--- a/emulator/qtools/parse_options.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef PARSE_OPTIONS_H
-#define PARSE_OPTIONS_H
-
-#include "bitvector.h"
-#include "hash_table.h"
-
-extern const char *root;
-extern bool lump_kernel;
-extern bool lump_libraries;
-extern Bitvector pid_include_vector;
-extern Bitvector pid_exclude_vector;
-extern bool include_some_pids;
-extern bool exclude_some_pids;
-
-extern HashTable<int> excluded_procedures;
-extern HashTable<int> included_procedures;
-extern bool exclude_some_procedures;
-extern bool include_some_procedures;
-
-extern bool exclude_kernel_syms;
-extern bool exclude_library_syms;
-extern bool include_kernel_syms;
-extern bool include_library_syms;
-extern bool demangle;
-
-extern void Usage(const char *program);
-extern void ParseOptions(int argc, char **argv);
-extern void OptionsUsage();
-
-#endif // PARSE_OPTIONS_H
diff --git a/emulator/qtools/post_trace.cpp b/emulator/qtools/post_trace.cpp
deleted file mode 100644
index becfc2b..0000000
--- a/emulator/qtools/post_trace.cpp
+++ /dev/null
@@ -1,151 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include "trace_reader.h"
-
-typedef struct MyStaticRec {
- StaticRec bb;
- uint32_t *insns;
-} MyStaticRec;
-
-const int kNumPids = 32768;
-char usedPids[kNumPids];
-
-int main(int argc, char **argv) {
- uint32_t insns[kMaxInsnPerBB];
-
- if (argc != 2) {
- fprintf(stderr, "Usage: %s trace_file\n", argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[1];
- TraceReaderBase *trace = new TraceReaderBase;
- trace->SetPostProcessing(true);
- trace->Open(trace_filename);
-
- // Count the number of static basic blocks and instructions.
- uint64_t num_static_bb = 0;
- uint64_t num_static_insn = 0;
- while (1) {
- StaticRec static_rec;
-
- if (trace->ReadStatic(&static_rec))
- break;
- if (static_rec.bb_num != num_static_bb) {
- fprintf(stderr,
- "Error: basic block numbers out of order; expected %lld, got %lld\n",
- num_static_bb, static_rec.bb_num);
- exit(1);
- }
- num_static_bb += 1;
- num_static_insn += static_rec.num_insns;
- trace->ReadStaticInsns(static_rec.num_insns, insns);
- }
- trace->Close();
-
- // Allocate space for all of the static blocks
- MyStaticRec *blocks = new MyStaticRec[num_static_bb];
-
- // Read the static blocks again and save pointers to them
- trace->Open(trace_filename);
- for (uint32_t ii = 0; ii < num_static_bb; ++ii) {
- trace->ReadStatic(&blocks[ii].bb);
- uint32_t num_insns = blocks[ii].bb.num_insns;
- if (num_insns > 0) {
- blocks[ii].insns = new uint32_t[num_insns];
- trace->ReadStaticInsns(num_insns, blocks[ii].insns);
- }
- }
-
- // Check the last basic block. If it contains a special undefined
- // instruction, then truncate the basic block at that point.
- uint32_t num_insns = blocks[num_static_bb - 1].bb.num_insns;
- uint32_t *insn_ptr = blocks[num_static_bb - 1].insns;
- for (uint32_t ii = 0; ii < num_insns; ++ii, ++insn_ptr) {
- if (*insn_ptr == 0xe6c00110) {
- uint32_t actual_num_insns = ii + 1;
- blocks[num_static_bb - 1].bb.num_insns = actual_num_insns;
- num_static_insn -= (num_insns - actual_num_insns);
-
- // Write the changes back to the trace file
- trace->TruncateLastBlock(actual_num_insns);
- break;
- }
- }
- TraceHeader *header = trace->GetHeader();
- strcpy(header->ident, TRACE_IDENT);
- header->num_static_bb = num_static_bb;
- header->num_dynamic_bb = 0;
- header->num_static_insn = num_static_insn;
- header->num_dynamic_insn = 0;
- trace->WriteHeader(header);
-
- // Reopen the trace file in order to force the trace manager to reread
- // the static blocks now that we have written that information to the
- // header.
- trace->Close();
- trace->Open(trace_filename);
-
- // Count the number of dynamic executions of basic blocks and instructions.
- // Also keep track of which process ids are used.
- uint64_t num_dynamic_bb = 0;
- uint64_t num_dynamic_insn = 0;
- while (1) {
- BBEvent event;
-
- if (trace->ReadBB(&event))
- break;
- if (event.bb_num >= num_static_bb) {
- fprintf(stderr,
- "Error: basic block number (%lld) too large (num blocks: %lld)\n",
- event.bb_num, num_static_bb);
- exit(1);
- }
- usedPids[event.pid] = 1;
- num_dynamic_bb += 1;
- num_dynamic_insn += event.num_insns;
- }
-
- // Count the number of process ids that are used and remember the first
- // unused pid.
- int numUsedPids = 0;
- int unusedPid = -1;
- for (int pid = 0; pid < kNumPids; pid++) {
- if (usedPids[pid] == 1) {
- numUsedPids += 1;
- } else if (unusedPid == -1) {
- unusedPid = pid;
- }
- }
-
- // Rewrite the header with the dynamic counts
- header->num_dynamic_bb = num_dynamic_bb;
- header->num_dynamic_insn = num_dynamic_insn;
- header->num_used_pids = numUsedPids;
- header->first_unused_pid = unusedPid;
- trace->WriteHeader(header);
- trace->Close();
-
- printf("Static basic blocks: %llu, Dynamic basic blocks: %llu\n",
- num_static_bb, num_dynamic_bb);
- printf("Static instructions: %llu, Dynamic instructions: %llu\n",
- num_static_insn, num_dynamic_insn);
-
- double elapsed_secs = header->elapsed_usecs / 1000000.0;
- double insn_per_sec = 0;
- if (elapsed_secs != 0)
- insn_per_sec = num_dynamic_insn / elapsed_secs;
- const char *suffix = "";
- if (insn_per_sec >= 1000000) {
- insn_per_sec /= 1000000.0;
- suffix = "M";
- } else if (insn_per_sec > 1000) {
- insn_per_sec /= 1000.0;
- suffix = "K";
- }
- printf("Elapsed seconds: %.2f, simulated instructions/sec: %.1f%s\n",
- elapsed_secs, insn_per_sec, suffix);
- return 0;
-}
diff --git a/emulator/qtools/profile_pid.cpp b/emulator/qtools/profile_pid.cpp
deleted file mode 100644
index 11acbf9..0000000
--- a/emulator/qtools/profile_pid.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <string.h>
-#include "trace_reader.h"
-#include "parse_options.h"
-
-typedef TraceReader<> TraceReaderType;
-
-#include "parse_options-inl.h"
-
-// This function is called from quicksort to compare the cpu time
-// of processes and sort into decreasing order.
-int cmp_dec_cpu_time(const void *a, const void *b) {
- ProcessState *proc1, *proc2;
-
- proc1 = (ProcessState*)a;
- proc2 = (ProcessState*)b;
- if (proc1 == NULL) {
- if (proc2 == NULL)
- return 0;
- return 1;
- }
- if (proc2 == NULL)
- return -1;
- if (proc1->cpu_time < proc2->cpu_time)
- return 1;
- if (proc1->cpu_time > proc2->cpu_time)
- return -1;
- // If the cpu_time times are the same, then sort into increasing
- // order of pid.
- return proc1->pid - proc2->pid;
-}
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_file\n", program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv) {
- // Parse the options
- ParseOptions(argc, argv);
- if (argc - optind != 1) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[optind];
- TraceReader<> *trace = new TraceReader<>;
- trace->Open(trace_filename);
- trace->SetRoot(root);
-
- while (1) {
- BBEvent event, ignored;
- symbol_type *dummy_sym;
-
- if (GetNextValidEvent(trace, &event, &ignored, &dummy_sym))
- break;
- }
-
- int num_procs;
- ProcessState *processes = trace->GetProcesses(&num_procs);
- qsort(processes, num_procs, sizeof(ProcessState), cmp_dec_cpu_time);
-
- uint64_t total_time = 0;
- for (int ii = 0; ii < num_procs; ++ii) {
- total_time += processes[ii].cpu_time;
- }
-
- uint64_t sum_time = 0;
- printf(" pid parent cpu_time %% %% flags argv\n");
- ProcessState *pstate = &processes[0];
- for (int ii = 0; ii < num_procs; ++ii, ++pstate) {
- sum_time += pstate->cpu_time;
- double per = 100.0 * pstate->cpu_time / total_time;
- double sum_per = 100.0 * sum_time / total_time;
- const char *print_flags = "";
- if ((pstate->flags & ProcessState::kCalledExec) == 0)
- print_flags = "T";
- if (pstate->name == NULL)
- pstate->name = "";
- printf("%5d %5d %10llu %6.2f %6.2f %5s %s",
- pstate->pid, pstate->parent_pid, pstate->cpu_time,
- per, sum_per, print_flags, pstate->name);
- for (int jj = 1; jj < pstate->argc; ++jj) {
- printf(" %s", pstate->argv[jj]);
- }
- printf("\n");
- }
- delete trace;
- return 0;
-}
diff --git a/emulator/qtools/profile_trace.cpp b/emulator/qtools/profile_trace.cpp
deleted file mode 100644
index 0b056cc..0000000
--- a/emulator/qtools/profile_trace.cpp
+++ /dev/null
@@ -1,131 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include "trace_reader.h"
-#include "parse_options.h"
-
-const int kMillion = 1000000;
-const int kMHz = 200 * kMillion;
-
-struct symbol {
- int count; // number of times a function is executed
- uint64_t elapsed; // elapsed time for this function
-};
-
-typedef TraceReader<symbol> TraceReaderType;
-
-#include "parse_options-inl.h"
-
-static const uint32_t kOffsetThreshold = 0x100000;
-
-// This comparison function is called from qsort() to sort
-// symbols into decreasing elapsed time.
-int cmp_sym_elapsed(const void *a, const void *b) {
- const symbol_type *syma, *symb;
- uint64_t elapsed1, elapsed2;
-
- syma = static_cast<symbol_type const *>(a);
- symb = static_cast<symbol_type const *>(b);
- elapsed1 = syma->elapsed;
- elapsed2 = symb->elapsed;
- if (elapsed1 < elapsed2)
- return 1;
- if (elapsed1 == elapsed2)
- return strcmp(syma->name, symb->name);
- return -1;
-}
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_file elf_file\n", program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv)
-{
- ParseOptions(argc, argv);
- if (argc - optind != 2) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[optind++];
- char *elf_file = argv[optind++];
- TraceReader<symbol> *trace = new TraceReader<symbol>;
- trace->Open(trace_filename);
- trace->SetDemangle(demangle);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
-
- symbol_type dummy;
- dummy.count = 0;
- dummy.elapsed = 0;
- symbol_type *prev_sym = &dummy;
- uint64_t prev_bb_time = 0;
- while (1) {
- symbol_type *sym;
- BBEvent event;
- BBEvent first_ignored_event;
-
- bool eof = GetNextValidEvent(trace, &event, &first_ignored_event, &sym);
-
- // Assign the elapsed time to the previous function symbol
- uint64_t elapsed = 0;
- if (first_ignored_event.time != 0)
- elapsed = first_ignored_event.time - prev_bb_time;
- else if (!eof)
- elapsed = event.time - prev_bb_time;
- prev_sym->elapsed += elapsed;
-
- if (eof)
- break;
-
- prev_bb_time = event.time;
- sym->count += 1;
- prev_sym = sym;
-#if 0
- printf("t%lld bb_num: %d, bb_addr: 0x%x func: %s, addr: 0x%x, count: %d\n",
- bb_time, bb_num, bb_addr, sym->name, sym->addr, sym->count);
-#endif
- }
-
- int nsyms;
- symbol_type *syms = trace->GetSymbols(&nsyms);
-
- // Sort the symbols into decreasing order of elapsed time
- qsort(syms, nsyms, sizeof(symbol_type), cmp_sym_elapsed);
-
- // Add up all the cycles
- uint64_t total = 0;
- symbol_type *sym = syms;
- for (int ii = 0; ii < nsyms; ++ii, ++sym) {
- total += sym->elapsed;
- }
-
- double secs = 1.0 * total / kMHz;
- printf("Total seconds: %.2f, total cycles: %lld, MHz: %d\n\n",
- secs, total, kMHz / kMillion);
-
- uint64_t sum = 0;
- printf("Elapsed secs Elapsed cyc %% %% Function\n");
- sym = syms;
- for (int ii = 0; ii < nsyms; ++ii, ++sym) {
- if (sym->elapsed == 0)
- break;
- sum += sym->elapsed;
- double per = 100.0 * sym->elapsed / total;
- double sum_per = 100.0 * sum / total;
- double secs = 1.0 * sym->elapsed / kMHz;
- const char *ksym = " ";
- if (sym->region->flags & region_type::kIsKernelRegion)
- ksym = "k";
- printf("%12.2f %11lld %6.2f %6.2f %s %s\n",
- secs, sym->elapsed, per, sum_per, ksym, sym->name);
- }
- delete[] syms;
- delete trace;
-
- return 0;
-}
diff --git a/emulator/qtools/q2dm.cpp b/emulator/qtools/q2dm.cpp
deleted file mode 100644
index 74dbaeb..0000000
--- a/emulator/qtools/q2dm.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <assert.h>
-#include "trace_reader.h"
-#include "bitvector.h"
-#include "parse_options.h"
-#include "dmtrace.h"
-#include "armdis.h"
-
-struct symbol {
- uint32_t id;
-};
-
-typedef TraceReader<symbol> TraceReaderType;
-
-#include "parse_options-inl.h"
-#include "callstack.h"
-
-DmTrace *dmtrace;
-
-class MyFrame : public StackFrame<symbol_type> {
- public:
- void push(int stackLevel, uint64_t time, CallStackBase *base);
- void pop(int stackLevel, uint64_t time, CallStackBase *base);
-};
-
-typedef CallStack<MyFrame> CallStackType;
-
-static const int kNumStackFrames = 500;
-static const int kMaxThreads = (32 * 1024);
-uint64_t thread_time[kMaxThreads];
-
-class FunctionStack {
- public:
- FunctionStack() {
- top = 0;
- }
- void push(symbol_type *sym) {
- if (top >= kNumStackFrames)
- return;
- frames[top] = sym;
- top += 1;
- }
-
- symbol_type* pop() {
- if (top <= 0) {
- return NULL;
- }
- top -= 1;
- return frames[top];
- }
-
- void showStack() {
- fprintf(stderr, "top %d\n", top);
- for (int ii = 0; ii < top; ii++) {
- fprintf(stderr, " %d: %s\n", ii, frames[ii]->name);
- }
- }
-
- private:
- int top;
- symbol_type *frames[kNumStackFrames];
-};
-
-FunctionStack *dmtrace_stack[kMaxThreads];
-
-void MyFrame::push(int stackLevel, uint64_t time, CallStackBase *base)
-{
- int pid = base->getId();
- CallStackType *stack = (CallStackType *) base;
-
-#if 0
- fprintf(stderr, "native push t %llu p %d s %d fid %d 0x%x %s\n",
- stack->getGlobalTime(time), pid, stackLevel,
- function->id, function->addr, function->name);
-#endif
-
- FunctionStack *fstack = dmtrace_stack[pid];
- if (fstack == NULL) {
- fstack = new FunctionStack();
- dmtrace_stack[pid] = fstack;
- }
-
- fstack->push(function);
- thread_time[pid] = time;
- dmtrace->addFunctionEntry(function->id, time, pid);
-}
-
-void MyFrame::pop(int stackLevel, uint64_t time, CallStackBase *base)
-{
- int pid = base->getId();
- CallStackType *stack = (CallStackType *) base;
-
-#if 0
- fprintf(stderr, "native pop t %llu p %d s %d fid %d 0x%x %s\n",
- stack->getGlobalTime(time), pid, stackLevel,
- function->id, function->addr, function->name);
-#endif
-
- FunctionStack *fstack = dmtrace_stack[pid];
- if (fstack == NULL) {
- fstack = new FunctionStack();
- dmtrace_stack[pid] = fstack;
- }
-
- symbol_type *sym = fstack->pop();
- if (sym != NULL && sym != function) {
- fprintf(stderr, "Error: q2dm function mismatch at time %llu pid %d sym %s\n",
- stack->getGlobalTime(time), pid, sym->name);
- fstack->showStack();
- exit(1);
- }
-
- thread_time[pid] = time;
- dmtrace->addFunctionExit(function->id, time, pid);
-}
-
-uint32_t nextFunctionId = 4;
-CallStackType *stacks[kMaxThreads];
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_name elf_file dmtrace_name\n",
- program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv)
-{
- bool useKernelStack = true;
-
- ParseOptions(argc, argv);
- if (argc - optind != 3) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *qemu_trace_file = argv[optind++];
- char *elf_file = argv[optind++];
- char *dmtrace_file = argv[optind++];
- TraceReaderType *trace = new TraceReaderType;
- trace->Open(qemu_trace_file);
- trace->SetDemangle(demangle);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
- TraceHeader *qheader = trace->GetHeader();
- uint64_t startTime = qheader->start_sec;
- startTime = (startTime << 32) | qheader->start_usec;
- int kernelPid = qheader->first_unused_pid;
-
- dmtrace = new DmTrace;
- dmtrace->open(dmtrace_file, startTime);
-
- bool inKernel = false;
- CallStackType *kernelStack = NULL;
- if (useKernelStack) {
- // Create a fake kernel thread stack where we will put all the kernel
- // code.
- kernelStack = new CallStackType(kernelPid, kNumStackFrames, trace);
- dmtrace->addThread(kernelPid, "(kernel)");
- }
-
- CallStackType *prevStack = NULL;
- BBEvent event;
- while (1) {
- BBEvent ignored;
- symbol_type *function;
-
- if (GetNextValidEvent(trace, &event, &ignored, &function))
- break;
- if (event.bb_num == 0)
- break;
-#if 0
- fprintf(stderr, "event t %llu p %d %s\n",
- event.time, event.pid, function->name);
-#endif
-
- CallStackType *pStack;
- if (useKernelStack) {
- uint32_t flags = function->region->flags;
- uint32_t region_mask = region_type::kIsKernelRegion
- | region_type::kIsUserMappedRegion;
- if ((flags & region_mask) == region_type::kIsKernelRegion) {
- // Use the kernel stack
- pStack = kernelStack;
- inKernel = true;
- } else {
- // If we were just in the kernel then pop off all of the
- // stack frames for the kernel thread.
- if (inKernel == true) {
- inKernel = false;
- kernelStack->popAll(event.time);
- }
-
- // Get the stack for the current thread
- pStack = stacks[event.pid];
- }
- } else {
- // Get the stack for the current thread
- pStack = stacks[event.pid];
- }
-
- // If the stack does not exist, then allocate a new one.
- if (pStack == NULL) {
- pStack = new CallStackType(event.pid, kNumStackFrames, trace);
- stacks[event.pid] = pStack;
- const char *name = trace->GetProcessName(event.pid);
- dmtrace->addThread(event.pid, name);
- }
-
- if (prevStack != pStack) {
- pStack->threadStart(event.time);
- if (prevStack)
- prevStack->threadStop(event.time);
- }
- prevStack = pStack;
-
- // If we have never seen this function before, then add it to the
- // list of known functions.
- if (function->id == 0) {
- function->id = nextFunctionId;
- nextFunctionId += 4;
- uint32_t flags = function->region->flags;
- const char *name = function->name;
- if (flags & region_type::kIsKernelRegion) {
- // To distinguish kernel function names from user library
- // names, add a marker to the name.
- int len = strlen(name) + strlen(" [kernel]") + 1;
- char *kernelName = new char[len];
- strcpy(kernelName, name);
- strcat(kernelName, " [kernel]");
- name = kernelName;
- }
- dmtrace->parseAndAddFunction(function->id, name);
- }
-
- // Update the stack
- pStack->updateStack(&event, function);
- }
-
- if (prevStack == NULL) {
- fprintf(stderr, "Error: no events in trace.\n");
- exit(1);
- }
- prevStack->threadStop(event.time);
- for (int ii = 0; ii < kMaxThreads; ++ii) {
- if (stacks[ii]) {
- stacks[ii]->threadStart(event.time);
- stacks[ii]->popAll(event.time);
- }
- }
- if (useKernelStack) {
- kernelStack->popAll(event.time);
- }
-
- // Read the pid events to find the names of the processes
- while (1) {
- PidEvent pid_event;
- if (trace->ReadPidEvent(&pid_event))
- break;
- if (pid_event.rec_type == kPidName) {
- dmtrace->updateName(pid_event.pid, pid_event.path);
- }
- }
-
- dmtrace->close();
- delete dmtrace;
- delete trace;
- return 0;
-}
diff --git a/emulator/qtools/q2g.cpp b/emulator/qtools/q2g.cpp
deleted file mode 100644
index 6b2ae92..0000000
--- a/emulator/qtools/q2g.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <assert.h>
-#include "trace_reader.h"
-#include "gtrace.h"
-#include "bitvector.h"
-#include "parse_options.h"
-
-struct symbol {
- int filenum; // the file number (for gtrace)
- int procnum; // the procedure number (for gtrace)
-};
-
-typedef TraceReader<symbol> TraceReaderType;
-
-#include "parse_options-inl.h"
-
-const int kMaxProcNum = 4095;
-int next_filenum = 1;
-int next_procnum = 1;
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_file elf_file gtrace_file\n",
- program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv)
-{
- ParseOptions(argc, argv);
- if (argc - optind != 3) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *qemu_trace_file = argv[optind++];
- char *elf_file = argv[optind++];
- char *gtrace_file = argv[optind++];
- TraceReader<symbol> *trace = new TraceReader<symbol>;
- trace->Open(qemu_trace_file);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
- TraceHeader *qheader = trace->GetHeader();
-
- // Get the first valid event to get the process id for the gtrace header.
- BBEvent event;
- BBEvent ignored;
- symbol_type *sym;
- if (GetNextValidEvent(trace, &event, &ignored, &sym))
- return 0;
-
- Gtrace *gtrace = new Gtrace;
- gtrace->Open(gtrace_file, qheader->pdate, qheader->ptime);
- gtrace->WriteFirstHeader(qheader->start_sec, event.pid);
-
- symbol_type *prev_sym = NULL;
- bool eof = false;
- while (!eof) {
- if (sym != prev_sym) {
- // This procedure is different from the previous procedure.
-
- // If we have never seen this symbol before, then add it to the
- // list of known procedures.
- if (sym->filenum == 0) {
- sym->filenum = next_filenum;
- sym->procnum = next_procnum;
- gtrace->AddProcedure(sym->filenum, sym->procnum, sym->name);
- next_procnum += 1;
- if (next_procnum > kMaxProcNum) {
- next_filenum += 1;
- next_procnum = 1;
- }
- }
-
- // If we haven't yet recorded the procedure exit for the previous
- // procedure, then do it now.
- if (prev_sym) {
- gtrace->AddProcExit(prev_sym->filenum, prev_sym->procnum, event.time,
- event.pid);
- }
-
- // If this is not the terminating record, then record a procedure
- // entry.
- if (event.bb_num != 0) {
- gtrace->AddProcEntry(sym->filenum, sym->procnum, event.time, event.pid);
- prev_sym = sym;
- }
- }
-
- eof = GetNextValidEvent(trace, &event, &ignored, &sym);
- if (ignored.time != 0 && prev_sym) {
- // We read an event that we are ignoring.
- // If we haven't already recorded a procedure exit, then do so.
- gtrace->AddProcExit(prev_sym->filenum, prev_sym->procnum, ignored.time,
- ignored.pid);
- prev_sym = NULL;
- }
- }
-
- delete gtrace;
- delete trace;
- return 0;
-}
diff --git a/emulator/qtools/read_addr.cpp b/emulator/qtools/read_addr.cpp
deleted file mode 100644
index 1c8c20f..0000000
--- a/emulator/qtools/read_addr.cpp
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include "trace_reader.h"
-
-int main(int argc, char **argv) {
- if (argc != 2) {
- fprintf(stderr, "Usage: %s trace_file\n", argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[1];
- TraceReaderBase *trace = new TraceReaderBase;
- trace->Open(trace_filename);
-
- while (1) {
- uint64_t time;
- uint32_t addr;
- int flags;
-
- if (trace->ReadAddr(&time, &addr, &flags))
- break;
- const char *op = "ld";
- if (flags == 1)
- op = "st";
- printf("%lld 0x%08x %s\n", time, addr, op);
- }
- return 0;
-}
diff --git a/emulator/qtools/read_elf.cpp b/emulator/qtools/read_elf.cpp
deleted file mode 100644
index 1d1a74a..0000000
--- a/emulator/qtools/read_elf.cpp
+++ /dev/null
@@ -1,210 +0,0 @@
-/*************************************************************************
- Copyright (C) 2002,2003,2004,2005 Wei Qin
- See file COPYING for more information.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-*************************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <assert.h>
-#include "read_elf.h"
-
-#define SwapHalf(a) (((a & 0x00ff) << 8) | ((a & 0xff00) >> 8))
-#define SwapWord(a) (((a & 0xff000000) >> 24) | ((a & 0x00ff0000) >> 8) | ((a & 0x0000ff00) << 8) | ((a & 0x000000ff) << 24))
-#define SwapAddr(a) SwapWord(a)
-#define SwapOff(a) SwapWord(a)
-#define SwapSection(a) SwapHalf(a)
-
-int LittleEndian()
-{
- Elf32_Word a = 0x01020304;
- return *(char *) &a == 0x04;
-}
-
-void SwapElfHeader(Elf32_Ehdr *hdr)
-{
- hdr->e_type = SwapHalf(hdr->e_type);
- hdr->e_machine = SwapHalf(hdr->e_machine);
- hdr->e_version = SwapWord(hdr->e_version);
- hdr->e_entry = SwapAddr(hdr->e_entry);
- hdr->e_phoff = SwapOff(hdr->e_phoff);
- hdr->e_shoff = SwapOff(hdr->e_shoff);
- hdr->e_flags = SwapWord(hdr->e_flags);
- hdr->e_ehsize = SwapHalf(hdr->e_ehsize);
- hdr->e_phentsize = SwapHalf(hdr->e_phentsize);
- hdr->e_phnum = SwapHalf(hdr->e_phnum);
- hdr->e_shentsize = SwapHalf(hdr->e_shentsize);
- hdr->e_shnum = SwapHalf(hdr->e_shnum);
- hdr->e_shstrndx = SwapHalf(hdr->e_shstrndx);
-}
-
-void SwapSectionHeader(Elf32_Shdr *shdr)
-{
- shdr->sh_name = SwapWord(shdr->sh_name);
- shdr->sh_type = SwapWord(shdr->sh_type);
- shdr->sh_flags = SwapWord(shdr->sh_flags);
- shdr->sh_addr = SwapAddr(shdr->sh_addr);
- shdr->sh_offset = SwapOff(shdr->sh_offset);
- shdr->sh_size = SwapWord(shdr->sh_size);
- shdr->sh_link = SwapWord(shdr->sh_link);
- shdr->sh_info = SwapWord(shdr->sh_info);
- shdr->sh_addralign = SwapWord(shdr->sh_addralign);
- shdr->sh_entsize = SwapWord(shdr->sh_entsize);
-}
-
-void SwapElfSymbol(Elf32_Sym *sym)
-{
- sym->st_name = SwapWord(sym->st_name);
- sym->st_value = SwapAddr(sym->st_value);
- sym->st_size = SwapWord(sym->st_size);
- sym->st_shndx = SwapSection(sym->st_shndx);
-}
-
-void AdjustElfHeader(Elf32_Ehdr *hdr)
-{
- switch(hdr->e_ident[EI_DATA])
- {
- case ELFDATA2LSB:
- if (!LittleEndian())
- SwapElfHeader(hdr);
- break;
- case ELFDATA2MSB:
- if (LittleEndian())
- SwapElfHeader(hdr);
- break;
- }
-}
-
-void AdjustSectionHeader(Elf32_Ehdr *hdr, Elf32_Shdr *shdr)
-{
- switch(hdr->e_ident[EI_DATA])
- {
- case ELFDATA2LSB:
- if (!LittleEndian())
- SwapSectionHeader(shdr);
- break;
- case ELFDATA2MSB:
- if (LittleEndian())
- SwapSectionHeader(shdr);
- break;
- }
-}
-
-void AdjustElfSymbols(Elf32_Ehdr *hdr, Elf32_Sym *elf_symbols, int num_entries)
-{
- if (hdr->e_ident[EI_DATA] == ELFDATA2LSB && LittleEndian())
- return;
- if (hdr->e_ident[EI_DATA] == ELFDATA2MSB && !LittleEndian())
- return;
- for (int ii = 0; ii < num_entries; ++ii) {
- SwapElfSymbol(&elf_symbols[ii]);
- }
-}
-
-Elf32_Ehdr *ReadElfHeader(FILE *fobj)
-{
- Elf32_Ehdr *hdr = new Elf32_Ehdr;
- int rval = fread(hdr, sizeof(Elf32_Ehdr), 1, fobj);
- if (rval != 1) {
- delete hdr;
- return NULL;
- }
- if (hdr->e_ident[EI_MAG0] != 0x7f || hdr->e_ident[EI_MAG1] != 'E' ||
- hdr->e_ident[EI_MAG2] != 'L' || hdr->e_ident[EI_MAG3] != 'F') {
- delete hdr;
- return NULL;
- }
- AdjustElfHeader(hdr);
- return hdr;
-}
-
-Elf32_Shdr *ReadSectionHeaders(Elf32_Ehdr *hdr, FILE *f)
-{
- int i;
- unsigned long sz = hdr->e_shnum * hdr->e_shentsize;
- assert(sizeof(Elf32_Shdr) == hdr->e_shentsize);
- Elf32_Shdr *shdr = new Elf32_Shdr[hdr->e_shnum];
-
- if (fseek(f, hdr->e_shoff, SEEK_SET) != 0)
- {
- delete[] shdr;
- return NULL;
- }
- if (fread(shdr, sz, 1, f) != 1)
- {
- delete[] shdr;
- return NULL;
- }
-
- for(i = 0; i < hdr->e_shnum; i++)
- AdjustSectionHeader(hdr, shdr + i);
-
- return shdr;
-}
-
-
-char *ReadStringTable(Elf32_Ehdr *hdr, Elf32_Shdr *shdr_table, FILE *f)
-{
- Elf32_Shdr *shdr = shdr_table + hdr->e_shstrndx;
- char *string_table;
-
- string_table = new char[shdr->sh_size];
- fseek(f, shdr->sh_offset, SEEK_SET);
- fread(string_table, shdr->sh_size, 1, f);
-
- return string_table;
-}
-
-int ReadSection(Elf32_Shdr *shdr, void *buffer, FILE *f)
-{
- if (fseek(f, shdr->sh_offset, SEEK_SET) != 0)
- return -1;
- if (fread(buffer, shdr->sh_size, 1, f) != 1)
- return -1;
- return 0;
-}
-
-char *GetSymbolName(Elf32_Half index, char *string_table)
-{
- return string_table + index;
-}
-
-Elf32_Shdr *FindSymbolTableSection(Elf32_Ehdr *hdr,
- Elf32_Shdr *shdr,
- char *string_table)
-{
- for(int ii = 0; ii < hdr->e_shnum; ii++) {
- if (shdr[ii].sh_type == SHT_SYMTAB &&
- strcmp(GetSymbolName(shdr[ii].sh_name, string_table),
- ".symtab") == 0)
- {
- return &shdr[ii];
- }
- }
- return NULL;
-}
-
-Elf32_Shdr *FindSymbolStringTableSection(Elf32_Ehdr *hdr,
- Elf32_Shdr *shdr,
- char *string_table)
-{
- for(int ii = 0; ii < hdr->e_shnum; ii++) {
- if (shdr[ii].sh_type == SHT_STRTAB &&
- strcmp(GetSymbolName(shdr[ii].sh_name, string_table),
- ".strtab") == 0)
- {
- return &shdr[ii];
- }
- }
- return NULL;
-}
diff --git a/emulator/qtools/read_elf.h b/emulator/qtools/read_elf.h
deleted file mode 100644
index 72266c3..0000000
--- a/emulator/qtools/read_elf.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef READ_ELF_H
-#define READ_ELF_H
-
-#include <stdio.h>
-#include <elf.h>
-
-Elf32_Ehdr *ReadElfHeader(FILE *fobj);
-Elf32_Shdr *ReadSectionHeaders(Elf32_Ehdr *hdr, FILE *fobj);
-char *ReadStringTable(Elf32_Ehdr *hdr, Elf32_Shdr *shdr, FILE *fobj);
-Elf32_Shdr *FindSymbolTableSection(Elf32_Ehdr *hdr,
- Elf32_Shdr *shdr,
- char *string_table);
-Elf32_Shdr *FindSymbolStringTableSection(Elf32_Ehdr *hdr,
- Elf32_Shdr *shdr,
- char *string_table);
-int ReadSection(Elf32_Shdr *shdr, void *buffer, FILE *f);
-void AdjustElfSymbols(Elf32_Ehdr *hdr, Elf32_Sym *elf_symbols,
- int num_entries);
-
-#endif /* READ_ELF_H */
diff --git a/emulator/qtools/read_method.cpp b/emulator/qtools/read_method.cpp
deleted file mode 100644
index 6aa0c1a..0000000
--- a/emulator/qtools/read_method.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include "trace_reader.h"
-#include "parse_options.h"
-
-typedef TraceReader<> TraceReaderType;
-
-#include "parse_options-inl.h"
-
-struct frame {
- uint64_t time;
- uint32_t addr;
- const char *name;
- bool isNative;
-
- frame(uint64_t time, uint32_t addr, const char *name, bool isNative) {
- this->time = time;
- this->addr = addr;
- this->name = name;
- this->isNative = isNative;
- }
-};
-
-class Stack {
- static const int kMaxFrames = 1000;
- int top;
- frame *frames[kMaxFrames];
-
-public:
- Stack() {
- top = 0;
- }
-
- void push(frame *pframe);
- frame* pop();
- void dump();
-};
-
-void Stack::push(frame *pframe) {
- if (top == kMaxFrames) {
- fprintf(stderr, "Error: stack overflow\n");
- exit(1);
- }
- frames[top] = pframe;
- top += 1;
-}
-
-frame *Stack::pop() {
- if (top <= 0)
- return NULL;
- top -= 1;
- return frames[top];
-}
-
-void Stack::dump() {
- frame *pframe;
-
- for (int ii = 0; ii < top; ii++) {
- pframe = frames[ii];
- const char *native = pframe->isNative ? "n" : " ";
- printf(" %s %d: %llu 0x%x %s\n",
- native, ii, pframe->time, pframe->addr,
- pframe->name == NULL ? "" : pframe->name);
- }
-}
-
-static const int kMaxThreads = (32 * 1024);
-Stack *stacks[kMaxThreads];
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] trace_name elf_file\n",
- program);
- OptionsUsage();
-}
-
-int main(int argc, char **argv) {
- ParseOptions(argc, argv);
- if (argc - optind != 2) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *qemu_trace_file = argv[optind++];
- char *elf_file = argv[optind++];
- TraceReaderType *trace = new TraceReaderType;
- trace->Open(qemu_trace_file);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
-
- while (1) {
- MethodRec method_record;
- symbol_type *sym;
- TraceReaderType::ProcessState *proc;
- frame *pframe;
-
- if (trace->ReadMethodSymbol(&method_record, &sym, &proc))
- break;
-
- if (!IsValidPid(proc->pid))
- continue;
-
- if (sym != NULL) {
- printf("%lld p %d 0x%x %d %s\n",
- method_record.time, proc->pid, method_record.addr,
- method_record.flags, sym->name);
- } else {
- printf("%lld p %d 0x%x %d\n",
- method_record.time, proc->pid, method_record.addr,
- method_record.flags);
- }
-
- // Get the stack for the current thread
- Stack *pStack = stacks[proc->pid];
-
- // If the stack does not exist, then allocate a new one.
- if (pStack == NULL) {
- pStack = new Stack();
- stacks[proc->pid] = pStack;
- }
-
- int flags = method_record.flags;
- if (flags == kMethodEnter || flags == kNativeEnter) {
- pframe = new frame(method_record.time, method_record.addr,
- sym == NULL ? NULL: sym->name,
- method_record.flags == kNativeEnter);
- pStack->push(pframe);
- } else {
- pframe = pStack->pop();
- delete pframe;
- }
- pStack->dump();
- }
- return 0;
-}
diff --git a/emulator/qtools/read_pid.cpp b/emulator/qtools/read_pid.cpp
deleted file mode 100644
index a2d69d4..0000000
--- a/emulator/qtools/read_pid.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include "trace_reader.h"
-
-int main(int argc, char **argv) {
- if (argc != 2) {
- fprintf(stderr, "Usage: %s trace_file\n", argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[1];
- TraceReaderBase *trace = new TraceReaderBase;
- trace->Open(trace_filename);
-
- while (1) {
- PidEvent event;
- if (trace->ReadPidEvent(&event))
- break;
- switch (event.rec_type) {
- case kPidFork:
- printf("t%lld fork tgid %d pid %d\n", event.time, event.tgid, event.pid);
- break;
- case kPidClone:
- printf("t%lld clone tgid %d pid %d\n", event.time, event.tgid, event.pid);
- break;
- case kPidSwitch:
- printf("t%lld switch %d\n", event.time, event.pid);
- break;
- case kPidExit:
- printf("t%lld exit %d\n", event.time, event.pid);
- break;
- case kPidMmap:
- printf("t%lld mmap %08x - %08x, offset %08x '%s'\n",
- event.time, event.vstart, event.vend, event.offset, event.path);
- delete[] event.path;
- break;
- case kPidMunmap:
- printf("t%lld munmap %08x - %08x\n",
- event.time, event.vstart, event.vend);
- break;
- case kPidSymbolAdd:
- printf("t%lld add sym %08x '%s'\n",
- event.time, event.vstart, event.path);
- delete[] event.path;
- break;
- case kPidSymbolRemove:
- printf("t%lld remove %08x\n", event.time, event.vstart);
- break;
- case kPidExec:
- printf("t%lld argc: %d\n", event.time, event.argc);
- for (int ii = 0; ii < event.argc; ++ii) {
- printf(" argv[%d]: %s\n", ii, event.argv[ii]);
- delete[] event.argv[ii];
- }
- delete[] event.argv;
- break;
- case kPidKthreadName:
- printf("t%lld kthread tgid %d pid %d %s\n",
- event.time, event.tgid, event.pid, event.path);
- delete[] event.path;
- break;
- case kPidName:
- printf("t%lld name %d %s\n",
- event.time, event.pid, event.path);
- delete[] event.path;
- break;
- }
- }
- return 0;
-}
diff --git a/emulator/qtools/read_trace.cpp b/emulator/qtools/read_trace.cpp
deleted file mode 100644
index fb4917c..0000000
--- a/emulator/qtools/read_trace.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <assert.h>
-#include "trace_reader.h"
-#include "armdis.h"
-#include "parse_options.h"
-
-typedef TraceReader<> TraceReaderType;
-
-#include "parse_options-inl.h"
-
-static const uint32_t kOffsetThreshold = 0x100000;
-static uint64_t startTime = 0;
-
-void Usage(const char *program)
-{
- fprintf(stderr,
- "Usage: %s [options] [-- -s start_time] trace_file elf_file\n",
- program);
- OptionsUsage();
-}
-
-
-bool localParseOptions(int argc, char **argv)
-{
- bool err = false;
- while (!err) {
- int opt = getopt(argc, argv, "+s:");
- if (opt == -1)
- break;
- switch (opt) {
- case 's':
- startTime = strtoull(optarg, NULL, 0);
- break;
- default:
- err = true;
- break;
- }
- }
- return err;
-}
-
-int main(int argc, char **argv) {
- // Parse the options
- ParseOptions(argc, argv);
- localParseOptions(argc, argv);
- if (argc - optind != 2) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *trace_filename = argv[optind++];
- char *elf_file = argv[optind++];
- TraceReader<> *trace = new TraceReader<>;
- trace->Open(trace_filename);
- trace->SetDemangle(demangle);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
-
- while (1) {
- symbol_type *sym;
- char buf[1024];
- BBEvent event;
- BBEvent ignored;
-
- if (GetNextValidEvent(trace, &event, &ignored, &sym))
- break;
-#if 0
- fprintf(stderr, "t%llu bb %lld %d\n",
- event.time, event.bb_num, event.num_insns);
-#endif
-
- uint32_t *insns = event.insns;
- uint32_t addr = event.bb_addr;
- uint32_t offset = addr - sym->addr - sym->region->base_addr;
- symbol_type *vm_sym = sym->vm_sym;
- const char *vm_name = NULL;
- if (vm_sym != NULL) {
- vm_name = vm_sym->name;
- offset = addr - vm_sym->addr - vm_sym->region->base_addr;
- }
-#if 0
- if (strcmp(sym->name, "(unknown)") == 0 || offset > kOffsetThreshold) {
- ProcessState *process = trace->GetCurrentProcess();
- ProcessState *manager = process->addr_manager;
- for (int ii = 0; ii < manager->nregions; ++ii) {
- printf(" %2d: %08x - %08x base: %08x offset: %u nsyms: %4d flags: 0x%x %s\n",
- ii,
- manager->regions[ii]->vstart,
- manager->regions[ii]->vend,
- manager->regions[ii]->base_addr,
- manager->regions[ii]->file_offset,
- manager->regions[ii]->nsymbols,
- manager->regions[ii]->flags,
- manager->regions[ii]->path);
- int nsymbols = manager->regions[ii]->nsymbols;
- for (int jj = 0; jj < 10 && jj < nsymbols; ++jj) {
- printf(" %08x %s\n",
- manager->regions[ii]->symbols[jj].addr,
- manager->regions[ii]->symbols[jj].name);
- }
- }
- }
-#endif
-#if 1
- for (int ii = 0; ii < event.num_insns; ++ii) {
- uint64_t sim_time = trace->ReadInsnTime(event.time);
- if (sim_time < startTime)
- continue;
-
- uint32_t insn = insns[ii];
- char *disasm;
- int bytes;
- if (vm_name != NULL) {
- sprintf(buf, "%s+%02x: %s", vm_name, offset, sym->name);
- } else {
- sprintf(buf, "%s+%02x", sym->name, offset);
- }
-
- if (insn_is_thumb(insn)) {
- bytes = 2;
- insn = insn_unwrap_thumb(insn);
-
- // thumb_pair is true if this is the first of a pair of
- // thumb instructions (BL or BLX).
- bool thumb_pair = ((insn & 0xf800) == 0xf000);
-
- // Get the next thumb instruction (if any) because we may need
- // it for the case where insn is BL or BLX.
- uint32_t insn2 = 0;
- if (thumb_pair && (ii + 1 < event.num_insns)) {
- insn2 = insns[ii + 1];
- insn2 = insn_unwrap_thumb(insn2);
- bytes = 4;
- ii += 1;
- }
- disasm = disasm_insn_thumb(addr, insn, insn2, NULL);
- if (thumb_pair) {
- printf("%llu p%-4d %08x %04x %04x %-30s %s\n",
- sim_time, event.pid, addr, insn, insn2, buf, disasm);
- } else {
- printf("%llu p%-4d %08x %04x %-30s %s\n",
- sim_time, event.pid, addr, insn, buf, disasm);
- }
- } else {
- bytes = 4;
- disasm = Arm::disasm(addr, insn, NULL);
- printf("%llu p%-4d %08x %08x %-30s %s\n",
- sim_time, event.pid, addr, insn, buf, disasm);
- }
- //printf("t%llu \t%08x\n", sim_time, addr);
- addr += bytes;
- offset += bytes;
- }
-#endif
-#if 0
- assert(offset < kOffsetThreshold);
-#endif
- }
-
- delete trace;
- return 0;
-}
diff --git a/emulator/qtools/stack_dump.cpp b/emulator/qtools/stack_dump.cpp
deleted file mode 100644
index f685cd0..0000000
--- a/emulator/qtools/stack_dump.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#include <stdio.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <inttypes.h>
-#include <assert.h>
-#include "trace_reader.h"
-#include "bitvector.h"
-#include "parse_options.h"
-#include "armdis.h"
-
-typedef TraceReader<> TraceReaderType;
-
-#include "parse_options-inl.h"
-#include "callstack.h"
-
-static uint64_t debugTime;
-static uint64_t dumpTime = 0;
-
-class MyFrame : public StackFrame<symbol_type> {
- public:
- void push(int stackLevel, uint64_t time, CallStackBase *base);
- void pop(int stackLevel, uint64_t time, CallStackBase *base);
- void getFrameType(char *type);
-};
-
-typedef CallStack<MyFrame> CallStackType;
-
-void MyFrame::getFrameType(char *type)
-{
- strcpy(type, "----");
- if (flags & kCausedException)
- type[0] = 'e';
- if (flags & kInterpreted)
- type[1] = 'm';
- if (function->region->flags & region_type::kIsKernelRegion)
- type[2] = 'k';
- if (function->flags & symbol_type::kIsVectorTable)
- type[3] = 'v';
-}
-
-void MyFrame::push(int stackLevel, uint64_t time, CallStackBase *base)
-{
- char type[5];
-
- if (dumpTime > 0)
- return;
-
- getFrameType(type);
- printf("%llu en thr %d %s %3d", time, base->getId(), type, stackLevel);
- for (int ii = 0; ii < stackLevel; ++ii)
- printf(".");
- printf(" 0x%08x %s\n", addr, function->name);
-}
-
-void MyFrame::pop(int stackLevel, uint64_t time, CallStackBase *base)
-{
- char type[5];
-
- if (dumpTime > 0)
- return;
-
- getFrameType(type);
- printf("%llu x thr %d %s %3d", time, base->getId(), type, stackLevel);
- for (int ii = 0; ii < stackLevel; ++ii)
- printf(".");
- printf(" 0x%08x %s\n", addr, function->name);
-}
-
-static const int kNumStackFrames = 500;
-static const int kMaxThreads = (32 * 1024);
-CallStackType *stacks[kMaxThreads];
-
-void Usage(const char *program)
-{
- fprintf(stderr, "Usage: %s [options] [-- -d dumpTime] trace_name elf_file\n",
- program);
- OptionsUsage();
-}
-
-bool localParseOptions(int argc, char **argv)
-{
- bool err = false;
- while (!err) {
- int opt = getopt(argc, argv, "+d:");
- if (opt == -1)
- break;
- switch (opt) {
- case 'd':
- dumpTime = strtoull(optarg, NULL, 0);
- break;
- default:
- err = true;
- break;
- }
- }
- return err;
-}
-
-int main(int argc, char **argv)
-{
- ParseOptions(argc, argv);
- localParseOptions(argc, argv);
- if (argc - optind != 2) {
- Usage(argv[0]);
- exit(1);
- }
-
- char *qemu_trace_file = argv[optind++];
- char *elf_file = argv[optind++];
- TraceReaderType *trace = new TraceReaderType;
- trace->Open(qemu_trace_file);
- trace->ReadKernelSymbols(elf_file);
- trace->SetRoot(root);
-
- BBEvent event;
- while (1) {
- BBEvent ignored;
- symbol_type *function;
-
- if (GetNextValidEvent(trace, &event, &ignored, &function))
- break;
- if (event.bb_num == 0)
- break;
-
- // Get the stack for the current thread
- CallStackType *pStack = stacks[event.pid];
-
- // If the stack does not exist, then allocate a new one.
- if (pStack == NULL) {
- pStack = new CallStackType(event.pid, kNumStackFrames, trace);
- stacks[event.pid] = pStack;
- }
- if (debugTime != 0 && event.time >= debugTime)
- printf("debug time: %lld\n", debugTime);
-
- // Update the stack
- pStack->updateStack(&event, function);
-
- // If the user requested a stack dump at a certain time,
- // and we are at that time, then dump the stack and exit.
- if (dumpTime > 0 && event.time >= dumpTime) {
- pStack->showStack(stdout);
- break;
- }
- }
-
- for (int ii = 0; ii < kMaxThreads; ++ii) {
- if (stacks[ii])
- stacks[ii]->popAll(event.time);
- }
-
- delete trace;
- return 0;
-}
diff --git a/emulator/qtools/tests/common_head.mk b/emulator/qtools/tests/common_head.mk
deleted file mode 100644
index e8170e9..0000000
--- a/emulator/qtools/tests/common_head.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-CC := arm-elf-gcc
-LD := arm-elf-ld
-AS := arm-elf-as
-OBJCOPY := arm-elf-objcopy
-OBJDUMP := arm-elf-objdump
-
-OPT := -g
-CFLAGS := $(OPT) -mcpu=arm9
-
-.SUFFIXES: .dis .bin .elf
-
-.c.elf:
- $(CC) $(CFLAGS) -Xlinker --script ../tests.ld -o $@ $< -nostdlib
-
-.c.s:
- $(CC) $(CFLAGS) -static -S $<
-
-.S.elf:
- $(CC) $(CFLAGS) -Xlinker --script ../tests.ld -nostdlib -o $@ $<
-
-.elf.dis:
- $(OBJDUMP) -adx $< > $@
-
-.elf.bin:
- $(OBJCOPY) -O binary $< $@
diff --git a/emulator/qtools/tests/common_tail.mk b/emulator/qtools/tests/common_tail.mk
deleted file mode 100644
index be1c141..0000000
--- a/emulator/qtools/tests/common_tail.mk
+++ /dev/null
@@ -1,3 +0,0 @@
-
-clean:
- rm -f *.elf *.dis *.bin *.o *~ a.out
diff --git a/emulator/qtools/tests/gtrace/Makefile b/emulator/qtools/tests/gtrace/Makefile
deleted file mode 100644
index 1d2050c..0000000
--- a/emulator/qtools/tests/gtrace/Makefile
+++ /dev/null
@@ -1,18 +0,0 @@
-include ../common_head.mk
-
-P4ROOT=/work/android
-QEMU=$(P4ROOT)/device/tools/qemu/arm-softmmu/qemu-system-arm
-QTOOLS=$(P4ROOT)/device/tools/qtools
-
-all: test.elf test.bin test.dis
-
-trace: test.elf test.bin
- $(QEMU) -QEMU -kernel test.bin -trace foo
- $(QTOOLS)/post_trace foo
- $(QTOOLS)/read_trace foo test.elf > t1
-
-gtrace: trace
- $(QTOOLS)/q2g -r $(P4ROOT)/device/out/linux-arm-release/symbols foo test.elf foo.gtrace
- gtracepost64 foo.gtrace > t2
-
-include ../common_tail.mk
diff --git a/emulator/qtools/tests/gtrace/test.c b/emulator/qtools/tests/gtrace/test.c
deleted file mode 100644
index e56a0f1..0000000
--- a/emulator/qtools/tests/gtrace/test.c
+++ /dev/null
@@ -1,201 +0,0 @@
-#include "../macros.h"
-
-int foo1();
-int foo2();
-void bar();
-int child1();
-int child2();
-int child3();
-int child4();
-int child5();
-
-int global;
-
-void start()
-{
- // Set the stack pointer
- asm(" mov r13,#0x200000");
- PRINT_STR("hello\n");
- TRACE_INIT_NAME(701, "proc_foo");
- TRACE_INIT_NAME(702, "proc_bar");
- TRACE_SWITCH(701);
- if (global++ > 0)
- global++;
- foo1();
- TRACE_SWITCH(702);
- if (global++ > 0)
- global++;
- bar();
- TRACE_SWITCH(701);
- if (global++ > 0)
- global++;
- foo2();
- TRACE_SWITCH(703);
- if (global++ > 0)
- global++;
- foo1();
- TRACE_SWITCH(701);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(704);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(701);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(705);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(701);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(706);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(701);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(707);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(701);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(708);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(701);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(709);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(701);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_SWITCH(710);
- if (global++ > 0)
- global++;
- foo1();
-
- TRACE_STOP_EMU();
-}
-
-int foo1()
-{
- int a = 0;
-
- int ii;
- for (ii = 0; ii < 3; ++ii) {
- a += child1();
- a += child2();
- a += child3();
- }
- return a;
-}
-
-int foo2()
-{
- int a = 0;
-
- int ii;
- for (ii = 0; ii < 2; ++ii) {
- a += child3();
- a += child4();
- a += child5();
- }
- return a;
-}
-
-#define kStride 64
-void bar()
-{
- int a = 0;
-
- static char mem[1000 * kStride];
-
- int ii, jj;
-
- for (ii = 0; ii < 4; ++ii) {
- for (jj = 0; jj < 10; ++jj)
- a += mem[jj * kStride];
- foo1();
- foo2();
- }
-}
-
-int child1()
-{
- int a = 0;
-
- int ii;
- for (ii = 0; ii < 2; ++ii)
- a += ii;
- return a;
-}
-
-int child2()
-{
- int a = 0;
-
- int ii;
- for (ii = 0; ii < 4; ++ii)
- a += ii;
- return a;
-}
-
-int child3()
-{
- int a = 0;
-
- int ii;
- for (ii = 0; ii < 6; ++ii)
- a += ii;
- return a;
-}
-
-int child4()
-{
- int a = 0;
-
- int ii;
- for (ii = 0; ii < 8; ++ii)
- a += ii;
- return a;
-}
-
-int child5()
-{
- int a = 0;
-
- int ii;
- for (ii = 0; ii < 10; ++ii)
- a += ii;
- return a;
-}
diff --git a/emulator/qtools/tests/macros.h b/emulator/qtools/tests/macros.h
deleted file mode 100644
index 066374b..0000000
--- a/emulator/qtools/tests/macros.h
+++ /dev/null
@@ -1,93 +0,0 @@
-#ifndef _TEST_TRACE_C_H_
-#define _TEST_TRACE_C_H_
-
-/* the base address of trace device */
-#define TRACE_DEV_BASE_ADDR 0x21000000
-
-/*the register addresses of the trace device */
-#define TRACE_DEV_REG_SWITCH 0
-#define TRACE_DEV_REG_FORK 1
-#define TRACE_DEV_REG_EXECVE_PID 2
-#define TRACE_DEV_REG_EXECVE_VMSTART 3
-#define TRACE_DEV_REG_EXECVE_VMEND 4
-#define TRACE_DEV_REG_EXECVE_OFFSET 5
-#define TRACE_DEV_REG_EXECVE_EXEPATH 6
-#define TRACE_DEV_REG_EXIT 7
-#define TRACE_DEV_REG_CMDLINE 8
-#define TRACE_DEV_REG_CMDLINE_LEN 9
-#define TRACE_DEV_REG_MMAP_EXEPATH 10
-#define TRACE_DEV_REG_INIT_PID 11
-#define TRACE_DEV_REG_INIT_NAME 12
-#define TRACE_DEV_REG_CLONE 13
-#define TRACE_DEV_REG_DYN_SYM 50
-#define TRACE_DEV_REG_DYN_SYM_ADDR 51
-#define TRACE_DEV_REG_PRINT_STR 60
-#define TRACE_DEV_REG_PRINT_NUM_DEC 61
-#define TRACE_DEV_REG_PRINT_NUM_HEX 62
-#define TRACE_DEV_REG_STOP_EMU 90
-#define TRACE_DEV_REG_ENABLE 100
-#define TRACE_DEV_REG_DISABLE 101
-
-/* write a word to a trace device register */
-#define DEV_WRITE_WORD(addr,value)\
- (*(volatile unsigned long *)(TRACE_DEV_BASE_ADDR + ((addr) << 2)) = (value))
-
-/*************************************************************/
-/* generates test events */
-
-/* context switch */
-#define TRACE_SWITCH(pid) DEV_WRITE_WORD(TRACE_DEV_REG_SWITCH, (pid))
-/* fork */
-#define TRACE_FORK(pid) DEV_WRITE_WORD(TRACE_DEV_REG_FORK, (pid))
-/* clone */
-#define TRACE_CLONE(pid) DEV_WRITE_WORD(TRACE_DEV_REG_CLONE, (pid))
-/* dump name and path of threads executed before trace device created */
-#define TRACE_INIT_NAME(pid,path)\
-do {\
- DEV_WRITE_WORD(TRACE_DEV_REG_INIT_PID, (pid));\
- DEV_WRITE_WORD(TRACE_DEV_REG_INIT_NAME, (unsigned long)(path));\
-}while(0)
-/* dump exec mapping of threads executed before trace device created */
-#define TRACE_INIT_EXEC(vstart,vend,eoff,path)\
-do {\
- DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_VMSTART, (vstart));\
- DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_VMEND, (vend));\
- DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_OFFSET, (eoff));\
- DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_EXEPATH, (unsigned long)(path));\
-}while(0)
-/* mmap */
-#define TRACE_MMAP(vstart,vend,eoff,path)\
-do {\
- DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_VMSTART, (vstart));\
- DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_VMEND, (vend));\
- DEV_WRITE_WORD(TRACE_DEV_REG_EXECVE_OFFSET, (eoff));\
- DEV_WRITE_WORD(TRACE_DEV_REG_MMAP_EXEPATH, (unsigned long)(path));\
-}while(0)
-/* execve */
-#define TRACE_EXECVE(cmdlen,cmd)\
-do {\
- DEV_WRITE_WORD(TRACE_DEV_REG_CMDLINE_LEN, (cmdlen));\
- DEV_WRITE_WORD(TRACE_DEV_REG_CMDLINE, (unsigned long)(cmd));\
-}while(0)
-/* exit */
-#define TRACE_EXIT(retv) DEV_WRITE_WORD(TRACE_DEV_REG_EXIT, (retv))
-
-/* other commands */
-
-/* stop emulation */
-#define TRACE_STOP_EMU() DEV_WRITE_WORD(TRACE_DEV_REG_STOP_EMU, 1)
-/* enable/disable tracing */
-#define TRACE_ENABLE_TRACING() DEV_WRITE_WORD(TRACE_DEV_REG_ENABLE, 1)
-#define TRACE_DISABLE_TRACING() DEV_WRITE_WORD(TRACE_DEV_REG_DISABLE, 1)
-/* dynamic symbols */
-#define TRACE_DYN_SYM(addr,sym)\
-do {\
- DEV_WRITE_WORD(TRACE_DEV_REG_DYN_SYM_ADDR, (addr));\
- DEV_WRITE_WORD(TRACE_DEV_REG_DYN_SYM, (unsigned long)(sym));\
-}while(0)
-/* prints */
-#define PRINT_STR(str) DEV_WRITE_WORD(TRACE_DEV_REG_PRINT_STR, (unsigned long)(str))
-#define PRINT_NUM_DEC(num) DEV_WRITE_WORD(TRACE_DEV_REG_PRINT_NUM_DEC, (num))
-#define PRINT_NUM_HEX(num) DEV_WRITE_WORD(TRACE_DEV_REG_PRINT_NUM_HEX, (num))
-
-#endif
diff --git a/emulator/qtools/tests/tests.ld b/emulator/qtools/tests/tests.ld
deleted file mode 100644
index 05fe41b..0000000
--- a/emulator/qtools/tests/tests.ld
+++ /dev/null
@@ -1,10 +0,0 @@
-SECTIONS {
- TEXT_START = 0x00010000 ;
- DATA_START = 0x00200000 ;
- handlers 0x0 : { *(handlers) }
- .text TEXT_START : { *(.text) }
- .data DATA_START : { *(.data) }
- .bss : { *(.bss) *(COMMON) }
- p00300000 0x00300000 : { *(p00300000) }
- p00400000 0x00400000 : { *(p00400000) }
-}
diff --git a/emulator/qtools/thumbdis.cpp b/emulator/qtools/thumbdis.cpp
deleted file mode 100644
index 07c482f..0000000
--- a/emulator/qtools/thumbdis.cpp
+++ /dev/null
@@ -1,503 +0,0 @@
-/* Instruction printing code for the ARM
- Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002
- Free Software Foundation, Inc.
- Contributed by Richard Earnshaw (rwe@pegasus.esprit.ec.org)
- Modification by James G. Smith (jsmith@cygnus.co.uk)
-
-This file is part of libopcodes.
-
-This program is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2 of the License, or (at your option)
-any later version.
-
-This program is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-/* Modified to fit into the qtools framework. The main differences are:
- *
- * - The disassembly function returns a string instead of writing it to a
- * file stream.
- *
- * - All the references to the struct "disassemble_info" have been removed.
- *
- * - A set of enums for the thumb opcodes have been defined, along with a
- * "decode()" function that maps a thumb instruction to an opcode enum.
- *
- * - Eliminated uses of the special characters ', `, and ? from the
- * thumb_opcodes[] table so that we can easily specify separate opcodes
- * for distinct instructions.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <inttypes.h>
-#include "opcode.h"
-
-
-struct thumb_opcode
-{
- unsigned short value, mask; /* recognise instruction if (op&mask)==value */
- Opcode opcode;
- const char * assembler; /* how to disassemble this instruction */
-};
-
-/* format of the assembler string :
-
- %% %
- %<bitfield>d print the bitfield in decimal
- %<bitfield>x print the bitfield in hex
- %<bitfield>X print the bitfield as 1 hex digit without leading "0x"
- %<bitfield>r print as an ARM register
- %<bitfield>f print a floating point constant if >7 else a
- floating point register
- %<code>y print a single precision VFP reg.
- Codes: 0=>Sm, 1=>Sd, 2=>Sn, 3=>multi-list, 4=>Sm pair
- %<code>z print a double precision VFP reg
- Codes: 0=>Dm, 1=>Dd, 2=>Dn, 3=>multi-list
- %c print condition code (always bits 28-31)
- %P print floating point precision in arithmetic insn
- %Q print floating point precision in ldf/stf insn
- %R print floating point rounding mode
- %<bitnum>'c print specified char iff bit is one
- %<bitnum>`c print specified char iff bit is zero
- %<bitnum>?ab print a if bit is one else print b
- %p print 'p' iff bits 12-15 are 15
- %t print 't' iff bit 21 set and bit 24 clear
- %o print operand2 (immediate or register + shift)
- %a print address for ldr/str instruction
- %s print address for ldr/str halfword/signextend instruction
- %b print branch destination
- %B print arm BLX(1) destination
- %A print address for ldc/stc/ldf/stf instruction
- %m print register mask for ldm/stm instruction
- %C print the PSR sub type.
- %F print the COUNT field of a LFM/SFM instruction.
-Thumb specific format options:
- %D print Thumb register (bits 0..2 as high number if bit 7 set)
- %S print Thumb register (bits 3..5 as high number if bit 6 set)
- %<bitfield>I print bitfield as a signed decimal
- (top bit of range being the sign bit)
- %M print Thumb register mask
- %N print Thumb register mask (with LR)
- %O print Thumb register mask (with PC)
- %T print Thumb condition code (always bits 8-11)
- %I print cirrus signed shift immediate: bits 0..3|4..6
- %<bitfield>B print Thumb branch destination (signed displacement)
- %<bitfield>W print (bitfield * 4) as a decimal
- %<bitfield>H print (bitfield * 2) as a decimal
- %<bitfield>a print (bitfield * 4) as a pc-rel offset + decoded symbol
-*/
-
-
-static struct thumb_opcode thumb_opcodes[] =
-{
- /* Thumb instructions. */
-
- /* ARM V5 ISA extends Thumb. */
- {0xbe00, 0xff00, OP_THUMB_BKPT, "bkpt\t%0-7x"},
- {0x4780, 0xff87, OP_THUMB_BLX, "blx\t%3-6r"}, /* note: 4 bit register number. */
- /* Format 5 instructions do not update the PSR. */
- {0x1C00, 0xFFC0, OP_THUMB_MOV, "mov\t%0-2r, %3-5r"},
- /* Format 4. */
- {0x4000, 0xFFC0, OP_THUMB_AND, "and\t%0-2r, %3-5r"},
- {0x4040, 0xFFC0, OP_THUMB_EOR, "eor\t%0-2r, %3-5r"},
- {0x4080, 0xFFC0, OP_THUMB_LSL, "lsl\t%0-2r, %3-5r"},
- {0x40C0, 0xFFC0, OP_THUMB_LSR, "lsr\t%0-2r, %3-5r"},
- {0x4100, 0xFFC0, OP_THUMB_ASR, "asr\t%0-2r, %3-5r"},
- {0x4140, 0xFFC0, OP_THUMB_ADC, "adc\t%0-2r, %3-5r"},
- {0x4180, 0xFFC0, OP_THUMB_SBC, "sbc\t%0-2r, %3-5r"},
- {0x41C0, 0xFFC0, OP_THUMB_ROR, "ror\t%0-2r, %3-5r"},
- {0x4200, 0xFFC0, OP_THUMB_TST, "tst\t%0-2r, %3-5r"},
- {0x4240, 0xFFC0, OP_THUMB_NEG, "neg\t%0-2r, %3-5r"},
- {0x4280, 0xFFC0, OP_THUMB_CMP, "cmp\t%0-2r, %3-5r"},
- {0x42C0, 0xFFC0, OP_THUMB_CMN, "cmn\t%0-2r, %3-5r"},
- {0x4300, 0xFFC0, OP_THUMB_ORR, "orr\t%0-2r, %3-5r"},
- {0x4340, 0xFFC0, OP_THUMB_MUL, "mul\t%0-2r, %3-5r"},
- {0x4380, 0xFFC0, OP_THUMB_BIC, "bic\t%0-2r, %3-5r"},
- {0x43C0, 0xFFC0, OP_THUMB_MVN, "mvn\t%0-2r, %3-5r"},
- /* format 13 */
- {0xB000, 0xFF80, OP_THUMB_ADD, "add\tsp, #%0-6W"},
- {0xB080, 0xFF80, OP_THUMB_SUB, "sub\tsp, #%0-6W"},
- /* format 5 */
- {0x4700, 0xFF80, OP_THUMB_BX, "bx\t%S"},
- {0x4400, 0xFF00, OP_THUMB_ADD, "add\t%D, %S"},
- {0x4500, 0xFF00, OP_THUMB_CMP, "cmp\t%D, %S"},
- {0x4600, 0xFF00, OP_THUMB_MOV, "mov\t%D, %S"},
- /* format 14 */
- {0xB400, 0xFE00, OP_THUMB_PUSH, "push\t%N"},
- {0xBC00, 0xFE00, OP_THUMB_POP, "pop\t%O"},
- /* format 2 */
- {0x1800, 0xFE00, OP_THUMB_ADD, "add\t%0-2r, %3-5r, %6-8r"},
- {0x1A00, 0xFE00, OP_THUMB_SUB, "sub\t%0-2r, %3-5r, %6-8r"},
- {0x1C00, 0xFE00, OP_THUMB_ADD, "add\t%0-2r, %3-5r, #%6-8d"},
- {0x1E00, 0xFE00, OP_THUMB_SUB, "sub\t%0-2r, %3-5r, #%6-8d"},
- /* format 8 */
- {0x5200, 0xFE00, OP_THUMB_STRH, "strh\t%0-2r, [%3-5r, %6-8r]"},
- {0x5A00, 0xFE00, OP_THUMB_LDRH, "ldrh\t%0-2r, [%3-5r, %6-8r]"},
- {0x5600, 0xFE00, OP_THUMB_LDRSB, "ldrsb\t%0-2r, [%3-5r, %6-8r]"},
- {0x5E00, 0xFE00, OP_THUMB_LDRSH, "ldrsh\t%0-2r, [%3-5r, %6-8r]"},
- /* format 7 */
- {0x5000, 0xFE00, OP_THUMB_STR, "str\t%0-2r, [%3-5r, %6-8r]"},
- {0x5400, 0xFE00, OP_THUMB_STRB, "strb\t%0-2r, [%3-5r, %6-8r]"},
- {0x5800, 0xFE00, OP_THUMB_LDR, "ldr\t%0-2r, [%3-5r, %6-8r]"},
- {0x5C00, 0xFE00, OP_THUMB_LDRB, "ldrb\t%0-2r, [%3-5r, %6-8r]"},
- /* format 1 */
- {0x0000, 0xF800, OP_THUMB_LSL, "lsl\t%0-2r, %3-5r, #%6-10d"},
- {0x0800, 0xF800, OP_THUMB_LSR, "lsr\t%0-2r, %3-5r, #%6-10d"},
- {0x1000, 0xF800, OP_THUMB_ASR, "asr\t%0-2r, %3-5r, #%6-10d"},
- /* format 3 */
- {0x2000, 0xF800, OP_THUMB_MOV, "mov\t%8-10r, #%0-7d"},
- {0x2800, 0xF800, OP_THUMB_CMP, "cmp\t%8-10r, #%0-7d"},
- {0x3000, 0xF800, OP_THUMB_ADD, "add\t%8-10r, #%0-7d"},
- {0x3800, 0xF800, OP_THUMB_SUB, "sub\t%8-10r, #%0-7d"},
- /* format 6 */
- /* TODO: Disassemble PC relative "LDR rD,=<symbolic>" */
- {0x4800, 0xF800, OP_THUMB_LDR, "ldr\t%8-10r, [pc, #%0-7W]\t(%0-7a)"},
- /* format 9 */
- {0x6000, 0xF800, OP_THUMB_STR, "str\t%0-2r, [%3-5r, #%6-10W]"},
- {0x6800, 0xF800, OP_THUMB_LDR, "ldr\t%0-2r, [%3-5r, #%6-10W]"},
- {0x7000, 0xF800, OP_THUMB_STRB, "strb\t%0-2r, [%3-5r, #%6-10d]"},
- {0x7800, 0xF800, OP_THUMB_LDRB, "ldrb\t%0-2r, [%3-5r, #%6-10d]"},
- /* format 10 */
- {0x8000, 0xF800, OP_THUMB_STRH, "strh\t%0-2r, [%3-5r, #%6-10H]"},
- {0x8800, 0xF800, OP_THUMB_LDRH, "ldrh\t%0-2r, [%3-5r, #%6-10H]"},
- /* format 11 */
- {0x9000, 0xF800, OP_THUMB_STR, "str\t%8-10r, [sp, #%0-7W]"},
- {0x9800, 0xF800, OP_THUMB_LDR, "ldr\t%8-10r, [sp, #%0-7W]"},
- /* format 12 */
- {0xA000, 0xF800, OP_THUMB_ADD, "add\t%8-10r, pc, #%0-7W\t(adr %8-10r,%0-7a)"},
- {0xA800, 0xF800, OP_THUMB_ADD, "add\t%8-10r, sp, #%0-7W"},
- /* format 15 */
- {0xC000, 0xF800, OP_THUMB_STMIA, "stmia\t%8-10r!,%M"},
- {0xC800, 0xF800, OP_THUMB_LDMIA, "ldmia\t%8-10r!,%M"},
- /* format 18 */
- {0xE000, 0xF800, OP_THUMB_B, "b\t%0-10B"},
- /* format 19 */
- /* special processing required in disassembler */
- {0xF000, 0xF800, OP_THUMB_BL, ""},
- {0xF800, 0xF800, OP_THUMB_BL, "second half of BL instruction %0-15x"},
- {0xE800, 0xF800, OP_THUMB_BLX, "second half of BLX instruction %0-15x"},
- /* format 16 */
- {0xD000, 0xFF00, OP_THUMB_B, "beq\t%0-7B"},
- {0xD100, 0xFF00, OP_THUMB_B, "bne\t%0-7B"},
- {0xD200, 0xFF00, OP_THUMB_B, "bcs\t%0-7B"},
- {0xD300, 0xFF00, OP_THUMB_B, "bcc\t%0-7B"},
- {0xD400, 0xFF00, OP_THUMB_B, "bmi\t%0-7B"},
- {0xD500, 0xFF00, OP_THUMB_B, "bpl\t%0-7B"},
- {0xD600, 0xFF00, OP_THUMB_B, "bvs\t%0-7B"},
- {0xD700, 0xFF00, OP_THUMB_B, "bvc\t%0-7B"},
- {0xD800, 0xFF00, OP_THUMB_B, "bhi\t%0-7B"},
- {0xD900, 0xFF00, OP_THUMB_B, "bls\t%0-7B"},
- {0xDA00, 0xFF00, OP_THUMB_B, "bge\t%0-7B"},
- {0xDB00, 0xFF00, OP_THUMB_B, "blt\t%0-7B"},
- {0xDC00, 0xFF00, OP_THUMB_B, "bgt\t%0-7B"},
- {0xDD00, 0xFF00, OP_THUMB_B, "ble\t%0-7B"},
- /* format 17 */
- {0xDE00, 0xFF00, OP_THUMB_UNDEFINED, "undefined"},
- {0xDF00, 0xFF00, OP_THUMB_SWI, "swi\t%0-7d"},
- /* format 9 */
- {0x6000, 0xF800, OP_THUMB_STR, "str\t%0-2r, [%3-5r, #%6-10W]"},
- {0x6800, 0xF800, OP_THUMB_LDR, "ldr\t%0-2r, [%3-5r, #%6-10W]"},
- {0x7000, 0xF800, OP_THUMB_STRB, "strb\t%0-2r, [%3-5r, #%6-10d]"},
- {0x7800, 0xF800, OP_THUMB_LDRB, "ldrb\t%0-2r, [%3-5r, #%6-10d]"},
- /* the rest */
- {0x0000, 0x0000, OP_THUMB_UNDEFINED, "undefined instruction %0-15x"},
- {0x0000, 0x0000, OP_END, 0}
-};
-
-#define BDISP23(x,y) ((((((x) & 0x07ff) << 11) | ((y) & 0x07ff)) \
- ^ 0x200000) - 0x200000) /* 23bit */
-
-static const char * arm_conditional[] =
-{"eq", "ne", "cs", "cc", "mi", "pl", "vs", "vc",
- "hi", "ls", "ge", "lt", "gt", "le", "", "nv"};
-
-typedef struct
-{
- const char * name;
- const char * description;
- const char * reg_names[16];
-}
-arm_regname;
-
-static arm_regname regnames[] =
-{
- { "raw" , "Select raw register names",
- { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"}},
- { "gcc", "Select register names used by GCC",
- { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "sl", "fp", "ip", "sp", "lr", "pc" }},
- { "std", "Select register names used in ARM's ISA documentation",
- { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11", "r12", "sp", "lr", "pc" }},
- { "apcs", "Select register names used in the APCS",
- { "a1", "a2", "a3", "a4", "v1", "v2", "v3", "v4", "v5", "v6", "sl", "fp", "ip", "sp", "lr", "pc" }},
- { "atpcs", "Select register names used in the ATPCS",
- { "a1", "a2", "a3", "a4", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "IP", "SP", "LR", "PC" }},
- { "special-atpcs", "Select special register names used in the ATPCS",
- { "a1", "a2", "a3", "a4", "v1", "v2", "v3", "WR", "v5", "SB", "SL", "FP", "IP", "SP", "LR", "PC" }}
-};
-
-/* Default to STD register name set. */
-static unsigned int regname_selected = 2;
-
-#define NUM_ARM_REGNAMES NUM_ELEM (regnames)
-#define arm_regnames regnames[regname_selected].reg_names
-
-Opcode decode_insn_thumb(uint32_t given)
-{
- struct thumb_opcode * insn;
-
- for (insn = thumb_opcodes; insn->assembler; insn++) {
- if ((given & insn->mask) == insn->value)
- return insn->opcode;
- }
- return OP_THUMB_UNDEFINED;
-}
-
-// Generates the disassembly string for the thumb instruction "insn1".
-// If "insn1" is a BL or BLX instruction that is the first of two Thumb
-// instructions, then insn2 is the second of two instructions. Otherwise,
-// insn2 is ignored.
-char *disasm_insn_thumb(uint32_t pc, uint32_t insn1, uint32_t insn2, char *result)
-{
- struct thumb_opcode * insn;
- static char buf[80];
- char *ptr;
- uint32_t addr;
- int len;
-
- if (result == NULL)
- result = buf;
- ptr = result;
-
- for (insn = thumb_opcodes; insn->assembler; insn++) {
- if ((insn1 & insn->mask) != insn->value)
- continue;
-
- const char * c = insn->assembler;
-
- /* Special processing for Thumb 2-instruction BL sequence: */
- if (!*c) { /* Check for empty (not NULL) assembler string. */
- uint32_t offset;
-
- offset = BDISP23 (insn1, insn2);
- offset = offset * 2 + pc + 4;
-
- if ((insn2 & 0x1000) == 0) {
- len = sprintf(ptr, "blx\t");
- offset &= 0xfffffffc;
- } else {
- len = sprintf(ptr, "bl\t");
- }
- ptr += len;
-
- sprintf(ptr, "0x%x", offset);
- return result;
- }
-
- insn1 &= 0xffff;
-
- for (; *c; c++) {
- if (*c != '%') {
- len = sprintf(ptr, "%c", *c);
- ptr += len;
- continue;
- }
-
- int domaskpc = 0;
- int domasklr = 0;
-
- switch (*++c) {
- case '%':
- len = sprintf(ptr, "%%");
- ptr += len;
- break;
-
- case 'S': {
- uint32_t reg;
-
- reg = (insn1 >> 3) & 0x7;
- if (insn1 & (1 << 6))
- reg += 8;
-
- len = sprintf(ptr, "%s", arm_regnames[reg]);
- ptr += len;
- break;
- }
-
- case 'D': {
- uint32_t reg;
-
- reg = insn1 & 0x7;
- if (insn1 & (1 << 7))
- reg += 8;
-
- len = sprintf(ptr, "%s", arm_regnames[reg]);
- ptr += len;
- break;
- }
-
- case 'T':
- len = sprintf(ptr, "%s",
- arm_conditional [(insn1 >> 8) & 0xf]);
- ptr += len;
- break;
-
- case 'N':
- if (insn1 & (1 << 8))
- domasklr = 1;
- /* Fall through. */
- case 'O':
- if (*c == 'O' && (insn1 & (1 << 8)))
- domaskpc = 1;
- /* Fall through. */
- case 'M': {
- int started = 0;
- int reg;
-
- len = sprintf(ptr, "{");
- ptr += len;
-
- /* It would be nice if we could spot
- ranges, and generate the rS-rE format: */
- for (reg = 0; (reg < 8); reg++)
- if ((insn1 & (1 << reg)) != 0) {
- if (started) {
- len = sprintf(ptr, ", ");
- ptr += len;
- }
- started = 1;
- len = sprintf(ptr, "%s", arm_regnames[reg]);
- ptr += len;
- }
-
- if (domasklr) {
- if (started) {
- len = sprintf(ptr, ", ");
- ptr += len;
- }
- started = 1;
- len = sprintf(ptr, arm_regnames[14] /* "lr" */);
- ptr += len;
- }
-
- if (domaskpc) {
- if (started) {
- len = sprintf(ptr, ", ");
- ptr += len;
- }
- len = sprintf(ptr, arm_regnames[15] /* "pc" */);
- ptr += len;
- }
-
- len = sprintf(ptr, "}");
- ptr += len;
- break;
- }
-
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9': {
- int bitstart = *c++ - '0';
- int bitend = 0;
-
- while (*c >= '0' && *c <= '9')
- bitstart = (bitstart * 10) + *c++ - '0';
-
- switch (*c) {
- case '-': {
- uint32_t reg;
-
- c++;
- while (*c >= '0' && *c <= '9')
- bitend = (bitend * 10) + *c++ - '0';
- if (!bitend)
- abort ();
- reg = insn1 >> bitstart;
- reg &= (2 << (bitend - bitstart)) - 1;
- switch (*c) {
- case 'r':
- len = sprintf(ptr, "%s", arm_regnames[reg]);
- break;
-
- case 'd':
- len = sprintf(ptr, "%d", reg);
- break;
-
- case 'H':
- len = sprintf(ptr, "%d", reg << 1);
- break;
-
- case 'W':
- len = sprintf(ptr, "%d", reg << 2);
- break;
-
- case 'a':
- /* PC-relative address -- the bottom two
- bits of the address are dropped
- before the calculation. */
- addr = ((pc + 4) & ~3) + (reg << 2);
- len = sprintf(ptr, "0x%x", addr);
- break;
-
- case 'x':
- len = sprintf(ptr, "0x%04x", reg);
- break;
-
- case 'I':
- reg = ((reg ^ (1 << bitend)) - (1 << bitend));
- len = sprintf(ptr, "%d", reg);
- break;
-
- case 'B':
- reg = ((reg ^ (1 << bitend)) - (1 << bitend));
- addr = reg * 2 + pc + 4;
- len = sprintf(ptr, "0x%x", addr);
- break;
-
- default:
- abort ();
- }
- ptr += len;
- break;
- }
-
- case '\'':
- c++;
- if ((insn1 & (1 << bitstart)) != 0) {
- len = sprintf(ptr, "%c", *c);
- ptr += len;
- }
- break;
-
- case '?':
- ++c;
- if ((insn1 & (1 << bitstart)) != 0)
- len = sprintf(ptr, "%c", *c++);
- else
- len = sprintf(ptr, "%c", *++c);
- ptr += len;
- break;
-
- default:
- abort ();
- }
- break;
- }
-
- default:
- abort ();
- }
- }
- return result;
- }
-
- /* No match. */
- abort ();
-}
diff --git a/emulator/qtools/trace_reader.cpp b/emulator/qtools/trace_reader.cpp
deleted file mode 100644
index 47b5d93..0000000
--- a/emulator/qtools/trace_reader.cpp
+++ /dev/null
@@ -1,1201 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include <inttypes.h>
-#include <assert.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <elf.h>
-#include "trace_reader.h"
-#include "decoder.h"
-
-// A struct for creating temporary linked-lists of DexSym structs
-struct DexSymList {
- DexSymList *next;
- DexSym sym;
-};
-
-// Declare static functions used in this file
-static char *ExtractDexPathFromMmap(const char *mmap_path);
-static void CopyDexSymbolsToArray(DexFileList *dexfile,
- DexSymList *head, int num_symbols);
-
-// This function creates the pathname to the a specific trace file. The
-// string space is allocated in this routine and must be freed by the
-// caller.
-static char *CreateTracePath(const char *filename, const char *ext)
-{
- char *fname;
- const char *base_start, *base_end;
- int ii, len, base_len, dir_len, path_len, qtrace_len;
-
- // Handle error cases
- if (filename == NULL || *filename == 0 || strcmp(filename, "/") == 0)
- return NULL;
-
- // Ignore a trailing slash, if any
- len = strlen(filename);
- if (filename[len - 1] == '/')
- len -= 1;
-
- // Find the basename. We don't use basename(3) because there are
- // different behaviors for GNU and Posix in the case where the
- // last character is a slash.
- base_start = base_end = &filename[len];
- for (ii = 0; ii < len; ++ii) {
- base_start -= 1;
- if (*base_start == '/') {
- base_start += 1;
- break;
- }
- }
- base_len = base_end - base_start;
- dir_len = len - base_len;
- qtrace_len = strlen("/qtrace");
-
- // Create space for the pathname: "/dir/basename/qtrace.ext"
- // The "ext" string already contains the dot, so just add a byte
- // for the terminating zero.
- path_len = dir_len + base_len + qtrace_len + strlen(ext) + 1;
- fname = new char[path_len];
- if (dir_len > 0)
- strncpy(fname, filename, dir_len);
- fname[dir_len] = 0;
- strncat(fname, base_start, base_len);
- strcat(fname, "/qtrace");
- strcat(fname, ext);
- return fname;
-}
-
-inline BBReader::Future *BBReader::AllocFuture()
-{
- Future *future = free_;
- free_ = free_->next;
- return future;
-}
-
-inline void BBReader::FreeFuture(Future *future)
-{
- future->next = free_;
- free_ = future;
-}
-
-inline void BBReader::InsertFuture(Future *future)
-{
- uint64_t future_time = future->bb.next_time;
- Future *prev = NULL;
- Future *ptr;
- for (ptr = head_; ptr; prev = ptr, ptr = ptr->next) {
- if (future_time <= ptr->bb.next_time)
- break;
- }
- if (prev == NULL) {
- // link it at the front
- future->next = head_;
- head_ = future;
- } else {
- // link it after "prev"
- future->next = prev->next;
- prev->next = future;
- }
-}
-
-// Decodes the next basic block record from the file. Returns 1
-// at end-of-file, otherwise returns 0.
-inline int BBReader::DecodeNextRec()
-{
- int64_t bb_diff = decoder_->Decode(true);
- uint64_t time_diff = decoder_->Decode(false);
- nextrec_.bb_rec.repeat = decoder_->Decode(false);
- if (time_diff == 0)
- return 1;
- if (nextrec_.bb_rec.repeat)
- nextrec_.bb_rec.time_diff = decoder_->Decode(false);
- nextrec_.bb_rec.bb_num += bb_diff;
- nextrec_.bb_rec.start_time += time_diff;
- return 0;
-}
-
-BBReader::BBReader(TraceReaderBase *trace)
-{
- trace_ = trace;
- decoder_ = new Decoder;
-}
-
-BBReader::~BBReader()
-{
- delete decoder_;
-}
-
-void BBReader::Open(const char *filename)
-{
- // Initialize the class variables
- memset(&nextrec_, 0, sizeof(TimeRec));
- memset(futures_, 0, sizeof(Future) * kMaxNumBasicBlocks);
- head_ = NULL;
-
- // Link all of the futures_[] array elements on the free list.
- for (int ii = 0; ii < kMaxNumBasicBlocks - 1; ++ii) {
- futures_[ii].next = &futures_[ii + 1];
- }
- futures_[kMaxNumBasicBlocks - 1].next = 0;
- free_ = &futures_[0];
-
- // Open the trace.bb file
- char *fname = CreateTracePath(filename, ".bb");
- decoder_->Open(fname);
- is_eof_ = DecodeNextRec();
- delete[] fname;
-}
-
-void BBReader::Close()
-{
- decoder_->Close();
-}
-
-// Returns true at end of file.
-bool BBReader::ReadBB(BBEvent *event)
-{
- if (is_eof_ && head_ == NULL) {
- return true;
- }
-
-#if 0
- if (nextrec_) {
- printf("nextrec: buffer[%d], bb_num: %lld start: %d diff %d repeat %d next %u\n",
- nextrec_ - &buffer_[0],
- nextrec_->bb_rec.bb_num, nextrec_->bb_rec.start_time,
- nextrec_->bb_rec.time_diff, nextrec_->bb_rec.repeat,
- nextrec_->next_time);
- }
- if (head_) {
- printf("head: 0x%x, bb_num: %lld start: %d diff %d repeat %d next %u\n",
- head_,
- head_->bb->bb_rec.bb_num, head_->bb->bb_rec.start_time,
- head_->bb->bb_rec.time_diff, head_->bb->bb_rec.repeat,
- head_->bb->next_time);
- }
-#endif
- if (!is_eof_) {
- if (head_) {
- TimeRec *bb = &head_->bb;
- if (bb->next_time < nextrec_.bb_rec.start_time) {
- // The head is earlier.
- event->time = bb->next_time;
- event->bb_num = bb->bb_rec.bb_num;
- event->bb_addr = trace_->GetBBAddr(event->bb_num);
- event->insns = trace_->GetInsns(event->bb_num);
- event->num_insns = trace_->FindNumInsns(event->bb_num, event->time);
- event->pid = trace_->FindCurrentPid(event->time);
- event->is_thumb = trace_->GetIsThumb(event->bb_num);
-
- // Remove the head element from the list
- Future *future = head_;
- head_ = head_->next;
- if (bb->bb_rec.repeat > 0) {
- // there are more repetitions of this bb
- bb->bb_rec.repeat -= 1;
- bb->next_time += bb->bb_rec.time_diff;
-
- // Insert this future into the sorted list
- InsertFuture(future);
- } else {
- // Add this future to the free list
- FreeFuture(future);
- }
- return false;
- }
- }
- // The nextrec is earlier (or there was no head)
- event->time = nextrec_.bb_rec.start_time;
- event->bb_num = nextrec_.bb_rec.bb_num;
- event->bb_addr = trace_->GetBBAddr(event->bb_num);
- event->insns = trace_->GetInsns(event->bb_num);
- event->num_insns = trace_->FindNumInsns(event->bb_num, event->time);
- event->pid = trace_->FindCurrentPid(event->time);
- event->is_thumb = trace_->GetIsThumb(event->bb_num);
- if (nextrec_.bb_rec.repeat > 0) {
- Future *future = AllocFuture();
- future->bb.bb_rec = nextrec_.bb_rec;
- future->bb.bb_rec.repeat -= 1;
- future->bb.next_time = nextrec_.bb_rec.start_time + nextrec_.bb_rec.time_diff;
- InsertFuture(future);
- }
-
- is_eof_ = DecodeNextRec();
- return false;
- }
-
- //printf("using head_ 0x%x\n", head_);
- assert(head_);
- TimeRec *bb = &head_->bb;
- event->time = bb->next_time;
- event->bb_num = bb->bb_rec.bb_num;
- event->bb_addr = trace_->GetBBAddr(event->bb_num);
- event->insns = trace_->GetInsns(event->bb_num);
- event->num_insns = trace_->FindNumInsns(event->bb_num, event->time);
- event->pid = trace_->FindCurrentPid(event->time);
- event->is_thumb = trace_->GetIsThumb(event->bb_num);
-
- // Remove the head element from the list
- Future *future = head_;
- head_ = head_->next;
- if (bb->bb_rec.repeat > 0) {
- // there are more repetitions of this bb
- bb->bb_rec.repeat -= 1;
- bb->next_time += bb->bb_rec.time_diff;
-
- // Insert this future into the sorted list
- InsertFuture(future);
- } else {
- // Add this future to the free list
- FreeFuture(future);
- }
- return false;
-}
-
-InsnReader::InsnReader()
-{
- decoder_ = new Decoder;
-}
-
-InsnReader::~InsnReader()
-{
- delete decoder_;
-}
-
-void InsnReader::Open(const char *filename)
-{
- prev_time_ = 0;
- time_diff_ = 0;
- repeat_ = -1;
-
- // Open the trace.insn file
- char *fname = CreateTracePath(filename, ".insn");
- decoder_->Open(fname);
- delete[] fname;
-}
-
-void InsnReader::Close()
-{
- decoder_->Close();
-}
-
-uint64_t InsnReader::ReadInsnTime(uint64_t min_time)
-{
- do {
- if (repeat_ == -1) {
- time_diff_ = decoder_->Decode(false);
- repeat_ = decoder_->Decode(false);
- }
- prev_time_ += time_diff_;
- repeat_ -= 1;
- } while (prev_time_ < min_time);
- return prev_time_;
-}
-
-AddrReader::AddrReader()
-{
- decoder_ = new Decoder;
- opened_ = false;
-}
-
-AddrReader::~AddrReader()
-{
- delete decoder_;
-}
-
-// Returns true if there is an error opening the file
-bool AddrReader::Open(const char *filename, const char *suffix)
-{
- struct stat stat_buf;
-
- prev_addr_ = 0;
- prev_time_ = 0;
-
- // Open the trace.addr file
- char *fname = CreateTracePath(filename, suffix);
- int rval = stat(fname, &stat_buf);
- if (rval == -1) {
- // The file does not exist
- delete[] fname;
- return true;
- }
- decoder_->Open(fname);
- opened_ = true;
- delete[] fname;
- return false;
-}
-
-void AddrReader::Close()
-{
- decoder_->Close();
-}
-
-// Returns true at end of file.
-bool AddrReader::ReadAddr(uint64_t *time, uint32_t *addr)
-{
- if (!opened_) {
- fprintf(stderr, "Cannot read address trace\n");
- exit(1);
- }
- uint32_t addr_diff = decoder_->Decode(true);
- uint64_t time_diff = decoder_->Decode(false);
- if (time_diff == 0 && addr_diff == 0) {
- *addr = 0;
- *time = 0;
- return true;
- }
- prev_addr_ += addr_diff;
- prev_time_ += time_diff;
- *addr = prev_addr_;
- *time = prev_time_;
- return false;
-}
-
-ExcReader::ExcReader()
-{
- decoder_ = new Decoder;
-}
-
-ExcReader::~ExcReader()
-{
- delete decoder_;
-}
-
-void ExcReader::Open(const char *filename)
-{
- prev_time_ = 0;
- prev_recnum_ = 0;
-
- // Open the trace.exc file
- char *fname = CreateTracePath(filename, ".exc");
- decoder_->Open(fname);
- delete[] fname;
-}
-
-void ExcReader::Close()
-{
- decoder_->Close();
-}
-
-// Returns true at end of file.
-bool ExcReader::ReadExc(uint64_t *time, uint32_t *current_pc, uint64_t *recnum,
- uint32_t *target_pc, uint64_t *bb_num,
- uint64_t *bb_start_time, int *num_insns)
-{
- uint64_t time_diff = decoder_->Decode(false);
- uint32_t pc = decoder_->Decode(false);
- if ((time_diff | pc) == 0) {
- decoder_->Decode(false);
- decoder_->Decode(false);
- decoder_->Decode(false);
- decoder_->Decode(false);
- decoder_->Decode(false);
- return true;
- }
- uint64_t recnum_diff = decoder_->Decode(false);
- prev_time_ += time_diff;
- prev_recnum_ += recnum_diff;
- *time = prev_time_;
- *current_pc = pc;
- *recnum = prev_recnum_;
- *target_pc = decoder_->Decode(false);
- *bb_num = decoder_->Decode(false);
- *bb_start_time = decoder_->Decode(false);
- *num_insns = decoder_->Decode(false);
- return false;
-}
-
-PidReader::PidReader()
-{
- decoder_ = new Decoder;
-}
-
-PidReader::~PidReader()
-{
- delete decoder_;
-}
-
-void PidReader::Open(const char *filename)
-{
- prev_time_ = 0;
-
- // Open the trace.pid file
- char *fname = CreateTracePath(filename, ".pid");
- decoder_->Open(fname);
- delete[] fname;
-}
-
-void PidReader::Close()
-{
- decoder_->Close();
-}
-
-// Returns true at end of file.
-bool PidReader::ReadPidEvent(PidEvent *event)
-{
- uint64_t time_diff = decoder_->Decode(false);
- int rec_type = decoder_->Decode(false);
- prev_time_ += time_diff;
- event->time = prev_time_;
- event->rec_type = rec_type;
- switch(rec_type) {
- case kPidEndOfFile:
- return true;
- case kPidSwitch:
- case kPidExit:
- event->pid = decoder_->Decode(false);
- break;
- case kPidFork:
- case kPidClone:
- event->tgid = decoder_->Decode(false);
- event->pid = decoder_->Decode(false);
- break;
- case kPidMmap:
- {
- event->vstart = decoder_->Decode(false);
- event->vend = decoder_->Decode(false);
- event->offset = decoder_->Decode(false);
- int len = decoder_->Decode(false);
- char *path = new char[len + 1];
- decoder_->Read(path, len);
- path[len] = 0;
- event->path = path;
- event->mmap_path = path;
- char *dexfile = ExtractDexPathFromMmap(path);
- if (dexfile != NULL) {
- delete[] event->path;
- event->path = dexfile;
- }
- }
- break;
- case kPidMunmap:
- {
- event->vstart = decoder_->Decode(false);
- event->vend = decoder_->Decode(false);
- }
- break;
- case kPidSymbolAdd:
- {
- event->vstart = decoder_->Decode(false);
- int len = decoder_->Decode(false);
- char *path = new char[len + 1];
- decoder_->Read(path, len);
- path[len] = 0;
- event->path = path;
- }
- break;
- case kPidSymbolRemove:
- event->vstart = decoder_->Decode(false);
- break;
- case kPidExec:
- {
- int argc = decoder_->Decode(false);
- event->argc = argc;
- char **argv = new char*[argc];
- event->argv = argv;
- for (int ii = 0; ii < argc; ++ii) {
- int alen = decoder_->Decode(false);
- argv[ii] = new char[alen + 1];
- decoder_->Read(argv[ii], alen);
- argv[ii][alen] = 0;
- }
- }
- break;
- case kPidName:
- case kPidKthreadName:
- {
- if (rec_type == kPidKthreadName) {
- event->tgid = decoder_->Decode(false);
- }
- event->pid = decoder_->Decode(false);
- int len = decoder_->Decode(false);
- char *path = new char[len + 1];
- decoder_->Read(path, len);
- path[len] = 0;
- event->path = path;
- }
- break;
- }
- return false;
-}
-
-// Frees the memory that might have been allocated for the given event.
-void PidReader::Dispose(PidEvent *event)
-{
- switch(event->rec_type) {
- case kPidMmap:
- case kPidSymbolAdd:
- case kPidName:
- case kPidKthreadName:
- delete[] event->path;
- event->path = NULL;
- event->mmap_path = NULL;
- break;
-
- case kPidExec:
- for (int ii = 0; ii < event->argc; ++ii) {
- delete[] event->argv[ii];
- }
- delete[] event->argv;
- event->argv = NULL;
- event->argc = 0;
- break;
- }
-}
-
-
-MethodReader::MethodReader()
-{
- decoder_ = new Decoder;
- opened_ = false;
-}
-
-MethodReader::~MethodReader()
-{
- delete decoder_;
-}
-
-bool MethodReader::Open(const char *filename)
-{
- struct stat stat_buf;
-
- prev_time_ = 0;
- prev_addr_ = 0;
- prev_pid_ = 0;
-
- // Open the trace.method file
- char *fname = CreateTracePath(filename, ".method");
- int rval = stat(fname, &stat_buf);
- if (rval == -1) {
- // The file does not exist
- delete[] fname;
- return true;
- }
- decoder_->Open(fname);
- delete[] fname;
- opened_ = true;
- return false;
-}
-
-void MethodReader::Close()
-{
- decoder_->Close();
-}
-
-// Returns true at end of file.
-bool MethodReader::ReadMethod(MethodRec *method_record)
-{
- if (!opened_)
- return true;
- uint64_t time_diff = decoder_->Decode(false);
- int32_t addr_diff = decoder_->Decode(true);
- if (time_diff == 0) {
- method_record->time = 0;
- method_record->addr = 0;
- method_record->flags = 0;
- return true;
- }
- int32_t pid_diff = decoder_->Decode(true);
- prev_time_ += time_diff;
- prev_addr_ += addr_diff;
- prev_pid_ += pid_diff;
- method_record->time = prev_time_;
- method_record->addr = prev_addr_;
- method_record->pid = prev_pid_;
- method_record->flags = decoder_->Decode(false);
- return false;
-}
-
-TraceReaderBase::TraceReaderBase()
-{
- static_filename_ = NULL;
- static_fstream_ = NULL;
- header_ = new TraceHeader;
- bb_reader_ = new BBReader(this);
- insn_reader_ = new InsnReader;
- load_addr_reader_ = new AddrReader;
- store_addr_reader_ = new AddrReader;
- exc_reader_ = new ExcReader;
- pid_reader_ = new PidReader;
- method_reader_ = new MethodReader;
- internal_exc_reader_ = new ExcReader;
- internal_pid_reader_ = new PidReader;
- internal_method_reader_ = new MethodReader;
- blocks_ = NULL;
- bb_recnum_ = 0;
- exc_recnum_ = 0;
- exc_end_ = false;
- exc_bb_num_ = 0;
- exc_time_ = 0;
- exc_num_insns_ = 0;
- current_pid_ = 0;
- next_pid_ = 0;
- next_pid_switch_time_ = 0;
- post_processing_ = false;
- dex_hash_ = NULL;
- load_eof_ = false;
- load_time_ = 0;
- load_addr_ = 0;
- store_eof_ = false;
- store_time_ = 0;
- store_addr_ = 0;
-}
-
-TraceReaderBase::~TraceReaderBase()
-{
- Close();
- delete bb_reader_;
- delete insn_reader_;
- delete load_addr_reader_;
- delete store_addr_reader_;
- delete exc_reader_;
- delete pid_reader_;
- delete method_reader_;
- delete internal_exc_reader_;
- delete internal_pid_reader_;
- delete internal_method_reader_;
- if (blocks_) {
- int num_static_bb = header_->num_static_bb;
- for (int ii = 0; ii < num_static_bb; ++ii) {
- delete[] blocks_[ii].insns;
- }
- delete[] blocks_;
- }
- delete header_;
- if (dex_hash_ != NULL) {
- HashTable<DexFileList*>::entry_type *ptr;
- for (ptr = dex_hash_->GetFirst(); ptr; ptr = dex_hash_->GetNext()) {
- DexFileList *dexfile = ptr->value;
- delete[] dexfile->path;
- int nsymbols = dexfile->nsymbols;
- DexSym *symbols = dexfile->symbols;
- for (int ii = 0; ii < nsymbols; ii++) {
- delete[] symbols[ii].name;
- }
- delete[] dexfile->symbols;
- delete dexfile;
- }
- }
- delete dex_hash_;
- delete[] static_filename_;
-}
-
-void TraceReaderBase::ReadTraceHeader(FILE *fstream, const char *filename,
- const char *tracename, TraceHeader *header)
-{
- int rval = fread(header, sizeof(TraceHeader), 1, fstream);
- if (rval != 1) {
- perror(filename);
- exit(1);
- }
-
- if (!post_processing_ && strcmp(header->ident, TRACE_IDENT) != 0) {
- fprintf(stderr, "%s: missing trace header; run 'post_trace %s' first\n",
- filename, tracename);
- exit(1);
- }
-
- if (header->version != TRACE_VERSION) {
- fprintf(stderr,
- "%s: trace header version (%d) does not match compiled tools version (%d)\n",
- tracename, header->version, TRACE_VERSION);
- exit(1);
- }
-
- convert32(header->version);
- convert32(header->start_sec);
- convert32(header->start_usec);
- convert32(header->pdate);
- convert32(header->ptime);
- convert64(header->num_static_bb);
- convert64(header->num_static_insn);
- convert64(header->num_dynamic_bb);
- convert64(header->num_dynamic_insn);
- convert64(header->elapsed_usecs);
-}
-
-
-void TraceReaderBase::Open(const char *filename)
-{
- char *fname;
- FILE *fstream;
-
- // Open the qtrace.bb file
- bb_reader_->Open(filename);
-
- // Open the qtrace.insn file
- insn_reader_->Open(filename);
-
- // Open the qtrace.load file and read the first line
- load_eof_ = load_addr_reader_->Open(filename, ".load");
- if (!load_eof_)
- load_eof_ = load_addr_reader_->ReadAddr(&load_time_, &load_addr_);
-
- // Open the qtrace.store file and read the first line
- store_eof_ = store_addr_reader_->Open(filename, ".store");
- if (!store_eof_)
- store_eof_ = store_addr_reader_->ReadAddr(&store_time_, &store_addr_);
-
- // Open the qtrace.exc file
- exc_reader_->Open(filename);
-
- // Open another file stream to the qtrace.exc file for internal reads.
- // This allows the caller to also read from the qtrace.exc file.
- internal_exc_reader_->Open(filename);
-
- // Open the qtrace.pid file
- pid_reader_->Open(filename);
- internal_pid_reader_->Open(filename);
-
- // Open the qtrace.method file
- method_reader_->Open(filename);
- internal_method_reader_->Open(filename);
-
- // Open the qtrace.static file
- fname = CreateTracePath(filename, ".static");
- static_filename_ = fname;
-
- fstream = fopen(fname, "r");
- if (fstream == NULL) {
- perror(fname);
- exit(1);
- }
- static_fstream_ = fstream;
-
- // Read the header
- ReadTraceHeader(fstream, fname, filename, header_);
-
- // Allocate space for all of the static blocks
- int num_static_bb = header_->num_static_bb;
- if (num_static_bb) {
- blocks_ = new StaticBlock[num_static_bb];
-
- // Read in all the static blocks
- for (int ii = 0; ii < num_static_bb; ++ii) {
- ReadStatic(&blocks_[ii].rec);
- int num_insns = blocks_[ii].rec.num_insns;
- if (num_insns > 0) {
- blocks_[ii].insns = new uint32_t[num_insns];
- ReadStaticInsns(num_insns, blocks_[ii].insns);
- } else {
- blocks_[ii].insns = NULL;
- }
- }
- fseek(static_fstream_, sizeof(TraceHeader), SEEK_SET);
- }
-
- ParseDexList(filename);
-
- // If the dex_hash_ is NULL, then assign it a small hash table
- // so that we can simply do a Find() operation without having
- // to check for NULL first.
- if (dex_hash_ == NULL) {
- dex_hash_ = new HashTable<DexFileList*>(1, NULL);
- }
-}
-
-// Reads the list of pid events looking for an mmap of a dex file.
-PidEvent * TraceReaderBase::FindMmapDexFileEvent()
-{
- static PidEvent event;
-
- while (!pid_reader_->ReadPidEvent(&event)) {
- if (event.rec_type == kPidMmap && event.path != event.mmap_path) {
- return &event;
- }
- pid_reader_->Dispose(&event);
- }
- return NULL;
-}
-
-static void CopyDexSymbolsToArray(DexFileList *dexfile,
- DexSymList *head, int num_symbols)
-{
- if (dexfile == NULL)
- return;
-
- DexSym *symbols = NULL;
- if (num_symbols > 0) {
- symbols = new DexSym[num_symbols];
- }
- dexfile->nsymbols = num_symbols;
- dexfile->symbols = symbols;
-
- // Copy the linked-list to the array.
- DexSymList *next_sym = NULL;
- int next_index = 0;
- for (DexSymList *sym = head; sym; sym = next_sym) {
- next_sym = sym->next;
- symbols[next_index].addr = sym->sym.addr;
- symbols[next_index].len = sym->sym.len;
- symbols[next_index].name = sym->sym.name;
- next_index += 1;
- delete sym;
- }
-}
-
-void TraceReaderBase::ParseDexList(const char *filename)
-{
- struct stat stat_buf;
- static const int kBufSize = 4096;
- char buf[kBufSize];
- char current_file[kBufSize];
-
- // Find an example dex file in the list of mmaps
- PidEvent *event = FindMmapDexFileEvent();
-
- // Reset the pid_reader to the beginning of the file.
- pid_reader_->Close();
- pid_reader_->Open(filename);
-
- // If there were no mmapped dex files, then there is no need to parse
- // the dexlist.
- if (event == NULL)
- return;
- char *mmap_dexfile = event->path;
-
- // Check if the dexlist file exists. It should have the name
- // "qtrace.dexlist"
- char *fname = CreateTracePath(filename, ".dexlist");
- int rval = stat(fname, &stat_buf);
- if (rval == -1) {
- // The file does not exist
- delete[] fname;
- return;
- }
-
- // Open the qtrace.dexlist file
- FILE *fstream = fopen(fname, "r");
- if (fstream == NULL) {
- perror(fname);
- exit(1);
- }
-
- // First pass: read all the filenames, looking for a match for the
- // example mmap dex filename. Also count the files so that we
- // know how big to make the hash table.
- char *match = NULL;
- int num_files = 0;
- while (fgets(buf, kBufSize, fstream)) {
- if (buf[0] != '#')
- continue;
- num_files += 1;
- match = strstr(buf + 1, mmap_dexfile);
-
- // Check that the dexlist file ends with the string mmap_dexfile.
- // We add one to the length of the mmap_dexfile because buf[]
- // ends with a newline. The strlen(mmap_dexfile) computation
- // could be moved above the loop but it should only ever be
- // executed once.
- if (match != NULL && strlen(match) == strlen(mmap_dexfile) + 1)
- break;
- }
-
- // Count the rest of the files
- while (fgets(buf, kBufSize, fstream)) {
- if (buf[0] == '#')
- num_files += 1;
- }
-
- if (match == NULL) {
- fprintf(stderr,
- "Cannot find the mmapped dex file '%s' in the dexlist\n",
- mmap_dexfile);
- exit(1);
- }
- delete[] mmap_dexfile;
-
- // The prefix length includes the leading '#'.
- int prefix_len = match - buf;
-
- // Allocate a hash table
- dex_hash_ = new HashTable<DexFileList*>(4 * num_files, NULL);
-
- // Reset the file stream to the beginning
- rewind(fstream);
-
- // Second pass: read the filenames, stripping off the common prefix.
- // And read all the (address, method) mappings. When we read a new
- // filename, create a new DexFileList and add it to the hash table.
- // Add new symbol mappings to a linked list until we have the whole
- // list and then create an array for them so that we can use binary
- // search on the address to find the symbol name quickly.
-
- // Use a linked list for storing the symbols
- DexSymList *head = NULL;
- DexSymList *prev = NULL;
- int num_symbols = 0;
-
- DexFileList *dexfile = NULL;
- int linenum = 0;
- while (fgets(buf, kBufSize, fstream)) {
- linenum += 1;
- if (buf[0] == '#') {
- // Everything after the '#' is a filename.
- // Ignore the common prefix.
-
- // First, save all the symbols from the previous file (if any).
- CopyDexSymbolsToArray(dexfile, head, num_symbols);
-
- dexfile = new DexFileList;
- // Subtract one because buf[] contains a trailing newline
- int pathlen = strlen(buf) - prefix_len - 1;
- char *path = new char[pathlen + 1];
- strncpy(path, buf + prefix_len, pathlen);
- path[pathlen] = 0;
- dexfile->path = path;
- dexfile->nsymbols = 0;
- dexfile->symbols = NULL;
- dex_hash_->Update(path, dexfile);
- num_symbols = 0;
- head = NULL;
- prev = NULL;
- continue;
- }
-
- uint32_t addr;
- int len, line;
- char clazz[kBufSize], method[kBufSize], sig[kBufSize], file[kBufSize];
- if (sscanf(buf, "0x%x %d %s %s %s %s %d",
- &addr, &len, clazz, method, sig, file, &line) != 7) {
- fprintf(stderr, "Cannot parse line %d of file %s:\n%s",
- linenum, fname, buf);
- exit(1);
- }
-
- // Concatenate the class name, method name, and signature
- // plus one for the period separating the class and method.
- int nchars = strlen(clazz) + strlen(method) + strlen(sig) + 1;
- char *name = new char[nchars + 1];
- strcpy(name, clazz);
- strcat(name, ".");
- strcat(name, method);
- strcat(name, sig);
-
- DexSymList *symbol = new DexSymList;
- symbol->sym.addr = addr;
- symbol->sym.len = len;
- symbol->sym.name = name;
- symbol->next = NULL;
-
- // Keep the list in the same order as the file
- if (head == NULL)
- head = symbol;
- if (prev != NULL)
- prev->next = symbol;
- prev = symbol;
- num_symbols += 1;
- }
- fclose(fstream);
-
- // Copy the symbols from the last file.
- CopyDexSymbolsToArray(dexfile, head, num_symbols);
- delete[] fname;
-}
-
-// Extracts the pathname to a jar file (or .apk file) from the mmap pathname.
-// An example mmap pathname looks something like this:
-// /data/dalvik-cache/system@app@TestHarness.apk@classes.dex
-// We want to convert that to this:
-// /system/app/TestHarness.apk
-// If the pathname is not of the expected form, then NULL is returned.
-// The space for the extracted path is allocated in this routine and should
-// be freed by the caller after it is no longer needed.
-static char *ExtractDexPathFromMmap(const char *mmap_path)
-{
- const char *end = rindex(mmap_path, '@');
- if (end == NULL)
- return NULL;
- const char *start = rindex(mmap_path, '/');
- if (start == NULL)
- return NULL;
- int len = end - start;
- char *path = new char[len + 1];
- strncpy(path, start, len);
- path[len] = 0;
-
- // Replace all the occurrences of '@' with '/'
- for (int ii = 0; ii < len; ii++) {
- if (path[ii] == '@')
- path[ii] = '/';
- }
- return path;
-}
-
-void TraceReaderBase::Close()
-{
- bb_reader_->Close();
- insn_reader_->Close();
- load_addr_reader_->Close();
- store_addr_reader_->Close();
- exc_reader_->Close();
- pid_reader_->Close();
- method_reader_->Close();
- internal_exc_reader_->Close();
- internal_pid_reader_->Close();
- internal_method_reader_->Close();
- fclose(static_fstream_);
- static_fstream_ = NULL;
-}
-
-void TraceReaderBase::WriteHeader(TraceHeader *header)
-{
- TraceHeader swappedHeader;
-
- freopen(static_filename_, "r+", static_fstream_);
- fseek(static_fstream_, 0, SEEK_SET);
-
- memcpy(&swappedHeader, header, sizeof(TraceHeader));
-
- convert32(swappedHeader.version);
- convert32(swappedHeader.start_sec);
- convert32(swappedHeader.start_usec);
- convert32(swappedHeader.pdate);
- convert32(swappedHeader.ptime);
- convert64(swappedHeader.num_static_bb);
- convert64(swappedHeader.num_static_insn);
- convert64(swappedHeader.num_dynamic_bb);
- convert64(swappedHeader.num_dynamic_insn);
- convert64(swappedHeader.elapsed_usecs);
-
- fwrite(&swappedHeader, sizeof(TraceHeader), 1, static_fstream_);
-}
-
-// Reads the next StaticRec from the trace file (not including the list
-// of instructions). On end-of-file, this function returns true.
-int TraceReaderBase::ReadStatic(StaticRec *rec)
-{
- int rval = fread(rec, sizeof(StaticRec), 1, static_fstream_);
- if (rval != 1) {
- if (feof(static_fstream_)) {
- return true;
- }
- perror(static_filename_);
- exit(1);
- }
- convert64(rec->bb_num);
- convert32(rec->bb_addr);
- convert32(rec->num_insns);
- return false;
-}
-
-// Reads "num" instructions into the array "insns" which must be large
-// enough to hold the "num" instructions.
-// Returns the actual number of instructions read. This will usually
-// be "num" but may be less if end-of-file occurred.
-int TraceReaderBase::ReadStaticInsns(int num, uint32_t *insns)
-{
- if (num == 0)
- return 0;
- int rval = fread(insns, sizeof(uint32_t), num, static_fstream_);
-
- // Convert from little-endian, if necessary
- for (int ii = 0; ii < num; ++ii)
- convert32(insns[ii]);
-
- if (rval != num) {
- if (feof(static_fstream_)) {
- return rval;
- }
- perror(static_filename_);
- exit(1);
- }
- return rval;
-}
-
-void TraceReaderBase::TruncateLastBlock(uint32_t num_insns)
-{
- uint32_t insns[kMaxInsnPerBB];
- StaticRec static_rec;
- long loc = 0, prev_loc = 0;
-
- freopen(static_filename_, "r+", static_fstream_);
- fseek(static_fstream_, sizeof(TraceHeader), SEEK_SET);
-
- // Find the last record
- while (1) {
- prev_loc = loc;
- loc = ftell(static_fstream_);
-
- // We don't need to byte-swap static_rec here because we are just
- // reading the records until we get to the last one.
- int rval = fread(&static_rec, sizeof(StaticRec), 1, static_fstream_);
- if (rval != 1)
- break;
- ReadStaticInsns(static_rec.num_insns, insns);
- }
- if (prev_loc != 0) {
- fseek(static_fstream_, prev_loc, SEEK_SET);
- static_rec.num_insns = num_insns;
-
- // Now we need to byte-swap, but just the field that we changed.
- convert32(static_rec.num_insns);
- fwrite(&static_rec, sizeof(StaticRec), 1, static_fstream_);
- int fd = fileno(static_fstream_);
- long len = ftell(static_fstream_);
- len += num_insns * sizeof(uint32_t);
- ftruncate(fd, len);
- }
-}
-
-int TraceReaderBase::FindNumInsns(uint64_t bb_num, uint64_t bb_start_time)
-{
- int num_insns;
-
- // Read the exception trace file. "bb_recnum_" is the number of
- // basic block records that have been read so far, and "exc_recnum_"
- // is the record number from the exception trace.
- while (!exc_end_ && exc_recnum_ < bb_recnum_) {
- uint32_t current_pc, target_pc;
- uint64_t time;
-
- exc_end_ = internal_exc_reader_->ReadExc(&time, &current_pc, &exc_recnum_,
- &target_pc, &exc_bb_num_,
- &exc_time_, &exc_num_insns_);
- }
-
- // If an exception occurred in this basic block, then use the
- // number of instructions specified in the exception record.
- if (!exc_end_ && exc_recnum_ == bb_recnum_) {
- num_insns = exc_num_insns_;
- } else {
- // Otherwise, use the number of instructions specified in the
- // static basic block.
- num_insns = blocks_[bb_num].rec.num_insns;
- }
- return num_insns;
-}
-
-// Finds the current pid for the given time. This routine reads the pid
-// trace file and assumes that the "time" parameter is monotonically
-// increasing.
-int TraceReaderBase::FindCurrentPid(uint64_t time)
-{
- PidEvent event;
-
- if (time < next_pid_switch_time_)
- return current_pid_;
-
- current_pid_ = next_pid_;
- while (1) {
- if (internal_pid_reader_->ReadPidEvent(&event)) {
- next_pid_switch_time_ = ~0ull;
- break;
- }
- if (event.rec_type != kPidSwitch)
- continue;
- if (event.time > time) {
- next_pid_ = event.pid;
- next_pid_switch_time_ = event.time;
- break;
- }
- current_pid_ = event.pid;
- }
- return current_pid_;
-}
diff --git a/emulator/qtools/trace_reader.h b/emulator/qtools/trace_reader.h
deleted file mode 100644
index b91cb1b..0000000
--- a/emulator/qtools/trace_reader.h
+++ /dev/null
@@ -1,1559 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef TRACE_READER_H
-#define TRACE_READER_H
-
-#include <string.h>
-#include <inttypes.h>
-#include <elf.h>
-#include <assert.h>
-#include <cxxabi.h>
-#include "read_elf.h"
-#include "trace_reader_base.h"
-#include "hash_table.h"
-
-struct TraceReaderEmptyStruct {
-};
-
-template <class T = TraceReaderEmptyStruct>
-class TraceReader : public TraceReaderBase {
- public:
-
- struct region_entry;
- typedef struct symbol_entry : public T {
- typedef region_entry region_type;
-
- // Define flag values
- static const uint32_t kIsPlt = 0x01;
- static const uint32_t kIsVectorStart = 0x02;
- static const uint32_t kIsVectorTable = (kIsPlt | kIsVectorStart);
- static const uint32_t kIsInterpreter = 0x04;
- static const uint32_t kIsMethod = 0x08;
-
- uint32_t addr;
-
- // This may hold the name of the interpreted method instead of
- // the name of the native function if the native function is a
- // virtual machine interpreter.
- const char *name;
-
- // The symbol for the virtual machine interpreter, or NULL
- symbol_entry *vm_sym;
- region_type *region;
- uint32_t flags;
- } symbol_type;
-
- typedef struct region_entry {
- // Define flag values
- static const uint32_t kIsKernelRegion = 0x01;
- static const uint32_t kSharedSymbols = 0x02;
- static const uint32_t kIsLibraryRegion = 0x04;
- static const uint32_t kIsUserMappedRegion = 0x08;
-
- region_entry() : refs(0), path(NULL), vstart(0), vend(0), base_addr(0),
- file_offset(0), flags(0), nsymbols(0), symbols(NULL) {}
-
- symbol_type *LookupFunctionByName(char *name) {
- // Just do a linear search
- for (int ii = 0; ii < nsymbols; ++ii) {
- if (strcmp(symbols[ii].name, name) == 0)
- return &symbols[ii];
- }
- return NULL;
- }
-
- region_entry *MakePrivateCopy(region_entry *dest) {
- dest->refs = 0;
- dest->path = Strdup(path);
- dest->vstart = vstart;
- dest->vend = vend;
- dest->base_addr = base_addr;
- dest->file_offset = file_offset;
- dest->flags = flags;
- dest->nsymbols = nsymbols;
- dest->symbols = symbols;
- return dest;
- }
-
- int refs; // reference count
- char *path;
- uint32_t vstart;
- uint32_t vend;
- uint32_t base_addr;
- uint32_t file_offset;
- uint32_t flags;
- int nsymbols;
- symbol_type *symbols;
- } region_type;
-
- typedef typename HashTable<region_type*>::entry_type hash_entry_type;
-
- class ProcessState {
- public:
-
- // The "regions" array below is a pointer to array of pointers to
- // regions. The size of the pointer array is kInitialNumRegions,
- // but grows if needed. There is a separate region for each mmap
- // call which includes shared libraries as well as .dex and .jar
- // files. In addition, there is a region for the main executable
- // for this process, as well as a few regions for the kernel.
- //
- // If a child process is a clone of a parent process, the
- // regions array is unused. Instead, the "addr_manager" pointer is
- // used to find the process that is the address space manager for
- // both the parent and child processes.
- static const int kInitialNumRegions = 10;
-
- static const int kMaxMethodStackSize = 1000;
-
- // Define values for the ProcessState flag bits
- static const int kCalledExec = 0x01;
- static const int kCalledExit = 0x02;
- static const int kIsClone = 0x04;
- static const int kHasKernelRegion = 0x08;
- static const int kHasFirstMmap = 0x10;
-
- struct methodFrame {
- uint32_t addr;
- bool isNative;
- };
-
- ProcessState() {
- cpu_time = 0;
- tgid = 0;
- pid = 0;
- parent_pid = 0;
- exit_val = 0;
- flags = 0;
- argc = 0;
- argv = NULL;
- name = NULL;
- nregions = 0;
- max_regions = 0;
- // Don't allocate space yet until we know if we are a clone.
- regions = NULL;
- parent = NULL;
- addr_manager = this;
- next = NULL;
- current_method_sym = NULL;
- method_stack_top = 0;
- }
-
- ~ProcessState() {
- delete[] name;
- if ((flags & kIsClone) != 0) {
- return;
- }
-
- // Free the regions. We must be careful not to free the symbols
- // within each region because the symbols are sometimes shared
- // between multiple regions. The TraceReader class has a hash
- // table containing all the unique regions and it will free the
- // region symbols in its destructor. We need to free only the
- // regions and the array of region pointers.
- //
- // Each region is also reference-counted. The count is zero
- // if no other processes are sharing this region.
- for (int ii = 0; ii < nregions; ii++) {
- if (regions[ii]->refs > 0) {
- regions[ii]->refs -= 1;
- continue;
- }
-
- delete regions[ii];
- }
-
- delete[] regions;
-
- for (int ii = 0; ii < argc; ++ii)
- delete[] argv[ii];
- delete[] argv;
- }
-
- // Dumps the stack contents to standard output. For debugging.
- void DumpStack(FILE *stream);
-
- uint64_t cpu_time;
- uint64_t start_time;
- uint64_t end_time;
- int tgid;
- int pid;
- int parent_pid;
- int exit_val;
- uint32_t flags;
- int argc;
- char **argv;
- const char *name;
- int nregions; // num regions in use
- int max_regions; // max regions allocated
- region_type **regions;
- ProcessState *parent;
- ProcessState *addr_manager; // the address space manager process
- ProcessState *next;
- int method_stack_top;
- methodFrame method_stack[kMaxMethodStackSize];
- symbol_type *current_method_sym;
- };
-
- TraceReader();
- ~TraceReader();
-
- void ReadKernelSymbols(const char *kernel_file);
- void CopyKernelRegion(ProcessState *pstate);
- void ClearRegions(ProcessState *pstate);
- void CopyRegions(ProcessState *parent, ProcessState *child);
- void DumpRegions(FILE *stream, ProcessState *pstate);
- symbol_type *LookupFunction(int pid, uint32_t addr, uint64_t time);
- symbol_type *GetSymbols(int *num_syms);
- ProcessState *GetCurrentProcess() { return current_; }
- ProcessState *GetProcesses(int *num_procs);
- ProcessState *GetNextProcess();
- const char *GetProcessName(int pid);
- void SetRoot(const char *root) { root_ = root; }
- void SetDemangle(bool demangle) { demangle_ = demangle; }
- bool ReadMethodSymbol(MethodRec *method_record,
- symbol_type **psym,
- ProcessState **pproc);
-
- protected:
- virtual int FindCurrentPid(uint64_t time);
-
- private:
-
- static const int kNumPids = 32768;
- static const uint32_t kIncludeLocalSymbols = 0x1;
-
- void AddPredefinedRegion(region_type *region, const char *path,
- uint32_t vstart, uint32_t vend,
- uint32_t base);
- void InitRegionSymbols(region_type *region, int nsymbols);
- void AddRegionSymbol(region_type *region, int idx,
- uint32_t addr, const char *name,
- uint32_t flags);
- void AddPredefinedRegions(ProcessState *pstate);
- void demangle_names(int nfuncs, symbol_type *functions);
- bool ReadElfSymbols(region_type *region, uint32_t flags);
- void AddRegion(ProcessState *pstate, region_type *region);
- region_type *FindRegion(uint32_t addr, int nregions,
- region_type **regions);
- int FindRegionIndex(uint32_t addr, int nregions,
- region_type **regions);
- void FindAndRemoveRegion(ProcessState *pstate,
- uint32_t vstart, uint32_t vend);
- symbol_type *FindFunction(uint32_t addr, int nsyms,
- symbol_type *symbols, bool exact_match);
- symbol_type *FindCurrentMethod(int pid, uint64_t time);
- void PopulateSymbolsFromDexFile(const DexFileList *dexfile,
- region_type *region);
- void HandlePidEvent(PidEvent *event);
- void HandleMethodRecord(ProcessState *pstate,
- MethodRec *method_rec);
-
- int cached_pid_;
- symbol_type *cached_func_;
- symbol_type unknown_;
- int next_pid_;
-
- PidEvent next_pid_event_;
- ProcessState *processes_[kNumPids];
- ProcessState *current_;
- MethodRec next_method_;
- uint64_t function_start_time_;
- const char *root_;
- HashTable<region_type*> *hash_;
- bool demangle_;
-};
-
-template<class T>
-TraceReader<T>::TraceReader()
-{
- static PidEvent event_no_action;
-
- cached_pid_ = -1;
- cached_func_ = NULL;
-
- memset(&unknown_, 0, sizeof(symbol_type));
- unknown_.name = "(unknown)";
- next_pid_ = 0;
-
- memset(&event_no_action, 0, sizeof(PidEvent));
- event_no_action.rec_type = kPidNoAction;
- next_pid_event_ = event_no_action;
- for (int ii = 1; ii < kNumPids; ++ii)
- processes_[ii] = NULL;
- current_ = new ProcessState;
- processes_[0] = current_;
- next_method_.time = 0;
- next_method_.addr = 0;
- next_method_.flags = 0;
- function_start_time_ = 0;
- root_ = "";
- hash_ = new HashTable<region_type*>(512);
- AddPredefinedRegions(current_);
- demangle_ = true;
-}
-
-template<class T>
-TraceReader<T>::~TraceReader()
-{
- hash_entry_type *ptr;
- for (ptr = hash_->GetFirst(); ptr; ptr = hash_->GetNext()) {
- region_type *region = ptr->value;
- // If the symbols are not shared with another region, then delete them.
- if ((region->flags & region_type::kSharedSymbols) == 0) {
- int nsymbols = region->nsymbols;
- for (int ii = 0; ii < nsymbols; ii++) {
- delete[] region->symbols[ii].name;
- }
- delete[] region->symbols;
- }
- delete[] region->path;
-
- // Do not delete the region itself here. Each region
- // is reference-counted and deleted by the ProcessState
- // object that owns it.
- }
- delete hash_;
-
- // Delete the ProcessState objects after the region symbols in
- // the hash table above so that we still have valid region pointers
- // when deleting the region symbols.
- for (int ii = 0; ii < kNumPids; ++ii) {
- delete processes_[ii];
- }
-}
-
-// This function is used by the qsort() routine to sort symbols
-// into increasing address order.
-template<class T>
-int cmp_symbol_addr(const void *a, const void *b) {
- typedef typename TraceReader<T>::symbol_type stype;
-
- const stype *syma = static_cast<stype const *>(a);
- const stype *symb = static_cast<stype const *>(b);
- uint32_t addr1 = syma->addr;
- uint32_t addr2 = symb->addr;
- if (addr1 < addr2)
- return -1;
- if (addr1 > addr2)
- return 1;
-
- // The addresses are the same, sort the symbols into
- // increasing alphabetical order. But put symbols that
- // that start with "_" last.
- if (syma->name[0] == '_' || symb->name[0] == '_') {
- // Count the number of leading underscores and sort the
- // symbol with the most underscores last.
- int aCount = 0;
- while (syma->name[aCount] == '_')
- aCount += 1;
- int bCount = 0;
- while (symb->name[bCount] == '_')
- bCount += 1;
- if (aCount < bCount) {
- return -1;
- }
- if (aCount > bCount) {
- return 1;
- }
- // If the symbols have the same number of underscores, then
- // fall through and sort by the whole name.
- }
- return strcmp(syma->name, symb->name);
-}
-
-// This function is used by the qsort() routine to sort region entries
-// into increasing address order.
-template<class T>
-int cmp_region_addr(const void *a, const void *b) {
- typedef typename TraceReader<T>::region_type rtype;
-
- const rtype *ma = *static_cast<rtype* const *>(a);
- const rtype *mb = *static_cast<rtype* const *>(b);
- uint32_t addr1 = ma->vstart;
- uint32_t addr2 = mb->vstart;
- if (addr1 < addr2)
- return -1;
- if (addr1 == addr2)
- return 0;
- return 1;
-}
-
-// This routine returns a new array containing all the symbols.
-template<class T>
-typename TraceReader<T>::symbol_type*
-TraceReader<T>::GetSymbols(int *num_syms)
-{
- // Count the symbols
- int nsyms = 0;
- for (hash_entry_type *ptr = hash_->GetFirst(); ptr; ptr = hash_->GetNext()) {
- region_type *region = ptr->value;
- nsyms += region->nsymbols;
- }
- *num_syms = nsyms;
-
- // Allocate space
- symbol_type *syms = new symbol_type[nsyms];
- symbol_type *next_sym = syms;
-
- // Copy the symbols
- for (hash_entry_type *ptr = hash_->GetFirst(); ptr; ptr = hash_->GetNext()) {
- region_type *region = ptr->value;
- memcpy(next_sym, region->symbols, region->nsymbols * sizeof(symbol_type));
- next_sym += region->nsymbols;
- }
-
- return syms;
-}
-
-// This routine returns all the valid processes.
-template<class T>
-typename TraceReader<T>::ProcessState*
-TraceReader<T>::GetProcesses(int *num_procs)
-{
- // Count the valid processes
- int nprocs = 0;
- for (int ii = 0; ii < kNumPids; ++ii) {
- if (processes_[ii])
- nprocs += 1;
- }
-
- // Allocate a new array to hold the valid processes.
- ProcessState *procs = new ProcessState[nprocs];
-
- // Copy the processes to the new array.
- ProcessState *pstate = procs;
- for (int ii = 0; ii < kNumPids; ++ii) {
- if (processes_[ii])
- memcpy(pstate++, processes_[ii], sizeof(ProcessState));
- }
-
- *num_procs = nprocs;
- return procs;
-}
-
-// This routine returns the next valid process, or NULL if there are no
-// more valid processes.
-template<class T>
-typename TraceReader<T>::ProcessState*
-TraceReader<T>::GetNextProcess()
-{
- while (next_pid_ < kNumPids) {
- if (processes_[next_pid_])
- return processes_[next_pid_++];
- next_pid_ += 1;
- }
- next_pid_ = 0;
- return NULL;
-}
-
-template<class T>
-const char* TraceReader<T>::GetProcessName(int pid)
-{
- if (pid < 0 || pid >= kNumPids || processes_[pid] == NULL)
- return "(unknown)";
- return processes_[pid]->name;
-}
-
-template<class T>
-void TraceReader<T>::AddPredefinedRegion(region_type *region, const char *path,
- uint32_t vstart, uint32_t vend,
- uint32_t base)
-{
- // Copy the path to make it easy to delete later.
- int len = strlen(path);
- region->path = new char[len + 1];
- strcpy(region->path, path);
- region->vstart = vstart;
- region->vend = vend;
- region->base_addr = base;
- region->flags = region_type::kIsKernelRegion;
-}
-
-template<class T>
-void TraceReader<T>::InitRegionSymbols(region_type *region, int nsymbols)
-{
- region->nsymbols = nsymbols;
- region->symbols = new symbol_type[nsymbols];
- memset(region->symbols, 0, nsymbols * sizeof(symbol_type));
-}
-
-template<class T>
-void TraceReader<T>::AddRegionSymbol(region_type *region, int idx,
- uint32_t addr, const char *name,
- uint32_t flags)
-{
- region->symbols[idx].addr = addr;
- region->symbols[idx].name = Strdup(name);
- region->symbols[idx].vm_sym = NULL;
- region->symbols[idx].region = region;
- region->symbols[idx].flags = flags;
-}
-
-template<class T>
-void TraceReader<T>::AddPredefinedRegions(ProcessState *pstate)
-{
- region_type *region = new region_type;
- AddPredefinedRegion(region, "(bootloader)", 0, 0x14, 0);
- InitRegionSymbols(region, 2);
- AddRegionSymbol(region, 0, 0, "(bootloader_start)", 0);
- AddRegionSymbol(region, 1, 0x14, "(bootloader_end)", 0);
- AddRegion(pstate, region);
- hash_->Update(region->path, region);
-
- region = new region_type;
- AddPredefinedRegion(region, "(exception vectors)", 0xffff0000, 0xffff0500,
- 0xffff0000);
- InitRegionSymbols(region, 2);
- AddRegionSymbol(region, 0, 0x0, "(vector_start)",
- symbol_type::kIsVectorStart);
- AddRegionSymbol(region, 1, 0x500, "(vector_end)", 0);
- AddRegion(pstate, region);
- hash_->Update(region->path, region);
-
- region = new region_type;
- AddPredefinedRegion(region, "(atomic ops)", 0xffff0f80, 0xffff1000,
- 0xffff0f80);
- // Mark this region as also being mapped in user-space.
- // This isn't used anywhere in this code but client code can test for
- // this flag and decide whether to treat this as kernel or user code.
- region->flags |= region_type::kIsUserMappedRegion;
-
- InitRegionSymbols(region, 4);
- AddRegionSymbol(region, 0, 0x0, "(kuser_atomic_inc)", 0);
- AddRegionSymbol(region, 1, 0x20, "(kuser_atomic_dec)", 0);
- AddRegionSymbol(region, 2, 0x40, "(kuser_cmpxchg)", 0);
- AddRegionSymbol(region, 3, 0x80, "(kuser_end)", 0);
- AddRegion(pstate, region);
- hash_->Update(region->path, region);
-}
-
-template<class T>
-void TraceReader<T>::ReadKernelSymbols(const char *kernel_file)
-{
- region_type *region = new region_type;
- // Copy the path to make it easy to delete later.
- int len = strlen(kernel_file);
- region->path = new char[len + 1];
- strcpy(region->path, kernel_file);
- region->flags = region_type::kIsKernelRegion;
- ReadElfSymbols(region, kIncludeLocalSymbols);
- region->vend = 0xffff0000;
- AddRegion(processes_[0], region);
- processes_[0]->flags |= ProcessState::kHasKernelRegion;
- hash_->Update(region->path, region);
-}
-
-template<class T>
-void TraceReader<T>::demangle_names(int nfuncs, symbol_type *functions)
-{
- char *demangled;
- int status;
-
- for (int ii = 0; ii < nfuncs; ++ii) {
- demangled = NULL;
- int len = strlen(functions[ii].name);
-
- // If we don't check for "len > 1" then the demangler will incorrectly
- // expand 1-letter function names. For example, "b" becomes "bool",
- // "c" becomes "char" and "d" becomes "double". Also check that the
- // first character is an underscore. Otherwise, on some strings
- // the demangler will try to read past the end of the string (because
- // the string is not really a C++ mangled name) and valgrind will
- // complain.
- if (demangle_ && len > 1 && functions[ii].name[0] == '_') {
- demangled = abi::__cxa_demangle(functions[ii].name, 0, NULL,
- &status);
- }
-
- if (demangled != NULL) {
- delete[] functions[ii].name;
- functions[ii].name = Strdup(demangled);
- free(demangled);
- }
- }
-}
-
-// Adds the symbols from the given ELF file to the given process.
-// Returns false if the file was not an ELF file or if there was an
-// error trying to read the sections of the ELF file.
-template<class T>
-bool TraceReader<T>::ReadElfSymbols(region_type *region, uint32_t flags)
-{
- static char full_path[4096];
- Elf32_Shdr *symtab, *symstr;
- Elf32_Ehdr *hdr;
- Elf32_Shdr *shdr;
-
- full_path[0] = 0;
- if (root_ && strcmp(root_, "/")) {
- strcpy(full_path, root_);
- }
- strcat(full_path, region->path);
- FILE *fobj = fopen(full_path, "r");
- if(fobj == NULL) {
- EmptyRegion:
- // we need to create an (unknown) symbol with address 0, otherwise some
- // other parts of the trace reader will simply crash when dealing with
- // an empty region
- region->vstart = 0;
- region->nsymbols = 1;
- region->symbols = new symbol_type[1];
- memset(region->symbols, 0, sizeof(symbol_type));
-
- region->symbols[0].addr = 0;
- region->symbols[0].name = Strdup("(unknown)");
- region->symbols[0].vm_sym = NULL;
- region->symbols[0].region = region;
- region->symbols[0].flags = 0;
-
- if (fobj != NULL)
- fclose(fobj);
- return false;
- }
-
- hdr = ReadElfHeader(fobj);
- if (hdr == NULL) {
- fprintf(stderr, "Cannot read ELF header from '%s'\n", full_path);
- goto EmptyRegion;
- }
-
- shdr = ReadSectionHeaders(hdr, fobj);
- if(shdr == NULL) {
- fprintf(stderr, "Can't read section headers from executable\n");
- goto EmptyRegion;
- }
- char *section_names = ReadStringTable(hdr, shdr, fobj);
-
- // Get the symbol table section
- symtab = FindSymbolTableSection(hdr, shdr, section_names);
- if (symtab == NULL || symtab->sh_size == 0) {
- fprintf(stderr, "Can't read symbol table from '%s'\n", full_path);
- goto EmptyRegion;
- }
-
- // Get the symbol string table section
- symstr = FindSymbolStringTableSection(hdr, shdr, section_names);
- if (symstr == NULL || symstr->sh_size == 0) {
- fprintf(stderr, "Can't read symbol string table from '%s'\n", full_path);
- goto EmptyRegion;
- }
-
- // Load the symbol string table data
- char *symbol_names = new char[symstr->sh_size];
- ReadSection(symstr, symbol_names, fobj);
-
- int num_entries = symtab->sh_size / symtab->sh_entsize;
- Elf32_Sym *elf_symbols = new Elf32_Sym[num_entries];
- ReadSection(symtab, elf_symbols, fobj);
- AdjustElfSymbols(hdr, elf_symbols, num_entries);
-#if 0
- printf("size: %d, ent_size: %d, num_entries: %d\n",
- symtab->sh_size, symtab->sh_entsize, num_entries);
-#endif
- int nfuncs = 0;
-
- // Allocate space for all of the symbols for now. We will
- // reallocate space for just the function symbols after we
- // know how many there are. Also, make sure there is room
- // for some extra symbols, including the text section names.
- int num_alloc = num_entries + hdr->e_shnum + 1;
- symbol_type *func_symbols = new symbol_type[num_alloc];
- memset(func_symbols, 0, num_alloc * sizeof(symbol_type));
-
- // If this is the shared library for a virtual machine, then
- // set the IsInterpreter flag for all symbols in that shared library.
- // This will allow us to replace the symbol names with the name of
- // the currently executing method on the virtual machine.
- int symbol_flags = 0;
- char *cp = strrchr(region->path, '/');
- if (cp != NULL) {
- // Move past the '/'
- cp += 1;
- } else {
- // There was no '/', so use the whole path
- cp = region->path;
- }
- if (strcmp(cp, "libdvm.so") == 0) {
- symbol_flags = symbol_type::kIsInterpreter;
- }
-
- bool zero_found = false;
- for (int ii = 1; ii < num_entries; ++ii) {
- int idx = elf_symbols[ii].st_name;
-
- // If the symbol does not have a name, or if the name starts with a
- // dollar sign ($), then skip it.
- if (idx == 0 || symbol_names[idx] == 0 || symbol_names[idx] == '$')
- continue;
-
- // If the section index is not executable, then skip it.
- uint32_t section = elf_symbols[ii].st_shndx;
- if (section == 0 || section >= hdr->e_shnum)
- continue;
- if ((shdr[section].sh_flags & SHF_EXECINSTR) == 0)
- continue;
-
- uint8_t sym_type = ELF32_ST_TYPE(elf_symbols[ii].st_info);
- uint8_t sym_bind = ELF32_ST_BIND(elf_symbols[ii].st_info);
-
- // Allow the caller to decide if we want local non-function
- // symbols to be included. We currently include these symbols
- // only for the kernel, where it is useful because the kernel
- // has lots of assembly language labels that have meaningful names.
- if ((flags & kIncludeLocalSymbols) == 0 && sym_bind == STB_LOCAL
- && sym_type != STT_FUNC) {
- continue;
- }
-#if 0
- printf("%08x %x %x %s\n",
- elf_symbols[ii].st_value,
- sym_bind,
- sym_type,
- &symbol_names[idx]);
-#endif
- if (sym_type != STT_FUNC && sym_type != STT_NOTYPE)
- continue;
-
- if (elf_symbols[ii].st_value == 0)
- zero_found = true;
-
- // The address of thumb functions seem to have the low bit set,
- // even though the instructions are really at an even address.
- uint32_t addr = elf_symbols[ii].st_value & ~0x1;
- func_symbols[nfuncs].addr = addr;
- func_symbols[nfuncs].name = Strdup(&symbol_names[idx]);
- func_symbols[nfuncs].flags = symbol_flags;
-
- nfuncs += 1;
- }
-
- // Add a [0, "(unknown)"] symbol pair if there is not already a
- // symbol with the address zero. We don't need to reallocate space
- // because we already have more than we need.
- if (!zero_found) {
- func_symbols[nfuncs].addr = 0;
- func_symbols[nfuncs].name = Strdup("(0 unknown)");
- nfuncs += 1;
- }
-
- // Add another entry at the end
- func_symbols[nfuncs].addr = 0xffffffff;
- func_symbols[nfuncs].name = Strdup("(end)");
- nfuncs += 1;
-
- // Add in the names of the text sections, but only if there
- // are no symbols with that address already.
- for (int section = 0; section < hdr->e_shnum; ++section) {
- if ((shdr[section].sh_flags & SHF_EXECINSTR) == 0)
- continue;
-
- uint32_t addr = shdr[section].sh_addr;
- // Search for a symbol with a matching address. The symbols aren't
- // sorted yet so we just search the whole list.
- int ii;
- for (ii = 0; ii < nfuncs; ++ii) {
- if (addr == func_symbols[ii].addr)
- break;
- }
- if (ii == nfuncs) {
- // Symbol at address "addr" does not exist, so add the text
- // section name. This will usually add the ".plt" section
- // (procedure linkage table).
- int idx = shdr[section].sh_name;
- func_symbols[nfuncs].addr = addr;
- func_symbols[nfuncs].name = Strdup(&section_names[idx]);
- if (strcmp(func_symbols[nfuncs].name, ".plt") == 0) {
- func_symbols[nfuncs].flags |= symbol_type::kIsPlt;
- // Change the name of the symbol to include the
- // name of the library. Otherwise we will have lots
- // of ".plt" symbols.
- int len = strlen(region->path);
- len += strlen(":.plt");
- char *name = new char[len + 1];
- strcpy(name, region->path);
- strcat(name, ":.plt");
- delete[] func_symbols[nfuncs].name;
- func_symbols[nfuncs].name = name;
-
- // Check if this is part of the virtual machine interpreter
- char *cp = strrchr(region->path, '/');
- if (cp != NULL) {
- // Move past the '/'
- cp += 1;
- } else {
- // There was no '/', so use the whole path
- cp = region->path;
- }
- if (strcmp(cp, "libdvm.so") == 0) {
- func_symbols[nfuncs].flags |= symbol_type::kIsInterpreter;
- }
- }
- nfuncs += 1;
- }
- }
-
- // Allocate just the space we need now that we know exactly
- // how many symbols we have.
- symbol_type *functions = new symbol_type[nfuncs];
-
- // Copy the symbols to the functions array
- memcpy(functions, func_symbols, nfuncs * sizeof(symbol_type));
- delete[] func_symbols;
-
- // Assign the region pointers
- for (int ii = 0; ii < nfuncs; ++ii) {
- functions[ii].region = region;
- }
-
- // Sort the symbols into increasing address order
- qsort(functions, nfuncs, sizeof(symbol_type), cmp_symbol_addr<T>);
-
- // If there are multiple symbols with the same address, then remove
- // the duplicates. First, count the number of duplicates.
- uint32_t prev_addr = ~0;
- int num_duplicates = 0;
- for (int ii = 0; ii < nfuncs; ++ii) {
- if (prev_addr == functions[ii].addr)
- num_duplicates += 1;
- prev_addr = functions[ii].addr;
- }
-
- if (num_duplicates > 0) {
- int num_uniq = nfuncs - num_duplicates;
-
- // Allocate space for the unique functions
- symbol_type *uniq_functions = new symbol_type[num_uniq];
-
- // Copy the unique functions
- prev_addr = ~0;
- int next_uniq = 0;
- for (int ii = 0; ii < nfuncs; ++ii) {
- if (prev_addr == functions[ii].addr) {
- delete[] functions[ii].name;
- continue;
- }
- memcpy(&uniq_functions[next_uniq++], &functions[ii],
- sizeof(symbol_type));
- prev_addr = functions[ii].addr;
- }
- assert(next_uniq == num_uniq);
-
- delete[] functions;
- functions = uniq_functions;
- nfuncs = num_uniq;
- }
-
- // Finally, demangle all of the symbol names
- demangle_names(nfuncs, functions);
-
- uint32_t min_addr = 0;
- if (!zero_found)
- min_addr = functions[1].addr;
- if (region->vstart == 0)
- region->vstart = min_addr;
- region->nsymbols = nfuncs;
- region->symbols = functions;
-
-#if 0
- printf("%s num symbols: %d min_addr: 0x%x\n", region->path, nfuncs, min_addr);
- for (int ii = 0; ii < nfuncs; ++ii) {
- printf("0x%08x %s\n", functions[ii].addr, functions[ii].name);
- }
-#endif
- delete[] elf_symbols;
- delete[] symbol_names;
- delete[] section_names;
- delete[] shdr;
- delete hdr;
- fclose(fobj);
-
- return true;
-}
-
-template<class T>
-void TraceReader<T>::CopyKernelRegion(ProcessState *pstate)
-{
- ProcessState *manager = pstate->addr_manager;
- if (manager->flags & ProcessState::kHasKernelRegion)
- return;
-
- int nregions = processes_[0]->nregions;
- region_type **regions = processes_[0]->regions;
- for (int ii = 0; ii < nregions; ii++) {
- if (regions[ii]->flags & region_type::kIsKernelRegion) {
- AddRegion(manager, regions[ii]);
- regions[ii]->refs += 1;
- }
- }
- manager->flags |= ProcessState::kHasKernelRegion;
-}
-
-template<class T>
-void TraceReader<T>::ClearRegions(ProcessState *pstate)
-{
- assert(pstate->pid != 0);
- int nregions = pstate->nregions;
- region_type **regions = pstate->regions;
-
- // Decrement the reference count on all the regions
- for (int ii = 0; ii < nregions; ii++) {
- if (regions[ii]->refs > 0) {
- regions[ii]->refs -= 1;
- continue;
- }
-
- delete regions[ii];
- }
- delete[] pstate->regions;
- pstate->regions = NULL;
- pstate->nregions = 0;
- pstate->max_regions = 0;
- pstate->addr_manager = pstate;
- pstate->flags &= ~ProcessState::kIsClone;
- pstate->flags &= ~ProcessState::kHasKernelRegion;
- CopyKernelRegion(pstate);
-}
-
-template<class T>
-void TraceReader<T>::AddRegion(ProcessState *pstate, region_type *region)
-{
- ProcessState *manager = pstate->addr_manager;
- if (manager->regions == NULL) {
- manager->max_regions = ProcessState::kInitialNumRegions;
- manager->regions = new region_type*[manager->max_regions];
- manager->nregions = 0;
- }
-
- // Check if we need to grow the array
- int nregions = manager->nregions;
- int max_regions = manager->max_regions;
- if (nregions >= max_regions) {
- max_regions <<= 1;
- manager->max_regions = max_regions;
- region_type **regions = new region_type*[max_regions];
- for (int ii = 0; ii < nregions; ii++) {
- regions[ii] = manager->regions[ii];
- }
- delete[] manager->regions;
- manager->regions = regions;
- }
-
- // Add the new region to the end of the array and resort
- manager->regions[nregions] = region;
- nregions += 1;
- manager->nregions = nregions;
-
- // Resort the regions into increasing start address
- qsort(manager->regions, nregions, sizeof(region_type*), cmp_region_addr<T>);
-}
-
-template<class T>
-void TraceReader<T>::FindAndRemoveRegion(ProcessState *pstate, uint32_t vstart,
- uint32_t vend)
-{
- ProcessState *manager = pstate->addr_manager;
- int nregions = manager->nregions;
- int index = FindRegionIndex(vstart, nregions, manager->regions);
- region_type *region = manager->regions[index];
-
- // If the region does not contain [vstart,vend], then return.
- if (vstart < region->vstart || vend > region->vend)
- return;
-
- // If the existing region exactly matches the address range [vstart,vend]
- // then remove the whole region.
- if (vstart == region->vstart && vend == region->vend) {
- // The regions are reference-counted.
- if (region->refs == 0) {
- // Free the region
- hash_->Remove(region->path);
- delete region;
- } else {
- region->refs -= 1;
- }
-
- if (nregions > 1) {
- // Assign the region at the end of the array to this empty slot
- manager->regions[index] = manager->regions[nregions - 1];
-
- // Resort the regions into increasing start address
- qsort(manager->regions, nregions - 1, sizeof(region_type*),
- cmp_region_addr<T>);
- }
- manager->nregions = nregions - 1;
- return;
- }
-
- // If the existing region contains the given range and ends at the
- // end of the given range (a common case for some reason), then
- // truncate the existing region so that it ends at vstart (because
- // we are deleting the range [vstart,vend]).
- if (vstart > region->vstart && vend == region->vend) {
- region_type *truncated;
-
- if (region->refs == 0) {
- // This region is not shared, so truncate it directly
- truncated = region;
- } else {
- // This region is shared, so make a copy that we can truncate
- region->refs -= 1;
- truncated = region->MakePrivateCopy(new region_type);
- }
- truncated->vend = vstart;
- manager->regions[index] = truncated;
- }
-}
-
-template<class T>
-void TraceReader<T>::CopyRegions(ProcessState *parent, ProcessState *child)
-{
- // Copy the parent's address space
- ProcessState *manager = parent->addr_manager;
- int nregions = manager->nregions;
- child->nregions = nregions;
- child->max_regions = manager->max_regions;
- region_type **regions = new region_type*[manager->max_regions];
- child->regions = regions;
- memcpy(regions, manager->regions, nregions * sizeof(region_type*));
-
- // Increment the reference count on all the regions
- for (int ii = 0; ii < nregions; ii++) {
- regions[ii]->refs += 1;
- }
-}
-
-template<class T>
-void TraceReader<T>::DumpRegions(FILE *stream, ProcessState *pstate) {
- ProcessState *manager = pstate->addr_manager;
- for (int ii = 0; ii < manager->nregions; ++ii) {
- fprintf(stream, " %08x - %08x offset: %5x nsyms: %4d refs: %d %s\n",
- manager->regions[ii]->vstart,
- manager->regions[ii]->vend,
- manager->regions[ii]->file_offset,
- manager->regions[ii]->nsymbols,
- manager->regions[ii]->refs,
- manager->regions[ii]->path);
- }
-}
-
-template<class T>
-typename TraceReader<T>::region_type *
-TraceReader<T>::FindRegion(uint32_t addr, int nregions, region_type **regions)
-{
- int high = nregions;
- int low = -1;
- while (low + 1 < high) {
- int middle = (high + low) / 2;
- uint32_t middle_addr = regions[middle]->vstart;
- if (middle_addr == addr)
- return regions[middle];
- if (middle_addr > addr)
- high = middle;
- else
- low = middle;
- }
-
- // If we get here then we did not find an exact address match. So use
- // the closest region address that is less than the given address.
- if (low < 0)
- low = 0;
- return regions[low];
-}
-
-template<class T>
-int TraceReader<T>::FindRegionIndex(uint32_t addr, int nregions,
- region_type **regions)
-{
- int high = nregions;
- int low = -1;
- while (low + 1 < high) {
- int middle = (high + low) / 2;
- uint32_t middle_addr = regions[middle]->vstart;
- if (middle_addr == addr)
- return middle;
- if (middle_addr > addr)
- high = middle;
- else
- low = middle;
- }
-
- // If we get here then we did not find an exact address match. So use
- // the closest region address that is less than the given address.
- if (low < 0)
- low = 0;
- return low;
-}
-
-template<class T>
-typename TraceReader<T>::symbol_type *
-TraceReader<T>::FindFunction(uint32_t addr, int nsyms, symbol_type *symbols,
- bool exact_match)
-{
- int high = nsyms;
- int low = -1;
- while (low + 1 < high) {
- int middle = (high + low) / 2;
- uint32_t middle_addr = symbols[middle].addr;
- if (middle_addr == addr)
- return &symbols[middle];
- if (middle_addr > addr)
- high = middle;
- else
- low = middle;
- }
-
- // If we get here then we did not find an exact address match. So use
- // the closest function address that is less than the given address.
- // We added a symbol with address zero so if there is no known
- // function containing the given address, then we will return the
- // "(unknown)" symbol.
- if (low >= 0 && !exact_match)
- return &symbols[low];
- return NULL;
-}
-
-template<class T>
-typename TraceReader<T>::symbol_type *
-TraceReader<T>::LookupFunction(int pid, uint32_t addr, uint64_t time)
-{
- // Check if the previous match is still a good match.
- if (cached_pid_ == pid) {
- uint32_t vstart = cached_func_->region->vstart;
- uint32_t vend = cached_func_->region->vend;
- if (addr >= vstart && addr < vend) {
- uint32_t sym_addr = addr - cached_func_->region->base_addr;
- if (sym_addr >= cached_func_->addr
- && sym_addr < (cached_func_ + 1)->addr) {
-
- // Check if there is a Java method on the method trace.
- symbol_type *sym = FindCurrentMethod(pid, time);
- if (sym != NULL) {
- sym->vm_sym = cached_func_;
- return sym;
- }
- return cached_func_;
- }
- }
- }
-
- ProcessState *pstate = processes_[pid];
- if (pstate == NULL) {
- // There is no process state for the specified pid.
- // This should never happen.
- cached_pid_ = -1;
- cached_func_ = NULL;
- return NULL;
- }
- ProcessState *manager = pstate->addr_manager;
- cached_pid_ = pid;
- region_type *region = FindRegion(addr, manager->nregions, manager->regions);
- uint32_t sym_addr = addr - region->base_addr;
-
- cached_func_ = FindFunction(sym_addr, region->nsymbols, region->symbols,
- false /* no exact match */);
- if (cached_func_ != NULL) {
- cached_func_->region = region;
-
- // Check if there is a Java method on the method trace.
- symbol_type *sym = FindCurrentMethod(pid, time);
- if (sym != NULL) {
- sym->vm_sym = cached_func_;
- return sym;
- }
- }
-
- return cached_func_;
-}
-
-template <class T>
-void TraceReader<T>::HandlePidEvent(PidEvent *event)
-{
- switch (event->rec_type) {
- case kPidFork:
- case kPidClone:
- // event->pid is the process id of the child
- if (event->pid >= kNumPids) {
- fprintf(stderr, "Error: pid (%d) too large\n", event->pid);
- exit(1);
- }
- // Create a new ProcessState struct for the child
- // and link it in at the front of the list for that
- // pid.
- {
- ProcessState *child = new ProcessState;
- processes_[event->pid] = child;
- child->pid = event->pid;
- child->tgid = event->tgid;
-
- // Link the new child at the front of the list (only needed if
- // pids wrap around, which will probably never happen when
- // tracing because it would take so long).
- child->next = processes_[event->pid];
- child->parent_pid = current_->pid;
- child->parent = current_;
- child->start_time = event->time;
- child->name = Strdup(current_->name);
- if (event->rec_type == kPidFork) {
- CopyRegions(current_, child);
- } else {
- // Share the parent's address space
- child->flags |= ProcessState::kIsClone;
-
- // The address space manager for the clone is the same
- // as the address space manager for the parent. This works
- // even if the child later clones itself.
- child->addr_manager = current_->addr_manager;
- }
- }
- break;
- case kPidSwitch:
- // event->pid is the process id of the process we are
- // switching to.
- {
- uint64_t elapsed = event->time - function_start_time_;
- function_start_time_ = event->time;
- current_->cpu_time += elapsed;
- }
- if (current_->flags & ProcessState::kCalledExit)
- current_->end_time = event->time;
-
- if (event->pid >= kNumPids) {
- fprintf(stderr, "Error: pid (%d) too large\n", event->pid);
- exit(1);
- }
-
- // If the process we are switching to does not exist, then
- // create one. This can happen because the tracing code does
- // not start tracing from the very beginning of the kernel.
- current_ = processes_[event->pid];
- if (current_ == NULL) {
- current_ = new ProcessState;
- processes_[event->pid] = current_;
- current_->pid = event->pid;
- current_->start_time = event->time;
- CopyKernelRegion(current_);
- }
-#if 0
- {
- printf("switching to p%d\n", current_->pid);
- ProcessState *manager = current_->addr_manager;
- for (int ii = 0; ii < manager->nregions; ++ii) {
- printf(" %08x - %08x offset: %d nsyms: %4d %s\n",
- manager->regions[ii]->vstart,
- manager->regions[ii]->vend,
- manager->regions[ii]->file_offset,
- manager->regions[ii]->nsymbols,
- manager->regions[ii]->path);
- }
- }
-#endif
- break;
- case kPidExit:
- current_->exit_val = event->pid;
- current_->flags |= ProcessState::kCalledExit;
- break;
- case kPidMunmap:
- FindAndRemoveRegion(current_, event->vstart, event->vend);
- break;
- case kPidMmap:
- {
- region_type *region;
- region_type *existing_region = hash_->Find(event->path);
- if (existing_region == NULL
- || existing_region->vstart != event->vstart
- || existing_region->vend != event->vend
- || existing_region->file_offset != event->offset) {
- // Create a new region and add it to the current process'
- // address space.
- region = new region_type;
-
- // The event->path is allocated by ReadPidEvent() and owned
- // by us.
- region->path = event->path;
- region->vstart = event->vstart;
- region->vend = event->vend;
- region->file_offset = event->offset;
- if (existing_region == NULL) {
- DexFileList *dexfile = dex_hash_->Find(event->path);
- if (dexfile != NULL) {
- PopulateSymbolsFromDexFile(dexfile, region);
- } else {
- ReadElfSymbols(region, 0);
- }
- hash_->Update(region->path, region);
- } else {
- region->nsymbols = existing_region->nsymbols;
- region->symbols = existing_region->symbols;
- region->flags |= region_type::kSharedSymbols;
- }
-
- // The base_addr is subtracted from an address before the
- // symbol name lookup and is either zero or event->vstart.
- // HACK: Determine if base_addr is non-zero by looking at the
- // second symbol address (skip the first symbol because that is
- // the special symbol "(unknown)" with an address of zero).
- if (region->nsymbols > 2 && region->symbols[1].addr < event->vstart)
- region->base_addr = event->vstart;
-
- // Treat all mmapped regions after the first as "libraries".
- // Profiling tools can test for this property.
- if (current_->flags & ProcessState::kHasFirstMmap)
- region->flags |= region_type::kIsLibraryRegion;
- else
- current_->flags |= ProcessState::kHasFirstMmap;
-#if 0
- printf("%s vstart: 0x%x vend: 0x%x offset: 0x%x\n",
- region->path, region->vstart, region->vend, region->file_offset);
-#endif
- } else {
- region = existing_region;
- region->refs += 1;
- delete[] event->path;
- }
- AddRegion(current_, region);
- }
- break;
- case kPidExec:
- if (current_->argc > 0) {
- for (int ii = 0; ii < current_->argc; ii++) {
- delete[] current_->argv[ii];
- }
- delete[] current_->argv;
- }
- delete[] current_->name;
-
- current_->argc = event->argc;
- current_->argv = event->argv;
- current_->name = Strdup(current_->argv[0]);
- current_->flags |= ProcessState::kCalledExec;
- ClearRegions(current_);
- break;
- case kPidName:
- case kPidKthreadName:
- {
- ProcessState *pstate = processes_[event->pid];
- if (pstate == NULL) {
- pstate = new ProcessState;
- if (event->rec_type == kPidKthreadName) {
- pstate->tgid = event->tgid;
- }
- pstate->pid = event->pid;
- pstate->start_time = event->time;
- processes_[event->pid] = pstate;
- CopyKernelRegion(pstate);
- } else {
- delete[] pstate->name;
- }
- pstate->name = event->path;
- }
- break;
- case kPidNoAction:
- break;
- case kPidSymbolAdd:
- delete[] event->path;
- break;
- case kPidSymbolRemove:
- break;
- }
-}
-
-// Finds the current pid for the given time. This routine reads the pid
-// trace file and assumes that the "time" parameter is monotonically
-// increasing.
-template <class T>
-int TraceReader<T>::FindCurrentPid(uint64_t time)
-{
- if (time < next_pid_event_.time)
- return current_->pid;
-
- while (1) {
- HandlePidEvent(&next_pid_event_);
-
- if (internal_pid_reader_->ReadPidEvent(&next_pid_event_)) {
- next_pid_event_.time = ~0ull;
- break;
- }
- if (next_pid_event_.time > time)
- break;
- }
- return current_->pid;
-}
-
-template <class T>
-void TraceReader<T>::ProcessState::DumpStack(FILE *stream)
-{
- const char *native;
- for (int ii = 0; ii < method_stack_top; ii++) {
- native = method_stack[ii].isNative ? "n" : " ";
- fprintf(stream, "%2d: %s 0x%08x\n", ii, native, method_stack[ii].addr);
- }
-}
-
-template <class T>
-void TraceReader<T>::HandleMethodRecord(ProcessState *pstate,
- MethodRec *method_rec)
-{
- uint32_t addr;
- int top = pstate->method_stack_top;
- int flags = method_rec->flags;
- bool isNative;
- if (flags == kMethodEnter || flags == kNativeEnter) {
- // Push this method on the stack
- if (top >= pstate->kMaxMethodStackSize) {
- fprintf(stderr, "Stack overflow at time %llu\n", method_rec->time);
- exit(1);
- }
- pstate->method_stack[top].addr = method_rec->addr;
- isNative = (flags == kNativeEnter);
- pstate->method_stack[top].isNative = isNative;
- pstate->method_stack_top = top + 1;
- addr = method_rec->addr;
- } else {
- if (top <= 0) {
- // If the stack underflows, then set the current method to NULL.
- pstate->current_method_sym = NULL;
- return;
- }
- top -= 1;
- addr = pstate->method_stack[top].addr;
-
- // If this is a non-native method then the address we are popping should
- // match the top-of-stack address. Native pops don't always match the
- // address of the native push for some reason.
- if (addr != method_rec->addr && !pstate->method_stack[top].isNative) {
- fprintf(stderr,
- "Stack method (0x%x) at index %d does not match trace record (0x%x) at time %llu\n",
- addr, top, method_rec->addr, method_rec->time);
- pstate->DumpStack(stderr);
- exit(1);
- }
-
- // If we are popping a native method, then the top-of-stack should also
- // be a native method.
- bool poppingNative = (flags == kNativeExit) || (flags == kNativeException);
- if (poppingNative != pstate->method_stack[top].isNative) {
- fprintf(stderr,
- "Popping native vs. non-native mismatch at index %d time %llu\n",
- top, method_rec->time);
- pstate->DumpStack(stderr);
- exit(1);
- }
-
- pstate->method_stack_top = top;
- if (top == 0) {
- // When we empty the stack, set the current method to NULL
- pstate->current_method_sym = NULL;
- return;
- }
- addr = pstate->method_stack[top - 1].addr;
- isNative = pstate->method_stack[top - 1].isNative;
- }
-
- // If the top-of-stack is a native method, then set the current method
- // to NULL.
- if (isNative) {
- pstate->current_method_sym = NULL;
- return;
- }
-
- ProcessState *manager = pstate->addr_manager;
- region_type *region = FindRegion(addr, manager->nregions, manager->regions);
- uint32_t sym_addr = addr - region->base_addr;
- symbol_type *sym = FindFunction(sym_addr, region->nsymbols,
- region->symbols, true /* exact match */);
-
- pstate->current_method_sym = sym;
- if (sym != NULL) {
- sym->region = region;
- }
-}
-
-// Returns the current top-of-stack Java method, if any, for the given pid
-// at the given time. The "time" parameter must be monotonically increasing
-// across successive calls to this method.
-// If the Java method stack is empty or if a native JNI method is on the
-// top of the stack, then this method returns NULL.
-template <class T>
-typename TraceReader<T>::symbol_type*
-TraceReader<T>::FindCurrentMethod(int pid, uint64_t time)
-{
- ProcessState *procState = processes_[pid];
-
- if (time < next_method_.time) {
- return procState->current_method_sym;
- }
-
- while (1) {
- if (next_method_.time != 0) {
- // We may have to process methods from a different pid so use
- // a local variable here so that we don't overwrite procState.
- ProcessState *pState = processes_[next_method_.pid];
- HandleMethodRecord(pState, &next_method_);
- }
-
- if (internal_method_reader_->ReadMethod(&next_method_)) {
- next_method_.time = ~0ull;
- break;
- }
- if (next_method_.time > time)
- break;
- }
- return procState->current_method_sym;
-}
-
-template <class T>
-void TraceReader<T>::PopulateSymbolsFromDexFile(const DexFileList *dexfile,
- region_type *region)
-
-{
- int nsymbols = dexfile->nsymbols;
- DexSym *dexsyms = dexfile->symbols;
- region->nsymbols = nsymbols + 1;
- symbol_type *symbols = new symbol_type[nsymbols + 1];
- memset(symbols, 0, (nsymbols + 1) * sizeof(symbol_type));
- region->symbols = symbols;
- for (int ii = 0; ii < nsymbols; ii++) {
- symbols[ii].addr = dexsyms[ii].addr;
- symbols[ii].name = Strdup(dexsyms[ii].name);
- symbols[ii].vm_sym = NULL;
- symbols[ii].region = region;
- symbols[ii].flags = symbol_type::kIsMethod;
- }
-
- // Add an entry at the end with an address of 0xffffffff. This
- // is required for LookupFunction() to work.
- symbol_type *symbol = &symbols[nsymbols];
- symbol->addr = 0xffffffff;
- symbol->name = Strdup("(end)");
- symbol->vm_sym = NULL;
- symbol->region = region;
- symbol->flags = symbol_type::kIsMethod;
-}
-
-template <class T>
-bool TraceReader<T>::ReadMethodSymbol(MethodRec *method_record,
- symbol_type **psym,
- ProcessState **pproc)
-{
- if (internal_method_reader_->ReadMethod(&next_method_)) {
- return true;
- }
-
- // Copy the whole MethodRec struct
- *method_record = next_method_;
-
- uint64_t time = next_method_.time;
-
- // Read the pid trace file up to this point to make sure the
- // process state is valid.
- FindCurrentPid(time);
-
- ProcessState *pstate = processes_[next_method_.pid];
- *pproc = pstate;
- HandleMethodRecord(pstate, &next_method_);
- *psym = pstate->current_method_sym;
- return false;
-}
-
-#endif /* TRACE_READER_H */
diff --git a/emulator/qtools/trace_reader_base.h b/emulator/qtools/trace_reader_base.h
deleted file mode 100644
index 416c3d1..0000000
--- a/emulator/qtools/trace_reader_base.h
+++ /dev/null
@@ -1,332 +0,0 @@
-// Copyright 2006 The Android Open Source Project
-
-#ifndef TRACE_READER_BASE_H
-#define TRACE_READER_BASE_H
-
-#include <inttypes.h>
-#include "trace_common.h"
-#include "hash_table.h"
-
-class BBReader;
-class InsnReader;
-class AddrReader;
-class ExcReader;
-class PidReader;
-class MethodReader;
-
-struct StaticRec {
- uint64_t bb_num;
- uint32_t bb_addr;
- uint32_t num_insns;
-};
-
-struct StaticBlock {
- StaticRec rec;
- uint32_t *insns;
-};
-
-struct BBEvent {
- uint64_t time;
- uint64_t bb_num;
- uint32_t bb_addr;
- uint32_t *insns;
- int num_insns;
- int pid;
- int is_thumb;
-};
-
-struct PidEvent {
- uint64_t time;
- int rec_type; // record type: fork, context switch, exit ...
- int tgid; // thread group id
- int pid; // for fork: child pid; for switch: next pid;
- // for exit: exit value
- uint32_t vstart; // virtual start address (only used with mmap)
- uint32_t vend; // virtual end address (only used with mmap)
- uint32_t offset; // virtual file offset (only used with mmap)
-
- // Dynamically allocated path to executable (or lib). In the case of
- // an mmapped dex file, the path is modified to be more useful for
- // comparing against the output of dexlist. For example, instead of this:
- // /data/dalvik-cache/system@app@TestHarness.apk@classes.dex
- // We convert to this:
- // /system/app/TestHarness.apk
- char *path;
- char *mmap_path; // unmodified mmap path
- int argc; // number of args
- char **argv; // dynamically allocated array of args
-};
-
-struct MethodRec {
- uint64_t time;
- uint32_t addr;
- int pid;
- int flags;
-};
-
-struct DexSym {
- uint32_t addr;
- int len;
- char *name;
-};
-
-struct DexFileList {
- char *path;
- int nsymbols;
- DexSym *symbols;
-};
-
-class TraceReaderBase {
- public:
- TraceReaderBase();
- virtual ~TraceReaderBase();
-
- friend class BBReader;
-
- void Open(const char *filename);
- void Close();
- void WriteHeader(TraceHeader *header);
- inline bool ReadBB(BBEvent *event);
- int ReadStatic(StaticRec *rec);
- int ReadStaticInsns(int num, uint32_t *insns);
- TraceHeader *GetHeader() { return header_; }
- inline uint64_t ReadInsnTime(uint64_t min_time);
- void TruncateLastBlock(uint32_t num_insns);
- inline bool ReadAddr(uint64_t *time, uint32_t *addr, int *flags);
- inline bool ReadExc(uint64_t *time, uint32_t *current_pc,
- uint64_t *recnum, uint32_t *target_pc,
- uint64_t *bb_num, uint64_t *bb_start_time,
- int *num_insns);
- inline bool ReadPidEvent(PidEvent *event);
- inline bool ReadMethod(MethodRec *method_record);
- StaticBlock *GetStaticBlock(uint64_t bb_num) { return &blocks_[bb_num]; }
- uint32_t *GetInsns(uint64_t bb_num) { return blocks_[bb_num].insns; }
- uint32_t GetBBAddr(uint64_t bb_num) {
- return blocks_[bb_num].rec.bb_addr & ~1;
- }
- int GetIsThumb(uint64_t bb_num) {
- return blocks_[bb_num].rec.bb_addr & 1;
- }
- void SetPostProcessing(bool val) { post_processing_ = val; }
-
- protected:
- virtual int FindCurrentPid(uint64_t time);
- int current_pid_;
- int next_pid_;
- uint64_t next_pid_switch_time_;
- PidReader *internal_pid_reader_;
- MethodReader *internal_method_reader_;
- HashTable<DexFileList*> *dex_hash_;
-
- private:
- int FindNumInsns(uint64_t bb_num, uint64_t bb_start_time);
- void ReadTraceHeader(FILE *fstream, const char *filename,
- const char *tracename, TraceHeader *header);
- PidEvent *FindMmapDexFileEvent();
- void ParseDexList(const char *filename);
-
- char *static_filename_;
- FILE *static_fstream_;
- TraceHeader *header_;
- BBReader *bb_reader_;
- InsnReader *insn_reader_;
- AddrReader *load_addr_reader_;
- AddrReader *store_addr_reader_;
- ExcReader *exc_reader_;
- PidReader *pid_reader_;
- MethodReader *method_reader_;
- ExcReader *internal_exc_reader_;
- StaticBlock *blocks_;
- bool exc_end_;
- uint64_t bb_recnum_;
- uint64_t exc_recnum_;
- uint64_t exc_bb_num_;
- uint64_t exc_time_;
- int exc_num_insns_;
- bool post_processing_;
-
- bool load_eof_;
- uint64_t load_time_;
- uint32_t load_addr_;
- bool store_eof_;
- uint64_t store_time_;
- uint32_t store_addr_;
-};
-
-class Decoder;
-
-class BBReader {
- public:
- explicit BBReader(TraceReaderBase *trace);
- ~BBReader();
- void Open(const char *filename);
- void Close();
- bool ReadBB(BBEvent *event);
-
- private:
- struct TimeRec {
- BBRec bb_rec;
- uint64_t next_time;
- };
-
- struct Future {
- Future *next;
- TimeRec bb;
- };
-
- inline Future *AllocFuture();
- inline void FreeFuture(Future *future);
- inline void InsertFuture(Future *future);
- inline int DecodeNextRec();
-
- TimeRec nextrec_;
- Future futures_[kMaxNumBasicBlocks];
- Future *head_;
- Future *free_;
- Decoder *decoder_;
- bool is_eof_;
- TraceReaderBase *trace_;
-};
-
-class InsnReader {
- public:
- InsnReader();
- ~InsnReader();
-
- void Open(const char *filename);
- void Close();
- uint64_t ReadInsnTime(uint64_t min_time);
-
- private:
- Decoder *decoder_;
- uint64_t prev_time_;
- uint64_t time_diff_;
- int repeat_;
-};
-
-class AddrReader {
- public:
- AddrReader();
- ~AddrReader();
-
- bool Open(const char *filename, const char *suffix);
- void Close();
- bool ReadAddr(uint64_t *time, uint32_t *addr);
-
- private:
- Decoder *decoder_;
- uint32_t prev_addr_;
- uint64_t prev_time_;
- bool opened_; // true after file is opened
-};
-
-class ExcReader {
- public:
- ExcReader();
- ~ExcReader();
-
- void Open(const char *filename);
- void Close();
- bool ReadExc(uint64_t *time, uint32_t *current_pc,
- uint64_t *recnum, uint32_t *target_pc,
- uint64_t *bb_num, uint64_t *bb_start_time,
- int *num_insns);
-
- private:
- Decoder *decoder_;
- uint64_t prev_time_;
- uint64_t prev_recnum_;
-};
-
-class PidReader {
- public:
- PidReader();
- ~PidReader();
-
- void Open(const char *filename);
- void Close();
- bool ReadPidEvent(struct PidEvent *event);
- void Dispose(struct PidEvent *event);
-
- private:
- Decoder *decoder_;
- uint64_t prev_time_;
-};
-
-class MethodReader {
- public:
- MethodReader();
- ~MethodReader();
-
- bool Open(const char *filename);
- void Close();
- bool ReadMethod(MethodRec *method_record);
-
- private:
- Decoder *decoder_;
- uint64_t prev_time_;
- uint32_t prev_addr_;
- int32_t prev_pid_;
- bool opened_; // true after file is opened
-};
-
-// Reads the next dynamic basic block from the trace.
-// Returns true on end-of-file.
-inline bool TraceReaderBase::ReadBB(BBEvent *event)
-{
- bb_recnum_ += 1;
- return bb_reader_->ReadBB(event);
-}
-
-inline uint64_t TraceReaderBase::ReadInsnTime(uint64_t min_time)
-{
- return insn_reader_->ReadInsnTime(min_time);
-}
-
-inline bool TraceReaderBase::ReadAddr(uint64_t *time, uint32_t *addr, int *flags)
-{
- if (load_eof_ && store_eof_)
- return true;
-
- if (store_eof_ || (!load_eof_ && load_time_ <= store_time_)) {
- *time = load_time_;
- *addr = load_addr_;
- *flags = 0;
- load_eof_ = load_addr_reader_->ReadAddr(&load_time_, &load_addr_);
- } else {
- *time = store_time_;
- *addr = store_addr_;
- *flags = 1;
- store_eof_ = store_addr_reader_->ReadAddr(&store_time_, &store_addr_);
- }
- return false;
-}
-
-inline bool TraceReaderBase::ReadExc(uint64_t *time, uint32_t *current_pc,
- uint64_t *recnum, uint32_t *target_pc,
- uint64_t *bb_num, uint64_t *bb_start_time,
- int *num_insns)
-{
- return exc_reader_->ReadExc(time, current_pc, recnum, target_pc, bb_num,
- bb_start_time, num_insns);
-}
-
-inline bool TraceReaderBase::ReadPidEvent(PidEvent *event)
-{
- return pid_reader_->ReadPidEvent(event);
-}
-
-inline bool TraceReaderBase::ReadMethod(MethodRec *method_record)
-{
- return method_reader_->ReadMethod(method_record);
-}
-
-// Duplicates a string, allocating space using new[].
-inline char * Strdup(const char *src) {
- int len = strlen(src);
- char *copy = new char[len + 1];
- strcpy(copy, src);
- return copy;
-}
-
-#endif /* TRACE_READER_BASE_H */
diff --git a/files/NOTICE b/files/NOTICE
new file mode 100644
index 0000000..06a9081
--- /dev/null
+++ b/files/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-2014, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/files/ant/NOTICE b/files/ant/NOTICE
new file mode 100644
index 0000000..06a9081
--- /dev/null
+++ b/files/ant/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-2014, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/files/ant/build.xml b/files/ant/build.xml
index 66d7139..222e7d1 100644
--- a/files/ant/build.xml
+++ b/files/ant/build.xml
@@ -157,7 +157,6 @@
<condition property="exe" value=".exe" else=""><os family="windows" /></condition>
<condition property="bat" value=".bat" else=""><os family="windows" /></condition>
<property name="adb" location="${android.platform.tools.dir}/adb${exe}" />
- <property name="zipalign" location="${android.tools.dir}/zipalign${exe}" />
<property name="lint" location="${android.tools.dir}/lint${bat}" />
<!-- Intermediate files -->
@@ -485,6 +484,7 @@
<property name="aidl" location="${android.build.tools.dir}/aidl${exe}" />
<property name="aapt" location="${android.build.tools.dir}/aapt${exe}" />
<property name="dx" location="${android.build.tools.dir}/dx${bat}" />
+ <property name="zipalign" location="${android.build.tools.dir}/zipalign${exe}" />
<!-- read the previous build mode -->
<property file="${out.build.prop.file}" />
diff --git a/files/devices.xml b/files/devices.xml
index e729986..0c7cb96 100644
--- a/files/devices.xml
+++ b/files/devices.xml
@@ -54,7 +54,7 @@
armeabi
</d:abi>
<d:dock> </d:dock>
- <d:power-type>plugged-in</d:power-type>
+ <d:power-type>battery</d:power-type>
</d:hardware>
<d:software>
<d:api-level>7-10</d:api-level>
@@ -136,7 +136,7 @@
armeabi
</d:abi>
<d:dock> </d:dock>
- <d:power-type>plugged-in</d:power-type>
+ <d:power-type>battery</d:power-type>
</d:hardware>
<d:software>
<d:api-level>9-16</d:api-level>
@@ -251,7 +251,7 @@
<!--dock (car, desk, tv, none)-->
<d:dock>
</d:dock>
- <!-- plugged in (never, charge, always) -->
+ <!-- power-type (battery, plugged-in) -->
<d:power-type>battery</d:power-type>
</d:hardware>
<d:software>
diff --git a/files/plugin.prop b/files/plugin.prop
index afa9faa..44a6a1b 100644
--- a/files/plugin.prop
+++ b/files/plugin.prop
@@ -1,3 +1,3 @@
# begin plugin.prop
-plugin.version=22.0.0
-# end plugin.prop \ No newline at end of file
+plugin.version=23.0.0
+# end plugin.prop
diff --git a/files/tools_source.properties b/files/tools_source.properties
index 7e6337e..5070081 100644
--- a/files/tools_source.properties
+++ b/files/tools_source.properties
@@ -1,3 +1,3 @@
Pkg.UserSrc=false
-Pkg.Revision=22.3
-Platform.MinPlatformToolsRev=18
+Pkg.Revision=23.0.2
+Platform.MinPlatformToolsRev=20
diff --git a/find_java/build.gradle b/find_java/build.gradle
new file mode 100644
index 0000000..b1dfa79
--- /dev/null
+++ b/find_java/build.gradle
@@ -0,0 +1,41 @@
+apply plugin: 'cpp'
+apply plugin: 'sdk-files'
+apply plugin: 'windows-setup'
+
+executables {
+ findJava {}
+}
+
+sources {
+ findJava {
+ cpp {
+ source {
+ srcDir "src/source"
+ include "**/*.cpp"
+ }
+ }
+ }
+}
+
+sdk {
+ windows {
+ item( { getExeName("windows") } ) {
+ into 'lib'
+ name 'find_java.exe'
+ builtBy 'findJavaExecutable'
+ notice 'NOTICE'
+ }
+ item('find_java.bat') {
+ into 'lib'
+ notice 'NOTICE'
+ }
+ }
+}
+
+def getExeName(String platform) {
+ // binaries will return a set of binaries
+ def binaries = executables.findJava.binaries.matching { it.name == "findJavaExecutable" }
+ // calling .exeFile on the set returns an array with the result from each item in the set...
+ return binaries.executableFile.get(0)
+}
+
diff --git a/find_java/find_java.h b/find_java/src/source/find_java.h
index 1181aa1..1181aa1 100755
--- a/find_java/find_java.h
+++ b/find_java/src/source/find_java.h
diff --git a/find_java/find_java_exe.cpp b/find_java/src/source/find_java_exe.cpp
index 6b1add9..6b1add9 100644
--- a/find_java/find_java_exe.cpp
+++ b/find_java/src/source/find_java_exe.cpp
diff --git a/find_java/find_java_lib.cpp b/find_java/src/source/find_java_lib.cpp
index 4c04e7f..4c04e7f 100755
--- a/find_java/find_java_lib.cpp
+++ b/find_java/src/source/find_java_lib.cpp
diff --git a/find_java/utils.cpp b/find_java/src/source/utils.cpp
index e2ce58f..e2ce58f 100755
--- a/find_java/utils.cpp
+++ b/find_java/src/source/utils.cpp
diff --git a/find_java/utils.h b/find_java/src/source/utils.h
index dc9031d..dc9031d 100755
--- a/find_java/utils.h
+++ b/find_java/src/source/utils.h
diff --git a/monitor/build.gradle b/monitor/build.gradle
new file mode 100644
index 0000000..211ca0c
--- /dev/null
+++ b/monitor/build.gradle
@@ -0,0 +1,114 @@
+apply plugin: 'sdk-files'
+
+// See $ANDROID_SRC/tools/buildSrc/base/version.gradle for definition of baseVersion
+// However, if Eclipse bundles don't get the same version as tools baseVersion, then this
+// will have to be hard coded and fixed by sdk/eclipse/scripts/update_version.sh
+def basePath = "../../out/host/maven/bundles-${rootProject.ext.baseVersion}-SNAPSHOT/products/"
+
+sdk {
+ linux {
+ item('monitor') {
+ notice null
+ executable true
+ }
+ item(basePath + 'lin64/monitor') {
+ into 'lib/monitor-x86_64'
+ notice null
+ builtBy 'unzipLinux64'
+ }
+ item(basePath + 'lin/monitor') {
+ into 'lib/monitor-x86'
+ notice null
+ builtBy 'unzipLinux'
+ }
+ }
+
+ mac {
+ item('monitor') {
+ notice null
+ executable true
+ }
+ item(basePath + 'mac64/monitor') {
+ into 'lib/monitor-x86_64'
+ notice null
+ builtBy 'unzipMac64'
+ }
+ }
+
+
+ windows {
+ item('monitor.bat') {
+ notice null
+ executable true
+ }
+ item(basePath + 'win64/monitor') {
+ into 'lib/monitor-x86_64'
+ notice null
+ builtBy 'unzipWin64'
+ }
+ item(basePath + 'win/monitor') {
+ into 'lib/monitor-x86'
+ notice null
+ builtBy 'unzipWin'
+ }
+ }
+}
+
+// Using PDE build, the size of monitor was 43M
+// With Tycho, we are at close to 75M. Until we figure out the proper way
+// to exclude unnecessary content, we just remove these plugins from the final build.
+def pluginsToRemove = [
+ 'org.eclipse.platform.doc.user_4.2.2.v20130121-200410.jar',
+ 'org.eclipse.debug.ui_3.8.2.v20130130-171415.ja',
+ 'org.apache.jasper.glassfish_2.2.2.v201205150955.jar',
+ 'org.eclipse.team.ui_3.6.201.v20130125-135424.jar',
+ 'org.apache.lucene.core_2.9.1.v201101211721.jar',
+ 'org.eclipse.help.webapp_3.6.101.v20130116-182509.jar',
+ 'org.eclipse.help.ui_3.5.201.v20130108-092756.jar',
+ 'org.eclipse.help.base_3.6.101.v201302041200.jar',
+ 'org.eclipse.team.core_3.6.100.v20120524-0627.jar',
+ 'org.eclipse.jetty.server_8.1.3.v20120522.jar',
+ 'org.eclipse.ui.intro_3.4.200.v20120521-2344.jar',
+ 'org.eclipse.ui.cheatsheets_3.4.200.v20120521-2344.jar',
+ 'org.apache.ant_1.8.3.v201301120609/**'
+]
+
+task unzipLinux64(type: Copy) {
+ from zipTree(file(basePath + 'monitorproduct-linux.gtk.x86_64.zip'))
+ into file(basePath + 'lin64/')
+ pluginsToRemove.each {
+ exclude "**/$it"
+ }
+}
+
+task unzipLinux(type: Copy) {
+ from zipTree(file(basePath + 'monitorproduct-linux.gtk.x86.zip'))
+ into file(basePath + 'lin/')
+ pluginsToRemove.each {
+ exclude "**/$it"
+ }
+}
+
+task unzipMac64(type: Copy) {
+ from zipTree(file(basePath + 'monitorproduct-macosx.cocoa.x86_64.zip'))
+ into file(basePath + 'mac64/')
+ pluginsToRemove.each {
+ exclude "**/$it"
+ }
+}
+
+task unzipWin64(type: Copy) {
+ from zipTree(file(basePath + 'monitorproduct-win32.win32.x86_64.zip'))
+ into file(basePath + 'win64/')
+ pluginsToRemove.each {
+ exclude "**/$it"
+ }
+}
+
+task unzipWin(type: Copy) {
+ from zipTree(file(basePath + 'monitorproduct-win32.win32.x86.zip'))
+ into file(basePath + 'win/')
+ pluginsToRemove.each {
+ exclude "**/$it"
+ }
+}
diff --git a/p2gen/README.txt b/p2gen/README.txt
new file mode 100644
index 0000000..3443b03
--- /dev/null
+++ b/p2gen/README.txt
@@ -0,0 +1,73 @@
+Summary:
+
+To generate p2 artifacts from jars, run:
+$ mvn --no-snapshot-updates --offline p2:site \
+ -Dmaven.repo.local=../../out/host/maven/localrepo
+The folder ${build.directory}/repository contains the resultant
+p2 repository. ${build.directory} is defined inside pom.xml
+
+Details:
+
+The Eclipse plugins in $root/sdk/eclipse/plugins depend on a number
+of jar files from:
+ $root/tools/base
+ $root/tools/swt
+ $root/prebuilts/tools/common/m2/repository
+
+In earlier versions, a script (create_all_symlinks.sh) knew about
+which plugins depended on which jars, and when executed, it would
+copy over those jars into the plugin's libs folder. Each plugin
+included the jars from its libs folder as part of its classpath,
+and the entire libs folder was bundled inside the plugin.
+
+Such a scheme has a number of issues:
+ - bundling jars inside libs/ folder inside each plugin is not
+ recommended by Eclipse. This causes performance degradation
+ at runtime.
+ - at build time, the script modifies the source folders to add
+ the contents inside libs folder. Ideally, the source folders
+ shouldn't be modified during build.
+ - the script has to maintain state about which plugin depends
+ on which jars.
+
+The approach suggested by Eclipse is to replace the regular jars
+with OSGI bundles, and for each plugin to explicitly add a dependency
+to the required OSGI bundles. In essence, this makes each of the
+jars to be similar to a plugin.
+
+This folder contains scripts that can be used to convert a set
+of jars into OSGI bundles using the p2-maven-plugin
+(https://github.com/reficio/p2-maven-plugin).
+
+$ mvn --no-snapshot-updates \
+ --offline \
+ -Dmaven.repo.local=../../out/host/maven/localRepo \
+ p2:site
+
+The pom.xml file lists the set of jars to be processed. The
+runtime options to Maven include:
+ --offline: We don't want Maven to fetch anything from the internet.
+ All required dependencies must be checked into git.
+ --no-snapshot-updates: If the tools artifacts have a -SNAPSHOT
+ in them, Maven will attempt to re-download those artifacts,
+ which would fail since we are running in offline mode. This
+ option instructs Maven to not attempt to download these
+ snapshots and use whatever is available in the local repositories.
+ -Dmaven.repo.local=path to the local repository that should be
+ used by maven. Without this, it'll use $HOME/.m2. This should
+ be initialized with all the necessary artifacts if running in
+ offline mode.
+
+Additional considerations for running in offline mode:
+
+When running in online mode, there are 3 sources from which files
+are downloaded by Maven:
+ 1 Maven Central
+ 2 the repository where the tools/base and tools/swt artifacts are
+ generated
+ 3 the prebuilts/tools/common/m2 repository (this is a subset of 1).
+Even though 2 and 3 are available locally, we cannot just use them
+in offline mode since Maven treats repositories with file:/// urls
+as remote as well. As a result, the only way to run offline is to
+first explicitly copy the contents of 2 and 3 into the local repository
+(-Dmaven.repo.local) before initiating an offline build.
diff --git a/p2gen/pom.xml b/p2gen/pom.xml
new file mode 100644
index 0000000..16e72ab
--- /dev/null
+++ b/p2gen/pom.xml
@@ -0,0 +1,137 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ This pom is used to take a set of files present in a Maven repo,
+ add OSGI manifest if necessary and put them in a p2 repository suitable
+ for consumption by the Eclipse Tycho builder.
+
+ See README.txt for more information and about invocation options.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>com.android.tools.rcp</groupId>
+ <artifactId>adt-eclipse</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0.0</version>
+
+ <properties>
+ <android.src.dir>${basedir}/../..</android.src.dir>
+ <android.out.dir>${basedir}/../../out</android.out.dir>
+ </properties>
+
+ <!--
+ Define two profiles: online and offline
+
+ The offline profile is default and will be used by the build server. For this
+ to work, all the required artifacts must already be in the local repository
+ pointed to by the settings.xml
+
+ The online profile could be used for testing/debugging purposes. It can be
+ activated by removing the offline option, and adding "-P online" to the list
+ of command line options. This allows downloading necessary artifacts either
+ from the internet, or from the prebuilts and generated artifacts of the gradle
+ builds.
+ -->
+ <profiles>
+ <profile>
+ <id>offline</id>
+ <activation>
+ <activeByDefault>true</activeByDefault>
+ </activation>
+ </profile>
+
+ <profile>
+ <id>online</id>
+ <repositories>
+ <repository>
+ <id>tools</id>
+ <url>file:///${android.out.dir}/repo/</url>
+ </repository>
+ <repository>
+ <id>tools-prebuilts</id>
+ <url>file:///${android.src.dir}/prebuilts/tools/common/m2/repository/</url>
+ </repository>
+ </repositories>
+ </profile>
+ </profiles>
+
+ <build>
+ <!-- Remap the build folder to be something inside out -->
+ <directory>${basedir}/../../out/host/maven/p2gen</directory>
+
+ <plugins>
+ <plugin>
+ <!-- org.reficio:p2-maven-plugin:1.1.0 is checked into prebuils/tools/common/m2/repository -->
+ <groupId>org.reficio</groupId>
+ <artifactId>p2-maven-plugin</artifactId>
+ <version>1.1.0</version>
+
+ <executions>
+ <execution>
+ <id>default-cli</id>
+ <configuration>
+ <artifacts>
+ <!-- tools/base dependencies -->
+ <artifact> <id>com.android.tools.build:manifest-merger:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools.ddms:ddmlib:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools.layoutlib:layoutlib-api:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools.lint:lint-api:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools.lint:lint-checks:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:asset-studio:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:common:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:dvlib:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:ninepatch:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:rule-api:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:sdk-common:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:sdklib:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:testutils:22.9.0</id> </artifact>
+
+ <!-- tools/swt dependencies -->
+ <artifact> <id>com.android.tools.ddms:ddmuilib:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:hierarchyviewer2lib:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:sdkstats:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:sdkuilib:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:swtmenubar:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:traceview:22.9.0</id> </artifact>
+ <artifact> <id>com.android.tools:uiautomatorviewer:22.9.0</id> </artifact>
+
+ <!-- prebuilts -->
+ <artifact> <id>com.android.tools.external.lombok:lombok-ast:0.2.2</id> </artifact>
+ <artifact> <id>com.android.tools.external:ant-glob:1.0</id> </artifact>
+ <artifact> <id>com.android.tools.external:liblzf:1.0</id> </artifact>
+ <artifact> <id>com.android.tools.external:libprotobuf-java-lite:2.3.0</id> </artifact>
+ <artifact> <id>com.android.tools.external:propertysheet:1.0</id> </artifact>
+ <artifact> <id>com.google.guava:guava:15.0</id> </artifact>
+ <artifact> <id>commons-codec:commons-codec:1.4</id> </artifact>
+ <artifact> <id>commons-logging:commons-logging:1.1.1</id> </artifact>
+ <artifact> <id>jfree:jcommon:1.0.12</id> </artifact>
+ <artifact> <id>jfree:jfreechart-swt:1.0.9</id> </artifact>
+ <artifact> <id>jfree:jfreechart:1.0.9</id> </artifact>
+ <artifact> <id>net.sf.kxml:kxml2:2.3.0</id> </artifact>
+ <artifact> <id>net.sf.kxml:kxml2:2.3.0</id> </artifact>
+ <artifact> <id>org.apache.commons:commons-compress:1.0</id> </artifact>
+ <artifact> <id>org.apache.httpcomponents:httpclient:4.1.1</id> </artifact>
+ <artifact> <id>org.apache.httpcomponents:httpcore:4.1</id> </artifact>
+ <artifact> <id>org.apache.httpcomponents:httpmime:4.1</id> </artifact>
+ <artifact>
+ <id>org.freemarker:freemarker:2.3.20</id>
+ <!--
+ freemarker 2.3.20 bundles an OSGI manifest..except that manifest is
+ incorrect. http://sourceforge.net/p/freemarker/bugs/411/
+ This rule rewrites the OSGI manifest.
+ -->
+ <override>true</override>
+ </artifact>
+ <artifact> <id>org.ow2.asm:asm-analysis:4.0</id> </artifact>
+ <artifact> <id>org.ow2.asm:asm-tree:4.0</id> </artifact>
+ <artifact> <id>org.ow2.asm:asm:4.0</id> </artifact>
+ </artifacts>
+ </configuration>
+
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/sdklauncher/Android.mk b/sdklauncher/Android.mk
index 6b317a5..3d5a989 100644
--- a/sdklauncher/Android.mk
+++ b/sdklauncher/Android.mk
@@ -16,7 +16,7 @@ include $(CLEAR_VARS)
ifeq ($(HOST_OS),windows)
LOCAL_SRC_FILES := \
- sdklauncher.c
+ src/source/sdklauncher.c
LOCAL_CFLAGS += -Wall -Wno-unused-parameter
LOCAL_CFLAGS += -D_XOPEN_SOURCE -D_GNU_SOURCE -DSH_HISTORY
diff --git a/sdklauncher/build.gradle b/sdklauncher/build.gradle
new file mode 100644
index 0000000..61b41e1
--- /dev/null
+++ b/sdklauncher/build.gradle
@@ -0,0 +1,36 @@
+apply plugin: 'c'
+apply plugin: 'sdk-files'
+apply plugin: 'windows-setup'
+
+executables {
+ sdkLauncher {}
+}
+
+sources {
+ sdkLauncher {
+ c {
+ source {
+ srcDir "src/source"
+ include "**/*.c"
+ }
+ }
+ }
+}
+
+sdk {
+ windows {
+ item( { getExeName("windows") } ) {
+ into 'lib'
+ name 'SDK Manager.exe'
+ builtBy 'sdkLauncherExecutable'
+ }
+ }
+}
+
+def getExeName(String platform) {
+ // binaries will return a set of binaries
+ def binaries = executables.sdkLauncher.binaries.matching { it.name == "sdkLauncherExecutable" }
+ // calling .exeFile on the set returns an array with the result from each item in the set...
+ return binaries.executableFile.get(0)
+}
+
diff --git a/sdklauncher/sdklauncher.c b/sdklauncher/src/source/sdklauncher.c
index 6b2c45c..6b2c45c 100644
--- a/sdklauncher/sdklauncher.c
+++ b/sdklauncher/src/source/sdklauncher.c
diff --git a/templates/NOTICE b/templates/NOTICE
new file mode 100644
index 0000000..06a9081
--- /dev/null
+++ b/templates/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-2014, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/templates/docs/default.css b/templates/docs/default.css
index 37d3977..76718ac 100644
--- a/templates/docs/default.css
+++ b/templates/docs/default.css
@@ -67,11 +67,17 @@ nav {
position: fixed;
left: 0;
top: 0;
- width: 224px;
- height: 100%;
- padding: 48px 0 48px 32px;
+ box-sizing: border-box;
+ width: 256px;
+ bottom: 0;
+ margin: 32px 0;
+ padding: 16px 0 16px 32px;
+ overflow-y: scroll;
font-size: 14px;
line-height: 16px;
+ border-top: 2px solid #eee;
+ border-bottom: 2px solid #eee;
+ border-right: 2px solid #eee;
}
nav span {
@@ -80,7 +86,6 @@ nav span {
padding-left: 16px;
padding-top: 4px;
padding-bottom: 4px;
- border-right: 2px solid #eee;
}
nav span:hover {
@@ -88,8 +93,8 @@ nav span:hover {
}
nav .selected > span {
- background-color: rgba(51,181,229,0.05);
- border-right: 2px solid #33b5e5;
+ background-color: #eee;
+ border-right: 2px solid #333;
}
nav > .item > span {
@@ -229,6 +234,27 @@ pre {
margin-bottom: 16px;
}
+.deprecated,
+.deprecated h4,
+.deprecated pre,
+.deprecated code {
+ color: #a77 !important;
+}
+
+.deprecated h4 {
+}
+
+.deprecated h4:after {
+ border-radius: 2px;
+ text-decoration: none;
+ background-color: #a77;
+ padding: 4px 6px;
+ margin-left: 10px;
+ color: #fff;
+ font-size: 12px;
+ content: 'DEPRECATED';
+}
+
/* print */
@media print {
diff --git a/templates/docs/default.js b/templates/docs/default.js
index 1722eea..4be99c9 100644
--- a/templates/docs/default.js
+++ b/templates/docs/default.js
@@ -16,13 +16,14 @@
$(document).ready(function() {
prettyPrint();
+ preventParentScrolls('nav');
var sluggify_ = function(s) {
return (s || '').replace(/ /g, '-').replace(/[^\w-]/g, '').toLowerCase();
};
$('h2, h3, h4.includetoc').each(function() {
- $(this).attr('id', 'toc_' + sluggify_($(this).data('toctitle') || $(this).text()));
+ $(this).attr('id', 'toc_' + sluggify_($(this).data('tocid') || $(this).data('toctitle') || $(this).text()));
$(this).click(function() {
smoothScrollToId($(this).attr('id'));
});
@@ -101,7 +102,6 @@ function buildNav() {
for (var i = headerPositionCache.length - 1; i >= 0; i--) {
if (scrollTop >= headerPositionCache[i].top) {
$('#' + headerPositionCache[i].id).addClass('selected');
- console.log($('#' + headerPositionCache[i].id));
break;
}
}
@@ -124,3 +124,32 @@ function smoothScrollToId(id) {
document.location.hash = id;
});
}
+
+// Based on http://stackoverflow.com/questions/5802467/prevent-scrolling-of-parent-element
+function preventParentScrolls($el) {
+ $($el).on('DOMMouseScroll mousewheel', function(ev) {
+ var $this = $(this),
+ scrollTop = this.scrollTop,
+ scrollHeight = this.scrollHeight,
+ height = $this.height(),
+ delta = (ev.type == 'DOMMouseScroll' ?
+ ev.originalEvent.detail * -40 :
+ ev.originalEvent.wheelDelta),
+ up = delta > 0;
+
+ if (!up && -delta > scrollHeight - height - scrollTop) {
+ // Scrolling down, but this will take us past the bottom.
+ $this.scrollTop(scrollHeight);
+ } else if (up && delta > scrollTop) {
+ // Scrolling up, but this will take us past the top.
+ $this.scrollTop(0);
+ } else {
+ $this.scrollTop(scrollTop - delta);
+ }
+
+ ev.stopPropagation();
+ ev.preventDefault();
+ ev.returnValue = false;
+ return false;
+ });
+} \ No newline at end of file
diff --git a/templates/docs/index.html b/templates/docs/index.html
index 77623fb..d127bfe 100644..100755
--- a/templates/docs/index.html
+++ b/templates/docs/index.html
@@ -17,7 +17,7 @@
-->
<head>
<meta charset="utf-8">
- <title>ADT Template Format</title>
+ <title>Android IDE Template Format</title>
<link rel="stylesheet" href="cssreset-min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:regular,medium,thin,italic,mediumitalic,bold;Inconsolata" title="roboto">
<link rel="stylesheet" href="prettify.css">
@@ -34,17 +34,14 @@
<div id="page-content">
-<h1>ADT Template Format</h1>
+<h1>Android IDE Template Format</h1>
<br>
<dl style="margin:0">
- <dt>Status</dt>
- <dd style="margin:0">Draft</dd>
-
<dt>Format Version</dt>
- <dd style="margin:0">3</dd>
+ <dd style="margin:0">4</dd>
<dt>Last Updated</dt>
- <dd style="margin:0">8/30/2012</dd>
+ <dd style="margin:0">1/30/2014</dd>
</dl>
@@ -78,7 +75,8 @@
<pre class="prettyprint lang-xml">
&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"&gt;
&lt;application&gt;
- &lt;activity android:name="<strong>.${activityClass}</strong>"
+ &lt;activity android:name="<strong>${packageName}.${activityClass}</strong>"
+ android:parentActivityName="<strong>${parentActivityClass}</strong>"
android:label="@string/title_<strong>${activityToLayout(activityClass)}</strong>">
<strong>&lt;#if parentActivityClass != ""&gt;</strong>
&lt;meta-data android:name="android.support.PARENT_ACTIVITY"
@@ -99,8 +97,8 @@
<ul>
<li>The expression <code>${activityClass}</code> is bound to the value of the 'Activity Class' template parameter.</li>
- <li>The expression <code>${activityToLayout(activityClass)}</code> uses the <code>activityToLayout</code> method built into ADT to convert an activity class such as <code>MyFooActivity</code> to <code>activity_my_foo</code>.</li>
- <li>The <code>isLauncher</code> boolean variable and <code>parentActivityClass</code> string varaibles are bound to the values of the 'Launcher Activity' and 'Hierarchical Parent' template parameter, respectively.</li>
+ <li>The expression <code>${activityToLayout(activityClass)}</code> uses the <code>activityToLayout</code> method built into the template engine to convert an activity class such as <code>MyFooActivity</code> to <code>activity_my_foo</code>.</li>
+ <li>The <code>isLauncher</code> boolean variable and <code>parentActivityClass</code> string variables are bound to the values of the 'Launcher Activity' and 'Hierarchical Parent' template parameter, respectively.</li>
</ul>
@@ -145,25 +143,19 @@
<pre class="prettyprint lang-xml">
&lt;!-- A template for a blank activity. Use template format
- version 3, as described in this document. -->
+ version 4, as described in this document. -->
&lt;template
- format="3"
- revision="1"
- minApi="4"
- minBuildApi="11"
- name="New Blank Activity"
+ format="4"
+ revision="2"
+ minApi="7"
+ minBuildApi="16"
+ name="Blank Activity"
description="Creates a new blank activity, with navigation."&gt;
- &lt;!-- Indicate that the Android Support Library (r8) should be
- added to the project, if it isn't already in the project. -->
- &lt;dependency name="android-support-v4" revision="8" /&gt;
-
- &lt;category value="Activities" /&gt;
-
&lt;!-- A string parameter; the value is available to FreeMarker
processed files (.ftl files) as ${activityName}. -->
&lt;parameter
- id="activityName"
+ id="activityClass"
name="Activity Name"
type="string"
constraints="class|unique|nonempty"
@@ -175,22 +167,32 @@
id="layoutName"
name="Layout Name"
type="string"
- constraints="layout|unique"
+ constraints="layout|unique|nonempty"
suggest="${activityToLayout(activityClass)}"
- default="main"
+ default="activity_main"
help="The name of the layout to create for the activity" /&gt;
&lt;parameter
id="navType"
name="Navigation Type"
type="enum"
- default="none"&gt;
- &lt;option id="none" default="true"&gt;None&lt;/option&gt;
+ default="none"
+ help="The type of navigation to use for the activity"&gt;
+ &lt;option id="none"&gt;None&lt;/option&gt;
&lt;option id="tabs" minApi="11"&gt;Tabs&lt;/option&gt;
&lt;option id="pager" minApi="11"&gt;Swipe Views&lt;/option&gt;
&lt;option id="dropdown" minApi="11"&gt;Dropdown&lt;/option&gt;
&lt;/parameter&gt;
+ &lt;parameter
+ id="fragmentName"
+ name="Fragment Name"
+ type="string"
+ constraints="class|unique|nonempty"
+ default="MainFragment"
+ visibility="navType != 'none'"
+ help="The name of the fragment class to create" /&gt;
+
&lt;!-- 512x512 PNG thumbnails. --&gt;
&lt;thumbs&gt;
&lt;!-- Default thumbnail. --&gt;
@@ -217,7 +219,7 @@
<dl>
<dt><code>format</code></dt>
- <dd>The template format version that this template adheres to. Should be <code>3</code>.</dd>
+ <dd>The template format version that this template adheres to. Should be <code>4</code>.</dd>
<dt><code>revision</code></dt>
<dd>Optional. The version of this template (which you can increment when updating the template), as an integer.</dd>
@@ -235,8 +237,11 @@
<dd>Optional. The minimum build target (expressed as an API level) required for this template. The IDE will ensure that the target project is targeting an API level greater than or equal to this value before instantiating the template. This ensures that the template can safely use newer APIs (optionally guarded by runtime API level checks) without introducing compile-time errors into the target project.</dd>
</dl>
+<div class="deprecated">
<h4 class="includetoc">&lt;dependency&gt;</h4>
+<p>This tag is deprecated for use in <code>template.xml</code>. Use <a href="#toc_recipe_dependency"><code>&lt;dependency&gt;</code></a> in <code>recipe.xml.ftl</code> instead.</p>
+
<p>Indicates that the template requires that a given library be present in the target project. If not present, the IDE will add the dependency to the project.</p>
<dl>
@@ -249,7 +254,9 @@
<dt><code>revision</code></dt>
<dd>The minimum revision of the library required by this template.</dd>
</dl>
+</div>
+<div class="deprecated">
<h4 class="includetoc">&lt;category&gt;</h4>
<p>The template type. This element is optional.</p>
@@ -262,6 +269,7 @@
<li><code>UI Components</code></li>
</ul></dd>
</dl>
+</div>
<h4 class="includetoc">&lt;parameter&gt;</h4>
@@ -282,6 +290,8 @@
<li><code>nonempty</code> &mdash; the value must not be empty</li>
<li><code>apilevel</code> &mdash; the value should represent a numeric API level</li>
<li><code>package</code> &mdash; the value should represent a valid Java package name</li>
+ <li><code>app_package</code> &mdash; the value should represent a valid Android app package name</li>
+ <li><code>module</code> &mdash; the value should represent a valid Module name</li>
<li><code>class</code> &mdash; the value should represent a valid Java class name</li>
<li><code>activity</code> &mdash; the value should represent a fully-qualified activity class name</li>
<li><code>layout</code> &mdash; the value should represent a valid layout resource name</li>
@@ -298,8 +308,11 @@
<dt><code>default</code></dt>
<dd>Optional. The default value for this parameter.</dd>
+ <dt><code>visibility</code></dt>
+ <dd>Optional. A FreeMarker expression that determines whether this parameter should be visible. The expression should evaluate to a boolean value (i.e. true or false).</dd>
+
<dt><code>help</code></dt>
- <dd>The help string to display to the user for this parameter.</dd>
+ <dd>Optional. The help string to display to the user for this parameter.</dd>
</dl>
@@ -331,6 +344,18 @@
<p>The template 'preview' thumbnail will show <code>template_tabs.png</code> if the value of the <code>navType</code> template parameter is <code>tabs</code> and <code>template.png</code> otherwise.</p>
+<h4 class="includetoc">&lt;icons&gt;</h4>
+
+<p>States that the template would like the Asset Studio icon creation tool of the given type to run, and save the output icons with the given name.</p>
+
+<dl>
+ <dt><code>type</code></dt>
+ <dd>The type of icon wizard to create. Valid values are <code>notification</code>, <code>actionbar</code>, <code>launcher</code>.</dd>
+
+ <dt><code>name</code></dt>
+ <dd>The base icon name to output, e.g. <code>ic_stat_my_notification</code>.</dd>
+</dl>
+
<h3>globals.xml.ftl</h3>
<p>The optional globals XML file contains global variable definitions, for use in all FreeMarker processing jobs for this template.</p>
@@ -350,7 +375,7 @@
<h3>recipe.xml.ftl</h3>
-<p>The recipe XML file contains the individual instructions that should be executed when generating code from this template. For example, you can copy certain files or directories (the copy instruction), optionally running the source files through FreeMarker (the instantiate instruction), and ask ADT to open a file in Eclipse after the code has been generated (the open instruction).</p>
+<p>The recipe XML file contains the individual instructions that should be executed when generating code from this template. For example, you can copy certain files or directories (the copy instruction), optionally running the source files through FreeMarker (the instantiate instruction), and ask the IDE to open a file after the code has been generated (the open instruction).</p>
<p class="note"><strong>Note:</strong> The name of the recipe file is up to you, and is defined in <code>template.xml</code>. By convention, however, it's best to call it <code>recipe.xml.ftl</code>.</p>
@@ -360,58 +385,84 @@
<pre class="prettyprint lang-xml">
&lt;recipe&gt;
- &lt;!-- runs FreeMarker, then copies from
- [template-directory]/root/ to [output-directory]. --&gt;
- &lt;instantiate from="AndroidManifest.xml.ftl" /&gt;
-
- &lt;!-- automatically creates directories as needed --&gt;
- &lt;copy from="res/drawable-hdpi" /&gt;
- &lt;copy from="res/drawable-mdpi" /&gt;
- &lt;copy from="res/drawable-xhdpi" /&gt;
- &lt;copy from="res/values/dimens.xml" /&gt;
- &lt;copy from="res/values/styles.xml" /&gt;
- &lt;copy from="res/values-large/dimens.xml" /&gt;
+ &lt;#if appCompat?has_content&gt;
+ &lt;dependency mavenUrl="com.android.support:appcompat-v7:+"/&gt;
+ &lt;/#if&gt;
+ &lt;!-- runs FreeMarker, then copies from
+ [template-directory]/root/ to [output-directory],
+ automatically creating directories as needed. --&gt;
+ &lt;merge from="AndroidManifest.xml.ftl"
+ to="${escapeXmlAttribute(manifestDir)}/AndroidManifest.xml" /&gt;
+
+ &lt;!-- simply copy file, don't run FreeMarker --&gt;
+ &lt;copy from="res/drawable-mdpi"
+ to="${escapeXmlAttribute(resDir)}/res/drawable-mdpi" /&gt;
+ &lt;copy from="res/drawable-hdpi"
+ to="${escapeXmlAttribute(resDir)}/res/drawable-hdpi" /&gt;
+ &lt;copy from="res/drawable-xhdpi"
+ to="${escapeXmlAttribute(resDir)}/res/drawable-xhdpi" /&gt;
+ &lt;copy from="res/drawable-xxhdpi"
+ to="${escapeXmlAttribute(resDir)}/res/drawable-xxhdpi" /&gt;
&lt;copy from="res/menu/main.xml"
- to="res/menu/${activityNameLower}.xml" /&gt;
-
- &lt;instantiate from="res/values/strings.xml.ftl" /&gt;
+ to="${escapeXmlAttribute(resDir)}/res/menu/${activityNameLower}.xml" /&gt;
+
+ &lt;!-- run FreeMarker and then merge with existing files --&gt;
+ &lt;merge from="res/values/dimens.xml"
+ to="${escapeXmlAttribute(resDir)}/res/values/dimens.xml" /&gt;
+ &lt;merge from="res/values-large/dimens.xml"
+ to="${escapeXmlAttribute(resDir)}/res/values-large/dimens.xml" /&gt;
+ &lt;merge from="res/values/styles.xml"
+ to="${escapeXmlAttribute(resDir)}/res/values/styles.xml" /&gt;
+ &lt;merge from="res/values/strings.xml.ftl"
+ to="${escapeXmlAttribute(resDir)}/res/values/strings.xml" /&gt;
&lt;!-- Decide which layout to add --&gt;
&lt;#if navType?contains("pager")&gt;
&lt;instantiate
- from="res/layout/activity_pager.xml.ftl"
- to="res/layout/activity_${activityNameLower}.xml" /&gt;
+ from="${escapeXmlAttribute(resDir)}/res/layout/activity_pager.xml.ftl"
+ to="${escapeXmlAttribute(resDir)}/res/layout/activity_${activityNameLower}.xml" /&gt;
&lt;#elseif navType == "tabs" || navType == "dropdown"&gt;
- &lt;copy from="res/layout/activity_fragment_container.xml"
- to="res/layout/activity_${activityNameLower}.xml" /&gt;
+ &lt;copy from="${escapeXmlAttribute(resDir)}/res/layout/activity_fragment_container.xml"
+ to="${escapeXmlAttribute(resDir)}/res/layout/activity_${activityNameLower}.xml" /&gt;
&lt;#else&gt;
- &lt;copy from="res/layout/activity_simple.xml"
- to="res/layout/activity_${activityNameLower}.xml" /&gt;
+ &lt;copy from="${escapeXmlAttribute(resDir)}/res/layout/activity_simple.xml"
+ to="${escapeXmlAttribute(resDir)}/res/layout/activity_${activityNameLower}.xml" /&gt;
&lt;/#if&gt;
&lt;!-- Decide which activity code to add --&gt;
&lt;#if navType == "none"&gt;
&lt;instantiate from="src/app_package/SimpleActivity.java.ftl"
- to="${srcOut}/${activityClass}.java" /&gt;
+ to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /&gt;
&lt;#elseif navType == "pager"&gt;
&lt;instantiate from="src/app_package/PagerActivity.java.ftl"
- to="${srcOut}/${activityClass}.java" /&gt;
+ to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /&gt;
&lt;#elseif navType == "tabs"&gt;
&lt;instantiate from="src/app_package/TabsActivity.java.ftl"
- to="${srcOut}/${activityClass}.java" /&gt;
+ to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /&gt;
&lt;#elseif navType == "dropdown"&gt;
&lt;instantiate from="src/app_package/DropdownActivity.java.ftl"
- to="${srcOut}/${activityClass}.java" /&gt;
+ to="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /&gt;
&lt;/#if&gt;
- &lt;!-- open the layout file when done --&gt;
- &lt;open file="res/layout/${activityNameLower}.xml" /&gt;
+ &lt;!-- open the layout file and Java class when done --&gt;
+ &lt;open file="${escapeXmlAttribute(resDir)}/res/layout/${activityNameLower}.xml" /&gt;
+ &lt;open file="${escapeXmlAttribute(srcOut)}/${activityClass}.java" /&gt;
&lt;/recipe&gt;
</pre>
<p>The instructions below are supported:</p>
+<h4 class="includetoc" data-tocid="recipe_dependency">&lt;dependency&gt;</h4>
+
+<p>Indicates that the template requires that a given library be present in the target project. If not present, the IDE will add the dependency to the project.</p>
+
+<dl>
+ <dt><code>mavenUrl</code></dt>
+ <dd>The maven coordinates of the library. For example,
+ <code>com.android.support:appcompat-v7:+</code></dd>
+</dl>
+
<h4 class="includetoc">&lt;copy&gt;</h4>
<p>The only required argument is <code>from</code> which specifies the location of the source files to copy under the <code>root/</code> directory. All necessary ancestor directories are automatically created if needed.</p>
@@ -426,11 +477,15 @@
<h4 class="includetoc">&lt;merge&gt;</h4>
-<p>This instruction will be used to merge the contents of a source file into an existing file in the project. The most common use case for this will be to add components to the <code>AndroidManifest.xml</code> file of the destination project, or to merge resources such as strings into an existing <code>strings.xml</code> file.</p>
+<p>This instruction will run the source file through FreeMarker and then merge the contents of the output into an existing file in the project, or create a new file. The most common use case for this is to add components to the <code>AndroidManifest.xml</code> file of the destination project, or to merge resources such as strings into an existing <code>strings.xml</code> file.</p>
<h4 class="includetoc">&lt;open&gt;</h4>
-<p>Instruct ADT to open the file created by the specified <code>file</code> argument in Eclipse after code generation is complete.</p>
+<p>Instruct the IDE to open the file created by the specified <code>file</code> argument after code generation is complete.</p>
+
+<h4 class="includetoc">&lt;mkdir&gt;</h4>
+
+<p>Ensures the directory provided in the <code>at</code> argument exists.</p>
<h3>root/</h3>
@@ -441,7 +496,7 @@
-<h2>Extra Template Functions</h2>
+<h2>Built-in Template Functions</h2>
<p>Several functions are available to FreeMarker expressions and files beyond the standard set of built-in FreeMarker functions. These are listed below.</p>
@@ -471,6 +526,16 @@
<h4>See also</h4>
<p><a href="#toc_underscoretocamelcase"><code>underscoreToCamelCase</code></a></p>
+<h3 data-toctitle="escapePropertyValue">string <em>escapePropertyValue</em>(string)</h3>
+
+<p>This function escapes a string, such as <code>foo=bar</code> such that it is suitable to be inserted in a Java <code>.properties</code> file as a property value, such as <code>foo\=bar</code>.</p>
+
+<h4>Arguments</h4>
+<dl>
+ <dt><code>str</code></dt>
+ <dd>The string, e.g. <code>foo=bar</code> to escape to a proper property value.</dd>
+</dl>
+
<h3 data-toctitle="escapeXmlAttribute">string <em>escapeXmlAttribute</em>(string)</h3>
<p>This function escapes a string, such as <code>Android's</code> such that it can be used as an XML attribute value: <code>Android&amp;apos;s</code>. In particular, it will escape ', ", &lt; and &amp;.</p>
@@ -579,6 +644,68 @@
<h4>See also</h4>
<p><a href="#toc_camelcasetounderscore"><code>camelCaseToUnderscore</code></a></p>
+
+
+<h2>Built-in Template Parameters</h2>
+
+<p>Several parameters are available to FreeMarker expressions and files beyond <a href="#toc_parameter">those defined by the template</a>. These are listed below.</p>
+
+<h3>packageName</h3>
+
+<p>The Java-style Android package name for the project, e.g. <code>com.example.foo</code></p>
+
+<h3>applicationPackage</h3>
+
+<p>Will be the application package (i.e. the package name declared in the app manifest) if the target package for this template is not the application package. Otherwise, this parameter will be empty.</p>
+
+<h3>isNewProject</h3>
+
+<p>A boolean indicating whether or not this template is being instantiated as part of a New Project flow.</p>
+
+<h3>minApi</h3>
+
+<p>The minimum API level the project supports. Note that this value could be a string so consider using <a href="#toc_minapilevel"><code>minApiLevel</code></a> instead.</p>
+
+<h3>minApiLevel</h3>
+
+<p>The minimum API level the project supports, guaranteed to be a number. This is generally used to guard the generation of code based on the project's API level, for example:</p>
+
+<pre>
+int drawableResourceId = android.R.layout.simple_list_item_<strong>&lt;#if minApiLevel gte 11&gt;</strong>activated_<strong>&lt;/#if&gt;</strong>_1;
+</pre>
+
+<h3>buildApi</h3>
+
+<p>The API level that the project is building against, guaranteed to be a number. This is generally used to guard the generation of code based on what version of the Android SDK the project is being built against, for example:</p>
+
+<pre>
+&lt;TextView android:layout_width="wrap_content"
+ android:layout_height="<strong>&lt;#if buildApi gte 8&gt;</strong>match_parent<strong>&lt;#else&gt;</strong>fill_parent<strong>&lt;/#if&gt;</strong>" /&gt;
+</pre>
+
+<h3>manifestDir</h3>
+
+<p>The target output directory for the <code>AndroidManifest.xml</code> file. This varies depending on the project's directory structure (Gradle-style or Ant-style).</p>
+
+<h3>srcDir</h3>
+
+<p>The target Java source root directory for the project. This varies depending on the project's directory structure (Gradle-style or Ant-style). It's common to concatenate the package name:</p>
+
+<pre>
+${srcDir}/${slashedPackageName(packageName)}
+</pre>
+
+<h4>See also</h4>
+<p><a href="#toc_slashedpackagename"><code>slashedPackageName</code></a></p>
+
+<h3>resDir</h3>
+
+<p>The target resource directory root (<code>res/</code> folder) for the project. This varies depending on the project's directory structure (Gradle-style or Ant-style).</p>
+
+
+
+
+
<h2>Notes for Template Authors</h2>
<h3>Tools metadata</h3>