From 4b9f618a76f016513b744eab99afb694a15c1df3 Mon Sep 17 00:00:00 2001 From: Mythri Alle Date: Wed, 25 Oct 2023 15:17:11 +0000 Subject: [PATCH] Don't minimize debug information if module explicitly asks for it In some configurations (for ex: go, auto) we minimize debug information to reduce disk and memory usage. However some tests need the debug information to work as expected. If a test explicitly requests for debug information by passing "-g" to javac flags don't add "-g:source,lines" to minimize debug information. Javac gives priority to -g:source,lines and doesn't respect the order. So check if there is a -g flag before adding flags to minimize debug information. Test: atest CtsJvmtiRunTest1912HostTestCases android.jvmti.cts.JvmtiHostTest1912#testJvmti Change-Id: I45e0f5fa9e79c16c2ff6e9413941a9a637753653 --- java/base.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/java/base.go b/java/base.go index 53f22a7c0..e1c2386ff 100644 --- a/java/base.go +++ b/java/base.go @@ -1014,8 +1014,16 @@ func (j *Module) collectJavacFlags( ctx android.ModuleContext, flags javaBuilderFlags, srcFiles android.Paths) javaBuilderFlags { // javac flags. javacFlags := j.properties.Javacflags + var needsDebugInfo bool - if ctx.Config().MinimizeJavaDebugInfo() && !ctx.Host() { + needsDebugInfo = false + for _, flag := range javacFlags { + if strings.HasPrefix(flag, "-g") { + needsDebugInfo = true + } + } + + if ctx.Config().MinimizeJavaDebugInfo() && !ctx.Host() && !needsDebugInfo { // For non-host binaries, override the -g flag passed globally to remove // local variable debug info to reduce disk and memory usage. javacFlags = append(javacFlags, "-g:source,lines")