This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
Re: Who's insane: gdb or I?
- From: Bernd Jendrissek <berndj at prism dot co dot za>
- To: gdb at sources dot redhat dot com
- Cc: carlo at alinoe dot com
- Date: Fri, 5 Jul 2002 12:04:51 +0200
- Subject: Re: Who's insane: gdb or I?
- References: <20020703151547.A28413@prism.co.za>
On Wed, Jul 03, 2002 at 03:15:47PM +0200, Bernd Jendrissek wrote:
> 1083 OVERtime+=(etv.tv_sec - stv.tv_sec) * 1000;
> (gdb) s
> 1084 OVERtime+=(etv.tv_usec - stv.tv_usec) / 1000;
> (gdb) s
> 1083 OVERtime+=(etv.tv_sec - stv.tv_sec) * 1000;
> (gdb) s
> 1084 OVERtime+=(etv.tv_usec - stv.tv_usec) / 1000;
> (gdb) s
> 1083 OVERtime+=(etv.tv_sec - stv.tv_sec) * 1000;
> (gdb) s
> 1084 OVERtime+=(etv.tv_usec - stv.tv_usec) / 1000;
> (gdb) list
> 1079 return;
> 1080 }
> 1081 if (PERMaccessconf->nnrpdoverstats) {
> 1082 gettimeofday(&etv, NULL);
> 1083 OVERtime+=(etv.tv_sec - stv.tv_sec) * 1000;
> 1084 OVERtime+=(etv.tv_usec - stv.tv_usec) / 1000;
> 1085 }
I then wondered why gdb hops between lines 1083 and 1084 a few times.
> if (PERMaccessconf->nnrpdoverstats) {
> 804cb25: a1 e8 9b 06 08 mov 0x8069be8,%eax
> 804cb2a: 83 78 74 00 cmpl $0x0,0x74(%eax)
> 804cb2e: 74 48 je 804cb78 <CMDxover+0x15c>
> gettimeofday(&etv, NULL);
> 804cb30: 83 c4 f8 add $0xfffffff8,%esp
> 804cb33: 6a 00 push $0x0
> 804cb35: 8d 5d d0 lea 0xffffffd0(%ebp),%ebx
> 804cb38: 53 push %ebx
> 804cb39: e8 b6 d9 ff ff call 804a4f4 <_init+0x780>
> OVERtime+=(etv.tv_sec - stv.tv_sec) * 1000;
> 804cb3e: 8b 45 d8 mov 0xffffffd8(%ebp),%eax
> 804cb41: 8b 4d d0 mov 0xffffffd0(%ebp),%ecx
> 804cb44: 29 c1 sub %eax,%ecx
> OVERtime+=(etv.tv_usec - stv.tv_usec) / 1000;
> 804cb46: 8b 45 dc mov 0xffffffdc(%ebp),%eax
> 804cb49: 8b 73 04 mov 0x4(%ebx),%esi
> 804cb4c: 69 c9 e8 03 00 00 imul $0x3e8,%ecx,%ecx
> 804cb52: 29 c6 sub %eax,%esi
> 804cb54: bb d3 4d 62 10 mov $0x10624dd3,%ebx
> 804cb59: 89 f0 mov %esi,%eax
> 804cb5b: f7 eb imul %ebx,%eax
> 804cb5d: 03 0d b0 9b 06 08 add 0x8069bb0,%ecx
> 804cb63: c1 fa 06 sar $0x6,%edx
> 804cb66: 89 f0 mov %esi,%eax
> 804cb68: c1 f8 1f sar $0x1f,%eax
> 804cb6b: 29 c2 sub %eax,%edx
> 804cb6d: 01 d1 add %edx,%ecx
> 804cb6f: 89 0d b0 9b 06 08 mov %ecx,0x8069bb0
> }
> 804cb75: 83 c4 10 add $0x10,%esp
I am happy with the explanation that I should get used to this when running
optimized code under gdb. With a look at the assembly (disassembled from
the actual binary) I can convince myself that the alternation between lines
1083 and 1084 is due to fancy instruction scheduling and strength reduction
on gcc's part. (gcc 2.95.2 BTW, and I know it's ancient. But it works.)
Thanks to all who looked at this. Unless anyone else thinks there's
something wrong here, I'm not too bothered about it. At -O2 I think I
deserve to be confused by gdb! :)
Carlo, do you still want me to look at -gstabs vs. -gdwarf?
bernd
--
berndj@users.sourceforge.net is probably better to bookmark than any
employer-specific email address I may have appearing in the headers.