8 #define errno uregerrno
10 typedef struct Lreg Lreg;
11 typedef struct Status Status;
12 typedef struct Psinfo Psinfo;
15 * UregLinux386 is 64-bit aligned within status, so we shouldn't
16 * have any packing problems.
39 StatusSize = sizeof(Status),
60 PsinfoSize = sizeof(Psinfo),
64 coreregslinux386(Elf *elf, ElfNote *note, uchar **up)
70 if(note->descsz < sizeof(Status)){
71 werrstr("elf status note too small");
74 s = (Status*)note->desc;
76 if((u = malloc(sizeof *u)) == nil)
84 corecmdlinux386(Elf *elf, ElfNote *note, char **pp)
90 if(note->descsz < sizeof(Psinfo)){
91 werrstr("elf psinfo note too small");
94 p = (Psinfo*)note->desc;
95 // print("elf name %s\nelf args %s\n", p->fname, p->psargs);
99 memmove(t, p->psargs, 80);
105 #define dprint if(0)print
108 elfcorelinux386(Fhdr *fp, Elf *elf, ElfNote *note)
117 dprint("%s ", note->name);
119 case ElfNotePrPsinfo:
120 ps = (Psinfo*)note->desc;
121 dprint("note info\n");
122 dprint("state=%d sname=%d zomb=%d nice=%d\n",
123 ps->state, ps->sname, ps->zomb, ps->nice);
124 dprint("flag=0x%ux uid=%ud gid=%ud pid=%ud ppid=%ud pgrp=%ud sid=%ud\n",
125 (uint)m->swap4(ps->flag),
126 (uint)m->swap2(ps->uid),
127 (uint)m->swap2(ps->gid),
128 (uint)m->swap4(ps->pid),
129 (uint)m->swap4(ps->ppid),
130 (uint)m->swap4(ps->pgrp),
131 (uint)m->swap4(ps->sid));
132 dprint("fname=%s psargs=%s\n", ps->fname, ps->psargs);
133 fp->pid = m->swap4(ps->pid);
134 if((fp->prog = strdup(ps->fname)) == nil)
135 fprint(2, "warning: out of memory saving core program name\n");
136 if((fp->cmdline = strdup(ps->psargs)) == nil)
137 fprint(2, "warning: out of memory saving core command line\n");
139 case ElfNotePrTaskstruct:
140 dprint("note taskstruct\n");
143 dprint("note auxv\n");
145 case ElfNotePrStatus:
146 dprint("note status\n");
147 if(note->descsz < StatusSize){
148 dprint("too small\n");
151 st = (Status*)note->desc;
152 dprint("sig=%ud code=%ud errno=%ud cursig=%ud sigpend=0x%ux sighold=0x%ux\n",
153 (uint)m->swap4(st->signo),
154 (uint)m->swap4(st->code),
155 (uint)m->swap4(st->errno),
156 (uint)m->swap4(st->cursig),
157 (uint)m->swap4(st->sigpend),
158 (uint)m->swap4(st->sighold));
159 dprint("pid=%ud ppid=%ud pgrp=%ud sid=%ud\n",
160 (uint)m->swap4(st->pid),
161 (uint)m->swap4(st->ppid),
162 (uint)m->swap4(st->pgrp),
163 (uint)m->swap4(st->sid));
164 dprint("utime=%ud.%06ud stime=%ud.%06ud cutime=%ud.%06ud cstime=%ud.%06ud\n",
165 (uint)m->swap4(st->utime[0]),
166 (uint)m->swap4(st->utime[1]),
167 (uint)m->swap4(st->stime[0]),
168 (uint)m->swap4(st->stime[1]),
169 (uint)m->swap4(st->cutime[0]),
170 (uint)m->swap4(st->cutime[1]),
171 (uint)m->swap4(st->cstime[0]),
172 (uint)m->swap4(st->cstime[1]));
173 dprint("fpvalid=%ud\n",
174 (uint)m->swap4(st->fpvalid));
175 if((fp->thread = realloc(fp->thread, (1+fp->nthread)*sizeof(fp->thread[0]))) == nil){
176 fprint(2, "warning: out of memory saving thread info\n");
180 fp->thread[i].id = m->swap4(st->pid);
181 u = malloc(sizeof *u);
183 fprint(2, "warning: out of memory saving thread info\n");
186 fp->thread[i].ureg = u;
187 linux2ureg386(&st->reg, u);
191 dprint("note fpreg\n");
192 /* XXX maybe record floating-point registers eventually */
194 case ElfNotePrXfpreg:
195 dprint("note xfpreg\n");
196 /* XXX maybe record floating-point registers eventually */
199 dprint("note %d\n", note->type);