* [9fans] libmach x86 botch
@ 2011-09-04 17:33 erik quanstrom
2011-09-04 17:38 ` erik quanstrom
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: erik quanstrom @ 2011-09-04 17:33 UTC (permalink / raw)
To: 9fans
it appers that either i386das and i386inst are misnamed, or they
are listed incorrectly in /sys/src/libmach/8db.c. since at least [v7]db
follow the same pattern, i'm pretty sure the header file is wrong.
also i believe the setting of errstr() in i386das and i386inst is incorrect.
(for a demonstration, try asm(stackaddress) on a running 386 executable.
you'll get a few bytes of unprintable garbage.)
- erik
Machdata i386mach =
{
{0xCC, 0, 0, 0}, /* break point: INT 3 */
1, /* break point size */
leswab, /* convert short to local byte order */
leswal, /* convert long to local byte order */
leswav, /* convert vlong to local byte order */
i386trace, /* C traceback */
i386frame, /* frame finder */
i386excep, /* print exception */
0, /* breakpoint fixup */
leieeesftos, /* single precision float printer */
leieeedftos, /* double precision float printer */
i386foll, /* following addresses */
>> i386inst, /* print instruction */
>> i386das, /* dissembler */
i386instlen, /* instruction size calculation */
};
yet
/sys/include/mach.h:202,219
struct Machdata { /* Machine-dependent debugger support */
uchar bpinst[4]; /* break point instr. */
short bpsize; /* size of break point instr. */
ushort (*swab)(ushort); /* ushort to local byte order */
ulong (*swal)(ulong); /* ulong to local byte order */
uvlong (*swav)(uvlong); /* uvlong to local byte order */
int (*ctrace)(Map*, uvlong, uvlong, uvlong, Tracer); /* C traceback */
uvlong (*findframe)(Map*, uvlong, uvlong, uvlong, uvlong);/* frame finder */
char* (*excep)(Map*, Rgetter); /* last exception */
ulong (*bpfix)(uvlong); /* breakpoint fixup */
int (*sftos)(char*, int, void*); /* single precision float */
int (*dftos)(char*, int, void*); /* double precision float */
int (*foll)(Map*, uvlong, Rgetter, uvlong*);/* follow set */
>> int (*das)(Map*, uvlong, char, char*, int); /* symbolic disassembly */
>> int (*hexinst)(Map*, uvlong, char*, int); /* hex disassembly */
int (*instsize)(Map*, uvlong); /* instruction size */
};
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9fans] libmach x86 botch
2011-09-04 17:33 [9fans] libmach x86 botch erik quanstrom
@ 2011-09-04 17:38 ` erik quanstrom
2011-09-04 18:32 ` Russ Cox
[not found] ` <CADSkJJUnyBgoCt7bek6482BJ2SZ7vh=DbaFwNLNcY36qj994+g@mail.gmail.c>
2 siblings, 0 replies; 4+ messages in thread
From: erik quanstrom @ 2011-09-04 17:38 UTC (permalink / raw)
To: quanstro, 9fans
forgot to include a proposed fix
; diffy -c 8db.c
/n/dump/2011/0904/sys/src/libmach/8db.c:2060,2066 - 8db.c:2060,2066
USED(modifier);
op = mkinstr(map, &instr, pc);
if (op == 0) {
- errstr(buf, n);
+ // errstr(buf, n);
return -1;
}
instr.curr = buf;
/n/dump/2011/0904/sys/src/libmach/8db.c:2076,2082 - 8db.c:2076,2082
int i;
if (mkinstr(map, &instr, pc) == 0) {
- errstr(buf, n);
+ // errstr(buf, n);
return -1;
}
for(i = 0; i < instr.n && n > 2; i++) {
before
; acid 1242799
/proc/1242799/text:386 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/386
acid: asm(0xdfffef8c)
0xdfffef8c 0xdfffef8c <stdin>:2: (error) indir: -<cr><enq>
acid: <eot>
echo kill > /proc/1242799/ctl
after
; acid 1242799
/proc/1242799/text:386 plan 9 executable
/sys/lib/acid/port
/sys/lib/acid/386
acid: asm(0xdfffef8c)
0xdfffef8c 0xdfffef8c <stdin>:2: (error) indir: can't read instruction: can't translate address 0xdfffef8c
acid: <eot>
echo kill > /proc/1242799/ctl
- erik
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [9fans] libmach x86 botch
2011-09-04 17:33 [9fans] libmach x86 botch erik quanstrom
2011-09-04 17:38 ` erik quanstrom
@ 2011-09-04 18:32 ` Russ Cox
[not found] ` <CADSkJJUnyBgoCt7bek6482BJ2SZ7vh=DbaFwNLNcY36qj994+g@mail.gmail.c>
2 siblings, 0 replies; 4+ messages in thread
From: Russ Cox @ 2011-09-04 18:32 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
asm(stackaddress) is bogus not because of libmach
but because asm is defined to disassemble from the
text file, not from memory. Run 'whatis asm' in acid and
notice that it says @addr++ not *addr++.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [9fans] libmach x86 botch
[not found] ` <CADSkJJUnyBgoCt7bek6482BJ2SZ7vh=DbaFwNLNcY36qj994+g@mail.gmail.c>
@ 2011-09-04 18:36 ` erik quanstrom
0 siblings, 0 replies; 4+ messages in thread
From: erik quanstrom @ 2011-09-04 18:36 UTC (permalink / raw)
On Sun Sep 4 14:34:41 EDT 2011, rsc at swtch.com wrote:
> asm(stackaddress) is bogus not because of libmach
> but because asm is defined to disassemble from the
> text file, not from memory. Run 'whatis asm' in acid and
> notice that it says @addr++ not *addr++.
clearly. but that's not what i'm complaining about.
i'm complaining that asm(stackaddress) accesses uninitialized
memory when printing out the error, which is therefore
exceptionally misleading.
- erik
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-09-04 18:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-04 17:33 [9fans] libmach x86 botch erik quanstrom
2011-09-04 17:38 ` erik quanstrom
2011-09-04 18:32 ` Russ Cox
[not found] ` <CADSkJJUnyBgoCt7bek6482BJ2SZ7vh=DbaFwNLNcY36qj994+g@mail.gmail.c>
2011-09-04 18:36 ` erik quanstrom
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).