Lazily allocate 'struct regsets_info'::disabled_regsets.

There's no need for every arch to pre-allocate disabled_regsets.
Chances are the array won't be used.

(I have a hunch that with some more work we could dispense with
initialize_regsets_info.)

Tested on x86_64 Fedora 17 w/ -lmcheck.

gdb/gdbserver/
2013-06-11  Pedro Alves  <palves@redhat.com>

	* linux-low.c (regset_disabled, disable_regset): New functions.
	(regsets_fetch_inferior_registers)
	(regsets_store_inferior_registers): Use them.
	(initialize_regsets_info); Don't allocate the disabled_regsets
	array here.
	* linux-low.h (struct regsets_info) <disabled_regsets>: Extend
	comment.
This commit is contained in:
Pedro Alves 2013-06-11 18:05:57 +00:00
parent 5da6eb0a10
commit 030031eed5
3 changed files with 39 additions and 14 deletions

View File

@ -1,3 +1,13 @@
2013-06-11 Pedro Alves <palves@redhat.com>
* linux-low.c (regset_disabled, disable_regset): New functions.
(regsets_fetch_inferior_registers)
(regsets_store_inferior_registers): Use them.
(initialize_regsets_info); Don't allocate the disabled_regsets
array here.
* linux-low.h (struct regsets_info) <disabled_regsets>: Extend
comment.
2013-06-11 Pedro Alves <palves@redhat.com>
* linux-low.c (initialize_regsets_info): Use xcalloc instead of

View File

@ -4051,6 +4051,28 @@ unstop_all_lwps (int unsuspend, struct lwp_info *except)
#define use_linux_regsets 1
/* Returns true if REGSET has been disabled. */
static int
regset_disabled (struct regsets_info *info, struct regset_info *regset)
{
return (info->disabled_regsets != NULL
&& info->disabled_regsets[regset - info->regsets]);
}
/* Disable REGSET. */
static void
disable_regset (struct regsets_info *info, struct regset_info *regset)
{
int dr_offset;
dr_offset = regset - info->regsets;
if (info->disabled_regsets == NULL)
info->disabled_regsets = xcalloc (1, info->num_regsets);
info->disabled_regsets[dr_offset] = 1;
}
static int
regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
struct regcache *regcache)
@ -4068,8 +4090,7 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
void *buf, *data;
int nt_type, res;
if (regset->size == 0
|| regsets_info->disabled_regsets[regset - regsets_info->regsets])
if (regset->size == 0 || regset_disabled (regsets_info, regset))
{
regset ++;
continue;
@ -4097,12 +4118,9 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info,
{
if (errno == EIO)
{
int dr_offset;
/* If we get EIO on a regset, do not try it again for
this process mode. */
dr_offset = regset - regsets_info->regsets;
regsets_info->disabled_regsets[dr_offset] = 1;
disable_regset (regsets_info, regset);
free (buf);
continue;
}
@ -4143,8 +4161,7 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info,
void *buf, *data;
int nt_type, res;
if (regset->size == 0
|| regsets_info->disabled_regsets[regset - regsets_info->regsets])
if (regset->size == 0 || regset_disabled (regsets_info, regset))
{
regset ++;
continue;
@ -4191,12 +4208,9 @@ regsets_store_inferior_registers (struct regsets_info *regsets_info,
{
if (errno == EIO)
{
int dr_offset;
/* If we get EIO on a regset, do not try it again for
this process mode. */
dr_offset = regset - regsets_info->regsets;
regsets_info->disabled_regsets[dr_offset] = 1;
disable_regset (regsets_info, regset);
free (buf);
continue;
}
@ -6072,7 +6086,6 @@ initialize_regsets_info (struct regsets_info *info)
info->regsets[info->num_regsets].size >= 0;
info->num_regsets++)
;
info->disabled_regsets = xcalloc (1, info->num_regsets);
}
#endif

View File

@ -60,7 +60,9 @@ struct regsets_info
/* If we get EIO on a regset, do not try it again. Note the set of
supported regsets may depend on processor mode on biarch
machines. */
machines. This is a (lazily allocated) array holding one boolean
byte (0/1) per regset, with each element corresponding to the
regset in the REGSETS array above at the same offset. */
char *disabled_regsets;
};