This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Bug in i386_process_record?


Hi Hui,

While experimenting with your dump/load commands, I think I discovered
a bug in i386_process_record, in the handling of the "string ops"
and the "rep" prefix.  Looks like we are saving the same data over
and over in the log.

This was made using the attached sample program.

  (gdb) break main
    Breakpoint 1 at 0x80483c4: file memrange-reverse.c, line 29.
  (gdb) run
    Starting program:
    Breakpoint 1, main ()
    29        memset (blob1, 'a', sizeof (blob1));
  (gdb) record
  (gdb) next
    30        blob1[sizeof (blob1) - 1] = '\0';
  (gdb) record dump
    Saving recording to file 'rec.27255'
    Writing 4-byte magic cookie RECORD_FILE_MAGIC (0x26070920)
  [...]
  Writing register 7 val 0x0000000008049684 (1 plus 8 plus 16 bytes)
  Writing memory 0x08049680 (1 plus 8 plus 8 bytes plus 1024 bytes)
  Writing register 1 val 0x00000000000000ff (1 plus 8 plus 16 bytes)
  Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
  Writing record_end (1 byte)
  Writing register 7 val 0x0000000008049688 (1 plus 8 plus 16 bytes)
  Writing memory 0x08049684 (1 plus 8 plus 8 bytes plus 1020 bytes)
  Writing register 1 val 0x00000000000000fe (1 plus 8 plus 16 bytes)
  Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
  Writing record_end (1 byte)
  Writing register 7 val 0x000000000804968c (1 plus 8 plus 16 bytes)
  Writing memory 0x08049688 (1 plus 8 plus 8 bytes plus 1016 bytes)
  Writing register 1 val 0x00000000000000fd (1 plus 8 plus 16 bytes)
  Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
  Writing record_end (1 byte)
  Writing register 7 val 0x0000000008049690 (1 plus 8 plus 16 bytes)
  Writing memory 0x0804968c (1 plus 8 plus 8 bytes plus 1012 bytes)
  Writing register 1 val 0x00000000000000fc (1 plus 8 plus 16 bytes)
  Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
  Writing record_end (1 byte)
  Writing register 7 val 0x0000000008049694 (1 plus 8 plus 16 bytes)
  Writing memory 0x08049690 (1 plus 8 plus 8 bytes plus 1008 bytes)
  Writing register 1 val 0x00000000000000fb (1 plus 8 plus 16 bytes)
  Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
  Writing record_end (1 byte)
  Writing register 7 val 0x0000000008049698 (1 plus 8 plus 16 bytes)
  Writing memory 0x08049694 (1 plus 8 plus 8 bytes plus 1004 bytes)
  Writing register 1 val 0x00000000000000fa (1 plus 8 plus 16 bytes)
  Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
  Writing record_end (1 byte)
  Writing register 7 val 0x000000000804969c (1 plus 8 plus 16 bytes)
  Writing memory 0x08049698 (1 plus 8 plus 8 bytes plus 1000 bytes)
  Writing register 1 val 0x00000000000000f9 (1 plus 8 plus 16 bytes)
  Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
  Writing record_end (1 byte)
  Writing register 7 val 0x00000000080496a0 (1 plus 8 plus 16 bytes)
  Writing memory 0x0804969c (1 plus 8 plus 8 bytes plus 996 bytes)
  Writing register 1 val 0x00000000000000f8 (1 plus 8 plus 16 bytes)
  Writing register 8 val 0x0000000000587be7 (1 plus 8 plus 16 bytes)
  [...]

Altogether there were 256 duplicate entries, each one is
four bytes shorter than the previous one.

/* This testcase is part of GDB, the GNU debugger.

   Copyright 2009 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

#include <string.h>

#define SIZE_BLOB1 1024
#define SIZE_BLOB2  256

char blob1[SIZE_BLOB1], blob2[SIZE_BLOB2];

int main ()
{
  int i;

  memset (blob1, 'a', sizeof (blob1));
  blob1[sizeof (blob1) - 1] = '\0';

  memset (blob2, 'b', sizeof (blob2));
  blob2[sizeof (blob2) - 1] = '\0';

  for (i = 2; i < 8; i++)
    {
      memcpy (blob1 + (sizeof (blob1) / i), blob2, sizeof (blob2));
    }

  return 0;	/* end of main */
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]