Reputation: 1
I want to debug my native library libtestnative.so
at the low level using lldb. In order to do that I have to know what is the base address of the target shared object. I wrote a lldb script leveraging the python framework to dump all memory regions but in the result list there was no entry of it though the code still executed normally.
I tried 2 things:
jobject myNativeMethod3(JNIEnv *env, jobject thiz, jobject arrayObj) {
LOGI("Reading string array");
struct timespec ts = {2, 0}; // 2 second sleep
while(true){
LOGI("waiting for lldb");
nanosleep(&ts, nullptr);
}
}
def get_memory_regions(debugger, command, result, internal_dict):
target = debugger.GetSelectedTarget()
process = target.GetProcess()
if not process:
print("No process available.")
return
region_list = process.GetMemoryRegions()
print(f"Total regions: {region_list.GetSize()}")
with open('regions.txt', 'w') as f:
for i in range(region_list.GetSize()):
region_info = lldb.SBMemoryRegionInfo()
if region_list.GetMemoryRegionAtIndex(i, region_info):
name = region_info.GetName()
f.write(f"{name}\n")
but the target shared object name not appeared in the list.
I could see there was an entry named /data/app/~~v4slxMbRQy4YqeFeTO3Rig==/com.example.testnative-Lkf80ctXP4dWS-iV201AwQ==/base.apk
appeared, but I also expect a lib named libtestnative.so
in the list.
Upvotes: 0
Views: 23