binutils-gdb/gdb/features/i386/32bit-core.c

67 lines
3.2 KiB
C
Raw Normal View History

/* THIS FILE IS GENERATED. -*- buffer-read-only: t -*- vi:set ro:
Original: 32bit-core.xml */
[GDBserver] Centralize tdesc for i386-linux tdesc_i386_XXX_linux is used in many places in linux-x86-low.c and this patch adds a new function i386_linux_read_description to return the right tdesc according to xcr0. i386_linux_read_description is quite similar to the counterpart in GDB, and the following patch will share the duplicated code, so this patch adds arch/tdesc.h includes the declarations of various tdesc apis which are used by the shared code. The generated c feature files can include arch/tdesc.h only. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * configure.srv (srv_tgtobj): Append linux-x86-tdesc.o. (ipa_obj): Likewise. * linux-i386-ipa.c: Include common/x86-xstate.h (get_ipa_tdesc): Call i386_linux_read_description. (initialize_low_tracepoint): Don't call init_registers_XXX functions, call initialize_low_tdesc instead. * linux-x86-low.c (x86_linux_read_description): Call i386_linux_read_description. (initialize_low_arch): Don't call init_registers_i386_XXX functions, call initialize_low_tdesc. * linux-x86-tdesc.c: New file. * linux-x86-tdesc.h (x86_linux_tdesc): New X86_TDESC_LAST. (i386_get_ipa_tdesc_idx): Declare. (i386_get_ipa_tdesc): Declare. (initialize_low_tdesc): Declare. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * arch/tdesc.h: New file. * regformats/regdat.sh: Generate code using tdesc_create_reg. * target-descriptions.c: Update comments. * target-descriptions.h: Include "arch/tdesc.h". Remove the declarations. * features/i386/32bit-avx.c: Re-generated. * features/i386/32bit-avx512.c: Re-generated. * features/i386/32bit-core.c: Re-generated. * features/i386/32bit-linux.c: Re-generated. * features/i386/32bit-mpx.c: Re-generated. * features/i386/32bit-pkeys.c: Re-generated. * features/i386/32bit-sse.c: Re-generated.
2017-09-05 16:54:53 +08:00
#include "arch/tdesc.h"
static int
create_feature_i386_32bit_core (struct target_desc *result, long regnum)
{
struct tdesc_feature *feature;
Dynamically composite xml in reply to GDB GDBserver still uses pre-generated target descriptions in order to reply to GDB's query on target description (see xml-builtin-generated.c in GDBserver build directory). This patch teaches GDBserver to create XML contents according to the target descriptions rather than using pre-generated ones. First, change target feature c files to pass the feature xml file name to tdesc_create_feature, so that target description in GDBserver can record them, and create XML contents from these features in buffer, like ... <xi:include href="$FEATURE1_XML_NAME"/> <xi:include href="$FEATURE2_XML_NAME"/> ... and send this buffer back to GDB. Note that this patch reuses target_desc.xmltarget a little bit, which is to hold the XML contents dynamically generated in tdesc_get_features_xml. However, it is not xfree'ed in ~target_desc, because we can't tell it is from xstrdup or a literal string. Since we don't delete target_desc, there is no memory leak yet. After we change all target descriptions to the new style, target_desc.xmltarget is from xstrdup, then, we can safely xfree it in ~target_desc. gdb: 2017-09-05 Yao Qi <yao.qi@linaro.org> * arch/tdesc.h (tdesc_create_feature): Add an argument xml. * target-descriptions.c (tdesc_create_feature): Likewise, and adjust code. * features/i386/32bit-avx.c: Re-generated. * features/i386/32bit-avx512.c: Re-generated. * features/i386/32bit-core.c: Re-generated. * features/i386/32bit-linux.c: Re-generated. * features/i386/32bit-mpx.c: Re-generated. * features/i386/32bit-pkeys.c: Re-generated. * features/i386/32bit-sse.c: Re-generated. gdb/gdbserver: 2017-09-05 Yao Qi <yao.qi@linaro.org> * linux-x86-tdesc.c: Don't include <inttypes.h>. (i386_linux_read_description) [!IN_PROCESS_AGENT]: Call set_tdesc_architecture and set_tdesc_osabi. Remove code setting .xmltarget. * server.c (get_features_xml): Call tdesc_get_features_xml. * tdesc.c (set_tdesc_architecture): New function. (set_tdesc_osabi): New function. (tdesc_get_features_xml): New function. (tdesc_create_feature): Add an argument. * tdesc.h (struct target_desc) <features>: New field. <arch, osabi>: New field. (~target_desc): xfree features, arch, and osabi. (target_desc::oerator==): Don't compare .xmltarget. [!IN_PROCESS_AGENT] (set_tdesc_architecture): Declare. (set_tdesc_osabi): Likewise. (tdesc_get_features_xml): Likewise.
2017-09-05 16:54:53 +08:00
feature = tdesc_create_feature (result, "org.gnu.gdb.i386.core", "32bit-core.xml");
struct tdesc_type *field_type;
struct tdesc_type *type;
type = tdesc_create_flags (feature, "i386_eflags", 4);
tdesc_add_flag (type, 0, "CF");
tdesc_add_flag (type, 1, "");
tdesc_add_flag (type, 2, "PF");
tdesc_add_flag (type, 4, "AF");
tdesc_add_flag (type, 6, "ZF");
tdesc_add_flag (type, 7, "SF");
tdesc_add_flag (type, 8, "TF");
tdesc_add_flag (type, 9, "IF");
tdesc_add_flag (type, 10, "DF");
tdesc_add_flag (type, 11, "OF");
tdesc_add_flag (type, 14, "NT");
tdesc_add_flag (type, 16, "RF");
tdesc_add_flag (type, 17, "VM");
tdesc_add_flag (type, 18, "AC");
tdesc_add_flag (type, 19, "VIF");
tdesc_add_flag (type, 20, "VIP");
tdesc_add_flag (type, 21, "ID");
tdesc_create_reg (feature, "eax", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "ecx", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "edx", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "ebx", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "esp", regnum++, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "ebp", regnum++, 1, NULL, 32, "data_ptr");
tdesc_create_reg (feature, "esi", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "edi", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "eip", regnum++, 1, NULL, 32, "code_ptr");
tdesc_create_reg (feature, "eflags", regnum++, 1, NULL, 32, "i386_eflags");
tdesc_create_reg (feature, "cs", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "ss", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "ds", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "es", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "fs", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "gs", regnum++, 1, NULL, 32, "int32");
tdesc_create_reg (feature, "st0", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st1", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st2", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st3", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st4", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st5", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st6", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "st7", regnum++, 1, NULL, 80, "i387_ext");
tdesc_create_reg (feature, "fctrl", regnum++, 1, "float", 32, "int");
tdesc_create_reg (feature, "fstat", regnum++, 1, "float", 32, "int");
tdesc_create_reg (feature, "ftag", regnum++, 1, "float", 32, "int");
tdesc_create_reg (feature, "fiseg", regnum++, 1, "float", 32, "int");
tdesc_create_reg (feature, "fioff", regnum++, 1, "float", 32, "int");
tdesc_create_reg (feature, "foseg", regnum++, 1, "float", 32, "int");
tdesc_create_reg (feature, "fooff", regnum++, 1, "float", 32, "int");
tdesc_create_reg (feature, "fop", regnum++, 1, "float", 32, "int");
return regnum;
}