1 /* i386 specific core note handling. 2 Copyright (C) 2002 Red Hat, Inc. 3 Written by Ulrich Drepper <drepper (at) redhat.com>, 2002. 4 5 This program is Open Source software; you can redistribute it and/or 6 modify it under the terms of the Open Software License version 1.0 as 7 published by the Open Source Initiative. 8 9 You should have received a copy of the Open Software License along 10 with this program; if not, you may obtain a copy of the Open Software 11 License version 1.0 from http://www.opensource.org/licenses/osl.php or 12 by writing the Open Source Initiative c/o Lawrence Rosen, Esq., 13 3001 King Ranch Road, Ukiah, CA 95482. */ 14 15 #ifdef HAVE_CONFIG_H 16 # include <config.h> 17 #endif 18 19 #include <elf.h> 20 #include <stddef.h> 21 #include <stdio.h> 22 #include <sys/time.h> 23 24 #include <libebl_i386.h> 25 26 27 /* We cannot include <sys/procfs.h> since it is available only on x86 28 systems. */ 29 struct elf_prstatus 30 { 31 struct 32 { 33 int si_signo; /* Signal number. */ 34 int si_code; /* Extra code. */ 35 int si_errno; /* Errno. */ 36 } pr_info; /* Info associated with signal. */ 37 short int pr_cursig; /* Current signal. */ 38 unsigned long int pr_sigpend; /* Set of pending signals. */ 39 unsigned long int pr_sighold; /* Set of held signals. */ 40 __pid_t pr_pid; 41 __pid_t pr_ppid; 42 __pid_t pr_pgrp; 43 __pid_t pr_sid; 44 struct timeval pr_utime; /* User time. */ 45 struct timeval pr_stime; /* System time. */ 46 struct timeval pr_cutime; /* Cumulative user time. */ 47 struct timeval pr_cstime; /* Cumulative system time. */ 48 unsigned long int pr_reg[17]; /* GP registers. */ 49 int pr_fpvalid; /* True if math copro being used. */ 50 }; 51 52 53 struct elf_prpsinfo 54 { 55 char pr_state; /* Numeric process state. */ 56 char pr_sname; /* Char for pr_state. */ 57 char pr_zomb; /* Zombie. */ 58 char pr_nice; /* Nice val. */ 59 unsigned long int pr_flag; /* Flags. */ 60 unsigned short int pr_uid; 61 unsigned short int pr_gid; 62 int pr_pid; 63 int pr_ppid; 64 int pr_pgrp; 65 int pr_sid; 66 /* Lots missing */ 67 char pr_fname[16]; /* Filename of executable. */ 68 char pr_psargs[80]; /* Initial part of arg list. */ 69 }; 70 71 72 bool 73 i386_core_note (name, type, descsz, desc) 74 const char *name; 75 uint32_t type; 76 uint32_t descsz; 77 const char *desc; 78 { 79 bool result = false; 80 81 switch (type) 82 { 83 case NT_PRSTATUS: 84 if (descsz < sizeof (struct elf_prstatus)) 85 /* Not enough data. */ 86 break; 87 88 struct elf_prstatus *stat = (struct elf_prstatus *) desc; 89 90 printf (" SIGINFO: signo: %d, code = %d, errno = %d\n" 91 " signal: %hd, pending: %#08lx, holding: %#08lx\n" 92 " pid: %d, ppid = %d, pgrp = %d, sid = %d\n" 93 " utime: %6ld.%06lds, stime: %6ld.%06lds\n" 94 " cutime: %6ld.%06lds, cstime: %6ld.%06lds\n" 95 " eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n" 96 " esi: %08lx edi: %08lx ebp: %08lx esp: %08lx\n" 97 " eip: %08lx eflags: %08lx, original eax: %08lx\n" 98 " cs: %04lx ds: %04lx es: %04lx fs: %04lx gs: %04lx" 99 " ss: %04lx\n\n" 100 , 101 stat->pr_info. si_signo, 102 stat->pr_info. si_code, 103 stat->pr_info. si_errno, 104 stat->pr_cursig, 105 stat->pr_sigpend, stat->pr_sighold, 106 stat->pr_pid, stat->pr_ppid, stat->pr_pgrp, stat->pr_sid, 107 stat->pr_utime.tv_sec, (long int) stat->pr_utime.tv_usec, 108 stat->pr_stime.tv_sec, (long int) stat->pr_stime.tv_usec, 109 stat->pr_cutime.tv_sec, (long int) stat->pr_cutime.tv_usec, 110 stat->pr_cstime.tv_sec, (long int) stat->pr_cstime.tv_usec, 111 stat->pr_reg[6], stat->pr_reg[0], stat->pr_reg[1], 112 stat->pr_reg[2], stat->pr_reg[3], stat->pr_reg[4], 113 stat->pr_reg[5], stat->pr_reg[15], stat->pr_reg[12], 114 stat->pr_reg[14], stat->pr_reg[11], stat->pr_reg[13] & 0xffff, 115 stat->pr_reg[7] & 0xffff, stat->pr_reg[8] & 0xffff, 116 stat->pr_reg[9] & 0xffff, stat->pr_reg[10] & 0xffff, 117 stat->pr_reg[16]); 118 119 /* We handled this entry. */ 120 result = true; 121 break; 122 123 case NT_PRPSINFO: 124 if (descsz < sizeof (struct elf_prpsinfo)) 125 /* Not enough data. */ 126 break; 127 128 struct elf_prpsinfo *info = (struct elf_prpsinfo *) desc; 129 130 printf (" state: %c (%hhd), zombie: %hhd, nice: %hhd\n" 131 " flags: %08lx, uid: %hd, gid: %hd\n" 132 " pid: %d, ppid: %d, pgrp: %d, sid: %d\n" 133 " fname: %.16s\n" 134 " args: %.80s\n\n", 135 info->pr_sname, info->pr_state, info->pr_zomb, info->pr_nice, 136 info->pr_flag, info->pr_uid, info->pr_gid, 137 info->pr_pid, info->pr_ppid, info->pr_pgrp, info->pr_sid, 138 info->pr_fname, info->pr_psargs); 139 140 /* We handled this entry. */ 141 result = true; 142 break; 143 144 default: 145 break; 146 } 147 148 return result; 149 } 150