Greetings,

The version of GDB that ships with Mandrake 8.0 has at least one problem, 
which is fixed in newer gdb snapshots.

As an Objective-C developer, I use the GNUstep base library.  The library 
includes a function NSLog() for logging messages to stderr.  Each message 
is timestamped with the current date & time.  I noticed that (for each 
program thread), the first timestamp printed is messed up.  As the program 
worked fine from the command line and in gdb-4.18, I came to suspect 
gdb-5.0.  When the cvs snapshot of gdb ran the program properly, I knew 
that gdb-5.0 was the cause of the problem.

As look would have it, I was able to reduce my test case to a simple C 
program.  I have attached several files and described them below.

I hope that you'll be able to release an updated gdb with fixes.

Thanks.

David

******************************************************************************

Attached are the following files:

        prog.c - a C program including GSTimeNow().  The call to library function 
gettimeofday() has been replaced by an inline copy of the function because 
the problem doesn't occur at all times of day.  The gcc command for 
building the executable is included in the program as a comment.

        run.prog.out - the output of the program run at the command line showing 
correct results.

        gdb-5.prog.out - the output of the program run under gdb-5 showing 
incorrect results.

        gdb-4.prog.out - the output of the program using gdb-4.18-unoff-objc 
showing correct results.

The difference between gdb-4 and gdb-5 outputs demonstrates that gdb-5 is 
doing something special, causing the problem.
#include <stdio.h>
#include <sys/time.h>

// make with the following commands:
//
//      gcc prog.c -fPIC -g -fno-omit-frame-pointer -I. -rdynamic -o prog -lpthread 
-ldl -lm

#define NULL    ((void *) 0)

#define UNIX_REFERENCE_INTERVAL -978307200.0    // from NSDate.h
#define _FLP_   __FILE__, __LINE__, __PRETTY_FUNCTION__

void  xx_gettimeofday (struct timeval *tp, void *v)
{
    tp->tv_sec = 988941076;
    tp->tv_usec = 43238;
}

double
GSTimeNow()
{

   double interval;
  struct timeval tp;

  xx_gettimeofday (&tp, NULL);
  interval = UNIX_REFERENCE_INTERVAL;
  printf( "%s:%d %s  %13.0f    ( %08X %08X )\n", 
          _FLP_, interval, interval );
  printf( "%s:%d %s  %13d    ( %08X )  %10d ( %08X )\n", 
          _FLP_, tp.tv_sec, tp.tv_sec, tp.tv_usec, tp.tv_usec );
  interval += tp.tv_sec;
  printf( "%s:%d %s  %16.2f ( %08X %08X )\n", 
          _FLP_, interval, interval );
  interval += (double)tp.tv_usec / 1000000.0;
  printf( "%s:%d %s  %16.2f ( %08X %08X )\n", 
          _FLP_, interval, interval );
  return interval;
}

int main( int argc, char **argv)
{

    GSTimeNow();
    printf( "\n" );
    GSTimeNow();

    return 0;
}

[relson@osage datetest]$ prog
prog.c:29 GSTimeNow     -978307200    ( 40000000 C1CD27E4 )
prog.c:31 GSTimeNow      988941076    ( 3AF20B14 )       43238 ( 0000A8E6 )
prog.c:34 GSTimeNow       10633876.00 ( 80000000 41644852 )
prog.c:37 GSTimeNow       10633876.04 ( 816234A8 41644852 )

prog.c:29 GSTimeNow     -978307200    ( 40000000 C1CD27E4 )
prog.c:31 GSTimeNow      988941076    ( 3AF20B14 )       43238 ( 0000A8E6 )
prog.c:34 GSTimeNow       10633876.00 ( 80000000 41644852 )
prog.c:37 GSTimeNow       10633876.04 ( 816234A8 41644852 )
Current directory is /home/relson/src/datetest/
GNU gdb 5.0mdk-11mdk Linux-Mandrake 8.0
Copyright 2001 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-mandrake-linux"...
Breakpoint 1 at 0x80487d3: file prog.c, line 44.
[New Thread 1024 (LWP 14027)]
[Switching to Thread 1024 (LWP 14027)]

Breakpoint 1, main (argc=2, argv=0xbffff27c) at prog.c:44
prog.c:29 GSTimeNow     -978307200    ( 40000000 C1CD27E4 )
prog.c:31 GSTimeNow      988941076    ( 3AF20B14 )       43238 ( 0000A8E6 )
prog.c:34 GSTimeNow               nan ( 00000000 FFF80000 )
prog.c:37 GSTimeNow               nan ( 00000000 FFF80000 )

prog.c:29 GSTimeNow     -978307200    ( 40000000 C1CD27E4 )
prog.c:31 GSTimeNow      988941076    ( 3AF20B14 )       43238 ( 0000A8E6 )
prog.c:34 GSTimeNow       10633876.00 ( 80000000 41644852 )
prog.c:37 GSTimeNow       10633876.04 ( 816234A8 41644852 )

Program exited normally.
(gdb) q

Debugger finished
Current directory is /home/relson/src/datetest/
GNU gdb 4.18-objc-unoff
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
Breakpoint 1 at 0x80487c3: file prog.c, line 44.

Breakpoint 1, main (argc=2, argv=0xbffff27c) at prog.c:44
prog.c:29 GSTimeNow     -978307200    ( 40000000 C1CD27E4 )
prog.c:31 GSTimeNow      988941076    ( 3AF20B14 )       43238 ( 0000A8E6 )
prog.c:34 GSTimeNow       10633876.00 ( 80000000 41644852 )
prog.c:37 GSTimeNow       10633876.04 ( 816234A8 41644852 )

prog.c:29 GSTimeNow     -978307200    ( 40000000 C1CD27E4 )
prog.c:31 GSTimeNow      988941076    ( 3AF20B14 )       43238 ( 0000A8E6 )
prog.c:34 GSTimeNow       10633876.00 ( 80000000 41644852 )
prog.c:37 GSTimeNow       10633876.04 ( 816234A8 41644852 )

Program exited normally.
(gdb) q

Debugger finished
--------------------------------------------------------
David Relson                   Osage Software Systems, Inc.
[EMAIL PROTECTED]       Ann Arbor, MI 48103
www.osagesoftware.com          tel:  734.821.8800

Reply via email to