@@ -1258,120 +1258,6 @@ static const char* __itt_get_env_var(const char* name)
1258
1258
static const char * __itt_get_lib_name (void )
1259
1259
{
1260
1260
const char * lib_name = __itt_get_env_var (ITT_TO_STR (LIB_VAR_NAME ));
1261
-
1262
- #ifdef __ANDROID__
1263
- if (lib_name == NULL )
1264
- {
1265
-
1266
- #if ITT_ARCH == ITT_ARCH_IA32 || ITT_ARCH == ITT_ARCH_ARM
1267
- const char * const marker_filename = "com.intel.itt.collector_lib_32" ;
1268
- #else
1269
- const char * const marker_filename = "com.intel.itt.collector_lib_64" ;
1270
- #endif
1271
-
1272
- char system_wide_marker_filename [PATH_MAX ] = {0 };
1273
- int itt_marker_file_fd = -1 ;
1274
- ssize_t res = 0 ;
1275
-
1276
- res = snprintf (system_wide_marker_filename , PATH_MAX - 1 , "%s%s" , "/data/local/tmp/" , marker_filename );
1277
- if (res < 0 )
1278
- {
1279
- ITT_ANDROID_LOGE ("Unable to concatenate marker file string." );
1280
- return lib_name ;
1281
- }
1282
- itt_marker_file_fd = open (system_wide_marker_filename , O_RDONLY );
1283
-
1284
- if (itt_marker_file_fd == -1 )
1285
- {
1286
- const pid_t my_pid = getpid ();
1287
- char cmdline_path [PATH_MAX ] = {0 };
1288
- char package_name [PATH_MAX ] = {0 };
1289
- char app_sandbox_file [PATH_MAX ] = {0 };
1290
- int cmdline_fd = 0 ;
1291
-
1292
- ITT_ANDROID_LOGI ("Unable to open system-wide marker file." );
1293
- res = snprintf (cmdline_path , PATH_MAX - 1 , "/proc/%d/cmdline" , my_pid );
1294
- if (res < 0 )
1295
- {
1296
- ITT_ANDROID_LOGE ("Unable to get cmdline path string." );
1297
- return lib_name ;
1298
- }
1299
-
1300
- ITT_ANDROID_LOGI ("CMD file: %s\n" , cmdline_path );
1301
- cmdline_fd = open (cmdline_path , O_RDONLY );
1302
- if (cmdline_fd == -1 )
1303
- {
1304
- ITT_ANDROID_LOGE ("Unable to open %s file!" , cmdline_path );
1305
- return lib_name ;
1306
- }
1307
- res = read (cmdline_fd , package_name , PATH_MAX - 1 );
1308
- if (res == -1 )
1309
- {
1310
- ITT_ANDROID_LOGE ("Unable to read %s file!" , cmdline_path );
1311
- res = close (cmdline_fd );
1312
- if (res == -1 )
1313
- {
1314
- ITT_ANDROID_LOGE ("Unable to close %s file!" , cmdline_path );
1315
- }
1316
- return lib_name ;
1317
- }
1318
- res = close (cmdline_fd );
1319
- if (res == -1 )
1320
- {
1321
- ITT_ANDROID_LOGE ("Unable to close %s file!" , cmdline_path );
1322
- return lib_name ;
1323
- }
1324
- ITT_ANDROID_LOGI ("Package name: %s\n" , package_name );
1325
- res = snprintf (app_sandbox_file , PATH_MAX - 1 , "/data/data/%s/%s" , package_name , marker_filename );
1326
- if (res < 0 )
1327
- {
1328
- ITT_ANDROID_LOGE ("Unable to concatenate marker file string." );
1329
- return lib_name ;
1330
- }
1331
-
1332
- ITT_ANDROID_LOGI ("Lib marker file name: %s\n" , app_sandbox_file );
1333
- itt_marker_file_fd = open (app_sandbox_file , O_RDONLY );
1334
- if (itt_marker_file_fd == -1 )
1335
- {
1336
- ITT_ANDROID_LOGE ("Unable to open app marker file!" );
1337
- return lib_name ;
1338
- }
1339
- }
1340
-
1341
- {
1342
- char itt_lib_name [PATH_MAX ] = {0 };
1343
-
1344
- res = read (itt_marker_file_fd , itt_lib_name , PATH_MAX - 1 );
1345
- if (res == -1 )
1346
- {
1347
- ITT_ANDROID_LOGE ("Unable to read %s file!" , itt_marker_file_fd );
1348
- res = close (itt_marker_file_fd );
1349
- if (res == -1 )
1350
- {
1351
- ITT_ANDROID_LOGE ("Unable to close %s file!" , itt_marker_file_fd );
1352
- }
1353
- return lib_name ;
1354
- }
1355
- ITT_ANDROID_LOGI ("ITT Lib path: %s" , itt_lib_name );
1356
- res = close (itt_marker_file_fd );
1357
- if (res == -1 )
1358
- {
1359
- ITT_ANDROID_LOGE ("Unable to close %s file!" , itt_marker_file_fd );
1360
- return lib_name ;
1361
- }
1362
- ITT_ANDROID_LOGI ("Set env %s to %s" , ITT_TO_STR (LIB_VAR_NAME ), itt_lib_name );
1363
- res = setenv (ITT_TO_STR (LIB_VAR_NAME ), itt_lib_name , 0 );
1364
- if (res == -1 )
1365
- {
1366
- ITT_ANDROID_LOGE ("Unable to set env var!" );
1367
- return lib_name ;
1368
- }
1369
- lib_name = __itt_get_env_var (ITT_TO_STR (LIB_VAR_NAME ));
1370
- ITT_ANDROID_LOGI ("ITT Lib path from env: %s" , lib_name );
1371
- }
1372
- }
1373
- #endif
1374
-
1375
1261
return lib_name ;
1376
1262
}
1377
1263
0 commit comments