9front - general discussion about 9front
 help / color / mirror / Atom feed
* profiling bug on amd64
@ 2014-02-17  6:11 Nick Owens
  2014-02-17  6:18 ` [9front] " Nick Owens
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Owens @ 2014-02-17  6:11 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 1209 bytes --]

when attempting to profile a program on amd64 (games/nes), there's a
problem where function arguments fail to be restored by the profiling
code.

acid: lstk()
_tas()+0x5 /sys/src/libc/amd64/tas.s:5
lock(lk=0x0)+0x13 /sys/src/libc/port/lock.c:10
	i=0x206b9700000000
atexit(f=0x0)+0x18 /sys/src/libc/port/atexit.c:21
	i=0x205f9f00000000
_profmain()+0x18d /sys/src/libc/port/profile.c:268
	n=0x7d0
	f=0x7d0ffffffff
	ename=0x0
_mainp+0x2c /sys/src/libc/amd64/main9p.s:12

obviously something is wrong here, with f=0x0 and i=0x205f9f00000000
in atexit.

but, if you move #pragma profile off up a little ways before the
definition of atexit in /sys/src/libc/port/atexit.c, you get the same
problem in lock() still.

acid: lstk()
_tas()+0x5 /sys/src/libc/amd64/tas.s:5
lock(lk=0x0)+0x13 /sys/src/libc/port/lock.c:10
  i=0x206b9200000000
atexit(f=0x205a6e)+0x13 /sys/src/libc/port/atexit.c:23
  i=0x205f9f00000000
_profmain()+0x18d /sys/src/libc/port/profile.c:268
  n=0x7d0
  f=0x7d0ffffffff
  ename=0x0
_mainp+0x2c /sys/src/libc/amd64/main9p.s:12

here, the argument to atexit is valid, but lock's argument is still zero,
so something in the profiling code is certainly affecting the program's behavior.

mischief


[-- Attachment #2: Type: application/pgp-signature, Size: 834 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9front] profiling bug on amd64
  2014-02-17  6:11 profiling bug on amd64 Nick Owens
@ 2014-02-17  6:18 ` Nick Owens
  2014-02-17 18:58   ` Nick Owens
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Owens @ 2014-02-17  6:18 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 1736 bytes --]

related, acid can't seem to handle disassembing profiled functions which
have breakpoints set.

acid: bpset(lock)
acid: asm(lock)
lock 0x00000000002068f9 CALL  _profin(SB)
lock+0x1 0x00000000002068fa JCC malloctopoolblock+0x13(SB)
lock+0x3 0x00000000002068fc <stdin>:64: (error) opcode: ??ffff??
acid: bpdel(lock)
acid: asm(lock)
lock 0x00000000002068f9 CALL  _profin(SB)
lock+0x5 0x00000000002068fe SUBQ  $0x20,SP
lock+0x9 0x0000000000206902 MOVQ  BP,lk+0x0(FP)
lock+0xe 0x0000000000206907 CALL  _tas(SB)
lock+0x13 0x000000000020690c  CMPL  AX,$0x0
lock+0x16 0x000000000020690f  JNE lock+0x22(SB)
lock+0x18 0x0000000000206911  ADDQ  $0x20,SP
lock+0x1c 0x0000000000206915  CALL  _profout(SB)
lock+0x21 0x000000000020691a  RET
lock+0x22 0x000000000020691b  XORL  CX,CX
lock+0x24 0x000000000020691d  CMPL  CX,$0x3e8
lock+0x2a 0x0000000000206923  MOVL  CX,i+0x1c(SP)
lock+0x2e 0x0000000000206927  JGE lock+0x62(SB)
lock+0x30 0x0000000000206929  MOVQ  lk+0x0(FP),BP
lock+0x35 0x000000000020692e  CALL  _tas(SB)
lock+0x3a 0x0000000000206933  CMPL  AX,$0x0
lock+0x3d 0x0000000000206936  JNE lock+0x49(SB)
lock+0x3f 0x0000000000206938  ADDQ  $0x20,SP
lock+0x43 0x000000000020693c  CALL  _profout(SB)
lock+0x48 0x0000000000206941  RET
lock+0x49 0x0000000000206942  XORL  BP,BP
lock+0x4b 0x0000000000206944  CALL  sleep(SB)
lock+0x50 0x0000000000206949  MOVL  i+0x1c(SP),CX
lock+0x54 0x000000000020694d  INCL  CX
lock+0x56 0x000000000020694f  CMPL  CX,$0x3e8
lock+0x5c 0x0000000000206955  MOVL  CX,i+0x1c(SP)
lock+0x60 0x0000000000206959  JLT lock+0x30(SB)
lock+0x62 0x000000000020695b  XORL  CX,CX
lock+0x64 0x000000000020695d  CMPL  CX,$0x3e8
lock+0x6a 0x0000000000206963  MOVL  CX,i+0x1c(SP)
acid: 


[-- Attachment #2: Type: application/pgp-signature, Size: 834 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9front] profiling bug on amd64
  2014-02-17  6:18 ` [9front] " Nick Owens
@ 2014-02-17 18:58   ` Nick Owens
  0 siblings, 0 replies; 3+ messages in thread
From: Nick Owens @ 2014-02-17 18:58 UTC (permalink / raw)
  To: 9front

[-- Attachment #1: Type: text/plain, Size: 47 bytes --]

fixed in revision 3487c674e3be.
thanks cinap.


[-- Attachment #2: Type: application/pgp-signature, Size: 834 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-02-17 18:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-17  6:11 profiling bug on amd64 Nick Owens
2014-02-17  6:18 ` [9front] " Nick Owens
2014-02-17 18:58   ` Nick Owens

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).