Lazily and dynamically create i386-linux target descriptions

Instead of using pre-generated target descriptions, this patch
changes GDB to lazily and dynamically create target descriptions
according to the target hardware capability (xcr0 in i386).
This support any combination of target features.

Some reg in target description has "regnum" attribute, so its register
number is got from the attribute value instead from sequential allocation.

  <reg name="xmm0" bitsize="128" type="vec128" regnum="32"/>

when target description is created, it should match the regnum, so this
patch adds a new field m_next_regnum to track it, if attribute number is
greater than the m_next_regnum, print the code to set register number
explicitly.

gdb:

2017-07-26  Yao Qi  <yao.qi@linaro.org>

	* i386-linux-tdep.c: Don't include features/i386/i386-*linux.c.
	Include features/i386/32bit-*.c.
	(i386_linux_read_description): Generate target description if it
	doesn't exist.
	(_initialize_i386_linux_tdep): Don't call _initialize_tdesc_i386
	functions.
	* features/i386/32bit-linux.c: Re-generated.
	* features/i386/32bit-sse.c: Likewise.
	* target-descriptions.c (print_c_feature::visit): Print code to
	set register number if needed.
	(print_c_feature) <m_next_regnum>: New field.
This commit is contained in:
Yao Qi
2017-07-26 14:39:54 +01:00
parent 25aa13e522
commit ea03d0d3c3
5 changed files with 112 additions and 34 deletions

View File

@ -9,6 +9,7 @@ create_feature_i386_32bit_linux (struct target_desc *result, long regnum)
struct tdesc_feature *feature;
feature = tdesc_create_feature (result, "org.gnu.gdb.i386.linux");
regnum = 41;
tdesc_create_reg (feature, "orig_eax", regnum++, 1, NULL, 32, "int");
return regnum;
}

View File

@ -61,6 +61,7 @@ create_feature_i386_32bit_sse (struct target_desc *result, long regnum)
tdesc_add_flag (type, 12, "PM");
tdesc_add_flag (type, 15, "FZ");
regnum = 32;
tdesc_create_reg (feature, "xmm0", regnum++, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm1", regnum++, 1, NULL, 128, "vec128");
tdesc_create_reg (feature, "xmm2", regnum++, 1, NULL, 128, "vec128");