From de70f17ee4157e30f27cac74192116c3cbb97c7a Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 8 May 2023 10:18:46 +0200 Subject: [PATCH] gdb: update to version 13.1 Issue #4827 --- repos/ports/lib/symbols/gdbserver_platform | 17 +- repos/ports/ports/gdb.hash | 2 +- repos/ports/ports/gdb.port | 4 +- repos/ports/src/app/gdb_monitor/target.mk | 3 +- .../gdb/patches/arm_single_step.patch | 6 +- .../gdb/patches/call_dummy_location.patch | 4 +- .../src/noux-pkg/gdb/patches/gdb_x86_64.patch | 45 ++- .../gdb/patches/gdbserver_genode.patch | 350 +++++++++--------- .../src/noux-pkg/gdb/patches/noux_build.patch | 76 ++-- .../noux-pkg/gdb/patches/shared_library.patch | 40 +- repos/ports/src/noux-pkg/gdb/target.inc | 10 +- tool/tool_chain | 11 + 12 files changed, 302 insertions(+), 266 deletions(-) diff --git a/repos/ports/lib/symbols/gdbserver_platform b/repos/ports/lib/symbols/gdbserver_platform index 065d474903..31558a4ae5 100644 --- a/repos/ports/lib/symbols/gdbserver_platform +++ b/repos/ports/lib/symbols/gdbserver_platform @@ -6,7 +6,6 @@ _Z13all_processesB5cxx11 U _Z13register_sizePK11target_desci U _Z14agent_loaded_pv U _Z14fetch_registerPKcmRm T -_Z14internal_errorPKciS0_z U _Z14linux_stop_lwpP8lwp_info U _Z14lwp_is_stoppedP8lwp_info U _Z14store_registerPKcRmm T @@ -20,6 +19,7 @@ _Z16find_process_pidi U _Z16init_target_descP11target_descPPKc U _Z16perror_with_namePKc U _Z16regcache_releasev U +_Z16switch_to_threadP11thread_info U _Z16tdesc_create_regP13tdesc_featurePKciiS2_iS2_ U _Z16tdesc_named_typePK13tdesc_featurePKc U _Z17iterate_over_lwps6ptid_tN3gdb13function_viewIFiP8lwp_infoEEE U @@ -153,18 +153,18 @@ _ZN20linux_process_target20qxfer_libraries_svr4EPKcPhPKhmi U _ZN20linux_process_target20stopped_data_addressEv U _ZN20linux_process_target20supports_exec_eventsEv U _ZN20linux_process_target20supports_fork_eventsEv U -_ZN20linux_process_target21done_accessing_memoryEv U +_ZN20linux_process_target20thread_pending_childEP11thread_info U _ZN20linux_process_target21stopped_by_watchpointEv U _ZN20linux_process_target21supports_qxfer_osdataEv U _ZN20linux_process_target21supports_read_offsetsEv U _ZN20linux_process_target21supports_vfork_eventsEv U +_ZN20linux_process_target21thread_pending_parentEP11thread_info U _ZN20linux_process_target22handle_monitor_commandEPc U _ZN20linux_process_target22supports_catch_syscallEv U _ZN20linux_process_target22supports_multi_processEv U _ZN20linux_process_target22supports_qxfer_siginfoEv U _ZN20linux_process_target23supports_range_steppingEv U _ZN20linux_process_target23supports_thread_stoppedEv U -_ZN20linux_process_target24prepare_to_access_memoryEv U _ZN20linux_process_target24stopped_by_hw_breakpointEv U _ZN20linux_process_target24stopped_by_sw_breakpointEv U _ZN20linux_process_target24supports_get_tls_addressEv U @@ -179,7 +179,7 @@ _ZN20linux_process_target33supports_stopped_by_hw_breakpointEv U _ZN20linux_process_target33supports_stopped_by_sw_breakpointEv U _ZN20linux_process_target4joinEi U _ZN20linux_process_target4killEP12process_info U -_ZN20linux_process_target4waitE6ptid_tP17target_waitstatusi U +_ZN20linux_process_target4waitE6ptid_tP17target_waitstatus10enum_flagsI16target_wait_flagE U _ZN20linux_process_target5asyncEb U _ZN20linux_process_target5mournEP12process_info U _ZN20linux_process_target6attachEm U @@ -191,17 +191,22 @@ _ZN20linux_process_target9pause_allEb U _ZN20linux_process_target9read_auxvEmPhj U _ZN22process_stratum_target11read_btraceEP18btrace_target_infoP6buffer16btrace_read_type U _ZN22process_stratum_target12read_loadmapEPKcmPhj U -_ZN22process_stratum_target13enable_btraceE6ptid_tPK13btrace_config U +_ZN22process_stratum_target13enable_btraceEP11thread_infoPK13btrace_config U +_ZN22process_stratum_target13fetch_memtagsEmmRSt6vectorIhN3gdb22default_init_allocatorIhSaIhEEEEi U +_ZN22process_stratum_target13store_memtagsEmmRKSt6vectorIhN3gdb22default_init_allocatorIhSaIhEEEEi U _ZN22process_stratum_target13thread_handleE6ptid_tPPhPi U _ZN22process_stratum_target14disable_btraceEP18btrace_target_info U _ZN22process_stratum_target15get_tib_addressE6ptid_tPm U +_ZN22process_stratum_target15supports_btraceEv U _ZN22process_stratum_target16read_btrace_confEPK18btrace_target_infoP6buffer U -_ZN22process_stratum_target17hostio_last_errorEPc U _ZN22process_stratum_target21supports_read_loadmapEv U _ZN22process_stratum_target23breakpoint_kind_from_pcEPm U +_ZN22process_stratum_target23supports_memory_taggingEv U _ZN22process_stratum_target24supports_get_tib_addressEv U _ZN22process_stratum_target29supports_software_single_stepEv U _ZN22process_stratum_target34breakpoint_kind_from_current_stateEPm U +_ZN29scoped_restore_current_threadC1Ev U +_ZN29scoped_restore_current_threadD1Ev U _ZN6Genode13Avl_node_baseC2Ev U _ZN6Genode14Rpc_entrypoint7_manageEPNS_15Rpc_object_baseE U _ZN6Genode14Rpc_entrypoint9_dissolveEPNS_15Rpc_object_baseE U diff --git a/repos/ports/ports/gdb.hash b/repos/ports/ports/gdb.hash index 1c9065c1d3..54ceb87e8a 100644 --- a/repos/ports/ports/gdb.hash +++ b/repos/ports/ports/gdb.hash @@ -1 +1 @@ -601cdd5711839f85cd2d151f51d989b678a02efc +59a56418c6720518cfc7e4485557dd2c707b5e03 diff --git a/repos/ports/ports/gdb.port b/repos/ports/ports/gdb.port index cae30f5b52..720ae456a9 100644 --- a/repos/ports/ports/gdb.port +++ b/repos/ports/ports/gdb.port @@ -1,9 +1,9 @@ LICENSE := GPLv3 -VERSION := 10.2 +VERSION := 13.1 DOWNLOADS := gdb.archive URL(gdb) := ftp://ftp.fu-berlin.de/gnu/gdb/gdb-$(VERSION).tar.xz -SHA(gdb) := aaa1223d534c9b700a8bec952d9748ee1977513f178727e1bee520ee000b4f29 +SHA(gdb) := 115ad5c18d69a6be2ab15882d365dda2a2211c14f480b3502c6eba576e2e95a0 SIG(gdb) := ${URL(gdb)}.sig KEY(gdb) := GNU DIR(gdb) := src/noux-pkg/gdb diff --git a/repos/ports/src/app/gdb_monitor/target.mk b/repos/ports/src/app/gdb_monitor/target.mk index cae42e9cc1..ca2f4874e0 100644 --- a/repos/ports/src/app/gdb_monitor/target.mk +++ b/repos/ports/src/app/gdb_monitor/target.mk @@ -32,7 +32,6 @@ SRC_CC += gdbserver/ax.cc \ gdbserver/dll.cc \ gdbserver/fork-child.cc \ gdbserver/hostio.cc \ - gdbserver/hostio-errno.cc \ gdbserver/i387-fp.cc \ gdbserver/inferiors.cc \ gdbserver/linux-low.cc \ @@ -59,6 +58,7 @@ SRC_CC += gdbsupport/agent.cc \ gdbsupport/environ.cc \ gdbsupport/errors.cc \ gdbsupport/event-loop.cc \ + gdbsupport/event-pipe.cc \ gdbsupport/fileio.cc \ gdbsupport/filestuff.cc \ gdbsupport/format.cc \ @@ -71,6 +71,7 @@ SRC_CC += gdbsupport/agent.cc \ gdbsupport/ptid.cc \ gdbsupport/rsp-low.cc \ gdbsupport/safe-strerror.cc \ + gdbsupport/search.cc \ gdbsupport/signals.cc \ gdbsupport/tdesc.cc \ gdbsupport/xml-utils.cc diff --git a/repos/ports/src/noux-pkg/gdb/patches/arm_single_step.patch b/repos/ports/src/noux-pkg/gdb/patches/arm_single_step.patch index cef875f826..e0b650e1ae 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/arm_single_step.patch +++ b/repos/ports/src/noux-pkg/gdb/patches/arm_single_step.patch @@ -8,11 +8,11 @@ Enable software single-stepping on ARM. 1 file changed, 2 insertions(+) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c -index be342117..8c87f098 100644 +index 2fcf104..ddff370 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c -@@ -9339,6 +9339,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - tdep = XCNEW (struct gdbarch_tdep); +@@ -10572,6 +10572,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + arm_gdbarch_tdep *tdep = new arm_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); + set_gdbarch_software_single_step(gdbarch, arm_software_single_step); diff --git a/repos/ports/src/noux-pkg/gdb/patches/call_dummy_location.patch b/repos/ports/src/noux-pkg/gdb/patches/call_dummy_location.patch index c73846abcf..8bd0591686 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/call_dummy_location.patch +++ b/repos/ports/src/noux-pkg/gdb/patches/call_dummy_location.patch @@ -8,10 +8,10 @@ From: Christian Prochaska 1 file changed, 2 insertions(+) diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c -index d97c5629..a6df6fe3 100644 +index 21c1101..81c6d45 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c -@@ -8573,7 +8573,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) +@@ -8567,7 +8567,9 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_get_longjmp_target (gdbarch, i386_get_longjmp_target); /* Call dummy code. */ diff --git a/repos/ports/src/noux-pkg/gdb/patches/gdb_x86_64.patch b/repos/ports/src/noux-pkg/gdb/patches/gdb_x86_64.patch index baa1243583..9849ddb4ed 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/gdb_x86_64.patch +++ b/repos/ports/src/noux-pkg/gdb/patches/gdb_x86_64.patch @@ -6,23 +6,23 @@ From: Christian Prochaska --- gdb/amd64-tdep.c | 14 ++++++++++++++ gdb/i386-tdep.c | 5 +++++ - gdb/osabi.c | 6 ++++++ + gdb/osabi.c | 3 +++ gdb/osabi.h | 1 + - 4 files changed, 26 insertions(+) + 4 files changed, 23 insertions(+) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c -index 1d8cfd0b..55eb6f60 100644 +index 74cb9cf..bf45fd0 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c -@@ -50,6 +50,7 @@ - #include "osabi.h" +@@ -51,6 +51,7 @@ #include "x86-tdep.h" + #include "amd64-ravenscar-thread.h" +#include "osabi.h" #include "solib-svr4.h" /* Note that the AMD64 architecture was previously known as x86-64. -@@ -3359,7 +3360,15 @@ amd64_target_description (uint64_t xcr0, bool segments) +@@ -3356,7 +3357,15 @@ amd64_target_description (uint64_t xcr0, bool segments) return *tdesc; } @@ -38,10 +38,10 @@ index 1d8cfd0b..55eb6f60 100644 void _initialize_amd64_tdep () { -@@ -3367,6 +3376,11 @@ _initialize_amd64_tdep () - amd64_none_init_abi); +@@ -3364,6 +3373,11 @@ _initialize_amd64_tdep () + amd64_none_init_abi); gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x64_32, GDB_OSABI_NONE, - amd64_x32_none_init_abi); + amd64_x32_none_init_abi); + + /* Genode */ + gdbarch_register_osabi(bfd_arch_i386, bfd_mach_x86_64, @@ -51,10 +51,10 @@ index 1d8cfd0b..55eb6f60 100644 diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c -index 057f3e3c..d97c5629 100644 +index 49a7497..21c1101 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c -@@ -9134,6 +9134,11 @@ Show Intel Memory Protection Extensions specific variables."), +@@ -9122,6 +9122,11 @@ is \"default\"."), gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SVR4, i386_svr4_init_abi); @@ -67,7 +67,7 @@ index 057f3e3c..d97c5629 100644 i386_init_reggroups (); diff --git a/gdb/osabi.c b/gdb/osabi.c -index 1a9cdc82..5e7e7731 100644 +index d18802a..3c9a812 100644 --- a/gdb/osabi.c +++ b/gdb/osabi.c @@ -82,6 +82,7 @@ static const struct osabi_names gdb_osabi_names[] = @@ -78,23 +78,20 @@ index 1a9cdc82..5e7e7731 100644 { "", NULL } }; -@@ -564,6 +565,11 @@ generic_elf_osabi_sniffer (bfd *abfd) - bfd_map_over_sections (abfd, - generic_elf_osabi_sniff_abi_tag_sections, - &osabi); -+/* Genode */ -+ if (osabi == GDB_OSABI_UNKNOWN) +@@ -609,6 +610,8 @@ generic_elf_osabi_sniffer (bfd *abfd) + if (memcmp (&elf_elfheader (abfd)->e_ident[8], + "FreeBSD", sizeof ("FreeBSD")) == 0) + osabi = GDB_OSABI_FREEBSD; ++ else + osabi = GDB_OSABI_GENODE; -+/* /Genode */ -+ - break; + } - case ELFOSABI_FREEBSD: + return osabi; diff --git a/gdb/osabi.h b/gdb/osabi.h -index c510f99f..06a4eb99 100644 +index 35f14ec..ae521e1 100644 --- a/gdb/osabi.h +++ b/gdb/osabi.h -@@ -47,6 +47,7 @@ enum gdb_osabi +@@ -46,6 +46,7 @@ enum gdb_osabi GDB_OSABI_NEWLIB, GDB_OSABI_SDE, GDB_OSABI_PIKEOS, diff --git a/repos/ports/src/noux-pkg/gdb/patches/gdbserver_genode.patch b/repos/ports/src/noux-pkg/gdb/patches/gdbserver_genode.patch index 3f33bc5dcd..fdc1e087f3 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/gdbserver_genode.patch +++ b/repos/ports/src/noux-pkg/gdb/patches/gdbserver_genode.patch @@ -4,13 +4,13 @@ From: Christian Prochaska --- - gdb/nat/fork-inferior.c | 4 + + gdb/nat/fork-inferior.c | 3 + gdb/nat/gdb_ptrace.h | 2 + gdb/nat/linux-ptrace.c | 28 +++++++++ gdb/nat/linux-ptrace.h | 4 + gdbserver/linux-aarch32-low.cc | 4 + gdbserver/linux-arm-low.cc | 8 +++ - gdbserver/linux-low.cc | 73 ++++++++++++++++++++++++ + gdbserver/linux-low.cc | 76 +++++++++++++++++++++++++ gdbserver/linux-low.h | 8 ++- gdbserver/linux-x86-low.cc | 120 +++++++++++++++++++++++++++++++++++++++- gdbserver/linux-x86-tdesc.cc | 8 +++ @@ -20,28 +20,28 @@ From: Christian Prochaska gdbsupport/common-inferior.cc | 4 + gdbsupport/common-types.h | 17 ++++++ gdbsupport/gdb-sigmask.h | 4 + - gdbsupport/gdb_tilde_expand.cc | 10 +++ + gdbsupport/gdb_tilde_expand.cc | 5 ++ gdbsupport/pathstuff.cc | 2 + - 18 files changed, 333 insertions(+), 14 deletions(-) + gnulib/import/rawmemchr.c | 3 + + 19 files changed, 333 insertions(+), 14 deletions(-) diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c -index 559773f7..bab829fb 100644 +index 968983b..0d531e0 100644 --- a/gdb/nat/fork-inferior.c +++ b/gdb/nat/fork-inferior.c -@@ -402,9 +402,9 @@ fork_inferior (const char *exec_file_arg, const std::string &allargs, - undebuggable. Indeed, you probably got an error message - saying "not parent". Sorry; you'll have to use print - statements! */ -- +@@ -400,8 +400,9 @@ fork_inferior (const char *exec_file_arg, const std::string &allargs, + saying "not parent". Sorry; you'll have to use print + statements! */ + +#ifndef __GENODE__ restore_original_signals_state (); - +#endif /* __GENODE__ */ /* There is no execlpe call, so we have to set the environment - for our child in the global variable. If we've vforked, this - clobbers the parent, but environ is restored a few lines down + for our child in the global variable. If we've vforked, this + clobbers the parent, but environ is restored a few lines down diff --git a/gdb/nat/gdb_ptrace.h b/gdb/nat/gdb_ptrace.h -index f7bdd113..8f148d10 100644 +index a5e3725..a338819 100644 --- a/gdb/nat/gdb_ptrace.h +++ b/gdb/nat/gdb_ptrace.h @@ -121,6 +121,7 @@ @@ -54,13 +54,13 @@ index f7bdd113..8f148d10 100644 macro that calls the real ptrace with the last argument set to @@ -141,5 +142,6 @@ # define ptrace(request, pid, addr, data) \ - ptrace ((PTRACE_TYPE_ARG1) request, pid, addr, data) + ptrace ((PTRACE_TYPE_ARG1) request, pid, addr, data) #endif +#endif /* __GENODE__ */ #endif /* NAT_GDB_PTRACE_H */ diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c -index 17f43154..842b8077 100644 +index f312779..7006c8e 100644 --- a/gdb/nat/linux-ptrace.c +++ b/gdb/nat/linux-ptrace.c @@ -36,6 +36,7 @@ static int supported_ptrace_options = -1; @@ -110,15 +110,15 @@ index 17f43154..842b8077 100644 /* Helper function to fork a process and make the child process call the function FUNCTION, passing CHILD_STACK as parameter. -@@ -341,6 +348,7 @@ static void linux_test_for_exitkill (int child_pid); +@@ -322,6 +329,7 @@ static void linux_test_for_exitkill (int child_pid); void linux_check_ptrace_features (void) { +#ifndef __GENODE__ int child_pid, ret, status; - /* Initialize the options. */ -@@ -370,6 +378,18 @@ linux_check_ptrace_features (void) + /* Initialize the options. We consider that these options are always +@@ -354,6 +362,18 @@ linux_check_ptrace_features (void) /* Kill child_pid. */ kill_child (child_pid, "linux_check_ptrace_features"); @@ -136,8 +136,8 @@ index 17f43154..842b8077 100644 +#endif } - /* Determine if PTRACE_O_TRACESYSGOOD can be used to catch -@@ -482,6 +502,7 @@ linux_test_for_exitkill (int child_pid) + /* Determine if PTRACE_O_EXITKILL can be used. */ +@@ -378,6 +398,7 @@ linux_test_for_exitkill (int child_pid) void linux_enable_event_reporting (pid_t pid, int options) { @@ -145,7 +145,7 @@ index 17f43154..842b8077 100644 /* Check if we have initialized the ptrace features for this target. If not, do it now. */ if (supported_ptrace_options == -1) -@@ -496,6 +517,7 @@ linux_enable_event_reporting (pid_t pid, int options) +@@ -392,6 +413,7 @@ linux_enable_event_reporting (pid_t pid, int options) /* Set the options. */ ptrace (PTRACE_SETOPTIONS, pid, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) (uintptr_t) options); @@ -153,7 +153,7 @@ index 17f43154..842b8077 100644 } /* Disable reporting of all currently supported ptrace events. */ -@@ -503,8 +525,10 @@ linux_enable_event_reporting (pid_t pid, int options) +@@ -399,8 +421,10 @@ linux_enable_event_reporting (pid_t pid, int options) void linux_disable_event_reporting (pid_t pid) { @@ -163,8 +163,8 @@ index 17f43154..842b8077 100644 +#endif /* __GENODE__ */ } - /* Returns non-zero if PTRACE_OPTIONS is contained within -@@ -583,7 +607,9 @@ linux_ptrace_init_warnings (void) + /* Display possible problems on this system. Display them only once per GDB +@@ -415,7 +439,9 @@ linux_ptrace_init_warnings (void) return; warned = 1; @@ -175,7 +175,7 @@ index 17f43154..842b8077 100644 /* Extract extended ptrace event from wait status. */ diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h -index 6e973dc5..16ba731f 100644 +index 19f4736..8e18cd4 100644 --- a/gdb/nat/linux-ptrace.h +++ b/gdb/nat/linux-ptrace.h @@ -115,7 +115,11 @@ struct buffer; @@ -191,7 +191,7 @@ index 6e973dc5..16ba731f 100644 /* The x86 kernel gets some of the si_code values backwards, like this: diff --git a/gdbserver/linux-aarch32-low.cc b/gdbserver/linux-aarch32-low.cc -index 8f733e7d..c621ec30 100644 +index 990a352..960cc1f 100644 --- a/gdbserver/linux-aarch32-low.cc +++ b/gdbserver/linux-aarch32-low.cc @@ -35,7 +35,11 @@ @@ -207,7 +207,7 @@ index 8f733e7d..c621ec30 100644 #if (defined __ARM_EABI__ || defined __aarch64__) static const unsigned long arm_breakpoint = arm_eabi_breakpoint; diff --git a/gdbserver/linux-arm-low.cc b/gdbserver/linux-arm-low.cc -index cba0f078..521e07c0 100644 +index 98ba0e0..85b6ae3 100644 --- a/gdbserver/linux-arm-low.cc +++ b/gdbserver/linux-arm-low.cc @@ -32,6 +32,9 @@ @@ -240,10 +240,10 @@ index cba0f078..521e07c0 100644 /* The default configuration uses legacy FPA registers, probably simulated. */ diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc -index b1f997ae..823c5e56 100644 +index 7e1de39..26cea36 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc -@@ -27,6 +27,11 @@ +@@ -29,6 +29,11 @@ #include "nat/linux-waitpid.h" #include "gdbsupport/gdb_wait.h" #include "nat/gdb_ptrace.h" @@ -255,19 +255,21 @@ index b1f997ae..823c5e56 100644 #include "nat/linux-ptrace.h" #include "nat/linux-procfs.h" #include "nat/linux-personality.h" -@@ -694,7 +699,11 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp, +@@ -718,8 +723,13 @@ linux_process_target::handle_extended_wait (lwp_info **orig_event_lwp, + /* Set the event status. */ - event_lwp->waitstatus.kind = TARGET_WAITKIND_EXECD; - event_lwp->waitstatus.value.execd_pathname + event_lwp->waitstatus.set_execd +#ifdef __GENODE__ -+ = xstrdup ("target"); + (make_unique_xstrdup + (linux_proc_pid_to_exec_file (lwpid_of (event_thr)))); +#else - = xstrdup (linux_proc_pid_to_exec_file (lwpid_of (event_thr))); ++ (make_unique_xstrdup ++ ("target")); +#endif /* Mark the exec status as pending. */ event_lwp->stopped = 1; -@@ -970,8 +979,10 @@ linux_process_target::create_inferior (const char *program, +@@ -968,8 +978,10 @@ linux_process_target::create_inferior (const char *program, ptid_t ptid; { @@ -278,7 +280,7 @@ index b1f997ae..823c5e56 100644 std::string str_program_args = construct_inferior_arguments (program_args); pid = fork_inferior (program, -@@ -1016,12 +1027,17 @@ linux_process_target::attach_lwp (ptid_t ptid) +@@ -1022,12 +1034,17 @@ linux_process_target::attach_lwp (ptid_t ptid) struct lwp_info *new_lwp; int lwpid = ptid.lwp (); @@ -296,7 +298,7 @@ index b1f997ae..823c5e56 100644 /* We need to wait for SIGSTOP before being able to make the next ptrace call on this LWP. */ new_lwp->must_set_ptrace_flags = 1; -@@ -1088,6 +1104,7 @@ linux_process_target::attach_lwp (ptid_t ptid) +@@ -1093,6 +1110,7 @@ linux_process_target::attach_lwp (ptid_t ptid) end of the list, and so the new thread has not yet reached wait_for_sigstop (but will). */ new_lwp->stop_expected = 1; @@ -304,15 +306,15 @@ index b1f997ae..823c5e56 100644 return 0; } -@@ -1163,6 +1180,7 @@ linux_process_target::attach (unsigned long pid) - error ("Cannot attach to process %ld: %s", pid, reason.c_str ()); - } +@@ -1166,6 +1184,7 @@ linux_process_target::attach (unsigned long pid) + + open_proc_mem_file (proc); +#ifndef __GENODE__ /* Don't ignore the initial SIGSTOP if we just attached to this process. It will be collected by wait shortly. */ - initial_thread = find_thread_ptid (ptid_t (pid, pid, 0)); -@@ -1209,6 +1227,7 @@ linux_process_target::attach (unsigned long pid) + initial_thread = find_thread_ptid (ptid_t (pid, pid)); +@@ -1212,6 +1231,7 @@ linux_process_target::attach (unsigned long pid) gdb_assert (proc->tdesc != NULL); } @@ -320,7 +322,7 @@ index b1f997ae..823c5e56 100644 return 0; } -@@ -1346,6 +1365,7 @@ kill_one_lwp_callback (thread_info *thread, int pid) +@@ -1347,6 +1367,7 @@ kill_one_lwp_callback (thread_info *thread, int pid) kill_wait_lwp (lwp); } @@ -328,7 +330,7 @@ index b1f997ae..823c5e56 100644 int linux_process_target::kill (process_info *process) { -@@ -1380,6 +1400,7 @@ linux_process_target::kill (process_info *process) +@@ -1377,6 +1398,7 @@ linux_process_target::kill (process_info *process) unstop_all_lwps (0, NULL); return 0; } @@ -336,7 +338,7 @@ index b1f997ae..823c5e56 100644 /* Get pending signal of THREAD, for detaching purposes. This is the signal the thread last stopped for, which we need to deliver to the -@@ -1466,10 +1487,13 @@ void +@@ -1458,10 +1480,13 @@ void linux_process_target::detach_one_lwp (lwp_info *lwp) { struct thread_info *thread = get_lwp_thread (lwp); @@ -349,8 +351,8 @@ index b1f997ae..823c5e56 100644 +#ifndef __GENODE__ if (lwp->stop_expected) { - if (debug_threads) -@@ -1479,7 +1503,9 @@ linux_process_target::detach_one_lwp (lwp_info *lwp) + threads_debug_printf ("Sending SIGCONT to %s", +@@ -1470,7 +1495,9 @@ linux_process_target::detach_one_lwp (lwp_info *lwp) kill_lwp (lwpid_of (thread), SIGCONT); lwp->stop_expected = 0; } @@ -360,10 +362,10 @@ index b1f997ae..823c5e56 100644 /* Pass on any pending signal for this thread. */ sig = get_detach_signal (thread); -@@ -1540,10 +1566,12 @@ linux_process_target::detach_one_lwp (lwp_info *lwp) - target_pid_to_str (ptid_of (thread)), - strsignal (sig)); - } +@@ -1529,10 +1556,12 @@ linux_process_target::detach_one_lwp (lwp_info *lwp) + threads_debug_printf ("PTRACE_DETACH (%s, %s, 0) (OK)", + target_pid_to_str (ptid_of (thread)).c_str (), + strsignal (sig)); +#endif delete_lwp (lwp); @@ -373,7 +375,7 @@ index b1f997ae..823c5e56 100644 int linux_process_target::detach (process_info *process) { -@@ -1592,6 +1620,7 @@ linux_process_target::detach (process_info *process) +@@ -1581,6 +1610,7 @@ linux_process_target::detach (process_info *process) unstop_all_lwps (0, NULL); return 0; } @@ -381,37 +383,46 @@ index b1f997ae..823c5e56 100644 /* Remove all LWPs that belong to process PROC from the lwp list. */ -@@ -1806,6 +1835,7 @@ iterate_over_lwps (ptid_t filter, +@@ -1780,6 +1810,7 @@ iterate_over_lwps (ptid_t filter, void linux_process_target::check_zombie_leaders () { +#ifndef __GENODE__ - for_each_process ([this] (process_info *proc) { - pid_t leader_pid = pid_of (proc); - struct lwp_info *leader_lp; -@@ -1860,6 +1890,7 @@ linux_process_target::check_zombie_leaders () - delete_lwp (leader_lp); - } + for_each_process ([this] (process_info *proc) + { + pid_t leader_pid = pid_of (proc); +@@ -1852,6 +1883,7 @@ linux_process_target::check_zombie_leaders () + delete_lwp (leader_lp); + } }); +#endif /* __GENODE__ */ } /* Callback for `find_thread'. Returns the first LWP that is not -@@ -2606,11 +2637,13 @@ linux_process_target::wait_for_event_filtered (ptid_t wait_ptid, +@@ -2253,9 +2285,11 @@ linux_process_target::filter_event (int lwpid, int wstat) + its PID and go back to waiting for the fork event to + be reported - the stopped process might be returned + from waitpid before or after the fork event is. */ ++#ifndef __GENODE__ + threads_debug_printf + ("Saving LWP %d status %s in stopped_pids list", + lwpid, status_to_str (wstat).c_str ()); ++#endif /* __GENODE__ */ + add_to_pid_list (&stopped_pids, lwpid, wstat); + } + } +@@ -2586,8 +2620,10 @@ linux_process_target::wait_for_event_filtered (ptid_t wait_ptid, if (ret > 0) { +#ifndef __GENODE__ - if (debug_threads) - { - debug_printf ("LLW: waitpid %ld received %s\n", - (long) ret, status_to_str (*wstatp)); - } + threads_debug_printf ("waitpid %ld received %s", + (long) ret, status_to_str (*wstatp).c_str ()); +#endif /* __GENODE__ */ /* Filter all events. IOW, leave all events pending. We'll randomly select an event LWP out of all that have events -@@ -2884,11 +2917,12 @@ linux_process_target::stabilize_threads () +@@ -2855,11 +2891,12 @@ linux_process_target::stabilize_threads () static ptid_t ignore_event (struct target_waitstatus *ourstatus) { @@ -422,10 +433,10 @@ index b1f997ae..823c5e56 100644 async_file_mark (); - +#endif /* __GENODE__ */ - ourstatus->kind = TARGET_WAITKIND_IGNORE; + ourstatus->set_ignore (); return null_ptid; } -@@ -3714,9 +3748,11 @@ linux_process_target::wait (ptid_t ptid, +@@ -3615,9 +3652,11 @@ linux_process_target::wait (ptid_t ptid, { ptid_t event_ptid; @@ -437,9 +448,9 @@ index b1f997ae..823c5e56 100644 do { -@@ -3726,12 +3762,14 @@ linux_process_target::wait (ptid_t ptid, +@@ -3627,12 +3666,14 @@ linux_process_target::wait (ptid_t ptid, && event_ptid == null_ptid - && ourstatus->kind == TARGET_WAITKIND_IGNORE); + && ourstatus->kind () == TARGET_WAITKIND_IGNORE); +#ifndef __GENODE__ /* If at least one stop was reported, there may be more. A single @@ -452,7 +463,7 @@ index b1f997ae..823c5e56 100644 return event_ptid; } -@@ -3741,6 +3779,9 @@ linux_process_target::wait (ptid_t ptid, +@@ -3642,6 +3683,9 @@ linux_process_target::wait (ptid_t ptid, static int kill_lwp (unsigned long lwpid, int signo) { @@ -462,7 +473,7 @@ index b1f997ae..823c5e56 100644 int ret; errno = 0; -@@ -3752,6 +3793,7 @@ kill_lwp (unsigned long lwpid, int signo) +@@ -3653,6 +3697,7 @@ kill_lwp (unsigned long lwpid, int signo) perror_with_name (("tkill")); } return ret; @@ -470,7 +481,7 @@ index b1f997ae..823c5e56 100644 } void -@@ -4253,6 +4295,21 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step, +@@ -4118,6 +4163,21 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step, regcache_invalidate_thread (thread); errno = 0; lwp->stepping = step; @@ -492,15 +503,15 @@ index b1f997ae..823c5e56 100644 if (step) ptrace_request = PTRACE_SINGLESTEP; else if (gdb_catching_syscalls_p (lwp)) -@@ -4265,6 +4322,7 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step, +@@ -4130,6 +4190,7 @@ linux_process_target::resume_one_lwp_throw (lwp_info *lwp, int step, /* Coerce to a uintptr_t first to avoid potential gcc warning of coercing an 8 byte integer to a 4 byte pointer. */ (PTRACE_TYPE_ARG4) (uintptr_t) signal); +#endif - current_thread = saved_thread; if (errno) -@@ -4308,7 +4366,7 @@ check_ptrace_stopped_lwp_gone (struct lwp_info *lp) + { +@@ -4180,7 +4241,7 @@ check_ptrace_stopped_lwp_gone (struct lwp_info *lp) (observed in Linux 3.18). See also the note on ESRCH in the ptrace(2) man page. Instead, check whether the LWP has any state other than ptrace-stopped. */ @@ -509,7 +520,7 @@ index b1f997ae..823c5e56 100644 /* Don't assume anything if /proc/PID/status can't be read. */ if (linux_proc_pid_is_trace_stopped_nowarn (lwpid_of (thread)) == 0) { -@@ -4316,6 +4374,7 @@ check_ptrace_stopped_lwp_gone (struct lwp_info *lp) +@@ -4188,6 +4249,7 @@ check_ptrace_stopped_lwp_gone (struct lwp_info *lp) lp->status_pending_p = 0; return 1; } @@ -517,7 +528,7 @@ index b1f997ae..823c5e56 100644 return 0; } -@@ -5135,6 +5194,7 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, +@@ -4973,6 +5035,7 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, optional, do not try it again for this process mode. */ disable_regset (regsets_info, regset); } @@ -525,7 +536,7 @@ index b1f997ae..823c5e56 100644 else if (errno == ENODATA) { /* ENODATA may be returned if the regset is currently -@@ -5147,6 +5207,7 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, +@@ -4985,6 +5048,7 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, already gone, in which case we simply ignore attempts to read its registers. */ } @@ -533,7 +544,7 @@ index b1f997ae..823c5e56 100644 else { char s[256]; -@@ -5445,6 +5506,7 @@ linux_process_target::usr_store_inferior_registers (const regs_info *regs_info, +@@ -5283,6 +5347,7 @@ linux_process_target::usr_store_inferior_registers (const regs_info *regs_info, #endif } @@ -541,7 +552,7 @@ index b1f997ae..823c5e56 100644 void linux_process_target::fetch_registers (regcache *regcache, int regno) { -@@ -5500,6 +5562,7 @@ linux_process_target::store_registers (regcache *regcache, int regno) +@@ -5338,6 +5403,7 @@ linux_process_target::store_registers (regcache *regcache, int regno) usr_store_inferior_registers (regs_info, regcache, regno, 1); } } @@ -549,31 +560,31 @@ index b1f997ae..823c5e56 100644 bool linux_process_target::low_fetch_register (regcache *regcache, int regno) -@@ -5515,6 +5578,7 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) +@@ -5353,6 +5419,7 @@ linux_read_memory (CORE_ADDR memaddr, unsigned char *myaddr, int len) return the_target->read_memory (memaddr, myaddr, len); } +#ifndef __GENODE__ - /* Copy LEN bytes from inferior's memory starting at MEMADDR - to debugger memory starting at MYADDR. */ -@@ -5695,6 +5759,7 @@ linux_process_target::write_memory (CORE_ADDR memaddr, + /* Helper for read_memory/write_memory using /proc/PID/mem. Because + we can use a single read/write call, this can be much more +@@ -5448,6 +5515,7 @@ linux_process_target::write_memory (CORE_ADDR memaddr, - return 0; + return proc_xfer_memory (memaddr, nullptr, myaddr, len); } +#endif /* __GENODE__ */ void linux_process_target::look_up_symbols () -@@ -6430,6 +6495,7 @@ linux_process_target::done_accessing_memory () - target_unpause_all (true); +@@ -6153,6 +6221,7 @@ linux_process_target::unpause_all (bool unfreeze) + unstop_all_lwps (unfreeze, NULL); } +#ifndef __GENODE__ /* Extract &phdr and num_phdr in the inferior. Return 0 on success. */ static int -@@ -6922,6 +6988,7 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex, +@@ -6712,6 +6781,7 @@ linux_process_target::qxfer_libraries_svr4 (const char *annex, return len; } @@ -581,7 +592,7 @@ index b1f997ae..823c5e56 100644 #ifdef HAVE_LINUX_BTRACE -@@ -7239,8 +7306,10 @@ initialize_low (void) +@@ -7055,8 +7125,10 @@ initialize_low (void) memset (&sigchld_action, 0, sizeof (sigchld_action)); set_target_ops (the_linux_target); @@ -593,7 +604,7 @@ index b1f997ae..823c5e56 100644 sigchld_action.sa_handler = sigchld_handler; sigemptyset (&sigchld_action.sa_mask); diff --git a/gdbserver/linux-low.h b/gdbserver/linux-low.h -index 0200e9e5..0e738698 100644 +index aebfe05..e2115f7 100644 --- a/gdbserver/linux-low.h +++ b/gdbserver/linux-low.h @@ -20,11 +20,16 @@ @@ -613,7 +624,7 @@ index 0200e9e5..0e738698 100644 /* Included for ptrace type definitions. */ #include "nat/linux-ptrace.h" -@@ -552,10 +557,11 @@ class linux_process_target : public process_stratum_target +@@ -563,10 +568,11 @@ class linux_process_target : public process_stratum_target error. */ int attach_lwp (ptid_t ptid); @@ -627,7 +638,7 @@ index 0200e9e5..0e738698 100644 reap their exits until all other threads in the group have exited. */ diff --git a/gdbserver/linux-x86-low.cc b/gdbserver/linux-x86-low.cc -index 79284473..56555d30 100644 +index 4a538b1..a0ea200 100644 --- a/gdbserver/linux-x86-low.cc +++ b/gdbserver/linux-x86-low.cc @@ -31,13 +31,19 @@ @@ -650,9 +661,9 @@ index 79284473..56555d30 100644 #include "gdbsupport/agent.h" #include "tdesc.h" #include "tracepoint.h" -@@ -52,11 +58,23 @@ static struct target_desc *tdesc_amd64_linux_no_xml; +@@ -52,11 +58,23 @@ static target_desc_up tdesc_amd64_linux_no_xml; #endif - static struct target_desc *tdesc_i386_linux_no_xml; + static target_desc_up tdesc_i386_linux_no_xml; - static unsigned char jump_insn[] = { 0xe9, 0, 0, 0, 0 }; @@ -673,9 +684,9 @@ index 79284473..56555d30 100644 + +#else - static const char *xmltarget_i386_linux_no_xml = "@\ + static const char xmltarget_i386_linux_no_xml[] = "@\ i386\ -@@ -70,7 +88,17 @@ static const char *xmltarget_amd64_linux_no_xml = "@\ +@@ -70,7 +88,17 @@ static const char xmltarget_amd64_linux_no_xml[] = "@\ "; #endif @@ -722,7 +733,7 @@ index 79284473..56555d30 100644 }; #define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof (x86_64_regmap[0])) -@@ -287,6 +321,7 @@ is_64bit_tdesc (void) +@@ -286,6 +320,7 @@ is_64bit_tdesc (thread_info *thread) /* Called by libthread_db. */ @@ -730,7 +741,7 @@ index 79284473..56555d30 100644 ps_err_e ps_get_thread_area (struct ps_prochandle *ph, lwpid_t lwpid, int idx, void **base) -@@ -325,6 +360,7 @@ ps_get_thread_area (struct ps_prochandle *ph, +@@ -326,6 +361,7 @@ ps_get_thread_area (struct ps_prochandle *ph, return PS_OK; } } @@ -738,10 +749,10 @@ index 79284473..56555d30 100644 /* Get the thread area address. This is used to recognize which thread is which when tracing with the in-process agent library. We -@@ -380,7 +416,11 @@ x86_target::low_cannot_store_register (int regno) +@@ -382,7 +418,11 @@ x86_target::low_cannot_store_register (int regno) { #ifdef __x86_64__ - if (is_64bit_tdesc ()) + if (is_64bit_tdesc (current_thread)) +#ifdef __GENODE__ + return regno >= X86_64_NUM_REGS; +#else @@ -750,10 +761,10 @@ index 79284473..56555d30 100644 #endif return regno >= I386_NUM_REGS; -@@ -391,12 +431,30 @@ x86_target::low_cannot_fetch_register (int regno) +@@ -393,12 +433,30 @@ x86_target::low_cannot_fetch_register (int regno) { #ifdef __x86_64__ - if (is_64bit_tdesc ()) + if (is_64bit_tdesc (current_thread)) +#ifdef __GENODE__ + return regno >= X86_64_NUM_REGS; +#else @@ -779,20 +790,21 @@ index 79284473..56555d30 100644 +#endif /* __x86_64__ */ + static void - x86_fill_gregset (struct regcache *regcache, void *buf) + collect_register_i386 (struct regcache *regcache, int regno, void *buf) { -@@ -420,8 +478,10 @@ x86_fill_gregset (struct regcache *regcache, void *buf) +@@ -447,9 +505,11 @@ x86_fill_gregset (struct regcache *regcache, void *buf) for (i = 0; i < I386_NUM_REGS; i++) - collect_register (regcache, i, ((char *) buf) + i386_regmap[i]); + collect_register_i386 (regcache, i, ((char *) buf) + i386_regmap[i]); +#ifndef __GENODE__ - collect_register_by_name (regcache, "orig_eax", - ((char *) buf) + ORIG_EAX * REGSIZE); + /* Handle ORIG_EAX, which is not in i386_regmap. */ + collect_register_i386 (regcache, find_regno (regcache->tdesc, "orig_eax"), + ((char *) buf) + ORIG_EAX * REGSIZE); +#endif /* __GENODE__ */ + } - #ifdef __x86_64__ - /* Sign extend EAX value to avoid potential syscall restart -@@ -458,8 +518,10 @@ x86_store_gregset (struct regcache *regcache, const void *buf) + static void +@@ -471,8 +531,10 @@ x86_store_gregset (struct regcache *regcache, const void *buf) for (i = 0; i < I386_NUM_REGS; i++) supply_register (regcache, i, ((char *) buf) + i386_regmap[i]); @@ -803,7 +815,7 @@ index 79284473..56555d30 100644 } static void -@@ -588,11 +650,23 @@ x86_target::low_set_pc (regcache *regcache, CORE_ADDR pc) +@@ -601,11 +663,23 @@ x86_target::low_set_pc (regcache *regcache, CORE_ADDR pc) int x86_target::low_decr_pc_after_break () { @@ -827,7 +839,7 @@ index 79284473..56555d30 100644 #define x86_breakpoint_len 1 bool -@@ -601,7 +675,7 @@ x86_target::low_breakpoint_at (CORE_ADDR pc) +@@ -614,7 +688,7 @@ x86_target::low_breakpoint_at (CORE_ADDR pc) unsigned char c; read_memory (pc, &c, 1); @@ -836,7 +848,7 @@ index 79284473..56555d30 100644 return true; return false; -@@ -689,8 +763,12 @@ x86_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr, +@@ -702,8 +776,12 @@ x86_target::low_remove_point (raw_bkpt_type type, CORE_ADDR addr, bool x86_target::low_stopped_by_watchpoint () { @@ -849,7 +861,7 @@ index 79284473..56555d30 100644 } CORE_ADDR -@@ -769,8 +847,10 @@ x86_target::low_new_fork (process_info *parent, process_info *child) +@@ -782,8 +860,10 @@ x86_target::low_new_fork (process_info *parent, process_info *child) void x86_target::low_prepare_to_resume (lwp_info *lwp) { @@ -860,7 +872,7 @@ index 79284473..56555d30 100644 } /* See nat/x86-dregs.h. */ -@@ -798,6 +878,7 @@ x86_debug_reg_state (pid_t pid) +@@ -811,6 +891,7 @@ x86_debug_reg_state (pid_t pid) bool x86_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction) { @@ -868,7 +880,7 @@ index 79284473..56555d30 100644 #ifdef __x86_64__ unsigned int machine; int tid = lwpid_of (current_thread); -@@ -812,9 +893,11 @@ x86_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction) +@@ -825,9 +906,11 @@ x86_target::low_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction) return amd64_linux_siginfo_fixup_common (ptrace, inf, direction, FIXUP_X32); #endif @@ -880,7 +892,7 @@ index 79284473..56555d30 100644 static int use_xml; -@@ -855,6 +938,13 @@ int have_ptrace_getfpxregs = +@@ -868,6 +951,13 @@ int have_ptrace_getfpxregs = static const struct target_desc * x86_linux_read_description (void) { @@ -894,7 +906,7 @@ index 79284473..56555d30 100644 unsigned int machine; int is_elf64; int xcr0_features; -@@ -970,7 +1060,7 @@ x86_linux_read_description (void) +@@ -983,7 +1073,7 @@ x86_linux_read_description (void) return tdesc; } @@ -903,7 +915,7 @@ index 79284473..56555d30 100644 gdb_assert_not_reached ("failed to return tdesc"); } -@@ -1005,6 +1095,14 @@ x86_target::update_xmltarget () +@@ -1016,6 +1106,14 @@ x86_target::update_xmltarget () void x86_target::process_qsupported (gdb::array_view features) { @@ -918,7 +930,7 @@ index 79284473..56555d30 100644 /* Return if gdb doesn't support XML. If gdb sends "xmlRegisters=" with "i386" in qSupported query, it supports x86 XML target descriptions. */ -@@ -1045,13 +1143,24 @@ static struct regsets_info x86_regsets_info = +@@ -1056,13 +1154,24 @@ static struct regsets_info x86_regsets_info = }; #ifdef __x86_64__ @@ -943,7 +955,7 @@ index 79284473..56555d30 100644 static struct usrregs_info i386_linux_usrregs_info = { I386_NUM_REGS, -@@ -1113,6 +1222,9 @@ x86_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno) +@@ -1124,6 +1233,9 @@ x86_target::low_get_syscall_trapinfo (regcache *regcache, int *sysno) bool x86_target::supports_tracepoints () { @@ -954,7 +966,7 @@ index 79284473..56555d30 100644 } diff --git a/gdbserver/linux-x86-tdesc.cc b/gdbserver/linux-x86-tdesc.cc -index 4682eb4c..f0861968 100644 +index ba81daa..5eac8a2 100644 --- a/gdbserver/linux-x86-tdesc.cc +++ b/gdbserver/linux-x86-tdesc.cc @@ -87,7 +87,11 @@ i386_linux_read_description (uint64_t xcr0) @@ -982,7 +994,7 @@ index 4682eb4c..f0861968 100644 init_target_desc (*tdesc, amd64_expedite_regs); } diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc -index 1195ce87..6e913ea2 100644 +index 80310bc..a039f0d 100644 --- a/gdbserver/remote-utils.cc +++ b/gdbserver/remote-utils.cc @@ -30,6 +30,12 @@ @@ -1010,7 +1022,7 @@ index 1195ce87..6e913ea2 100644 static int listen_desc = -1; #ifdef USE_WIN32API -@@ -339,7 +348,11 @@ remote_open (const char *name) +@@ -341,7 +350,11 @@ remote_open (const char *name) struct stat statbuf; if (stat (name, &statbuf) == 0 @@ -1023,7 +1035,7 @@ index 1195ce87..6e913ea2 100644 else { diff --git a/gdbserver/server.cc b/gdbserver/server.cc -index 9c403a64..e0d1dfc1 100644 +index d802e8b..41a2305 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -32,6 +32,14 @@ @@ -1041,7 +1053,7 @@ index 9c403a64..e0d1dfc1 100644 #include "tracepoint.h" #include "dll.h" #include "hostio.h" -@@ -1286,7 +1294,9 @@ handle_detach (char *own_buf) +@@ -1264,7 +1272,9 @@ handle_detach (char *own_buf) need to hang around doing nothing, until the child is gone. */ join_inferior (pid); @@ -1051,7 +1063,7 @@ index 9c403a64..e0d1dfc1 100644 } } } -@@ -3156,11 +3166,11 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len) +@@ -3162,11 +3172,11 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len) return; } } @@ -1065,7 +1077,7 @@ index 9c403a64..e0d1dfc1 100644 if (startswith (own_buf, "vAttach;")) { if ((!extended_protocol || !cs.multi_process) && target_running ()) -@@ -3785,7 +3795,9 @@ captured_main (int argc, char *argv[]) +@@ -3867,7 +3877,9 @@ captured_main (int argc, char *argv[]) opened by remote_prepare. */ notice_open_fds (); @@ -1075,7 +1087,7 @@ index 9c403a64..e0d1dfc1 100644 /* We need to know whether the remote connection is stdio before starting the inferior. Inferiors created in this scenario have -@@ -3987,7 +3999,11 @@ captured_main (int argc, char *argv[]) +@@ -4070,7 +4082,11 @@ captured_main (int argc, char *argv[]) /* Main function. */ int @@ -1087,7 +1099,7 @@ index 9c403a64..e0d1dfc1 100644 { try -@@ -4088,6 +4104,10 @@ process_serial_event (void) +@@ -4169,6 +4185,10 @@ process_serial_event (void) } response_needed = true; @@ -1098,7 +1110,7 @@ index 9c403a64..e0d1dfc1 100644 char ch = cs.own_buf[0]; switch (ch) { -@@ -4335,7 +4355,11 @@ process_serial_event (void) +@@ -4415,7 +4435,11 @@ process_serial_event (void) return 0; } else @@ -1110,7 +1122,7 @@ index 9c403a64..e0d1dfc1 100644 case 'T': { -@@ -4410,7 +4434,9 @@ process_serial_event (void) +@@ -4489,7 +4513,9 @@ process_serial_event (void) cs.own_buf[0] = '\0'; break; } @@ -1122,7 +1134,7 @@ index 9c403a64..e0d1dfc1 100644 putpkt_binary (cs.own_buf, new_packet_len); else diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h -index e5ece3ba..8fc25878 100644 +index 5e529f6..19521c7 100644 --- a/gdbsupport/common-defs.h +++ b/gdbsupport/common-defs.h @@ -28,7 +28,9 @@ @@ -1135,7 +1147,7 @@ index e5ece3ba..8fc25878 100644 /* From: https://www.gnu.org/software/gnulib/manual/html_node/stdint_002eh.html -@@ -102,6 +104,7 @@ +@@ -104,6 +106,7 @@ #endif #include "ansidecl.h" @@ -1143,16 +1155,16 @@ index e5ece3ba..8fc25878 100644 /* This is defined by ansidecl.h, but we prefer gnulib's version. On MinGW, gnulib might enable __USE_MINGW_ANSI_STDIO, which may or not require use of attribute gnu_printf instead of printf. gnulib -@@ -109,6 +112,7 @@ - is compatible with ATTRIBUTE_PRINTF, simply use it. */ - #undef ATTRIBUTE_PRINTF - #define ATTRIBUTE_PRINTF _GL_ATTRIBUTE_FORMAT_PRINTF +@@ -186,6 +189,7 @@ + with it everywhere. */ + #undef ATTRIBUTE_NONNULL + #define ATTRIBUTE_NONNULL(m) +#endif /* __GENODE__ */ #if GCC_VERSION >= 3004 #define ATTRIBUTE_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) diff --git a/gdbsupport/common-inferior.cc b/gdbsupport/common-inferior.cc -index aed88409..2f03118d 100644 +index 55149ec..53fa051 100644 --- a/gdbsupport/common-inferior.cc +++ b/gdbsupport/common-inferior.cc @@ -23,7 +23,11 @@ @@ -1168,7 +1180,7 @@ index aed88409..2f03118d 100644 /* See common-inferior.h. */ diff --git a/gdbsupport/common-types.h b/gdbsupport/common-types.h -index 23f983d8..6c67d21d 100644 +index e863d65..da0f8e8 100644 --- a/gdbsupport/common-types.h +++ b/gdbsupport/common-types.h @@ -26,12 +26,29 @@ @@ -1202,7 +1214,7 @@ index 23f983d8..6c67d21d 100644 /* * The largest CORE_ADDR value. */ #define CORE_ADDR_MAX (~(CORE_ADDR) 0) diff --git a/gdbsupport/gdb-sigmask.h b/gdbsupport/gdb-sigmask.h -index b4988cb4..a15601eb 100644 +index 492b10e..26c3ebd 100644 --- a/gdbsupport/gdb-sigmask.h +++ b/gdbsupport/gdb-sigmask.h @@ -39,6 +39,10 @@ @@ -1217,40 +1229,27 @@ index b4988cb4..a15601eb 100644 diff --git a/gdbsupport/gdb_tilde_expand.cc b/gdbsupport/gdb_tilde_expand.cc -index b31fc484..dcb32777 100644 +index d6bdb87..246625c 100644 --- a/gdbsupport/gdb_tilde_expand.cc +++ b/gdbsupport/gdb_tilde_expand.cc -@@ -71,7 +71,12 @@ private: - std::string - gdb_tilde_expand (const char *dir) - { +@@ -97,7 +97,12 @@ gdb_tilde_expand (const char *dir) + const std::string to_expand (d.cbegin (), first_sep); + const std::string remainder (first_sep, d.cend ()); + +#ifdef __GENODE__ + /* GLOB_TILDE_CHECK is not defined in Genode's libc */ -+ gdb_glob glob (dir, GLOB_TILDE, NULL); ++ const gdb_glob glob (to_expand.c_str (), GLOB_TILDE, nullptr); +#else - gdb_glob glob (dir, GLOB_TILDE_CHECK, NULL); + const gdb_glob glob (to_expand.c_str (), GLOB_TILDE_CHECK, nullptr); +#endif /* __GENODE__ */ - gdb_assert (glob.pathc () > 0); - /* "glob" may return more than one match to the path provided by the -@@ -86,7 +91,12 @@ gdb_tilde_expand (const char *dir) - gdb::unique_xmalloc_ptr - gdb_tilde_expand_up (const char *dir) - { -+#ifdef __GENODE__ -+ /* GLOB_TILDE_CHECK is not defined in Genode's libc */ -+ gdb_glob glob (dir, GLOB_TILDE, NULL); -+#else - gdb_glob glob (dir, GLOB_TILDE_CHECK, NULL); -+#endif - - gdb_assert (glob.pathc () > 0); - /* "glob" may return more than one match to the path provided by the + gdb_assert (glob.pathc () == 1); + return std::string (glob.pathv ()[0]) + remainder; diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc -index 48c477fa..c3065efe 100644 +index d1a61f4..69ecd7a 100644 --- a/gdbsupport/pathstuff.cc +++ b/gdbsupport/pathstuff.cc -@@ -55,6 +55,7 @@ gdb_realpath (const char *filename) +@@ -59,6 +59,7 @@ gdb_realpath (const char *filename) does not exist locally), we rely instead on GetFullPathName to perform the canonicalization. */ @@ -1258,7 +1257,7 @@ index 48c477fa..c3065efe 100644 #if defined (_WIN32) { char buf[MAX_PATH]; -@@ -75,6 +76,7 @@ gdb_realpath (const char *filename) +@@ -79,6 +80,7 @@ gdb_realpath (const char *filename) return gdb::unique_xmalloc_ptr (rp); } #endif @@ -1266,3 +1265,20 @@ index 48c477fa..c3065efe 100644 /* This system is a lost cause, just dup the buffer. */ return make_unique_xstrdup (filename); +diff --git a/gnulib/import/rawmemchr.c b/gnulib/import/rawmemchr.c +index ea68c1b..5ce70ed 100644 +--- a/gnulib/import/rawmemchr.c ++++ b/gnulib/import/rawmemchr.c +@@ -34,10 +34,11 @@ rawmemchr (const void *s, int c_in) + { + /* Change this typedef to experiment with performance. */ + typedef uintptr_t longword; ++#ifndef __GENODE__ + /* If you change the "uintptr_t", you should change UINTPTR_WIDTH to match. + This verifies that the type does not have padding bits. */ + verify (UINTPTR_WIDTH == UCHAR_WIDTH * sizeof (longword)); +- ++#endif /* __GENODE__ */ + const unsigned char *char_ptr; + unsigned char c = c_in; + diff --git a/repos/ports/src/noux-pkg/gdb/patches/noux_build.patch b/repos/ports/src/noux-pkg/gdb/patches/noux_build.patch index f70f8904ab..872313e3e3 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/noux_build.patch +++ b/repos/ports/src/noux-pkg/gdb/patches/noux_build.patch @@ -4,33 +4,18 @@ From: Christian Prochaska --- - gdb/configure | 10 +++++----- - gdb/dwarf2/index-write.c | 2 +- - gnulib/config.in | 2 ++ - sim/common/Make-common.in | 2 +- - 4 files changed, 9 insertions(+), 7 deletions(-) + gdb/configure | 2 +- + gdb/dwarf2/index-write.c | 2 +- + gdbsupport/scoped_ignore_signal.h | 2 ++ + gnulib/config.in | 2 ++ + sim/common/Make-common.in | 2 +- + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gdb/configure b/gdb/configure -index 03464ae5..6f705fc7 100755 +index bdc84be..5122989 100755 --- a/gdb/configure +++ b/gdb/configure -@@ -6699,11 +6699,11 @@ fi - # configuration. - gdb_host_obs=posix-hdep.o - --if test "${target}" = "${host}"; then -- gdb_native=yes --else -+#if test "${target}" = "${host}"; then -+# gdb_native=yes -+#else - gdb_native=no --fi -+#fi - - . $srcdir/configure.host - -@@ -14353,7 +14353,7 @@ sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1); +@@ -26053,7 +26053,7 @@ sigjmp_buf env; return 0; } _ACEOF @@ -40,10 +25,10 @@ index 03464ae5..6f705fc7 100755 else gdb_cv_func_sigsetjmp=no diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c -index 0079c0fe..376a9151 100644 +index ced58ea..ef0bf35 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c -@@ -777,7 +777,7 @@ class debug_names +@@ -618,7 +618,7 @@ class debug_names gdb_assert (m_abbrev_table.empty ()); const size_t name_count = m_name_to_value_set.size (); m_bucket_table.resize @@ -52,36 +37,49 @@ index 0079c0fe..376a9151 100644 m_hash_table.reserve (name_count); m_name_table_string_offs.reserve (name_count); m_name_table_entry_offs.reserve (name_count); +diff --git a/gdbsupport/scoped_ignore_signal.h b/gdbsupport/scoped_ignore_signal.h +index 1c015a9..5105a94 100644 +--- a/gdbsupport/scoped_ignore_signal.h ++++ b/gdbsupport/scoped_ignore_signal.h +@@ -22,6 +22,8 @@ + + #include + ++#undef HAVE_SIGPROCMASK ++ + /* RAII class used to ignore a signal in a scope. If sigprocmask is + supported, then the signal is only ignored by the calling thread. + Otherwise, the signal disposition is set to SIG_IGN, which affects diff --git a/gnulib/config.in b/gnulib/config.in -index d8a5e8be..cc1cc9fc 100644 +index f70c6a5..09675d9 100644 --- a/gnulib/config.in +++ b/gnulib/config.in -@@ -1192,6 +1192,7 @@ - /* Define to 1 to make NetBSD features available. MINIX 3 needs this. */ - #undef _NETBSD_SOURCE +@@ -1492,6 +1492,7 @@ + /* Define to 1 on Solaris. */ + #undef _LCONV_C99 +#if 0 /* The _Noreturn keyword of C11. */ #ifndef _Noreturn # if (defined __cplusplus \ -@@ -1220,6 +1221,7 @@ +@@ -1521,6 +1522,7 @@ # define _Noreturn # endif #endif +#endif - /* Define to 2 if the system does not provide POSIX.1 features except with + /* Define to 1 in order to get the POSIX compatible declarations of socket diff --git a/sim/common/Make-common.in b/sim/common/Make-common.in -index 21e1d991..2ea1ab60 100644 +index 88c66b3..645bf41 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in -@@ -236,7 +236,7 @@ CSEARCH = -I. -I$(srcdir) -I../common -I$(srccom) \ +@@ -175,7 +175,7 @@ CSEARCH = -I. -I$(srcdir) -I$(srccom) \ -I../../bfd -I$(srcroot)/bfd \ - -I../../opcodes -I$(srcroot)/opcodes \ - @INCINTL@ --ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CFLAGS) -+ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(CPPFLAGS) $(CFLAGS) - BUILD_CFLAGS = -g -O $(CSEARCH) + -I$(srcroot)/opcodes \ + -I../.. +-ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(INCGNU) $(SIM_EXTRA_CFLAGS) $(CFLAGS) ++ALL_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(INCGNU) $(SIM_EXTRA_CFLAGS) $(CPPFLAGS) $(CFLAGS) + BUILD_CFLAGS = $(CFLAGS_FOR_BUILD) $(CSEARCH) - COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) + COMMON_DEP_CFLAGS = $(CONFIG_CFLAGS) $(CSEARCH) $(SIM_EXTRA_CFLAGS) diff --git a/repos/ports/src/noux-pkg/gdb/patches/shared_library.patch b/repos/ports/src/noux-pkg/gdb/patches/shared_library.patch index a660faf93d..a99906bafb 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/shared_library.patch +++ b/repos/ports/src/noux-pkg/gdb/patches/shared_library.patch @@ -11,19 +11,19 @@ Enable shared library support. 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c -index 3a24b0d9..1d8cfd0b 100644 +index b8cd818..74cb9cf 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c -@@ -50,6 +50,8 @@ - #include "osabi.h" +@@ -51,6 +51,8 @@ #include "x86-tdep.h" + #include "amd64-ravenscar-thread.h" +#include "solib-svr4.h" + /* Note that the AMD64 architecture was previously known as x86-64. The latter is (forever) engraved into the canonical system name as returned by config.guess, and used as the name for the AMD64 port -@@ -3127,6 +3129,8 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch, +@@ -3122,6 +3124,8 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch, static const char *const stap_register_indirection_suffixes[] = { ")", NULL }; @@ -33,10 +33,10 @@ index 3a24b0d9..1d8cfd0b 100644 floating-point registers. */ tdep->sizeof_fpregset = I387_SIZEOF_FXSAVE; diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c -index 415f11e1..be342117 100644 +index 58b9c5f..2fcf104 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c -@@ -66,6 +66,8 @@ +@@ -67,6 +67,8 @@ #include "gdbsupport/selftest.h" #endif @@ -44,9 +44,9 @@ index 415f11e1..be342117 100644 + static bool arm_debug; - /* Macros for setting and testing a bit in a minimal symbol that marks -@@ -9337,6 +9339,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - tdep = XCNEW (struct gdbarch_tdep); + /* Print an "arm" debug statement. */ +@@ -10570,6 +10572,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + arm_gdbarch_tdep *tdep = new arm_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); + set_solib_svr4_fetch_link_map_offsets(gdbarch, svr4_ilp32_fetch_link_map_offsets); @@ -55,19 +55,19 @@ index 415f11e1..be342117 100644 These are gdbarch discriminators, like the OSABI. */ tdep->arm_abi = arm_abi; diff --git a/gdb/configure.tgt b/gdb/configure.tgt -index a3e11c4b..3756809c 100644 +index e84e222..d7d8e29 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt -@@ -189,7 +189,7 @@ arm*-*-symbianelf*) +@@ -200,7 +200,7 @@ arm*-*-openbsd*) ;; arm*-*-*) # Target: ARM embedded system - gdb_target_obs="arm-pikeos-tdep.o" + gdb_target_obs="solib-svr4.o" - gdb_sim=../sim/arm/libsim.a ;; -@@ -725,8 +725,11 @@ x86_64-*-dicos*) + avr-*-*) +@@ -698,8 +698,11 @@ x86_64-*-dicos*) dicos-tdep.o i386-dicos-tdep.o amd64-dicos-tdep.o" ;; x86_64-*-elf*) @@ -81,20 +81,20 @@ index a3e11c4b..3756809c 100644 # Target: GNU/Linux x86-64 gdb_target_obs="amd64-linux-tdep.o ${i386_tobjs} \ diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c -index c33983b6..057f3e3c 100644 +index 88daca4..49a7497 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c -@@ -67,6 +67,8 @@ - #include - #include "producer.h" +@@ -70,6 +70,8 @@ + #include "infcall.h" + #include "maint.h" +#include "solib-svr4.h" + /* Register names. */ - static const char *i386_register_names[] = -@@ -8465,6 +8467,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - tdep = XCNEW (struct gdbarch_tdep); + static const char * const i386_register_names[] = +@@ -8459,6 +8461,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + i386_gdbarch_tdep *tdep = new i386_gdbarch_tdep; gdbarch = gdbarch_alloc (&info, tdep); + set_solib_svr4_fetch_link_map_offsets(gdbarch, svr4_ilp32_fetch_link_map_offsets); diff --git a/repos/ports/src/noux-pkg/gdb/target.inc b/repos/ports/src/noux-pkg/gdb/target.inc index 2839f436f8..964f4488af 100644 --- a/repos/ports/src/noux-pkg/gdb/target.inc +++ b/repos/ports/src/noux-pkg/gdb/target.inc @@ -11,11 +11,19 @@ CFLAGS += -Wno-error=sizeof-pointer-memaccess \ -Wno-error=unused-value \ -Wno-error=overflow -LIBS += stdcxx ncurses expat +LIBS += stdcxx ncurses expat gmp # workaround for problems with makeinfo version 5 MAKE_ENV += "MAKEINFO=true" INSTALL_TARGET = install +.SECONDARY: dummy_libs +dummy_libs: libgmp.a + +libgmp.a: + $(VERBOSE)$(AR) -rc $@ + +Makefile: dummy_libs + include $(call select_from_repositories,mk/noux.mk) diff --git a/tool/tool_chain b/tool/tool_chain index 2ef45f59a9..75332c5271 100755 --- a/tool/tool_chain +++ b/tool/tool_chain @@ -138,6 +138,13 @@ EXPAT_OK = $(call check_equal_f,\ $(shell pkg-config --exists expat && echo ok),ok,\ Need to have 'libexpat' installed.) +# +# Check if 'libgmp' is installed +# +GMP_OK = $(call check_equal_f,\ + $(shell pkg-config --exists gmp && echo ok),ok,\ + Need to have 'libgmp' installed.) + # # Check if 'GNAT' is installed # @@ -155,6 +162,10 @@ ifneq ($(filter ada,$(ENABLE_FEATURES)),) TOOLS_OK += $(GNAT_OK) $(GPRBUILD_OK) endif +ifneq ($(filter gdb,$(ENABLE_FEATURES)),) +TOOLS_OK += $(GMP_OK) +endif + ifneq ($(strip $(TOOLS_OK)),) $(error Please install missing tools.) endif