From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27516 invoked by alias); 6 Apr 2010 14:15:22 -0000 Received: (qmail 27231 invoked by uid 22791); 6 Apr 2010 14:15:13 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=BAYES_00,MSGID_MULTIPLE_AT,TW_DB,TW_DJ,TW_EB,TW_FP,TW_GP,TW_IW,TW_JG,TW_MX,TW_SD,TW_VF X-Spam-Check-By: sourceware.org Received: from mailhost.u-strasbg.fr (HELO mailhost.u-strasbg.fr) (130.79.200.156) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 06 Apr 2010 14:15:01 +0000 Received: from baal.u-strasbg.fr (baal.u-strasbg.fr [IPv6:2001:660:2402::41]) by mailhost.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o36EEubN038730 for ; Tue, 6 Apr 2010 16:14:57 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from mailserver.u-strasbg.fr (ms3.u-strasbg.fr [IPv6:2001:660:2402:d::12]) by baal.u-strasbg.fr (8.14.0/jtpda-5.5pre1) with ESMTP id o36EEu6T045701 for ; Tue, 6 Apr 2010 16:14:56 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) Received: from d620muller (gw-ics.u-strasbg.fr [130.79.210.225]) (user=mullerp mech=LOGIN) by mailserver.u-strasbg.fr (8.14.3/jtpda-5.5pre1) with ESMTP id o36EEugH090789 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NO) for ; Tue, 6 Apr 2010 16:14:56 +0200 (CEST) (envelope-from pierre.muller@ics-cnrs.unistra.fr) From: "Pierre Muller" To: References: <002a01cad517$d36eab90$7a4c02b0$@muller@ics-cnrs.unistra.fr> In-Reply-To: <002a01cad517$d36eab90$7a4c02b0$@muller@ics-cnrs.unistra.fr> Subject: [RFC] Fix for Go32-v2 native woes Date: Tue, 06 Apr 2010 14:15:00 -0000 Message-ID: <001801cad593$8e70daf0$ab5290d0$@muller@ics-cnrs.unistra.fr> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-04/txt/msg00094.txt.bz2 In an email to gdb list,=20 I complained about go32 native GDB giving internal errors... The problem is that some code in i386-tdep.c is not compatible with a target that supports no SSE registers. I finally managed to find a fix, but it is not straightforward: I had to add a new xml file in features/i386 directory specific for go32v2 target, that does not read i386-sse.xml. I had to adapt the code in i386-tdep.c to support missing feature_vector and to set tdesc to tdesc_i386_go32v2 instead of tdesc_i386 when go32v2 osabi was detected. This allows me to use CVS GDB on DJGPP again. I checked with a testsuite run on gcc-farm that nothing changed for at least that other target (amd64-linux). Similar fixes might be required for other 'old' i386 targets that do not support SSE registers. Comments welcome as usual! Pierre Muller Pascal language support maintainer for GDB 2010-04-06 Pierre Muller * i386-tdep.c: Add include features/i386/i386-go32v2.c. (i386_go32_init_abi): Set TDESC field to TDESC_I386_GO32V2. (i386_validate_tdesc_p): Do not require FEATURE_VECTOR. Adapt code accordingly. (i386_gdbarch_init): Set TDESC to TDESC_I386_GO32V2 if os abi is GDB_OSABI_GO32V2. (_initialize_i386_tdep): Call initialize_tdes_i386_go32v2 function. * features/Makefile (WHICH): Add new i386/i386-go32v2 entry. * features/i386/i386-go32v2.xml: New file. Without SSE regsiters. * features/i386/i386-go32v2.c: New generated file. * regformats/i386/i386-go32v2.dat: New generated file. Index: src/gdb/i386-tdep.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/i386-tdep.c,v retrieving revision 1.308 diff -u -p -r1.308 i386-tdep.c --- src/gdb/i386-tdep.c 2 Apr 2010 05:09:29 -0000 1.308 +++ src/gdb/i386-tdep.c 6 Apr 2010 13:46:02 -0000 @@ -56,6 +56,7 @@ #include =20 #include "features/i386/i386.c" +#include "features/i386/i386-go32v2.c" =20 /* Register names. */ =20 @@ -2761,6 +2762,9 @@ i386_go32_init_abi (struct gdbarch_info=20 tdep->num_xmm_regs =3D 0; set_gdbarch_num_regs (gdbarch, I386_NUM_GREGS + I387_NUM_REGS); =20 + if (! tdesc_has_registers (info.target_desc)) + tdep->tdesc =3D tdesc_i386_go32v2; + /* Native compiler is GCC, which uses the SVR4 register numbering even in COFF and STABS. See the comment in i386_gdbarch_init, before the calls to set_gdbarch_stab_reg_to_regnum and @@ -6461,7 +6465,7 @@ i386_validate_tdesc_p (struct gdbarch_td /* Get SSE registers. */ feature_vector =3D tdesc_find_feature (tdesc, "org.gnu.gdb.i386.sse"); =20 - if (feature_core =3D=3D NULL || feature_vector =3D=3D NULL) + if (feature_core =3D=3D NULL) return 0; =20 valid_p =3D 1; @@ -6472,10 +6476,14 @@ i386_validate_tdesc_p (struct gdbarch_td tdep->register_names[i]); =20 /* Need to include %mxcsr, so add one. */ - num_regs +=3D tdep->num_xmm_regs + 1; - for (; i < num_regs; i++) - valid_p &=3D tdesc_numbered_register (feature_vector, tdesc_data, i, - tdep->register_names[i]); + if (feature_vector !=3D NULL) + { + if (tdep->num_xmm_regs) + num_regs +=3D tdep->num_xmm_regs + 1; + for (; i < num_regs; i++) + valid_p &=3D tdesc_numbered_register (feature_vector, tdesc_data, i, + tdep->register_names[i]); + } =20 return valid_p; } @@ -6661,7 +6669,13 @@ i386_gdbarch_init (struct gdbarch_info i /* Get the x86 target description from INFO. */ tdesc =3D info.target_desc; if (! tdesc_has_registers (tdesc)) - tdesc =3D tdesc_i386; + { + if (info.osabi =3D=3D GDB_OSABI_GO32) + tdesc =3D tdesc_i386_go32v2; + else + tdesc =3D tdesc_i386; + } + tdep->tdesc =3D tdesc; =20 tdep->num_core_regs =3D I386_NUM_GREGS + I387_NUM_REGS; @@ -6797,6 +6811,9 @@ is \"default\"."), =20 /* Initialize the standard target descriptions. */ initialize_tdesc_i386 (); + /* Initialize the go32v2 target descriptions. */ + initialize_tdesc_i386_go32v2 (); + =20 /* Tell remote stub that we support XML target description. */ register_remote_support_xml ("i386"); Index: src/gdb/features/Makefile =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvs/src/src/gdb/features/Makefile,v retrieving revision 1.17 diff -u -p -r1.17 Makefile --- src/gdb/features/Makefile 8 Feb 2010 05:08:46 -0000 1.17 +++ src/gdb/features/Makefile 6 Apr 2010 13:46:03 -0000 @@ -31,7 +31,7 @@ # make GDB=3D/path/to/gdb XMLTOC=3D"xml files" cfiles =20 WHICH =3D arm-with-iwmmxt arm-with-vfpv2 arm-with-vfpv3 arm-with-neon \ - i386/i386 i386/i386-linux \ + i386/i386 i386/i386-go32v2 i386/i386-linux \ i386/amd64 i386/amd64-linux \ mips-linux mips64-linux \ rs6000/powerpc-32l rs6000/powerpc-altivec32l rs6000/powerpc-e500l \ @@ -42,6 +42,7 @@ WHICH =3D arm-with-iwmmxt arm-with-vfpv2 a # Record which registers should be sent to GDB by default after stop. arm-expedite =3D r11,sp,pc i386/i386-expedite =3D ebp,esp,eip +i386/i386-go32v2-expedite =3D ebp,esp,eip i386/i386-linux-expedite =3D ebp,esp,eip i386/amd64-expedite =3D rbp,rsp,rip i386/amd64-linux-expedite =3D rbp,rsp,rip Index: src/gdb/features/i386/i386-go32v2.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: features/i386/i386-go32v2.c diff -N features/i386/i386-go32v2.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/gdb/features/i386/i386-go32v2.c 6 Apr 2010 13:46:03 -0000 @@ -0,0 +1,73 @@ +/* THIS FILE IS GENERATED. Original: i386-go32v2.xml */ + +#include "defs.h" +#include "osabi.h" +#include "target-descriptions.h" + +struct target_desc *tdesc_i386_go32v2; +static void +initialize_tdesc_i386_go32v2 (void) +{ + struct target_desc *result =3D allocate_target_description (); + struct tdesc_feature *feature; + struct tdesc_type *field_type, *type; + + set_tdesc_architecture (result, bfd_scan_arch ("i386")); + + set_tdesc_osabi (result, osabi_from_tdesc_string ("DJGPP")); + + feature =3D tdesc_create_feature (result, "org.gnu.gdb.i386.core"); + field_type =3D tdesc_create_flags (feature, "i386_eflags", 4); + tdesc_add_flag (field_type, 0, "CF"); + tdesc_add_flag (field_type, 1, ""); + tdesc_add_flag (field_type, 2, "PF"); + tdesc_add_flag (field_type, 4, "AF"); + tdesc_add_flag (field_type, 6, "ZF"); + tdesc_add_flag (field_type, 7, "SF"); + tdesc_add_flag (field_type, 8, "TF"); + tdesc_add_flag (field_type, 9, "IF"); + tdesc_add_flag (field_type, 10, "DF"); + tdesc_add_flag (field_type, 11, "OF"); + tdesc_add_flag (field_type, 14, "NT"); + tdesc_add_flag (field_type, 16, "RF"); + tdesc_add_flag (field_type, 17, "VM"); + tdesc_add_flag (field_type, 18, "AC"); + tdesc_add_flag (field_type, 19, "VIF"); + tdesc_add_flag (field_type, 20, "VIP"); + tdesc_add_flag (field_type, 21, "ID"); + + tdesc_create_reg (feature, "eax", 0, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "ecx", 1, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "edx", 2, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "ebx", 3, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "esp", 4, 1, NULL, 32, "data_ptr"); + tdesc_create_reg (feature, "ebp", 5, 1, NULL, 32, "data_ptr"); + tdesc_create_reg (feature, "esi", 6, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "edi", 7, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "eip", 8, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "eflags", 9, 1, NULL, 32, "i386_eflags"); + tdesc_create_reg (feature, "cs", 10, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "ss", 11, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "ds", 12, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "es", 13, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "fs", 14, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "gs", 15, 1, NULL, 32, "int32"); + tdesc_create_reg (feature, "st0", 16, 1, NULL, 80, "i387_ext"); + tdesc_create_reg (feature, "st1", 17, 1, NULL, 80, "i387_ext"); + tdesc_create_reg (feature, "st2", 18, 1, NULL, 80, "i387_ext"); + tdesc_create_reg (feature, "st3", 19, 1, NULL, 80, "i387_ext"); + tdesc_create_reg (feature, "st4", 20, 1, NULL, 80, "i387_ext"); + tdesc_create_reg (feature, "st5", 21, 1, NULL, 80, "i387_ext"); + tdesc_create_reg (feature, "st6", 22, 1, NULL, 80, "i387_ext"); + tdesc_create_reg (feature, "st7", 23, 1, NULL, 80, "i387_ext"); + tdesc_create_reg (feature, "fctrl", 24, 1, "float", 32, "int"); + tdesc_create_reg (feature, "fstat", 25, 1, "float", 32, "int"); + tdesc_create_reg (feature, "ftag", 26, 1, "float", 32, "int"); + tdesc_create_reg (feature, "fiseg", 27, 1, "float", 32, "int"); + tdesc_create_reg (feature, "fioff", 28, 1, "float", 32, "int"); + tdesc_create_reg (feature, "foseg", 29, 1, "float", 32, "int"); + tdesc_create_reg (feature, "fooff", 30, 1, "float", 32, "int"); + tdesc_create_reg (feature, "fop", 31, 1, "float", 32, "int"); + + tdesc_i386_go32v2 =3D result; +} Index: src/gdb/features/i386/i386-go32v2.xml =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: features/i386/i386-go32v2.xml diff -N features/i386/i386-go32v2.xml --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/gdb/features/i386/i386-go32v2.xml 6 Apr 2010 13:46:03 -0000 @@ -0,0 +1,15 @@ + + + + + + + + i386 + DJGPP + + Index: src/gdb/regformats/i386/i386-go32v2.dat =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: regformats/i386/i386-go32v2.dat diff -N regformats/i386/i386-go32v2.dat --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/gdb/regformats/i386/i386-go32v2.dat 6 Apr 2010 13:46:03 -0000 @@ -0,0 +1,36 @@ +# DO NOT EDIT: generated from i386/i386-go32v2.xml +name:i386_go32v2 +xmltarget:i386-go32v2.xml +expedite:ebp,esp,eip +32:eax +32:ecx +32:edx +32:ebx +32:esp +32:ebp +32:esi +32:edi +32:eip +32:eflags +32:cs +32:ss +32:ds +32:es +32:fs +32:gs +80:st0 +80:st1 +80:st2 +80:st3 +80:st4 +80:st5 +80:st6 +80:st7 +32:fctrl +32:fstat +32:ftag +32:fiseg +32:fioff +32:foseg +32:fooff +32:fop =20=20 > -----Message d'origine----- > De=A0: gdb-owner@sourceware.org [mailto:gdb-owner@sourceware.org] De la > part de Pierre Muller > Envoy=E9=A0: Tuesday, April 06, 2010 1:29 AM > =C0=A0: gdb@sourceware.org > Objet=A0: Go32-v2 native woes >=20 > There are again internal-error problems > with go32v2 native about registers that are > not correct. >=20 > Current CVS gives this: >=20 > Breakpoint 2 at 0xc485: file ../../src/gdb/cli/cli-cmds.c, line 223. > (top-gdb) set prompt top> > #Note top> is an older gdb that works fine. > top> r ./gdb > Starting program: e:/cygwin/usr/local/src/gdbcvs/djcvsbuild/gdb/gdb.exe > ./gdb > GNU gdb (GDB) 7.1.50.20100405-cvs > Copyright (C) 2010 Free Software Foundation, Inc. > License GPLv3+: GNU GPL version 3 or later > > This is free software: you are free to change and redistribute it. > There is NO WARRANTY, to the extent permitted by law. Type "show > copying" > and "show warranty" for details. > This GDB was configured as "--host=3Di586-pc-msdosdjgpp --target=3Ddjgpp". > For bug reporting instructions, please see: > ... >=20 > Breakpoint 1, internal_error ( > file=3D0xe6d70 "../../src/gdb/target-descriptions.c", line=3D1140, > string=3D0xe6d55 "%s: Assertion `%s' failed.") at > ../../src/gdb/utils.c:1050 > 1050 va_start (ap, string); > top> bt > #0 internal_error (file=3D0xe6d70 "../../src/gdb/target-descriptions.c", > line=3D1140, string=3D0xe6d55 "%s: Assertion `%s' failed.") > at ../../src/gdb/utils.c:1050 > #1 0x000e8cf2 in tdesc_use_registers (gdbarch=3D0x46eda0, > target_desc=3D0x3ed480, > early_data=3D0x46fd90) at ../../src/gdb/target-descriptions.c:1140 > #2 0x0013a17c in i386_gdbarch_init (info=3D..., arches=3D0x0) > at ../../src/gdb/i386-tdep.c:6699 > #3 0x0004dbd6 in gdbarch_find_by_info (info=3D...) > at ../../src/gdb/gdbarch.c:3979 > #4 0x00088785 in set_gdbarch_from_file (abfd=3D0x42c0a0) > at ../../src/gdb/arch-utils.c:552 > #5 0x00017c8b in exec_file_attach (filename=3D0x3eaeb8 "./gdb", > from_tty=3D1) > at ../../src/gdb/exec.c:296 > #6 0x000256dd in catch_command_errors (command=3D0x179e7 > , > arg=3D0x3eaeb8 "./gdb", from_tty=3D1, mask=3D6) at > ../../src/gdb/exceptions.c:525 > #7 0x00002a2a in captured_main (data=3D0x3ea208) at > ../../src/gdb/main.c:808 > #8 0x00025649 in catch_errors (func=3D0x1dfa , > func_args=3D0x3ea208, errstring=3D0x1b94 "", mask=3D6) > at ../../src/gdb/exceptions.c:510 > #9 0x00002d72 in gdb_main (args=3D0x3ea208) at ../../src/gdb/main.c:916 > #10 0x0000180d in main (argc=3D2, argv=3D0x3eaed8) at > ../../src/gdb/gdb.c:33 > top> f 1 > #1 0x000e8cf2 in tdesc_use_registers (gdbarch=3D0x46eda0, > target_desc=3D0x3ed480, > early_data=3D0x46fd90) at ../../src/gdb/target-descriptions.c:1140 > 1140 gdb_assert (VEC_length (tdesc_arch_reg, data->arch_regs) <=3D > num_regs); >=20 > top> p num_regs > $1 =3D 32 > top> p *data.arch_regs > $2 =3D {num =3D 33, alloc =3D 36, vec =3D {{reg =3D 0x3ed6d8, type =3D 0x= 0}}} > top> >=20 > The additional reg in arch_regs seems to come from > i386_validate_tdesc_p function: > /* Need to include %mxcsr, so add one. */ > num_regs +=3D tdep->num_xmm_regs + 1; >=20 > Adding this condition > if (tdep->num_xmm_regs) > removes the problem above, > but I get another error later: > Breakpoint 1 at 0x479d: file ../../src/gdb/utils.c, line 1050. > Breakpoint 2 at 0xc485: file ../../src/gdb/cli/cli-cmds.c, line 223. > (top-gdb) start > Temporary breakpoint 3 at 0x17d4: file ../../src/gdb/gdb.c, line 28. > Starting program: e:/cygwin/usr/local/src/gdbcvs/djcvsbuild/gdb/gdb.exe >=20 > Temporary breakpoint 3, main (argc=3D1, argv=3D0x3eae78) at > ../../src/gdb/gdb.c:28 > 28 memset (&args, 0, sizeof args); > (top-gdb) inf reg > eax 0x10 16 > ecx 0x0 0 > edx 0x100 256 > ebx 0x3f6 1014 > esp 0x3ea1f0 0x3ea1f0 > ebp 0x3ea220 0x3ea220 > esi 0x54 84 > edi 0x36a258 3580504 > eip 0x17d4 0x17d4 > eflags 0x3206 [ PF IF #12 #13 ] > cs 0x28f 655 > ss 0x297 663 > ds 0x297 663 > es 0x297 663 > fs 0x2a7 679 > gs 0x2a7 679 >=20 > Breakpoint 1, internal_error (file=3D0x1286ab "../../src/gdb/go32-nat.c", > line=3D546, string=3D0x128680 "Invalid register no. %d in > fetch_register.") > at ../../src/gdb/utils.c:1050 > 1050 va_start (ap, string); >=20 > GDB is trying to display register 32 which is normally "xmm0" > and thus should not be displayed for go32v2. >=20 > I was not able o fix that second problem :( >=20 > Pierre Muller > Pascal language support maintainer for GDB > and old-DOS lover ...