aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2018-04-25 11:55:56 -0700
committerMax Filippov <jcmvbkbc@gmail.com>2018-05-09 09:30:06 -0700
commit37d9e0623102352e0ae27c311760a9e6569ae5e0 (patch)
tree308150ef1110d72414922a26daf348c771105ca7 /gdb
parent60cb2c8a331ed8e4ad20afc51f9cdb3d8d18a869 (diff)
downloadfsf-binutils-gdb-37d9e0623102352e0ae27c311760a9e6569ae5e0.zip
fsf-binutils-gdb-37d9e0623102352e0ae27c311760a9e6569ae5e0.tar.gz
fsf-binutils-gdb-37d9e0623102352e0ae27c311760a9e6569ae5e0.tar.bz2
gdb: xtensa: handle privileged registers
xtensa GDB may be used with both bare-metal and linux-based applications. In case of bare-metal application gdbserver is able to provide information about all CPU registers: both unprivileged and privileged. In case of linux-based application only a small subset of privileged state is available. Currently xtensa GDB only expects unprivileged registers in 'g' packets and it fails to communicate with server that sends both privileged and unprivileged registers. Allow bare-metal xtensa GDB to deal with both privileged and unprivileged registers by initializing tdep->num_regs with the total number of target CPU registers. Keep linux-based xtensa GDB functionality as is by copying tdep->num_nopriv_regs to tdep->num_regs. gdb/ 2018-05-09 Max Filippov <jcmvbkbc@gmail.com> * xtensa-linux-tdep.c (xtensa-tdep.h): New include. (xtensa_linux_init_abi): Limit tdep->num_regs by tdep->num_nopriv_regs. * xtensa-tdep.c (xtensa_derive_tdep): Calculate tdep->num_nopriv_regs and only copy it to tdep->num_regs if it's not initialized.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/xtensa-linux-tdep.c6
-rw-r--r--gdb/xtensa-tdep.c12
3 files changed, 19 insertions, 8 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index a1059aef..728ed8c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,12 @@
+2018-05-09 Max Filippov <jcmvbkbc@gmail.com>
+
+ * xtensa-linux-tdep.c (xtensa-tdep.h): New include.
+ (xtensa_linux_init_abi): Limit tdep->num_regs by
+ tdep->num_nopriv_regs.
+ * xtensa-tdep.c (xtensa_derive_tdep): Calculate
+ tdep->num_nopriv_regs and only copy it to tdep->num_regs if it's
+ not initialized.
+
2018-05-08 Simon Marchi <simon.marchi@ericsson.com>
* unittests/string_view-selftests.c: Define GNULIB_NAMESPACE.
diff --git a/gdb/xtensa-linux-tdep.c b/gdb/xtensa-linux-tdep.c
index a9b30c7..b62085d 100644
--- a/gdb/xtensa-linux-tdep.c
+++ b/gdb/xtensa-linux-tdep.c
@@ -18,6 +18,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
+#include "xtensa-tdep.h"
#include "osabi.h"
#include "linux-tdep.h"
#include "solib-svr4.h"
@@ -97,6 +98,11 @@ xtensa_linux_gdb_signal_to_target (struct gdbarch *gdbarch,
static void
xtensa_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
+ struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
+
+ if (tdep->num_nopriv_regs < tdep->num_regs)
+ tdep->num_regs = tdep->num_nopriv_regs;
+
linux_init_abi (info, gdbarch);
set_solib_svr4_fetch_link_map_offsets
diff --git a/gdb/xtensa-tdep.c b/gdb/xtensa-tdep.c
index a1ecf5f..01f9616 100644
--- a/gdb/xtensa-tdep.c
+++ b/gdb/xtensa-tdep.c
@@ -3145,16 +3145,12 @@ xtensa_derive_tdep (struct gdbarch_tdep *tdep)
max_size = rmap->byte_size;
if (rmap->mask != 0 && tdep->num_regs == 0)
tdep->num_regs = n;
- /* Find out out how to deal with priveleged registers.
-
- if ((rmap->flags & XTENSA_REGISTER_FLAGS_PRIVILEGED) != 0
- && tdep->num_nopriv_regs == 0)
- tdep->num_nopriv_regs = n;
- */
if ((rmap->flags & XTENSA_REGISTER_FLAGS_PRIVILEGED) != 0
- && tdep->num_regs == 0)
- tdep->num_regs = n;
+ && tdep->num_nopriv_regs == 0)
+ tdep->num_nopriv_regs = n;
}
+ if (tdep->num_regs == 0)
+ tdep->num_regs = tdep->num_nopriv_regs;
/* Number of pseudo registers. */
tdep->num_pseudo_regs = n - tdep->num_regs;