Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

C program to analyze core files

AIX Commands

C program to analyze core files

by  cspilman  Posted    (Edited  )
This is tried and tested on AIX 4.3 versions:


#include <stdio.h>
#include <sys/core.h>

void main(int argc, char *argv[])
{
FILE *corefile;
struct core_dumpx c_file;
char command[256];

if (argc != 2) {
fprintf(stderr, "Usage: %s <corefile>\n", *argv);
exit(1);
}

if ((corefile = fopen(argv[1], "r")) == NULL) {
perror(argv[1]);
exit(1);
}

fread(&c_file, sizeof(c_file), 1, corefile);
fclose(corefile);

sprintf(command, "lquerypv -h %s 6E0 64 | head -1 | awk '{print $6}'", argv[1]);

printf("Core created by: \n");

system(command);

printf("Signal number and cause of error number: %i\n", c_file.c_signo);
printf("Core file type: %i\n", c_file.c_flag);
printf("Number of core dump modules: %i\n", c_file.c_entries);
printf("Core file format number: %i\n", c_file.c_version);
printf("Thread identifier: %i\n", c_file.c_flt.th.ti_tid);
printf("Process identifier: %i\n", c_file.c_flt.th.ti_pid);
printf("Current effective priority: %i\n", c_file.c_flt.th.ti_pri);
printf("Processor Usage: %i\n", c_file.c_flt.th.ti_cpu);
printf("Processor bound to: cpu%i\n", c_file.c_flt.th.ti_cpuid);

/* if (c_file.c_flt.th.ti_cpu > 1) printf("Last Processor: cpu%i\n", c_file.c_flt.th.ti_affinity);
*/
exit(0);
}


Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top