diff options
author | H.J. Lu <hjl.tools@gmail.com> | 2010-03-02 13:14:36 +0000 |
---|---|---|
committer | H.J. Lu <hjl.tools@gmail.com> | 2010-03-02 13:14:36 +0000 |
commit | 1ba53b71caf9544b0c1dc040af4052561c32d47b (patch) | |
tree | 8e3eb732fad2c1b52dc3a76c54ab65e5d1c198f2 /gdb/testsuite | |
parent | 5488d830ec018f8528fe806eeeaa39ce5ff7ffb1 (diff) | |
download | gdb-1ba53b71caf9544b0c1dc040af4052561c32d47b.zip gdb-1ba53b71caf9544b0c1dc040af4052561c32d47b.tar.gz gdb-1ba53b71caf9544b0c1dc040af4052561c32d47b.tar.bz2 |
Support x86 pseudo byte, word and dword registers.
gdb/
2010-03-02 H.J. Lu <hongjiu.lu@intel.com>
* amd64-tdep.c (amd64_byte_names): New.
(amd64_word_names): Likewise.
(amd64_dword_names): Likewise.
(amd64_pseudo_register_name): Likewise.
(amd64_pseudo_register_read): Likewise.
(amd64_pseudo_register_write): Likewise.
(amd64_init_abi): Set num_byte_regs, num_word_regs, num_dword_regs
and num_mmx_regs. Call set_gdbarch_pseudo_register_read,
set_gdbarch_pseudo_register_write and
set_tdesc_pseudo_register_name. Don't call
set_gdbarch_num_pseudo_regs. Don't set mm0_regnum.
* i386-tdep.c (i386_num_mmx_regs): Removed.
(i386_num_pseudo_regs): Likewise.
(i386_byte_names): New.
(i386_word_names): Likewise.
(i386_byte_regnum_p): Likewise.
(i386_word_regnum_p): Likewise.
(i386_mmx_regnum_p): Updated.
(i386_pseudo_register_name): Make it global. Handle byte and
word pseudo-registers.
(i386_pseudo_register_read): Likewise.
(i386_pseudo_register_write): Likewise.
(i386_pseudo_register_type): Handle byte, word and dword
pseudo-registers
(i386_register_reggroup_p): Don't include pseudo
registers, except for MXX, in any register groups. Don't
include pseudo byte, word, dword registers in general_reggroup.
(i386_gdbarch_init): Set num_byte_regs, num_word_regs,
num_dword_regs, al_regnum, ax_regnum and eax_regnum. Put MMX
pseudo-registers after word pseudo-registers. Call
set_gdbarch_num_pseudo_regs after calling gdbarch_init_osabi.
* i386-tdep.h (gdbarch_tdep): Add num_mmx_regs, num_byte_regs,
al_regnum, num_word_regs, ax_regnum, num_dword_regs and
eax_regnum.
(i386_byte_regnum_p): New.
(i386_word_regnum_p): Likewise.
(i386_dword_regnum_p): Likewise.
(i386_pseudo_register_name): Likewise.
(i386_pseudo_register_read): Likewise.
(i386_pseudo_register_write): Likewise.
gdb/testsuite/
2010-03-02 H.J. Lu <hongjiu.lu@intel.com>
* gdb.arch/amd64-byte.exp: New.
* gdb.arch/amd64-dword.exp: Likewise.
* gdb.arch/amd64-pseudo.c: Likewise.
* gdb.arch/amd64-word.exp: Likewise.
* gdb.arch/i386-byte.exp: Likewise.
* gdb.arch/i386-pseudo.c: Likewise.
* gdb.arch/i386-word.exp: Likewise.
Diffstat (limited to 'gdb/testsuite')
-rw-r--r-- | gdb/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/amd64-byte.exp | 121 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/amd64-dword.exp | 123 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/amd64-pseudo.c | 91 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/amd64-word.exp | 123 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-byte.exp | 98 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-pseudo.c | 51 | ||||
-rw-r--r-- | gdb/testsuite/gdb.arch/i386-word.exp | 84 |
8 files changed, 701 insertions, 0 deletions
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ae3a548..7bcc512 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,13 @@ +2010-03-02 H.J. Lu <hongjiu.lu@intel.com> + + * gdb.arch/amd64-byte.exp: New. + * gdb.arch/amd64-dword.exp: Likewise. + * gdb.arch/amd64-pseudo.c: Likewise. + * gdb.arch/amd64-word.exp: Likewise. + * gdb.arch/i386-byte.exp: Likewise. + * gdb.arch/i386-pseudo.c: Likewise. + * gdb.arch/i386-word.exp: Likewise. + 2010-03-01 Daniel Jacobowitz <dan@codesourcery.com> * gdb.xml/extra-regs.xml: Add struct1, struct2, and flags diff --git a/gdb/testsuite/gdb.arch/amd64-byte.exp b/gdb/testsuite/gdb.arch/amd64-byte.exp new file mode 100644 index 0000000..9a14099 --- /dev/null +++ b/gdb/testsuite/gdb.arch/amd64-byte.exp @@ -0,0 +1,121 @@ +# Copyright 2010 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/>. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@gnu.org + +# This file is part of the gdb testsuite. + +if $tracelevel { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +if { ![istarget x86_64-*-* ] } { + verbose "Skipping amd64 byte register tests." + return +} + +set testfile "amd64-byte" +set srcfile amd64-pseudo.c +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug]] != "" } { + untested ${testfile} + return +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + gdb_suppress_tests +} + +set nr_regs 14 +set byte_regs(1) al +set byte_regs(2) bl +set byte_regs(3) cl +set byte_regs(4) dl +set byte_regs(5) sil +set byte_regs(6) dil +set byte_regs(7) r8l +set byte_regs(8) r9l +set byte_regs(9) r10l +set byte_regs(10) r11l +set byte_regs(11) r12l +set byte_regs(12) r13l +set byte_regs(13) r14l +set byte_regs(14) r15l + +gdb_test "break [gdb_get_line_number "first breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set first breakpoint in main" +gdb_continue_to_breakpoint "continue to first breakpoint in main" + +for { set r 1 } { $r <= 6 } { incr r } { + gdb_test "print/x \$$byte_regs($r)" \ + ".. = 0x[format %x $r]1" \ + "check contents of %$byte_regs($r)" +} + +gdb_test "break [gdb_get_line_number "second breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set second breakpoint in main" +gdb_continue_to_breakpoint "continue to second breakpoint in main" + +for { set r 7 } { $r <= $nr_regs } { incr r } { + gdb_test "print/x \$$byte_regs($r)" \ + ".. = 0x[format %x $r]1" \ + "check contents of %$byte_regs($r)" +} + +for { set r 1 } { $r <= 6 } { incr r } { + gdb_test "set var \$$byte_regs($r) = $r" "" "set %$byte_regs($r)" +} + +gdb_test "break [gdb_get_line_number "third breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set third breakpoint in main" +gdb_continue_to_breakpoint "continue to third breakpoint in main" + +for { set r 1 } { $r <= 6 } { incr r } { + gdb_test "print \$$byte_regs($r)" \ + ".. = $r" \ + "check contents of %$byte_regs($r)" +} + +for { set r 7 } { $r <= $nr_regs } { incr r } { + gdb_test "set var \$$byte_regs($r) = $r" "" "set %$byte_regs($r)" +} + +gdb_test "break [gdb_get_line_number "forth breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set forth breakpoint in main" +gdb_continue_to_breakpoint "continue to forth breakpoint in main" + +for { set r 7 } { $r <= $nr_regs } { incr r } { + gdb_test "print \$$byte_regs($r)" \ + ".. = $r" \ + "check contents of %$byte_regs($r)" +} diff --git a/gdb/testsuite/gdb.arch/amd64-dword.exp b/gdb/testsuite/gdb.arch/amd64-dword.exp new file mode 100644 index 0000000..632e46b --- /dev/null +++ b/gdb/testsuite/gdb.arch/amd64-dword.exp @@ -0,0 +1,123 @@ +# Copyright 2010 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/>. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@gnu.org + +# This file is part of the gdb testsuite. + +if $tracelevel { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +if { ![istarget x86_64-*-* ] } { + verbose "Skipping amd64 dword register tests." + return +} + +set testfile "amd64-dword" +set srcfile amd64-pseudo.c +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug]] != "" } { + untested ${testfile} + return +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + gdb_suppress_tests +} + +set nr_regs 14 +set dword_regs(1) eax +set dword_regs(2) ebx +set dword_regs(3) ecx +set dword_regs(4) edx +set dword_regs(5) esi +set dword_regs(6) edi +set dword_regs(7) r8d +set dword_regs(8) r9d +set dword_regs(9) r10d +set dword_regs(10) r11d +set dword_regs(11) r12d +set dword_regs(12) r13d +set dword_regs(13) r14d +set dword_regs(14) r15d + +gdb_test "break [gdb_get_line_number "first breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set first breakpoint in main" +gdb_continue_to_breakpoint "continue to first breakpoint in main" + +for { set r 1 } { $r <= 6 } { incr r } { + set hex [format %x $r] + gdb_test "print/x \$$dword_regs($r)" \ + ".. = 0x${hex}4${hex}3${hex}2${hex}1" \ + "check contents of %$dword_regs($r)" +} + +gdb_test "break [gdb_get_line_number "second breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set second breakpoint in main" +gdb_continue_to_breakpoint "continue to second breakpoint in main" + +for { set r 7 } { $r <= $nr_regs } { incr r } { + set hex [format %x $r] + gdb_test "print/x \$$dword_regs($r)" \ + ".. = 0x${hex}4${hex}3${hex}2${hex}1" \ + "check contents of %$dword_regs($r)" +} + +for { set r 1 } { $r <= 6 } { incr r } { + gdb_test "set var \$$dword_regs($r) = $r" "" "set %$dword_regs($r)" +} + +gdb_test "break [gdb_get_line_number "third breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set third breakpoint in main" +gdb_continue_to_breakpoint "continue to third breakpoint in main" + +for { set r 1 } { $r <= 6 } { incr r } { + gdb_test "print \$$dword_regs($r)" \ + ".. = $r" \ + "check contents of %$dword_regs($r)" +} + +for { set r 7 } { $r <= $nr_regs } { incr r } { + gdb_test "set var \$$dword_regs($r) = $r" "" "set %$dword_regs($r)" +} + +gdb_test "break [gdb_get_line_number "forth breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set forth breakpoint in main" +gdb_continue_to_breakpoint "continue to forth breakpoint in main" + +for { set r 7 } { $r <= $nr_regs } { incr r } { + gdb_test "print \$$dword_regs($r)" \ + ".. = $r" \ + "check contents of %$dword_regs($r)" +} diff --git a/gdb/testsuite/gdb.arch/amd64-pseudo.c b/gdb/testsuite/gdb.arch/amd64-pseudo.c new file mode 100644 index 0000000..78b7899 --- /dev/null +++ b/gdb/testsuite/gdb.arch/amd64-pseudo.c @@ -0,0 +1,91 @@ +/* Test program for byte registers. + + Copyright 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 <stdio.h> + +int data[] = { + 0x14131211, + 0x24232221, + 0x34333231, + 0x44434241, + 0x54535251, + 0x64636261, + 0x74737271, + 0x84838281, + 0x94939291, + 0xa4a3a2a1, + 0xb4b3b2b1, + 0xc4c3c2c1, + 0xd4d3d2d1, + 0xe4e3e2e1, +}; + +int +main (int argc, char **argv) +{ + asm ("mov 0(%0), %%eax\n\t" + "mov 4(%0), %%ebx\n\t" + "mov 8(%0), %%ecx\n\t" + "mov 12(%0), %%edx\n\t" + "mov 16(%0), %%esi\n\t" + "mov 20(%0), %%edi\n\t" + : /* no output operands */ + : "r" (data) + : "eax", "ebx", "ecx", "edx", "esi", "edi"); + asm ("nop"); /* first breakpoint here */ + + asm ("mov 24(%0), %%r8d\n\t" + "mov 28(%0), %%r9d\n\t" + "mov 32(%0), %%r10d\n\t" + "mov 36(%0), %%r11\n\t" + "mov 40(%0), %%r12d\n\t" + "mov 44(%0), %%r13d\n\t" + "mov 48(%0), %%r14d\n\t" + "mov 52(%0), %%r15d\n\t" + : /* no output operands */ + : "r" (data) + : "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"); + asm ("nop"); /* second breakpoint here */ + + asm ("mov %%eax, 0(%0)\n\t" + "mov %%ebx, 4(%0)\n\t" + "mov %%ecx, 8(%0)\n\t" + "mov %%edx, 12(%0)\n\t" + "mov %%esi, 16(%0)\n\t" + "mov %%edi, 20(%0)\n\t" + : /* no output operands */ + : "r" (data) + : "eax", "ebx", "ecx", "edx", "esi", "edi"); + asm ("nop"); /* third breakpoint here */ + + asm ("mov %%r8d, 24(%0)\n\t" + "mov %%r9d, 28(%0)\n\t" + "mov %%r10d, 32(%0)\n\t" + "mov %%r11d, 36(%0)\n\t" + "mov %%r12d, 40(%0)\n\t" + "mov %%r13d, 44(%0)\n\t" + "mov %%r14d, 48(%0)\n\t" + "mov %%r15d, 52(%0)\n\t" + : /* no output operands */ + : "r" (data) + : "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"); + puts ("Bye!"); /* forth breakpoint here */ + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/amd64-word.exp b/gdb/testsuite/gdb.arch/amd64-word.exp new file mode 100644 index 0000000..98116cb --- /dev/null +++ b/gdb/testsuite/gdb.arch/amd64-word.exp @@ -0,0 +1,123 @@ +# Copyright 2010 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/>. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@gnu.org + +# This file is part of the gdb testsuite. + +if $tracelevel { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +if { ![istarget x86_64-*-* ] } { + verbose "Skipping amd64 word register tests." + return +} + +set testfile "amd64-word" +set srcfile amd64-pseudo.c +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug]] != "" } { + untested ${testfile} + return +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + gdb_suppress_tests +} + +set nr_regs 14 +set word_regs(1) ax +set word_regs(2) bx +set word_regs(3) cx +set word_regs(4) dx +set word_regs(5) si +set word_regs(6) di +set word_regs(7) r8w +set word_regs(8) r9w +set word_regs(9) r10w +set word_regs(10) r11w +set word_regs(11) r12w +set word_regs(12) r13w +set word_regs(13) r14w +set word_regs(14) r15w + +gdb_test "break [gdb_get_line_number "first breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set first breakpoint in main" +gdb_continue_to_breakpoint "continue to first breakpoint in main" + +for { set r 1 } { $r <= 6 } { incr r } { + set hex [format %x $r] + gdb_test "print/x \$$word_regs($r)" \ + ".. = 0x${hex}2${hex}1" \ + "check contents of %$word_regs($r)" +} + +gdb_test "break [gdb_get_line_number "second breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set second breakpoint in main" +gdb_continue_to_breakpoint "continue to second breakpoint in main" + +for { set r 7 } { $r <= $nr_regs } { incr r } { + set hex [format %x $r] + gdb_test "print/x \$$word_regs($r)" \ + ".. = 0x${hex}2${hex}1" \ + "check contents of %$word_regs($r)" +} + +for { set r 1 } { $r <= 6 } { incr r } { + gdb_test "set var \$$word_regs($r) = $r" "" "set %$word_regs($r)" +} + +gdb_test "break [gdb_get_line_number "third breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set third breakpoint in main" +gdb_continue_to_breakpoint "continue to third breakpoint in main" + +for { set r 1 } { $r <= 6 } { incr r } { + gdb_test "print \$$word_regs($r)" \ + ".. = $r" \ + "check contents of %$word_regs($r)" +} + +for { set r 7 } { $r <= $nr_regs } { incr r } { + gdb_test "set var \$$word_regs($r) = $r" "" "set %$word_regs($r)" +} + +gdb_test "break [gdb_get_line_number "forth breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set forth breakpoint in main" +gdb_continue_to_breakpoint "continue to forth breakpoint in main" + +for { set r 7 } { $r <= $nr_regs } { incr r } { + gdb_test "print \$$word_regs($r)" \ + ".. = $r" \ + "check contents of %$word_regs($r)" +} diff --git a/gdb/testsuite/gdb.arch/i386-byte.exp b/gdb/testsuite/gdb.arch/i386-byte.exp new file mode 100644 index 0000000..865257d --- /dev/null +++ b/gdb/testsuite/gdb.arch/i386-byte.exp @@ -0,0 +1,98 @@ +# Copyright 2010 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/>. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@gnu.org + +# This file is part of the gdb testsuite. + +if $tracelevel { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +if { ![istarget i?86-*-*] } { + verbose "Skipping i386 byte register tests." + return +} + +set testfile "i386-byte" +set srcfile i386-pseudo.c +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug]] != "" } { + untested ${testfile} + return +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + gdb_suppress_tests +} + +set byte_regs(1) al +set byte_regs(2) bl +set byte_regs(3) cl +set byte_regs(4) dl +set byte_regs(5) ah +set byte_regs(6) bh +set byte_regs(7) ch +set byte_regs(8) dh + +gdb_test "break [gdb_get_line_number "first breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set first breakpoint in main" +gdb_continue_to_breakpoint "continue to first breakpoint in main" + +for { set r 1 } { $r <= 4 } { incr r } { + gdb_test "print/x \$$byte_regs($r)" \ + ".. = 0x[format %x $r]1" \ + "check contents of %$byte_regs($r)" + set h [expr $r + 4] + gdb_test "print/x \$$byte_regs($h)" \ + ".. = 0x[format %x $r]2" \ + "check contents of %$byte_regs($h)" +} + +for { set r 1 } { $r <= 4 } { incr r } { + gdb_test "set var \$$byte_regs($r) = $r" "" "set %$byte_regs($r)" + set h [expr $r + 4] + gdb_test "set var \$$byte_regs($h) = $h" "" "set %$byte_regs($h)" +} + +gdb_test "break [gdb_get_line_number "second breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set second breakpoint in main" +gdb_continue_to_breakpoint "continue to second breakpoint in main" + +for { set r 1 } { $r <= 4 } { incr r } { + gdb_test "print \$$byte_regs($r)" \ + ".. = $r" \ + "check contents of %$byte_regs($r)" + set h [expr $r + 4] + gdb_test "print \$$byte_regs($h)" \ + ".. = $h" \ + "check contents of %$byte_regs($h)" +} diff --git a/gdb/testsuite/gdb.arch/i386-pseudo.c b/gdb/testsuite/gdb.arch/i386-pseudo.c new file mode 100644 index 0000000..84e9a3d --- /dev/null +++ b/gdb/testsuite/gdb.arch/i386-pseudo.c @@ -0,0 +1,51 @@ +/* Test program for byte registers. + + Copyright 2010 Free Software Foundation, Inc. + + This file is part of GDB. + + 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 <stdio.h> + +int data[] = { + 0x14131211, + 0x24232221, + 0x34333231, + 0x44434241, +}; + +int +main (int argc, char **argv) +{ + asm ("mov 0(%0), %%eax\n\t" + "mov 4(%0), %%ebx\n\t" + "mov 8(%0), %%ecx\n\t" + "mov 12(%0), %%edx\n\t" + : /* no output operands */ + : "r" (data) + : "eax", "ebx", "ecx", "edx"); + asm ("nop"); /* first breakpoint here */ + + asm ("mov %%eax, 0(%0)\n\t" + "mov %%ebx, 4(%0)\n\t" + "mov %%ecx, 8(%0)\n\t" + "mov %%edx, 12(%0)\n\t" + : /* no output operands */ + : "r" (data) + : "eax", "ebx", "ecx", "edx"); + puts ("Bye!"); /* second breakpoint here */ + + return 0; +} diff --git a/gdb/testsuite/gdb.arch/i386-word.exp b/gdb/testsuite/gdb.arch/i386-word.exp new file mode 100644 index 0000000..73f3b59 --- /dev/null +++ b/gdb/testsuite/gdb.arch/i386-word.exp @@ -0,0 +1,84 @@ +# Copyright 2010 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/>. + +# Please email any bugs, comments, and/or additions to this file to: +# bug-gdb@gnu.org + +# This file is part of the gdb testsuite. + +if $tracelevel { + strace $tracelevel +} + +set prms_id 0 +set bug_id 0 + +if { ![istarget i?86-*-*] } { + verbose "Skipping i386 word register tests." + return +} + +set testfile "i386-word" +set srcfile i386-pseudo.c +set binfile ${objdir}/${subdir}/${testfile} + +if [get_compiler_info ${binfile}] { + return -1 +} + +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable [list debug]] != "" } { + untested ${testfile} + return +} + +gdb_exit +gdb_start +gdb_reinitialize_dir $srcdir/$subdir +gdb_load ${binfile} + +if ![runto_main] then { + gdb_suppress_tests +} + +set word_regs(1) ax +set word_regs(2) bx +set word_regs(3) cx +set word_regs(4) dx + +gdb_test "break [gdb_get_line_number "first breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set first breakpoint in main" +gdb_continue_to_breakpoint "continue to first breakpoint in main" + +for { set r 1 } { $r <= 4 } { incr r } { + gdb_test "print/x \$$word_regs($r)" \ + ".. = 0x[format %x $r]2[format %x $r]1" \ + "check contents of %$word_regs($r)" +} + +for { set r 1 } { $r <= 4 } { incr r } { + gdb_test "set var \$$word_regs($r) = $r" "" "set %$word_regs($r)" +} + +gdb_test "break [gdb_get_line_number "second breakpoint here"]" \ + "Breakpoint .* at .*${srcfile}.*" \ + "set second breakpoint in main" +gdb_continue_to_breakpoint "continue to second breakpoint in main" + +for { set r 1 } { $r <= 4 } { incr r } { + gdb_test "print \$$word_regs($r)" \ + ".. = $r" \ + "check contents of %$word_regs($r)" +} |