From: Nick B. <ni...@sg...> - 2005-04-21 06:26:56
|
Using the following sial script (note this is on ia64/sn2 system): string stats_usage() { return ""; } string stats_help() { return "Displays CXFS client statistics data.";} void stats() { cxfsstat_client_info_t *pStats pStats = (cxfsstat_client_info_t*)cxfsclientstats; printf("Struct member address:\n"); p = &pStats->cxfs_vfssync; printf("&stats = %lx\n", pStats); printf("&stats->cxfs_vfssync = %lx (offset = %d)\n", &pStats->cxfs_vfssync, &pStats->cxfs_vfssync - pStats); printf("Struct member value (incorrect):\n"); printf("stats->cxfs_vfssync = %d\n", pStats->cxfs_vfssync); printf("Struct member value (using correct offset):\n"); printf("*(int *)&pSatst->cxfs_vfssync = %d\n", *(int *)&pStats->cxfs_vfssync); } I get the following (incorrect) output: >> load stats.sial >> stats Struct member address: &stats = a0000002055a4d60 &stats->cxfs_vfssync = a0000002055a5000 (offset = 672) Struct member value (incorrect): stats->cxfs_vfssync = 2 Struct member value (using correct offset): *(int *)&pStats->cxfs_vfssync = 378 The returned value for cxfs_vfssync is incorrect. It seems that this chunk of code (in sial_exemem()) is making some bad assumptions: case 4: if(sizeof(long) == 8){ /* XXX */ API_GETMEM(mempos, &v->v.ull, 8); v->v.ul = API_GET_UINT32(((char*)&(v-> v.ul)) + 4); } else { API_GETMEM(mempos, &v->v.ul, 4); v->v.ul = API_GET_UINT32(&v->v.ul); } break; This results in the wrong 4 bytes been used for the value. Removing the top 4 lines fixes this problem and I get the correct results from the stats script. Thanks Nick |