Skip to content

Commit bde8cbe

Browse files
dcpleungstephanosio
authored andcommitted
gdb: xtensa: support disabling use of 'g' packet
The xt-ocd from Xtensa's official toolchain may not support 'g' packet. So this allows building GDB which won't query registers using 'g' packets but instead using 'p' packets only. Signed-off-by: Daniel Leung <daniel.leung@intel.com> Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
1 parent 6702310 commit bde8cbe

File tree

3 files changed

+48
-2
lines changed

3 files changed

+48
-2
lines changed

gdb/configure

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,7 @@ with_libbabeltrace_prefix
977977
with_libbabeltrace_type
978978
enable_libctf
979979
enable_xtensa_use_target_regnum
980+
enable_xtensa_remote_g_packet
980981
enable_unit_tests
981982
'
982983
ac_precious_vars='build_alias
@@ -1665,6 +1666,8 @@ Optional Features:
16651666
--enable-libctf Handle .ctf type-info sections [default=yes]
16661667
--enable-xtensa-use-target-regnum
16671668
Use remote target register numbers (Xtensa target)
1669+
--disable-xtensa-remote-g-packet
1670+
Disable g packet for remote Xtensa target
16681671
--enable-unit-tests Enable the inclusion of unit tests when compiling
16691672
GDB
16701673

@@ -11503,7 +11506,7 @@ else
1150311506
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1150411507
lt_status=$lt_dlunknown
1150511508
cat > conftest.$ac_ext <<_LT_EOF
11506-
#line 11506 "configure"
11509+
#line 11509 "configure"
1150711510
#include "confdefs.h"
1150811511

1150911512
#if HAVE_DLFCN_H
@@ -11609,7 +11612,7 @@ else
1160911612
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
1161011613
lt_status=$lt_dlunknown
1161111614
cat > conftest.$ac_ext <<_LT_EOF
11612-
#line 11612 "configure"
11615+
#line 11615 "configure"
1161311616
#include "confdefs.h"
1161411617

1161511618
#if HAVE_DLFCN_H
@@ -33656,6 +33659,23 @@ if test x"$enable_xtensa_use_target_regnum" = xyes; then
3365633659
CPPFLAGS="$CPPFLAGS -DXTENSA_USE_TGT_REGNUM"
3365733660
fi
3365833661

33662+
# Use g packet for remote Xtensa target
33663+
# Check whether --enable-xtensa-remote-g-packet was given.
33664+
if test "${enable_xtensa_remote_g_packet+set}" = set; then :
33665+
enableval=$enable_xtensa_remote_g_packet; case $enableval in
33666+
yes | no)
33667+
enable_xtensa_use_g_packet=$enableval ;;
33668+
*)
33669+
as_fn_error $? "bad value $enableval for --enable-xtensa-remote-g-packet" "$LINENO" 5 ;;
33670+
esac
33671+
else
33672+
enable_xtensa_use_g_packet=yes
33673+
fi
33674+
33675+
if test x"$enable_xtensa_use_g_packet" = xno; then
33676+
CPPFLAGS="$CPPFLAGS -DXTENSA_DISABLE_REMOTE_G_PACKET"
33677+
fi
33678+
3365933679
NM_H=
3366033680
rm -f nm.h
3366133681
if test "${nativefile}" != ""; then

gdb/configure.ac

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,20 @@ if test x"$enable_xtensa_use_target_regnum" = xyes; then
22442244
CPPFLAGS="$CPPFLAGS -DXTENSA_USE_TGT_REGNUM"
22452245
fi
22462246

2247+
# Use g packet for remote Xtensa target
2248+
AC_ARG_ENABLE(xtensa-remote-g-packet,
2249+
AS_HELP_STRING([--disable-xtensa-remote-g-packet], [Disable g packet for remote Xtensa target]),
2250+
[case $enableval in
2251+
yes | no)
2252+
enable_xtensa_use_g_packet=$enableval ;;
2253+
*)
2254+
AC_MSG_ERROR([bad value $enableval for --enable-xtensa-remote-g-packet]) ;;
2255+
esac],
2256+
[enable_xtensa_use_g_packet=yes])
2257+
if test x"$enable_xtensa_use_g_packet" = xno; then
2258+
CPPFLAGS="$CPPFLAGS -DXTENSA_DISABLE_REMOTE_G_PACKET"
2259+
fi
2260+
22472261
NM_H=
22482262
rm -f nm.h
22492263
if test "${nativefile}" != ""; then

gdb/xtensa-tdep.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3161,6 +3161,16 @@ xtensa_remote_register_number (struct gdbarch *gdbarch, int regnum)
31613161
}
31623162
#endif
31633163

3164+
static int
3165+
xtensa_remote_supports_g_packet (struct gdbarch *gdbarch)
3166+
{
3167+
#ifdef XTENSA_DISABLE_REMOTE_G_PACKET
3168+
return 0;
3169+
#else
3170+
return 1;
3171+
#endif
3172+
}
3173+
31643174
/* Module "constructor" function. */
31653175

31663176
extern xtensa_register_t xtensa_rmap[];
@@ -3261,6 +3271,8 @@ xtensa_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
32613271
set_solib_svr4_fetch_link_map_offsets
32623272
(gdbarch, svr4_ilp32_fetch_link_map_offsets);
32633273

3274+
set_gdbarch_remote_supports_g_packet (gdbarch, xtensa_remote_supports_g_packet);
3275+
32643276
/* Hook in the ABI-specific overrides, if they have been registered. */
32653277
gdbarch_init_osabi (info, gdbarch);
32663278

0 commit comments

Comments
 (0)