[debugger] make the ScriptGroup inspection point weak
Breakpoints set on named ScriptGroups were never resolved by the
debugger due to aggressive optimizations by clang in release builds.
`debugHintScriptGroup2`, used by the debugger to inspect ScriptGroup
compilations at `optlevel == 0`, had its inner loop optimized away
completely as there are no visible side effects (where the ALOGV calls
are actually empty macros). This was fixed by using an `__asm__
__volatile__ ("")` construct as per the gcc docs:
noinline This function attribute prevents a function from being
considered for inlining. If the function does not have side-effects,
there are optimizations other than inlining that causes function
calls to be optimized away, although the function call is live. To
keep such calls from being optimized away, put `asm ("")` in the
called function, to serve as a special side-effect.
(see also
https://gcc.gnu.org/onlinedocs/gcc/Alternate-Keywords.html
https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes)
Although preventing the inner loop from being optimized away is enough
to get the function called, it is apparent that clang only sets up the
call frame with arguments that it can see are used inside the function
body, meaning that we had garbage values for `groupName` and
`groupNameSize` unless the symbol is weakly visible so that the compiler
can no longer introspect that the arguments are ignored.
Test: aosp_x86_64-eng (emulator)
- RsTest (32-bit, 64-bit)
- cts -m RenderscriptTest
- rs/lldb (required various other pending CLs)
Bug: 23535482
Change-Id: I24e23895e67d1ede8bf8e671165a3a6843a11082
Signed-off-by: Luke Drummond <luke.drummond@codeplay.com>
1 file changed