From c40e1eabaff716503a421b869605606eb3d37968 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sat, 19 Apr 2003 14:43:50 +0000 Subject: [PATCH] * i386-tdep.c (i386_num_register_names): New variable. (i386_num_mmx_regs): Renamed from mmx_num_regs. (MM0_REGNUM): Remove redundant parentheses in define. (i386_mmx_regnum_p): Use i386_mmx_regnum instead of mmx_num_regs. (i386_fp_regnum_p, i386_fpc_regnum_p, i386_sse_regnum_p, i386_mxcsr_regnum_p): Remove redundant parentheses. (i386_register_name): Use i386_num_register_names. --- gdb/ChangeLog | 8 ++++++++ gdb/i386-tdep.c | 34 ++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index fa9446b6fda..ad86a9055ca 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2003-04-19 Mark Kettenis + * i386-tdep.c (i386_num_register_names): New variable. + (i386_num_mmx_regs): Renamed from mmx_num_regs. + (MM0_REGNUM): Remove redundant parentheses in define. + (i386_mmx_regnum_p): Use i386_mmx_regnum instead of mmx_num_regs. + (i386_fp_regnum_p, i386_fpc_regnum_p, i386_sse_regnum_p, + i386_mxcsr_regnum_p): Remove redundant parentheses. + (i386_register_name): Use i386_num_register_names. + * i386-tdep.c (i386_extract_return_value, i386_store_return_value): Correct check for availability of floating-point registers. diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index dd30aa53eb8..2406e3ffefc 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -46,6 +46,7 @@ /* Names of the registers. The first 10 registers match the register numbering scheme used by GCC for stabs and DWARF. */ + static char *i386_register_names[] = { "eax", "ecx", "edx", "ebx", @@ -61,6 +62,9 @@ static char *i386_register_names[] = "mxcsr" }; +static const int i386_num_register_names = + (sizeof (i386_register_names) / sizeof (*i386_register_names)); + /* MMX registers. */ static char *i386_mmx_names[] = @@ -68,14 +72,17 @@ static char *i386_mmx_names[] = "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7" }; -static const int mmx_num_regs = (sizeof (i386_mmx_names) - / sizeof (i386_mmx_names[0])); -#define MM0_REGNUM (NUM_REGS) + +static const int i386_num_mmx_regs = + (sizeof (i386_mmx_names) / sizeof (i386_mmx_names[0])); + +#define MM0_REGNUM NUM_REGS static int -i386_mmx_regnum_p (int reg) +i386_mmx_regnum_p (int regnum) { - return (reg >= MM0_REGNUM && reg < MM0_REGNUM + mmx_num_regs); + return (regnum >= MM0_REGNUM + && regnum < MM0_REGNUM + i386_num_mmx_regs); } /* FP register? */ @@ -84,14 +91,14 @@ int i386_fp_regnum_p (int regnum) { return (regnum < NUM_REGS - && (FP0_REGNUM && FP0_REGNUM <= (regnum) && (regnum) < FPC_REGNUM)); + && (FP0_REGNUM && FP0_REGNUM <= regnum && regnum < FPC_REGNUM)); } int i386_fpc_regnum_p (int regnum) { return (regnum < NUM_REGS - && (FPC_REGNUM <= (regnum) && (regnum) < XMM0_REGNUM)); + && (FPC_REGNUM <= regnum && regnum < XMM0_REGNUM)); } /* SSE register? */ @@ -100,14 +107,14 @@ int i386_sse_regnum_p (int regnum) { return (regnum < NUM_REGS - && (XMM0_REGNUM <= (regnum) && (regnum) < MXCSR_REGNUM)); + && (XMM0_REGNUM <= regnum && regnum < MXCSR_REGNUM)); } int i386_mxcsr_regnum_p (int regnum) { return (regnum < NUM_REGS - && (regnum == MXCSR_REGNUM)); + && regnum == MXCSR_REGNUM); } /* Return the name of register REG. */ @@ -115,14 +122,13 @@ i386_mxcsr_regnum_p (int regnum) const char * i386_register_name (int reg) { - if (reg < 0) - return NULL; + if (reg >= 0 && reg < i386_num_register_names) + return i386_register_names[reg]; + if (i386_mmx_regnum_p (reg)) return i386_mmx_names[reg - MM0_REGNUM]; - if (reg >= sizeof (i386_register_names) / sizeof (*i386_register_names)) - return NULL; - return i386_register_names[reg]; + return NULL; } /* Convert stabs register number REG to the appropriate register -- 2.30.2