This is the mail archive of the gdb-patches@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]

[RFA] change to i386_process_record, with test


Hi Hui,

Would you please try this test on a 32 bit intel target?
I think it demonstrates the need for the attached change.
This also fixes four fails in machinestate.exp.

Thanks,
Michael

2009-08-22  Michael Snyder  <msnyder@vmware.com>

	* i386-tdep.c (i386_process_record): Break out of prefix loop
	if not amd64.  Otherwise inc/dec instructions are lost.

Index: i386-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/i386-tdep.c,v
retrieving revision 1.283
diff -u -p -r1.283 i386-tdep.c
--- i386-tdep.c	10 Aug 2009 03:02:39 -0000	1.283
+++ i386-tdep.c	23 Aug 2009 02:55:10 -0000
@@ -3280,23 +3280,23 @@ i386_process_record (struct gdbarch *gdb
 	case 0x67:
 	  prefixes |= PREFIX_ADDR;
 	  break;
-        case 0x40:
-        case 0x41:
-        case 0x42:
-        case 0x43:
-        case 0x44:
-        case 0x45:
-        case 0x46:
-        case 0x47:
-        case 0x48:
-        case 0x49:
-        case 0x4a:
-        case 0x4b:
-        case 0x4c:
-        case 0x4d:
-        case 0x4e:
-        case 0x4f:
-          if (ir.regmap[X86_RECORD_R8_REGNUM])
+        case 0x40:	/* i386 inc %eax */
+        case 0x41:	/* i386 inc %ecx */
+        case 0x42:	/* i386 inc %edx */
+        case 0x43:	/* i386 inc %ebx */
+        case 0x44:	/* i386 inc %esp */
+        case 0x45:	/* i386 inc %ebp */
+        case 0x46:	/* i386 inc %esi */
+        case 0x47:	/* i386 inc %edi */
+        case 0x48:	/* i386 dec %eax */
+        case 0x49:	/* i386 dec %ecx */
+        case 0x4a:	/* i386 dec %edx */
+        case 0x4b:	/* i386 dec %ebx */
+        case 0x4c:	/* i386 dec %esp */
+        case 0x4d:	/* i386 dec %ebp */
+        case 0x4e:	/* i386 dec %esi */
+        case 0x4f:	/* i386 dec %edi */
+          if (ir.regmap[X86_RECORD_R8_REGNUM])	/* 64 bit target */
             {
                /* REX */
                rex = 1;
@@ -3305,6 +3305,8 @@ i386_process_record (struct gdbarch *gdb
                ir.rex_x = (tmpu8 & 0x2) << 2;
                ir.rex_b = (tmpu8 & 0x1) << 3;
             }
+	  else					/* 32 bit target */
+	    goto out_prefixes;
           break;
 	default:
 	  goto out_prefixes;
/* 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/>.  */

/* Architecture tests for intel i386 platform.  */

void 
inc_dec_tests (void)
{
  asm ("inc %eax");
  asm ("inc %ecx");
  asm ("inc %edx");
  asm ("inc %ebx");
  asm ("inc %esp");
  asm ("inc %ebp");
  asm ("inc %esi");
  asm ("inc %edi");
  asm ("dec %eax");
  asm ("dec %ecx");
  asm ("dec %edx");
  asm ("dec %ebx");
  asm ("dec %esp");
  asm ("dec %ebp");
  asm ("dec %esi");
  asm ("dec %edi");
} /* end inc_dec_tests */

int 
main ()
{
  inc_dec_tests ();
  return 0;	/* end of main */
}
# 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/>.

# This file is part of the gdb testsuite.

if $tracelevel {
    strace $tracelevel
}

set prms_id 0
set bug_id 0

if ![istarget "i?86-*linux*"] then {
    verbose "Skipping i386 reverse tests."
    return
}

set testfile "i386-reverse"
set srcfile ${testfile}.c
set binfile ${objdir}/${subdir}/${testfile}

# some targets have leading underscores on assembly symbols.
# TODO: detect this automatically
set additional_flags ""
if [istarget "i?86-*-cygwin*"] then {
  set additional_flags "additional_flags=-DSYMBOL_PREFIX=\"_\""
}

if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug $additional_flags]] != "" } {
    untested i386-reverse
    return -1
}

set end_of_main          [gdb_get_line_number " end of main "]
set end_of_inc_dec_tests [gdb_get_line_number " end inc_dec_tests "]

# Get things started.

gdb_exit
gdb_start
gdb_reinitialize_dir $srcdir/$subdir
gdb_load ${binfile}
runto main

if [target_info exists gdb,use_precord] {
    # Activate process record/replay
    gdb_test "record" "" "Turn on process record"
    # FIXME: command ought to acknowledge, so we can test if it succeeded.
}

global hex
global decimal

gdb_test "step" "inc .eax.*" "step to inc eax 1st time"
send_gdb "info reg eax\n"
gdb_expect {
    -re "eax *($hex)\t.*$gdb_prompt " {
	set preinc_eax $expect_out(1,string)
    }
}

gdb_test "step" "inc .ecx.*" "step to inc ecx 1st time"
send_gdb "info reg ecx\n"
gdb_expect {
    -re "ecx *($hex)\t.*$gdb_prompt " {
	set preinc_ecx $expect_out(1,string)
    }
}

gdb_test "step" "inc .edx.*" "step to inc edx 1st time"
send_gdb "info reg edx\n"
gdb_expect {
    -re "edx *($hex)\t.*$gdb_prompt " {
	set preinc_edx $expect_out(1,string)
    }
}

gdb_test "step" "inc .ebx.*" "step to inc ebx 1st time"
send_gdb "info reg ebx\n"
gdb_expect {
    -re "ebx *($hex)\t.*$gdb_prompt " {
	set preinc_ebx $expect_out(1,string)
    }
}

gdb_test "step" "inc .esp.*" "step to inc esp 1st time"
send_gdb "info reg esp\n"
gdb_expect {
    -re "esp *($hex)\t.*$gdb_prompt " {
	set preinc_esp $expect_out(1,string)
    }
}

gdb_test "step" "inc .ebp.*" "step to inc ebp 1st time"
send_gdb "info reg ebp\n"
gdb_expect {
    -re "ebp *($hex)\t.*$gdb_prompt " {
	set preinc_ebp $expect_out(1,string)
    }
}

gdb_test "step" "inc .esi.*" "step to inc esi 1st time"
send_gdb "info reg esi\n"
gdb_expect {
    -re "esi *($hex)\t.*$gdb_prompt " {
	set preinc_esi $expect_out(1,string)
    }
}

gdb_test "step" "inc .edi.*" "step to inc edi 1st time"
send_gdb "info reg edi\n"
gdb_expect {
    -re "edi *($hex)\t.*$gdb_prompt " {
	set preinc_edi $expect_out(1,string)
    }
}

gdb_test "step" "dec .eax.*" "step to dec eax 1st time"
send_gdb "info reg eax\n"
gdb_expect {
    -re "eax *($hex)\t.*$gdb_prompt " {
	set predec_eax $expect_out(1,string)
    }
}

gdb_test "step" "dec .ecx.*" "step to dec ecx 1st time"
send_gdb "info reg ecx\n"
gdb_expect {
    -re "ecx *($hex)\t.*$gdb_prompt " {
	set predec_ecx $expect_out(1,string)
    }
}

gdb_test "step" "dec .edx.*" "step to dec edx 1st time"
send_gdb "info reg edx\n"
gdb_expect {
    -re "edx *($hex)\t.*$gdb_prompt " {
	set predec_edx $expect_out(1,string)
    }
}

gdb_test "step" "dec .ebx.*" "step to dec ebx 1st time"
send_gdb "info reg ebx\n"
gdb_expect {
    -re "ebx *($hex)\t.*$gdb_prompt " {
	set predec_ebx $expect_out(1,string)
    }
}

gdb_test "step" "dec .esp.*" "step to dec esp 1st time"
send_gdb "info reg esp\n"
gdb_expect {
    -re "esp *($hex)\t.*$gdb_prompt " {
	set predec_esp $expect_out(1,string)
    }
}

gdb_test "step" "dec .ebp.*" "step to dec ebp 1st time"
send_gdb "info reg ebp\n"
gdb_expect {
    -re "ebp *($hex)\t.*$gdb_prompt " {
	set predec_ebp $expect_out(1,string)
    }
}

gdb_test "step" "dec .esi.*" "step to dec esi 1st time"
send_gdb "info reg esi\n"
gdb_expect {
    -re "esi *($hex)\t.*$gdb_prompt " {
	set predec_esi $expect_out(1,string)
    }
}

gdb_test "step" "dec .edi.*" "step to dec edi 1st time"
send_gdb "info reg edi\n"
gdb_expect {
    -re "edi *($hex)\t.*$gdb_prompt " {
	set predec_edi $expect_out(1,string)
    }
}

# gdb_test "step" "end inc_dec_tests .*" "step to end inc_dec_tests 1st time"

gdb_test "break $end_of_main" \
    "Breakpoint $decimal at .* line $end_of_main\." \
    "set breakpoint at end of main"

gdb_test "continue" \
    " end of main .*" \
    "continue to end of main"

gdb_test "break $end_of_inc_dec_tests" \
    "Breakpoint $decimal at .* line $end_of_inc_dec_tests\." \
    "set breakpoint at end of inc_dec_tests"

gdb_test "reverse-continue" \
    " end inc_dec_tests .*" \
    "reverse to inc_dec_tests"

#
# Now reverse step, and check register values.
#

gdb_test "info reg edi" "edi *$preinc_edi\t.*" "edi before reverse-dec"
gdb_test "reverse-step" "dec .edi.*" "reverse-step to dec edi"
gdb_test "info reg edi" "edi *$predec_edi\t.*" "edi after reverse-dec"

gdb_test "info reg esi" "esi *$preinc_esi\t.*" "esi before reverse-dec"
gdb_test "reverse-step" "dec .esi.*" "reverse-step to dec esi"
gdb_test "info reg esi" "esi *$predec_esi\t.*" "esi after reverse-dec"

gdb_test "info reg ebp" "ebp *$preinc_ebp\t.*" "ebp before reverse-dec"
gdb_test "reverse-step" "dec .ebp.*" "reverse-step to dec ebp"
gdb_test "info reg ebp" "ebp *$predec_ebp\t.*" "ebp after reverse-dec"

gdb_test "info reg esp" "esp *$preinc_esp\t.*" "esp before reverse-dec"
gdb_test "reverse-step" "dec .esp.*" "reverse-step to dec esp"
gdb_test "info reg esp" "esp *$predec_esp\t.*" "esp after reverse-dec"

gdb_test "info reg ebx" "ebx *$preinc_ebx\t.*" "ebx before reverse-dec"
gdb_test "reverse-step" "dec .ebx.*" "reverse-step to dec ebx"
gdb_test "info reg ebx" "ebx *$predec_ebx\t.*" "ebx after reverse-dec"

gdb_test "info reg edx" "edx *$preinc_edx\t.*" "edx before reverse-dec"
gdb_test "reverse-step" "dec .edx.*" "reverse-step to dec edx"
gdb_test "info reg edx" "edx *$predec_edx\t.*" "edx after reverse-dec"

gdb_test "info reg ecx" "ecx *$preinc_ecx\t.*" "ecx before reverse-dec"
gdb_test "reverse-step" "dec .ecx.*" "reverse-step to dec ecx"
gdb_test "info reg ecx" "ecx *$predec_ecx\t.*" "ecx after reverse-dec"

gdb_test "info reg eax" "eax *$preinc_eax\t.*" "eax before reverse-dec"
gdb_test "reverse-step" "dec .eax.*" "reverse-step to dec eax"
gdb_test "info reg eax" "eax *$predec_eax\t.*" "eax after reverse-dec"

gdb_test "info reg edi" "edi *$predec_edi\t.*" "edi before reverse-inc"
gdb_test "reverse-step" "inc .edi.*" "reverse-step to inc edi"
gdb_test "info reg edi" "edi *$preinc_edi\t.*" "edi after reverse-inc"

gdb_test "info reg esi" "esi *$predec_esi\t.*" "esi before reverse-inc"
gdb_test "reverse-step" "inc .esi.*" "reverse-step to inc esi"
gdb_test "info reg esi" "esi *$preinc_esi\t.*" "esi after reverse-inc"

gdb_test "info reg ebp" "ebp *$predec_ebp\t.*" "ebp before reverse-inc"
gdb_test "reverse-step" "inc .ebp.*" "reverse-step to inc ebp"
gdb_test "info reg ebp" "ebp *$preinc_ebp\t.*" "ebp after reverse-inc"

gdb_test "info reg esp" "esp *$predec_esp\t.*" "esp before reverse-inc"
gdb_test "reverse-step" "inc .esp.*" "reverse-step to inc esp"
gdb_test "info reg esp" "esp *$preinc_esp\t.*" "esp after reverse-inc"

gdb_test "info reg ebx" "ebx *$predec_ebx\t.*" "ebx before reverse-inc"
gdb_test "reverse-step" "inc .ebx.*" "reverse-step to inc ebx"
gdb_test "info reg ebx" "ebx *$preinc_ebx\t.*" "ebx after reverse-inc"

gdb_test "info reg edx" "edx *$predec_edx\t.*" "edx before reverse-inc"
gdb_test "reverse-step" "inc .edx.*" "reverse-step to inc edx"
gdb_test "info reg edx" "edx *$preinc_edx\t.*" "edx after reverse-inc"

gdb_test "info reg ecx" "ecx *$predec_ecx\t.*" "ecx before reverse-inc"
gdb_test "reverse-step" "inc .ecx.*" "reverse-step to inc ecx"
gdb_test "info reg ecx" "ecx *$preinc_ecx\t.*" "ecx after reverse-inc"

gdb_test "info reg eax" "eax *$predec_eax\t.*" "eax before reverse-inc"
gdb_test "reverse-step" "inc .eax.*" "reverse-step to inc eax"
gdb_test "info reg eax" "eax *$preinc_eax\t.*" "eax after reverse-inc"



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