From 5e23a935dede8ac3e6a60444b1e72102ade40cd0 Mon Sep 17 00:00:00 2001 From: kevinjeon-g <136382173+kevinjeon-g@users.noreply.github.com> Date: Fri, 20 Dec 2024 12:58:18 -0500 Subject: [PATCH] Add full oatdump output behind filters (#7233) This change makes full oatdump output visible behind the "Directives" filter. This does the same thing as the --full-output flag, but is more-easily used. The default code snippets have been updated to include this. --- examples/android-java/default.java | 3 +++ examples/android-kotlin/default.kt | 3 +++ lib/compilers/dex2oat.ts | 4 ++-- test/android-tests.ts | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/android-java/default.java b/examples/android-java/default.java index 8fdbfb493..b3049143c 100644 --- a/examples/android-java/default.java +++ b/examples/android-java/default.java @@ -3,6 +3,9 @@ // For R8, please load R8Example for an example with a keep annotation, // which will prevent unused code from being removed from the final output. // +// For dex2oat, 'Filter...' > 'Directives' can be unchecked for full +// oatdump output. +// // (For advanced use only) Click "Templates > Android Java IDE" for // profile-guided compilation. diff --git a/examples/android-kotlin/default.kt b/examples/android-kotlin/default.kt index a41ad43dd..66c00b1f7 100644 --- a/examples/android-kotlin/default.kt +++ b/examples/android-kotlin/default.kt @@ -3,6 +3,9 @@ // For R8, please load R8Example for an example with a keep annotation, // which will prevent unused code from being removed from the final output. // +// For dex2oat, 'Filter...' > 'Directives' can be unchecked for full +// oatdump output. +// // (For advanced use only) Click "Templates > Android Kotlin IDE" for // profile-guided compilation. diff --git a/lib/compilers/dex2oat.ts b/lib/compilers/dex2oat.ts index 5d60080f1..a49a5ed21 100644 --- a/lib/compilers/dex2oat.ts +++ b/lib/compilers/dex2oat.ts @@ -361,7 +361,7 @@ export class Dex2OatCompiler extends BaseCompiler { }; } - override async processAsm(result) { + override async processAsm(result, filters: ParseFiltersAndOutputOptions) { let asm: string = ''; if (typeof result.asm === 'string') { @@ -381,7 +381,7 @@ export class Dex2OatCompiler extends BaseCompiler { } const segments: ParsedAsmResultLine[] = []; - if (this.fullOutput) { + if (this.fullOutput || !filters.directives) { // Returns entire dex2oat output. segments.push({text: asm, source: null}); } else { diff --git a/test/android-tests.ts b/test/android-tests.ts index 969f71d08..39ecfe2ec 100644 --- a/test/android-tests.ts +++ b/test/android-tests.ts @@ -97,7 +97,7 @@ describe('dex2oat', () => { const objdumpResult = { asm, }; - const processed = await compiler.processAsm(objdumpResult); + const processed = await compiler.processAsm(objdumpResult, compiler.getDefaultFilters()); expect(processed).toHaveProperty('asm'); const actualSegments = (processed as {asm: ParsedAsmResultLine[]}).asm;