google / gapid

Graphics API Debugger
https://gapid.dev
Apache License 2.0
2.2k stars 327 forks source link

gapid tool building for X86-64 bit Android platform #2346

Closed gittmi closed 4 years ago

gittmi commented 5 years ago

Hi, We are unable to run gapid on x86-64 bit android platform. We are running 64-bit app on the platform. From the other issues threads, I got to know currently gapid is not supporting X86-64 bit android platform for 64 bit apps. Is there any specific reason for not supporting this platform? What could be the major dependencies for building gapid for x86-64bit? I am thinking If we have 64-bit OpenGLES/Vulkan libraries from driver side, we can make 64 bit interceptor library and use?

If this is not the case, what changes we need to consider on gapid side? Do we have an platform specific code that need to be modified in gapid?

Thanks, Hithendra

AWoloszyn commented 5 years ago

Due to how interception works on Android, we maintain a driver patching layer that will, at runtime patch function headers, and write trampolines to our interception layer.

This has not yet been implemented for x86_64. That is the only thing that is missing for x86_64.

The x86 version is here: https://github.com/google/gapid/blob/master/gapii/interceptor-lib/cc/lib/X86/target_x86.cc

Andrew

gittmi commented 5 years ago

Thanks Andrew. I have not fully understood the code yet. From my understanding, based on x86 code available, By following the same guidelines if I can create target_x86_64.cc, gapid support for x86_64 is done. Is this correct? I am sure there must be something else we need to modify to achieve this. Can you provide pointers to understand how this target code generation is done? Which modules need to be understood etc ..? I am trying to understand the complexity of this task?

Thanks, Hithendra

AWoloszyn commented 5 years ago

The only complex code that has to be handled is target_x86_64.cc.

There will be some other minor work that needs to be done to have the rest of the project know that x86_64 exists for Android. However most of the rest of the project already understands x86_64 since that is what we ship for desktop.

If you look through the project for "armeabi-v7a", "android-armeabi-v7a", "gapid-armeabi.apk" You should be able to imitate those to add the android build for x86_64.

Specifically for target_x86_64.cc, you need a pretty good understanding of x86_64 assembly. The code basically disassembles the function in the driver, re-writes it to point to our function instead, and generates us a trampoline that we can call back into the driver.

gittmi commented 5 years ago

Hi Andrew, Any plans of implementing interceptor librray for android x86_64?

pau-baiget commented 4 years ago

Closing this as duplicate of https://github.com/google/gapid/issues/3138. We'll track all the work to support x86_64 there.