Date: Wed, 19 Jan 1994 21:51:55 +0100 From: Stefan Eckart To: djgpp AT sun DOT soe DOT clarkson DOT edu Subject: -pg bug mostly fixed Thanks to the advice from Charles Sandmann and DJ Delorie I can report the following: This patch solves two of three known problems when compiling with the -pg profiling option: a) segmentation violation during disk transfers b) zero time entries in the gprof report under certain circumstances (e.g. large global data arrays) Problem a) was caused by DS not being valid during timer interrupts, the reason for b) was gas assembling 'cmp $1,%ax' as 'cmpl $1,%eax' instead of 'cmpw $1,%eax'. The third problem still remains: c) system crashes when profiling a program that pages to disk In this case the system hangs (CTRL-ALT-DEL doesn't work) and the topline displays the R and m> flags. This is a bug one probably can live with, because profiling a paging program doesn't make much sense anyway... Bye, Stefan. *** \djgpp\lib\crt0.s Tue Nov 30 02:23:02 1993 --- crt0.s Wed Jan 19 20:10:00 1994 *************** *** 139,146 **** mcount_isr_init: movw __go32_info_block+36, %ax /* run mode */ ! cmp $1,%ax jb skip_mcount ! cmp $3,%ax ja skip_mcount movw $16,%ax --- 139,148 ---- mcount_isr_init: movw __go32_info_block+36, %ax /* run mode */ ! cmpw $1,%ax jb skip_mcount ! cmpw $3,%ax ja skip_mcount + + movw %ds,__ds_sav movw $16,%ax *************** *** 175,181 **** mcount_isr: pushl %eax cmpl $1,mcount_skip je L0 ! movl 4(%esp),%eax /* get the PC */ subl $0x1020,%eax /* to fit in low..high */ andl $0xfffffffc,%eax --- 177,185 ---- mcount_isr: pushl %eax + pushl %ds + movw %cs:__ds_sav,%ds cmpl $1,mcount_skip je L0 ! movl 8(%esp),%eax /* get the PC */ subl $0x1020,%eax /* to fit in low..high */ andl $0xfffffffc,%eax *************** *** 184,190 **** incw (%eax) L0: popl %eax ! ljmp mc_chain /* chain to the next timer vector */ iret #endif --- 188,198 ---- incw (%eax) L0: + popl %ds popl %eax ! ljmp %cs:mc_chain /* chain to the next timer vector */ iret + .align 2 + __ds_sav: + .short 0 #endif