Module Name: src Committed By: martin Date: Thu Oct 3 17:33:42 UTC 2019
Modified Files: src/external/gpl3/gdb/dist/gdb [netbsd-9]: arm-nbsd-nat.c Log Message: Pull up following revision(s) (requested by christos in ticket #281): external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c: revision 1.13 Validate register number before fetching/storing it (Gopikrishnan Sidhardhan) To generate a diff of this commit: cvs rdiff -u -r1.11.2.1 -r1.11.2.2 \ src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c diff -u src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c:1.11.2.1 src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c:1.11.2.2 --- src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c:1.11.2.1 Sun Sep 1 14:15:24 2019 +++ src/external/gpl3/gdb/dist/gdb/arm-nbsd-nat.c Thu Oct 3 17:33:42 2019 @@ -49,6 +49,24 @@ public: static arm_nbsd_nat_target the_arm_nbsd_nat_target; +/* Determine if PT_GETREGS fetches REGNUM. */ + +static bool +getregs_supplies (int regnum) +{ + return ((regnum >= ARM_A1_REGNUM && regnum <= ARM_PC_REGNUM) + || regnum == ARM_PS_REGNUM); +} + +/* Determine if PT_GETFPREGS fetches REGNUM. */ + +static bool +getfpregs_supplies (int regnum) +{ + return ((regnum >= ARM_D0_REGNUM && regnum <= ARM_D31_REGNUM) + || regnum == ARM_FPSCR_REGNUM); +} + extern int arm_apcs_32; #define FPSCR(r) ((char *) &(r)->fpr_vfp.vfp_fpscr) @@ -256,10 +274,12 @@ arm_nbsd_nat_target::fetch_registers (st { if (regno >= 0) { - if (regno >= ARM_D0_REGNUM && regno <= ARM_FPSCR_REGNUM) + if (getregs_supplies (regno)) + fetch_register (regcache, regno); + else if (getfpregs_supplies (regno)) fetch_fp_register (regcache, regno); else - fetch_register (regcache, regno); + warning (_("unable to fetch register %d"), regno); } else { @@ -442,10 +462,12 @@ arm_nbsd_nat_target::store_registers (st { if (regno >= 0) { - if (regno >= ARM_D0_REGNUM && regno <= ARM_FPSCR_REGNUM) + if (getregs_supplies (regno)) + store_register (regcache, regno); + else if (getfpregs_supplies (regno)) store_fp_register (regcache, regno); else - store_register (regcache, regno); + warning (_("unable to store register %d"), regno); } else {