接着2016-02-15 11:54:14的问题,打印出的log如下:
I/DEBUG ( 310):
I/DEBUG ( 310): backtrace:
I/DEBUG ( 310): #00 pc 0000000000000c44 /system/lib64/libhardware.so (hw_get_module_by_class+560)
I/DEBUG ( 310): #01 pc 0000000000021d08 /system/lib64/libandroid_servers.so
I/DEBUG ( 310): #02 pc 0000000000125054 /data/dalvik-cache/arm64/system@framework@services.jar@classes.dex
根据log中的backtrace,在android源码根目录下定位报错所在源文件及行号:
aarch64-linux-android-addr2line -e out/target/product/msm8916_64/symbols/system/lib64/libandroid_servers.so 0000000000021d08
/home/embedded/android/410c_yk_1/APQ8016_410C_LA.BR.1.2.4018108x16.0_5.1.1_Lollipop_P2/frameworks/base/services/core/jni/com_android_server_SwtledService.cpp:66
aarch64-linux-android-addr2line -e out/target/product/msm8916_64/symbols/system/lib64/libhardware.so 0000000000000c44
home/embedded/android/410c_yk_1/APQ8016_410C_LA.BR.1.2.4-01810-8x16.0_5.1.1_Lollipop_P2/hardware/libhardware/hardware.c:104
贴出load()函数:
static int load(const char *id,
const char *path,
const struct hw_module_t **pHmi)
{
int status;
void *handle;
struct hw_module_t *hmi;
/*
* load the symbols resolving undefined symbols before
* dlopen returns. Since RTLD_GLOBAL is not or'd in with
* RTLD_NOW the external symbols will not be global
*/
ALOGE("20160219 load: id=%s,path=%s\n", id, path);
handle = dlopen(path, RTLD_NOW);
if (handle == NULL) {
char const *err_str = dlerror();
ALOGE("load: module=%s\n%s", path, err_str?err_str:"unknown");
status = -EINVAL;
goto done;
}
ALOGE("load: handle=0x%X\n", handle);
/* Get the address of the struct hal_module_info. */
const char *sym = HAL_MODULE_INFO_SYM_AS_STR;
hmi = (struct hw_module_t *)dlsym(handle, sym);
if (hmi == NULL) {
ALOGE("load: couldn't find symbol %s", sym);
status = -EINVAL;
goto done;
}
ALOGE("load: id=%s,hmi=0x%X,hmi->id=%s\n",id,hmi,hmi->id);
/* Check that the id matches */
if (strcmp(id, hmi->id) != 0) {
ALOGE("load: id=%s != hmi->id=%s", id, hmi->id);
status = -EINVAL;
goto done;
}
hmi->dso = handle;
ALOGE("load: hmi->dso=0x%X,handle=0x%X\n", hmi->dso,handle);
/* success */
status = 0;
done:
if (status != 0) {
hmi = NULL;
if (handle != NULL) {
dlclose(handle);
handle = NULL;
}
} else {
ALOGE("loaded HAL id=%s path=%s hmi=%p handle=%p",
id, path, *pHmi, handle);
}
ALOGE("load: hmi=0x%X\n", hmi);
*pHmi = hmi;
ALOGE("load: *PHmi=0x%X,status=%d\n", *pHmi,status);
return status;
}
最终定位出在这句代码:hmi->dso = handle;不太理解这句有什么问题?