diff --git a/repos/ports/lib/mk/gdbserver_platform.inc b/repos/ports/lib/mk/gdbserver_platform.inc index 7997dd012..28c91ff82 100644 --- a/repos/ports/lib/mk/gdbserver_platform.inc +++ b/repos/ports/lib/mk/gdbserver_platform.inc @@ -4,33 +4,21 @@ INC_DIR += $(REP_DIR)/src/lib/gdbserver_libc_support \ $(REP_DIR)/src/lib/gdbserver_platform \ $(REP_DIR)/src/app/gdb_monitor \ $(GDB_CONTRIB_DIR)/include \ + $(GDB_CONTRIB_DIR)/gdb \ $(GDB_CONTRIB_DIR)/gdb/common \ $(GDB_CONTRIB_DIR)/gdb/gdbserver \ + $(GDB_CONTRIB_DIR)/gdb/gnulib/import \ $(GDB_CONTRIB_DIR)/gdb/regformats \ $(REP_DIR)/src/app/gdb_monitor/gdbserver SRC_CC += gdbserver_platform_helper.cc -LIBS += libc +CC_OPT_gdbserver_platform_helper += -fpermissive -# generated files +CC_OPT += -DGDBSERVER +CC_OPT += -DHAVE_DECL_PTRACE -DHAVE_SYS_PTRACE_H -REGFORMATS_DIR := $(abspath ${GDB_CONTRIB_DIR}/gdb/regformats) - -reg-arm.c: - $(VERBOSE) cd $(dir $@) && $(SHELL) $(REGFORMATS_DIR)/regdat.sh $(REGFORMATS_DIR)/reg-arm.dat $(notdir $@) - -i386.c: - $(VERBOSE) cd $(dir $@) && $(SHELL) $(REGFORMATS_DIR)/regdat.sh $(REGFORMATS_DIR)/i386/i386.dat $(notdir $@) - -i386-avx.c: - $(VERBOSE) cd $(dir $@) && $(SHELL) $(REGFORMATS_DIR)/regdat.sh $(REGFORMATS_DIR)/i386/i386-avx.dat $(notdir $@) - -amd64.c: - $(VERBOSE) cd $(dir $@) && $(SHELL) $(REGFORMATS_DIR)/regdat.sh $(REGFORMATS_DIR)/i386/amd64.dat $(notdir $@) - -amd64-avx.c: - $(VERBOSE) cd $(dir $@) && $(SHELL) $(REGFORMATS_DIR)/regdat.sh $(REGFORMATS_DIR)/i386/amd64-avx.dat $(notdir $@) +LIBS += stdcxx libc vpath %.cc $(REP_DIR)/src/lib/gdbserver_platform -vpath %.c $(GDB_CONTRIB_DIR)/gdb/gdbserver +vpath %.cc $(GDB_CONTRIB_DIR)/gdb diff --git a/repos/ports/lib/mk/spec/x86_32/gdbserver_platform-x86_32.inc b/repos/ports/lib/mk/spec/x86_32/gdbserver_platform-x86_32.inc index cb4e665a6..a340a18b6 100644 --- a/repos/ports/lib/mk/spec/x86_32/gdbserver_platform-x86_32.inc +++ b/repos/ports/lib/mk/spec/x86_32/gdbserver_platform-x86_32.inc @@ -1,9 +1,11 @@ INC_DIR += $(REP_DIR)/src/lib/gdbserver_platform/spec/x86_32 -SRC_C = i386.c \ - i386-avx.c \ - linux-x86-low.c +SRC_CC += arch/i386.cc \ + gdbserver/linux-x86-low.cc \ + gdbserver/linux-x86-tdesc.cc \ + nat/x86-linux.cc \ + nat/x86-linux-dregs.cc -CC_OPT_linux-x86-low += -Wno-unused-function +CC_OPT += -fpermissive -Wno-unused-function include $(REP_DIR)/lib/mk/gdbserver_platform.inc diff --git a/repos/ports/lib/mk/spec/x86_64/gdbserver_platform-nova.mk b/repos/ports/lib/mk/spec/x86_64/gdbserver_platform-nova.mk index 63159dab8..d762d40bf 100644 --- a/repos/ports/lib/mk/spec/x86_64/gdbserver_platform-nova.mk +++ b/repos/ports/lib/mk/spec/x86_64/gdbserver_platform-nova.mk @@ -1,7 +1,7 @@ REQUIRES += nova -SRC_CC = spec/x86_64/low.cc \ - native_cpu.cc +SRC_CC += spec/x86_64/low.cc \ + native_cpu.cc SHARED_LIB = yes diff --git a/repos/ports/lib/mk/spec/x86_64/gdbserver_platform-x86_64.inc b/repos/ports/lib/mk/spec/x86_64/gdbserver_platform-x86_64.inc index 989df6761..1fdf54781 100644 --- a/repos/ports/lib/mk/spec/x86_64/gdbserver_platform-x86_64.inc +++ b/repos/ports/lib/mk/spec/x86_64/gdbserver_platform-x86_64.inc @@ -1,11 +1,12 @@ INC_DIR += $(REP_DIR)/src/lib/gdbserver_platform/spec/x86_64 -SRC_C = i386.c \ - i386-avx.c \ - amd64.c \ - amd64-avx.c \ - linux-x86-low.c +SRC_CC += arch/i386.cc \ + arch/amd64.cc \ + gdbserver/linux-x86-low.cc \ + gdbserver/linux-x86-tdesc.cc \ + nat/x86-linux.cc \ + nat/x86-linux-dregs.cc -CC_OPT_linux-x86-low += -Wno-unused-function +CC_OPT += -fpermissive -Wno-unused-function include $(REP_DIR)/lib/mk/gdbserver_platform.inc diff --git a/repos/ports/lib/symbols/gdbserver_platform b/repos/ports/lib/symbols/gdbserver_platform index c1be76327..75843442b 100644 --- a/repos/ports/lib/symbols/gdbserver_platform +++ b/repos/ports/lib/symbols/gdbserver_platform @@ -1,120 +1,97 @@ -abort U -__aeabi_unwind_cpp_pr0 U -__aeabi_unwind_cpp_pr1 U -all_lwps U -all_threads U -amd64_emit_ops D 248 -collect_register_by_name U -collect_register U -current_inferior U -current_insn_ptr U -current_process U -__cxa_allocate_exception U -__cxa_begin_catch U -__cxa_end_catch U -__cxa_end_cleanup U -__cxa_get_exception_ptr U -__cxa_pure_virtual U -__cxa_throw U -debug_threads U -delete_gdb_breakpoint_at U -dl_unwind_find_exidx W -__dynamic_cast U -emit_error U -__error U -error U -expedite_regs_amd64_avx D 32 -expedite_regs_amd64 D 32 -expedite_regs_arm D 16 -expedite_regs_i386_avx D 32 -expedite_regs_i386 D 32 -fatal U -find_inferior_id U -find_inferior U -find_lwp_pid U -find_regno U -fprintf U -free U -gdbserver_expedite_regs U -gdbserver_xmltarget U -genode_fetch_register T -genode_read_memory_byte U -genode_store_register T -get_raw_reg_func_addr U -get_thread_regcache U -__gnu_Unwind_Find_exidx T -__gxx_personality_v0 U -i386_dr_low_get_addr T -i386_dr_low_get_control T -i386_dr_low_get_status T -i386_dr_low_set_addr T -i386_dr_low_set_control T -i386_emit_ops D 248 -i386_low_init_dregs U -i386_low_insert_watchpoint U -i386_low_remove_watchpoint U -i386_low_stopped_by_watchpoint U -i386_low_stopped_data_address U -inferior_target_data U -init_registers_amd64_avx T -init_registers_amd64 T -init_registers_arm T -init_registers_i386_avx T -init_registers_i386 T -_init T -internal_error U -l4_atomic_add T -l4_atomic_cmpxchg T -l4_atomic_xchg T -l4_utcb_wrap W -linux_stop_lwp U -memcpy U -num_xmm_registers U -paddress U -pid_to_ptid U -ps_get_thread_area T -ptid_get_lwp U -ptid_get_pid U -ptrace U -regcache_invalidate U -register_size U -regs_amd64_avx D 1168 -regs_amd64 D 912 -regs_arm D 312 -regs_i386_avx D 784 -regs_i386 D 656 -relocate_instruction U -set_gdb_breakpoint_at U -set_register_cache U -__stderrp U -strtok U -strtoul U -supply_register_by_name U -supply_register U -target_regsets D 112 -the_low_target D 216 -the_target U _Unwind_Resume U -write_inferior_memory U -x86_xcr0 U -xcalloc U -xmltarget_amd64_avx D 8 -xmltarget_amd64 D 8 -xmltarget_arm D 4 -xmltarget_i386_avx D 8 -xmltarget_i386 D 8 -xstrdup U +_Z11ptid_of_lwpP8lwp_info U +_Z12debug_printfPKcz U +_Z12find_lwp_pid6ptid_t U +_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 +_Z14tdesc_add_flagP22tdesc_type_with_fieldsiPKc U +_Z15current_processv U +_Z15lwp_stop_reasonP8lwp_info U +_Z15set_tdesc_osabiP11target_descPKc U +_Z15tdesc_add_fieldP22tdesc_type_with_fieldsPKcP10tdesc_type U +_Z16current_lwp_ptidv U +_Z16find_process_pidi U +_Z16init_target_descP11target_descPPKc U +_Z16perror_with_namePKc U +_Z16regcache_releasev U +_Z16tdesc_create_regP13tdesc_featurePKciiS2_iS2_ U +_Z16tdesc_named_typePK13tdesc_featurePKc U +_Z17i386_emit_eq_gotoPiS_ T +_Z17i386_emit_ge_gotoPiS_ T +_Z17i386_emit_gt_gotoPiS_ T +_Z17i386_emit_le_gotoPiS_ T +_Z17i386_emit_lt_gotoPiS_ T +_Z17i386_emit_ne_gotoPiS_ T +_Z17iterate_over_lwps6ptid_tPFiP8lwp_infoPvES2_ U +_Z18amd64_emit_eq_gotoPiS_ T +_Z18amd64_emit_ge_gotoPiS_ T +_Z18amd64_emit_gt_gotoPiS_ T +_Z18amd64_emit_le_gotoPiS_ T +_Z18amd64_emit_lt_gotoPiS_ T +_Z18amd64_emit_ne_gotoPiS_ T +_Z18tdesc_add_bitfieldP22tdesc_type_with_fieldsPKcii U +_Z18tdesc_create_flagsP13tdesc_featurePKci U +_Z18tdesc_create_unionP13tdesc_featurePKc U +_Z18x86_low_init_dregsP19x86_debug_reg_state U +_Z19get_thread_regcacheP11thread_infoi U +_Z19initialize_low_archv T +_Z19tdesc_create_structP13tdesc_featurePKc U +_Z19tdesc_create_vectorP13tdesc_featurePKcP10tdesc_typei U +_Z19x86_debug_reg_statei T +_Z19x86_linux_regs_infov T +_Z20relocate_instructionPyy U +_Z20tdesc_create_featureP11target_descPKc U +_Z20x86_linux_new_threadP8lwp_info T _Z21cannot_fetch_registerPKc T _Z21cannot_store_registerPKcm T +_Z21genode_fetch_registeriPm T +_Z21genode_store_registerim T +_Z21get_raw_reg_func_addrv U +_Z21lwp_arch_private_infoP8lwp_info U +_Z21tdesc_set_struct_sizeP22tdesc_type_with_fieldsi U +_Z21write_inferior_memoryyPKhi U +_Z21x86_linux_dr_get_addri T +_Z21x86_linux_dr_set_addriy T +_Z22claim_trampoline_spaceyPy U +_Z22find_any_thread_of_pidi U _Z22genode_child_resourcesv U +_Z22i386_get_ipa_tdesc_idxPK11target_desc T +_Z22set_tdesc_architectureP11target_descPKc U +_Z23amd64_get_ipa_tdesc_idxPK11target_desc T +_Z23copy_target_descriptionP11target_descPKS_ U +_Z23initialize_regsets_infoP12regsets_info U +_Z23supply_register_by_nameP8regcachePKcPKv U +_Z23x86_linux_delete_threadP13arch_lwp_info T +_Z23x86_linux_dr_get_statusv T +_Z24collect_register_by_nameP8regcachePKcPv U _Z24get_current_thread_statev T _Z24set_current_thread_stateN6Genode12Thread_stateE T -_ZdlPvRN6Genode11DeallocatorE U -_ZdlPv U +_Z24x86_dr_insert_watchpointP19x86_debug_reg_state17target_hw_bp_typeyi U +_Z24x86_dr_remove_watchpointP19x86_debug_reg_state17target_hw_bp_typeyi U +_Z24x86_linux_dr_get_controlv T +_Z24x86_linux_dr_set_controlm T +_Z25lwp_set_arch_private_infoP8lwp_infoP13arch_lwp_info U +_Z27allocate_target_descriptionv U +_Z27i386_linux_read_descriptionm T +_Z27lwp_debug_registers_changedP8lwp_info T +_Z27x86_dr_stopped_data_addressP19x86_debug_reg_statePy U +_Z27x86_linux_prepare_to_resumeP8lwp_info T +_Z28amd64_linux_read_descriptionmb T +_Z30i386_create_target_descriptionmb T +_Z31amd64_create_target_descriptionmbbb T +_Z31lwp_set_debug_registers_changedP8lwp_infoi T +_Z32x86_linux_update_debug_registersP8lwp_info T +_Z34raw_bkpt_type_to_target_hw_bp_type13raw_bkpt_type U +_Z38have_fast_tracepoint_trampoline_bufferPc U +_Z7warningPKcz U +_Z8paddressy U _ZN11Gdb_monitor21Cpu_session_component10thread_capEm U -_ZN11Gdb_monitor21Cpu_session_component17lookup_cpu_threadEN6Genode10CapabilityINS1_10Cpu_threadEEE U _ZN11Gdb_monitor21Cpu_session_component17_setup_native_cpuEv T _ZN11Gdb_monitor21Cpu_session_component18parent_cpu_sessionEv U _ZN11Gdb_monitor21Cpu_session_component19_cleanup_native_cpuEv T @@ -128,20 +105,48 @@ _ZN6Genode15Cancelable_lockC2ENS0_5StateE U _ZN6Genode17Native_capability4_decEv U _ZN6Genode17Native_capability4_incEv U _ZN6Genode17Native_capabilityC1Ev U -_ZN6Genode17Native_capabilityC2Ev U _ZN6Genode3Log3logEv U _ZN6Genode3Log8_acquireENS0_4TypeE U _ZN6Genode3Log8_releaseEv U -_ZN6Genode5printERNS_6OutputEl U +_ZN6Genode5Trace6Logger17_evaluate_controlEv U _ZN6Genode5printERNS_6OutputEPKc U _ZN6Genode5printERNS_6OutputEPKv U -_ZN6Genode5Trace6Logger17_evaluate_controlEv U +_ZN6Genode5printERNS_6OutputEl U _ZN6Genode6Thread7_loggerEv U _ZN6Genode8ipc_callENS_17Native_capabilityERNS_11Msgbuf_baseES2_m U _ZNK6Genode17Native_capability10local_nameEv U -_ZnwjRN6Genode9AllocatorE U _ZSt9terminatev U _ZTIN11Gdb_monitor20Cpu_thread_componentE U _ZTVN10__cxxabiv117__class_type_infoE U _ZTVN10__cxxabiv120__si_class_type_infoE U _ZTVN10__cxxabiv121__vmi_class_type_infoE U +_ZdlPv U +_ZdlPvRN6Genode11DeallocatorE U +_ZnwmRN6Genode9AllocatorE U +__cxa_allocate_exception U +__cxa_begin_catch U +__cxa_end_catch U +__cxa_get_exception_ptr U +__cxa_pure_virtual U +__cxa_throw U +__dynamic_cast U +__error U +__gxx_personality_v0 U +abort U +amd64_emit_ops D 296 +current_insn_ptr U +current_thread U +debug_threads U +emit_error U +free U +have_ptrace_getfpxregs B 4 +i386_emit_ops D 296 +ptrace U +sprintf U +strtok U +strtoul U +the_low_target D 296 +the_target U +x86_dr_low D 48 +xcalloc U +xstrdup U diff --git a/repos/ports/ports/gdb.hash b/repos/ports/ports/gdb.hash index 0012ed550..354ec23b9 100644 --- a/repos/ports/ports/gdb.hash +++ b/repos/ports/ports/gdb.hash @@ -1 +1 @@ -d551192c3d4c27c03d68e104e6ba62d2dfe6e661 +b82025f7f85938ce713b6c442c693afe465dd83a diff --git a/repos/ports/ports/gdb.port b/repos/ports/ports/gdb.port index 55308f998..766a65e90 100644 --- a/repos/ports/ports/gdb.port +++ b/repos/ports/ports/gdb.port @@ -1,9 +1,9 @@ LICENSE := GPLv3 -VERSION := 7.3.1 +VERSION := 8.2.1 DOWNLOADS := gdb.archive -URL(gdb) := ftp://ftp.fu-berlin.de/gnu/gdb/gdb-$(VERSION).tar.bz2 -SHA(gdb) := 6d7bff716fde98d03866a1b747c0929ee7dba49bca13e01d975e0b0fa9b33a28 +URL(gdb) := ftp://ftp.fu-berlin.de/gnu/gdb/gdb-$(VERSION).tar.xz +SHA(gdb) := 0a6a432907a03c5c8eaad3c3cffd50c00a40c3a5e3c4039440624bae703f2202 SIG(gdb) := ${URL(gdb)}.sig KEY(gdb) := GNU DIR(gdb) := src/noux-pkg/gdb @@ -11,3 +11,62 @@ DIR(gdb) := src/noux-pkg/gdb PATCHES := $(addprefix ${DIR(gdb)}/patches/, \ $(shell cat $(REP_DIR)/${DIR(gdb)}/patches/series)) PATCH_OPT := -p1 -d ${DIR(gdb)} + +default: symlinks + +# +# These .c files need to be compiled with g++ +# +symlinks: $(DOWNLOADS) + $(VERBOSE)ln -s amd64.c ${DIR(gdb)}/gdb/arch/amd64.cc + $(VERBOSE)ln -s i386.c ${DIR(gdb)}/gdb/arch/i386.cc + $(VERBOSE)ln -s agent.c ${DIR(gdb)}/gdb/common/agent.cc + $(VERBOSE)ln -s buffer.c ${DIR(gdb)}/gdb/common/buffer.cc + $(VERBOSE)ln -s cleanups.c ${DIR(gdb)}/gdb/common/cleanups.cc + $(VERBOSE)ln -s common-debug.c ${DIR(gdb)}/gdb/common/common-debug.cc + $(VERBOSE)ln -s common-exceptions.c ${DIR(gdb)}/gdb/common/common-exceptions.cc + $(VERBOSE)ln -s common-utils.c ${DIR(gdb)}/gdb/common/common-utils.cc + $(VERBOSE)ln -s environ.c ${DIR(gdb)}/gdb/common/environ.cc + $(VERBOSE)ln -s errors.c ${DIR(gdb)}/gdb/common/errors.cc + $(VERBOSE)ln -s filestuff.c ${DIR(gdb)}/gdb/common/filestuff.cc + $(VERBOSE)ln -s format.c ${DIR(gdb)}/gdb/common/format.cc + $(VERBOSE)ln -s gdb_tilde_expand.c ${DIR(gdb)}/gdb/common/gdb_tilde_expand.cc + $(VERBOSE)ln -s gdb_vecs.c ${DIR(gdb)}/gdb/common/gdb_vecs.cc + $(VERBOSE)ln -s job-control.c ${DIR(gdb)}/gdb/common/job-control.cc + $(VERBOSE)ln -s pathstuff.c ${DIR(gdb)}/gdb/common/pathstuff.cc + $(VERBOSE)ln -s posix-strerror.c ${DIR(gdb)}/gdb/common/posix-strerror.cc + $(VERBOSE)ln -s print-utils.c ${DIR(gdb)}/gdb/common/print-utils.cc + $(VERBOSE)ln -s ptid.c ${DIR(gdb)}/gdb/common/ptid.cc + $(VERBOSE)ln -s rsp-low.c ${DIR(gdb)}/gdb/common/rsp-low.cc + $(VERBOSE)ln -s signals.c ${DIR(gdb)}/gdb/common/signals.cc + $(VERBOSE)ln -s tdesc.c ${DIR(gdb)}/gdb/common/tdesc.cc + $(VERBOSE)ln -s vec.c ${DIR(gdb)}/gdb/common/vec.cc + $(VERBOSE)ln -s xml-utils.c ${DIR(gdb)}/gdb/common/xml-utils.cc + $(VERBOSE)ln -s ax.c ${DIR(gdb)}/gdb/gdbserver/ax.cc + $(VERBOSE)ln -s debug.c ${DIR(gdb)}/gdb/gdbserver/debug.cc + $(VERBOSE)ln -s dll.c ${DIR(gdb)}/gdb/gdbserver/dll.cc + $(VERBOSE)ln -s event-loop.c ${DIR(gdb)}/gdb/gdbserver/event-loop.cc + $(VERBOSE)ln -s fork-child.c ${DIR(gdb)}/gdb/gdbserver/fork-child.cc + $(VERBOSE)ln -s hostio.c ${DIR(gdb)}/gdb/gdbserver/hostio.cc + $(VERBOSE)ln -s i387-fp.c ${DIR(gdb)}/gdb/gdbserver/i387-fp.cc + $(VERBOSE)ln -s inferiors.c ${DIR(gdb)}/gdb/gdbserver/inferiors.cc + $(VERBOSE)ln -s linux-low.c ${DIR(gdb)}/gdb/gdbserver/linux-low.cc + $(VERBOSE)ln -s linux-x86-low.c ${DIR(gdb)}/gdb/gdbserver/linux-x86-low.cc + $(VERBOSE)ln -s linux-x86-tdesc.c ${DIR(gdb)}/gdb/gdbserver/linux-x86-tdesc.cc + $(VERBOSE)ln -s mem-break.c ${DIR(gdb)}/gdb/gdbserver/mem-break.cc + $(VERBOSE)ln -s notif.c ${DIR(gdb)}/gdb/gdbserver/notif.cc + $(VERBOSE)ln -s regcache.c ${DIR(gdb)}/gdb/gdbserver/regcache.cc + $(VERBOSE)ln -s remote-utils.c ${DIR(gdb)}/gdb/gdbserver/remote-utils.cc + $(VERBOSE)ln -s server.c ${DIR(gdb)}/gdb/gdbserver/server.cc + $(VERBOSE)ln -s symbol.c ${DIR(gdb)}/gdb/gdbserver/symbol.cc + $(VERBOSE)ln -s target.c ${DIR(gdb)}/gdb/gdbserver/target.cc + $(VERBOSE)ln -s tdesc.c ${DIR(gdb)}/gdb/gdbserver/tdesc.cc + $(VERBOSE)ln -s tracepoint.c ${DIR(gdb)}/gdb/gdbserver/tracepoint.cc + $(VERBOSE)ln -s utils.c ${DIR(gdb)}/gdb/gdbserver/utils.cc + $(VERBOSE)ln -s x86-low.c ${DIR(gdb)}/gdb/gdbserver/x86-low.cc + $(VERBOSE)ln -s fork-inferior.c ${DIR(gdb)}/gdb/nat/fork-inferior.cc + $(VERBOSE)ln -s linux-ptrace.c ${DIR(gdb)}/gdb/nat/linux-ptrace.cc + $(VERBOSE)ln -s x86-dregs.c ${DIR(gdb)}/gdb/nat/x86-dregs.cc + $(VERBOSE)ln -s x86-linux.c ${DIR(gdb)}/gdb/nat/x86-linux.cc + $(VERBOSE)ln -s x86-linux-dregs.c ${DIR(gdb)}/gdb/nat/x86-linux-dregs.cc + $(VERBOSE)ln -s waitstatus.c ${DIR(gdb)}/gdb/target/waitstatus.cc diff --git a/repos/ports/run/debug_nitpicker.run b/repos/ports/run/debug_nitpicker.run index 5d116a1c2..d2adfa308 100644 --- a/repos/ports/run/debug_nitpicker.run +++ b/repos/ports/run/debug_nitpicker.run @@ -112,7 +112,7 @@ proc binary_name_gdbserver_platform_lib_so { } { # generic modules build_boot_image { - libc.lib.so vfs.lib.so libc_pipe.lib.so + stdcxx.lib.so libc.lib.so libm.lib.so vfs.lib.so libc_pipe.lib.so pc_uart_drv gdb_monitor gdbserver_platform.lib.so } diff --git a/repos/ports/run/gdb_monitor.run b/repos/ports/run/gdb_monitor.run index e3e1434ba..143363a75 100644 --- a/repos/ports/run/gdb_monitor.run +++ b/repos/ports/run/gdb_monitor.run @@ -97,7 +97,7 @@ proc binary_name_gdbserver_platform_lib_so { } { set boot_modules { core init timer ld.lib.so libc.lib.so vfs.lib.so libm.lib.so libc_pipe.lib.so - pc_uart_drv posix.lib.so + pc_uart_drv posix.lib.so stdcxx.lib.so gdb_monitor gdbserver_platform.lib.so test-gdb_monitor } @@ -142,6 +142,9 @@ append gdb_cmds [gdb_initial_breakpoint_cmds $gdb_target_binary] eval spawn [gdb] debug/ld.lib.so -n $gdb_cmds set gdb_id [list $spawn_id $genode_id] +send "set pagination off\n" +run_genode_until {\(gdb\)} 20 $gdb_id + puts "" puts "----- test: breakpoint in 'main()' -----" puts "" @@ -244,8 +247,8 @@ if {![regexp {Breakpoint 4, test_thread_start} $output]} { send "info threads\n" run_genode_until {\(gdb\)} 20 $gdb_id -if {![regexp { 4 Thread 3} $output] || - ![regexp {\* 3 Thread 4 test_thread_start} $output] || +if {![regexp {\* 4 Thread 4 test_thread_start} $output] || + ![regexp { 3 Thread 3} $output] || ![regexp { 2 Thread 2} $output] || ![regexp { 1 Thread 1} $output]} { puts stderr "*** Error: Thread info is not as expected" @@ -274,7 +277,7 @@ puts "" send "c\n" run_genode_until {\(gdb\)} 20 $gdb_id -if {![regexp {Program received signal SIGSEGV, Segmentation fault.} $output]} { +if {![regexp {Thread 4 received signal SIGSEGV, Segmentation fault.} $output]} { puts stderr "*** Error: Segmentation fault exception was not caught" exit -1 } @@ -292,10 +295,10 @@ if {![have_spec arm]} { send "bt\n" run_genode_until {\(gdb\)} 20 $gdb_id - if {![regexp {Genode::Cancelable_lock::lock\(\)} $output] || - ![regexp {Genode::Signal_receiver::block_for_signal\(\)} $output] || - ![regexp {Genode::Entrypoint::_wait_and_dispatch_one_io_signal\(bool\)} $output] || - ![regexp {Libc::Kernel::run\(Libc::Application_code&\)} $output] } { + if {![regexp {Genode::Cancelable_lock::lock} $output] || + ![regexp {Genode::Signal_receiver::block_for_signal} $output] || + ![regexp {Genode::Entrypoint::_wait_and_dispatch_one_io_signal} $output] || + ![regexp {Libc::Kernel::run} $output] } { puts stderr "*** Error: Stack trace when in syscall is not as expected" exit -1 diff --git a/repos/ports/run/noux_gdb.run b/repos/ports/run/noux_gdb.run index 14dead955..e1838a62d 100644 --- a/repos/ports/run/noux_gdb.run +++ b/repos/ports/run/noux_gdb.run @@ -10,9 +10,10 @@ import_from_depot [depot_user]/src/[base_src] \ [depot_user]/pkg/terminal \ [depot_user]/src/init \ [depot_user]/src/libc \ + [depot_user]/src/ncurses \ [depot_user]/src/noux \ [depot_user]/src/posix \ - [depot_user]/src/ncurses + [depot_user]/src/stdcxx source ${genode_dir}/repos/ports/run/noux_gdb.inc diff --git a/repos/ports/src/app/gdb_monitor/app_child.h b/repos/ports/src/app/gdb_monitor/app_child.h index 8410c53b1..05a011886 100644 --- a/repos/ports/src/app/gdb_monitor/app_child.h +++ b/repos/ports/src/app/gdb_monitor/app_child.h @@ -228,13 +228,16 @@ class Gdb_monitor::App_child : public Child_policy, /** * Constructor */ - App_child(Env &env, - Allocator &alloc, - char const *unique_name, - Ram_quota ram_quota, - Cap_quota cap_quota, - Entrypoint &signal_ep, - Xml_node target_node) + App_child(Env &env, + Allocator &alloc, + char const *unique_name, + Ram_quota ram_quota, + Cap_quota cap_quota, + Entrypoint &signal_ep, + Xml_node target_node, + int const new_thread_pipe_write_end, + int const breakpoint_len, + unsigned char const *breakpoint_data) : _env(env), _alloc(alloc), @@ -246,7 +249,9 @@ class Gdb_monitor::App_child : public Child_policy, _unresolved_page_fault_handler(signal_ep, *this, &App_child::_handle_unresolved_page_fault), _cpu_factory(_env, _env.ep().rpc_ep(), _alloc, _pd.core_pd_cap(), - signal_ep, &_genode_child_resources), + signal_ep, new_thread_pipe_write_end, + breakpoint_len, breakpoint_data, + &_genode_child_resources), _rom_factory(_env, _env.ep().rpc_ep(), _alloc) { _genode_child_resources.region_map_component(&_pd.region_map()); diff --git a/repos/ports/src/app/gdb_monitor/cpu_session_component.cc b/repos/ports/src/app/gdb_monitor/cpu_session_component.cc index 711a98794..a228d582b 100644 --- a/repos/ports/src/app/gdb_monitor/cpu_session_component.cc +++ b/repos/ports/src/app/gdb_monitor/cpu_session_component.cc @@ -254,7 +254,10 @@ Thread_capability Cpu_session_component::create_thread(Capability pd { Cpu_thread_component *cpu_thread = new (_md_alloc) Cpu_thread_component(*this, _core_pd, name, - affinity, weight, utcb); + affinity, weight, utcb, + _new_thread_pipe_write_end, + _breakpoint_len, + _breakpoint_data); _thread_list.append(cpu_thread); @@ -309,13 +312,19 @@ Cpu_session_component::Cpu_session_component(Env &env, Pd_session_capability core_pd, Entrypoint &signal_ep, const char *args, - Affinity const &affinity) + Affinity const &affinity, + int const new_thread_pipe_write_end, + int const breakpoint_len, + unsigned char const *breakpoint_data) : _env(env), _ep(ep), _md_alloc(md_alloc), _core_pd(core_pd), _parent_cpu_session(env.session(_id_space_element.id(), args, affinity)), _signal_ep(signal_ep), + _new_thread_pipe_write_end(new_thread_pipe_write_end), + _breakpoint_len(breakpoint_len), + _breakpoint_data(breakpoint_data), _native_cpu_cap(_setup_native_cpu()) { _ep.manage(this); diff --git a/repos/ports/src/app/gdb_monitor/cpu_session_component.h b/repos/ports/src/app/gdb_monitor/cpu_session_component.h index a74b802d1..39b144961 100644 --- a/repos/ports/src/app/gdb_monitor/cpu_session_component.h +++ b/repos/ports/src/app/gdb_monitor/cpu_session_component.h @@ -60,6 +60,10 @@ class Gdb_monitor::Cpu_session_component : public Rpc_object Cpu_session_client _parent_cpu_session; Entrypoint &_signal_ep; + int const _new_thread_pipe_write_end; + int const _breakpoint_len; + unsigned char const *_breakpoint_data; + Append_list _thread_list; bool _stop_new_threads = true; @@ -81,7 +85,10 @@ class Gdb_monitor::Cpu_session_component : public Rpc_object Pd_session_capability core_pd, Entrypoint &signal_ep, const char *args, - Affinity const &affinity); + Affinity const &affinity, + int const new_thread_pipe_write_end, + int const breakpoint_len, + unsigned char const *breakpoint_data); /** * Destructor @@ -137,6 +144,9 @@ class Gdb_monitor::Local_cpu_factory : public Cpu_service::Factory Allocator &_md_alloc; Pd_session_capability _core_pd; Entrypoint &_signal_ep; + int const _new_thread_pipe_write_end; + int const _breakpoint_len; + unsigned char const *_breakpoint_data; Genode_child_resources *_genode_child_resources; @@ -147,11 +157,17 @@ class Gdb_monitor::Local_cpu_factory : public Cpu_service::Factory Allocator &md_alloc, Pd_session_capability core_pd, Entrypoint &signal_ep, + int new_thread_pipe_write_end, + int const breakpoint_len, + unsigned char const *breakpoint_data, Genode_child_resources *genode_child_resources) : _env(env), _ep(ep), _md_alloc(md_alloc), _core_pd(core_pd), _signal_ep(signal_ep), + _new_thread_pipe_write_end(new_thread_pipe_write_end), + _breakpoint_len(breakpoint_len), + _breakpoint_data(breakpoint_data), _genode_child_resources(genode_child_resources) { } @@ -169,7 +185,10 @@ class Gdb_monitor::Local_cpu_factory : public Cpu_service::Factory _core_pd, _signal_ep, args.string(), - affinity); + affinity, + _new_thread_pipe_write_end, + _breakpoint_len, + _breakpoint_data); _genode_child_resources->cpu_session_component(cpu_session_component); return *cpu_session_component; } diff --git a/repos/ports/src/app/gdb_monitor/cpu_thread_component.cc b/repos/ports/src/app/gdb_monitor/cpu_thread_component.cc index 83e521159..43b9f0759 100644 --- a/repos/ports/src/app/gdb_monitor/cpu_thread_component.cc +++ b/repos/ports/src/app/gdb_monitor/cpu_thread_component.cc @@ -14,21 +14,12 @@ /* GDB monitor includes */ #include "cpu_thread_component.h" +#include "genode-low.h" /* libc includes */ #include #include -/* mem-break.c */ -extern "C" int breakpoint_len; -extern "C" const unsigned char *breakpoint_data; -extern "C" int set_gdb_breakpoint_at(long long where); - -/* genode-low.cc */ -extern "C" int genode_read_memory(long long memaddr, unsigned char *myaddr, int len); -extern "C" int genode_write_memory (long long memaddr, const unsigned char *myaddr, int len); -extern void genode_set_initial_breakpoint_at(long long addr); - static unsigned long new_lwpid = GENODE_MAIN_LWPID; @@ -41,13 +32,13 @@ bool Cpu_thread_component::_set_breakpoint_at_first_instruction(addr_t ip) _breakpoint_ip = ip; if (genode_read_memory(_breakpoint_ip, _original_instructions, - breakpoint_len) != 0) { + _breakpoint_len) != 0) { warning(__PRETTY_FUNCTION__, ": could not read memory at thread start address"); return false; } - if (genode_write_memory(_breakpoint_ip, breakpoint_data, - breakpoint_len) != 0) { + if (genode_write_memory(_breakpoint_ip, _breakpoint_data, + _breakpoint_len) != 0) { warning(__PRETTY_FUNCTION__, ": could not set breakpoint at thread start address"); return false; } @@ -59,7 +50,7 @@ bool Cpu_thread_component::_set_breakpoint_at_first_instruction(addr_t ip) void Cpu_thread_component::_remove_breakpoint_at_first_instruction() { if (genode_write_memory(_breakpoint_ip, _original_instructions, - breakpoint_len) != 0) + _breakpoint_len) != 0) warning(__PRETTY_FUNCTION__, ": could not remove breakpoint at thread start address"); } @@ -87,15 +78,21 @@ Cpu_thread_component::Cpu_thread_component(Cpu_session_component &cpu_session_ Cpu_session::Name const &name, Affinity::Location affinity, Cpu_session::Weight weight, - addr_t utcb) + addr_t utcb, + int const new_thread_pipe_write_end, + int const breakpoint_len, + unsigned char const *breakpoint_data) : _cpu_session_component(cpu_session_component), _parent_cpu_thread( - _cpu_session_component.parent_cpu_session().create_thread(pd, - name, - affinity, - weight, - utcb)), + _cpu_session_component.parent_cpu_session().create_thread(pd, + name, + affinity, + weight, + utcb)), + _new_thread_pipe_write_end(new_thread_pipe_write_end), + _breakpoint_len(breakpoint_len), + _breakpoint_data(breakpoint_data), _exception_handler(_cpu_session_component.signal_ep(), *this, &Cpu_thread_component::_handle_exception), _sigstop_handler(_cpu_session_component.signal_ep(), *this, @@ -192,13 +189,24 @@ int Cpu_thread_component::deliver_signal(int signo) break; case SIGINFO: if (_verbose) - log("delivering initial SIGSTOP to thread ", _lwpid); + if (_lwpid != GENODE_MAIN_LWPID) + log("delivering initial SIGSTOP to thread ", _lwpid); break; default: error("unexpected signal ", signo); } - write(_pipefd[1], &signo, sizeof(signo)); + if (!((signo == SIGINFO) && (_lwpid == GENODE_MAIN_LWPID))) + write(_pipefd[1], &signo, sizeof(signo)); + + /* + * gdbserver might be blocking in 'waitpid()' without having + * the new thread's pipe fd in its 'select' fd set yet. Writing + * into the 'new thread pipe' here will unblock 'select' in this + * case. + */ + if (signo == SIGINFO) + write(_new_thread_pipe_write_end, &_lwpid, sizeof(_lwpid)); return 0; } diff --git a/repos/ports/src/app/gdb_monitor/cpu_thread_component.h b/repos/ports/src/app/gdb_monitor/cpu_thread_component.h index af994e964..edf13c42d 100644 --- a/repos/ports/src/app/gdb_monitor/cpu_thread_component.h +++ b/repos/ports/src/app/gdb_monitor/cpu_thread_component.h @@ -36,6 +36,10 @@ class Gdb_monitor::Cpu_thread_component : public Rpc_object, Cpu_session_component &_cpu_session_component; Cpu_thread_client _parent_cpu_thread; + int const _new_thread_pipe_write_end; + int const _breakpoint_len; + unsigned char const *_breakpoint_data; + unsigned long _lwpid { 0 }; addr_t _initial_ip { 0 }; @@ -72,7 +76,10 @@ class Gdb_monitor::Cpu_thread_component : public Rpc_object, Cpu_session::Name const &name, Affinity::Location affinity, Cpu_session::Weight weight, - addr_t utcb); + addr_t utcb, + int const new_thread_pipe_write_end, + int const breakpoint_len, + unsigned char const *breakpoint_data); ~Cpu_thread_component(); diff --git a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc index c1591e360..bfc203779 100644 --- a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc +++ b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc @@ -27,28 +27,32 @@ #include #include -extern "C" { -#define private _private #include "genode-low.h" #include "server.h" #include "linux-low.h" -#define _private private -int linux_detach_one_lwp (struct inferior_list_entry *entry, void *args); -} +void linux_detach_one_lwp (struct lwp_info *lwp); static bool verbose = false; Genode::Env *genode_env; +/* + * 'waitpid()' is implemented using 'select()'. When a new thread is created, + * 'select()' needs to unblock, so there is a dedicated pipe for that. The + * lwpid of the new thread needs to be read from the pipe in 'waitpid()', so + * that the next 'select()' call can block again. The lwpid needs to be stored + * in a variable until it is inquired later. + */ static int _new_thread_pipe[2]; +static unsigned long _new_thread_lwpid; /* * When 'waitpid()' reports a SIGTRAP, this variable stores the lwpid of the * corresponding thread. This information is used in the initial breakpoint * handler to let the correct thread handle the event. */ -static unsigned long sigtrap_lwpid; +static unsigned long _sigtrap_lwpid; using namespace Genode; using namespace Gdb_monitor; @@ -248,7 +252,7 @@ static void genode_stop_thread(unsigned long lwpid) } -extern "C" pid_t waitpid(pid_t pid, int *status, int flags) +pid_t my_waitpid(pid_t pid, int *status, int flags) { extern int remote_desc; @@ -296,7 +300,7 @@ extern "C" pid_t waitpid(pid_t pid, int *status, int flags) cc = read (remote_desc, &c, 1); - if (cc == 1 && c == '\003' && current_inferior != NULL) { + if (cc == 1 && c == '\003' && current_thread != NULL) { /* this causes a SIGINT to be delivered to one of the threads */ (*the_target->request_interrupt)(); continue; @@ -308,13 +312,39 @@ extern "C" pid_t waitpid(pid_t pid, int *status, int flags) } else if (FD_ISSET(_new_thread_pipe[0], &readset)) { - unsigned long lwpid = GENODE_MAIN_LWPID; + /* + * Linux 'ptrace(2)' manual text related to the main thread: + * + * "If the PTRACE_O_TRACEEXEC option is not in effect, all + * successful calls to execve(2) by the traced process will + * cause it to be sent a SIGTRAP signal, giving the parent a + * chance to gain control before the new program begins + * execution." + * + * Linux 'ptrace' manual text related to other threads: + * + * "PTRACE_O_CLONE + * ... + * A waitpid(2) by the tracer will return a status value such + * that + * + * status>>8 == (SIGTRAP | (PTRACE_EVENT_CLONE<<8)) + * + * The PID of the new process can be retrieved with + * PTRACE_GETEVENTMSG." + */ - genode_stop_thread(lwpid); + *status = W_STOPCODE(SIGTRAP); - *status = W_STOPCODE(SIGTRAP) | (PTRACE_EVENT_CLONE << 16); + read(_new_thread_pipe[0], &_new_thread_lwpid, + sizeof(_new_thread_lwpid)); - return lwpid; + if (_new_thread_lwpid != GENODE_MAIN_LWPID) { + *status |= (PTRACE_EVENT_CLONE << 16); + genode_stop_thread(GENODE_MAIN_LWPID); + } + + return GENODE_MAIN_LWPID; } else { @@ -341,7 +371,7 @@ extern "C" pid_t waitpid(pid_t pid, int *status, int flags) if (signal == SIGTRAP) { - sigtrap_lwpid = lwpid; + _sigtrap_lwpid = lwpid; } else if (signal == SIGSTOP) { @@ -369,9 +399,6 @@ extern "C" pid_t waitpid(pid_t pid, int *status, int flags) if (verbose) log("received SIGINFO for new lwpid ", lwpid); - if (lwpid != GENODE_MAIN_LWPID) - write(_new_thread_pipe[1], &lwpid, sizeof(lwpid)); - /* * First signal of a new thread. On Genode originally a * SIGTRAP, but gdbserver expects SIGSTOP. @@ -411,13 +438,12 @@ extern "C" long ptrace(enum __ptrace_request request, pid_t pid, void *addr, voi case PTRACE_SETREGS: request_str = "PTRACE_SETREGS"; break; case PTRACE_ATTACH: request_str = "PTRACE_ATTACH"; break; case PTRACE_DETACH: request_str = "PTRACE_DETACH"; break; + case PTRACE_GETSIGINFO: request_str = "PTRACE_GETSIGINFO"; break; case PTRACE_GETEVENTMSG: /* * Only PTRACE_EVENT_CLONE is currently supported. - * - * Read the lwpid of the new thread from the pipe. */ - read(_new_thread_pipe[0], data, sizeof(unsigned long)); + *(unsigned long*)data = _new_thread_lwpid; return 0; case PTRACE_GETREGSET: request_str = "PTRACE_GETREGSET"; break; } @@ -429,7 +455,7 @@ extern "C" long ptrace(enum __ptrace_request request, pid_t pid, void *addr, voi } -extern "C" int fork() +extern "C" int vfork() { /* create the thread announcement pipe */ @@ -499,13 +525,20 @@ extern "C" int fork() static Entrypoint signal_ep { *genode_env, SIGNAL_EP_STACK_SIZE, "sig_handler", Affinity::Location() }; + int breakpoint_len = 0; + unsigned char const *breakpoint_data = + the_target->sw_breakpoint_from_kind(0, &breakpoint_len); + App_child *child = new (alloc) App_child(*genode_env, alloc, filename.string(), Ram_quota{ram_quota}, cap_quota, signal_ep, - target_node); + target_node, + _new_thread_pipe[1], + breakpoint_len, + breakpoint_data); _genode_child_resources = child->genode_child_resources(); @@ -527,6 +560,8 @@ extern "C" int kill(pid_t pid, int sig) { Cpu_session_component &csc = genode_child_resources().cpu_session_component(); + if (pid <= 0) pid = GENODE_MAIN_LWPID; + Thread_capability thread_cap = csc.thread_cap(pid); if (!thread_cap.valid()) { @@ -542,11 +577,11 @@ extern "C" int kill(pid_t pid, int sig) extern "C" int initial_breakpoint_handler(CORE_ADDR addr) { Cpu_session_component &csc = genode_child_resources().cpu_session_component(); - return csc.handle_initial_breakpoint(sigtrap_lwpid); + return csc.handle_initial_breakpoint(_sigtrap_lwpid); } -void genode_set_initial_breakpoint_at(CORE_ADDR addr) +void genode_set_initial_breakpoint_at(unsigned long addr) { set_breakpoint_at(addr, initial_breakpoint_handler); } @@ -554,13 +589,14 @@ void genode_set_initial_breakpoint_at(CORE_ADDR addr) void genode_remove_thread(unsigned long lwpid) { - int pid = GENODE_MAIN_LWPID; - linux_detach_one_lwp((struct inferior_list_entry *) - find_thread_ptid(ptid_build(GENODE_MAIN_LWPID, lwpid, 0)), &pid); + struct thread_info *thread_info = + find_thread_ptid(ptid_t(GENODE_MAIN_LWPID, lwpid, 0)); + struct lwp_info *lwp = get_thread_lwp(thread_info); + linux_detach_one_lwp(lwp); } -extern "C" void genode_stop_all_threads() +void genode_stop_all_threads() { Cpu_session_component &csc = genode_child_resources().cpu_session_component(); csc.pause_all_threads(); @@ -609,10 +645,12 @@ void genode_continue_thread(unsigned long lwpid, int single_step) void genode_fetch_registers(struct regcache *regcache, int regno) { + const struct regs_info *regs_info = (*the_low_target.regs_info) (); + unsigned long reg_content = 0; if (regno == -1) { - for (regno = 0; regno < the_low_target.num_regs; regno++) { + for (regno = 0; regno < regs_info->usrregs->num_regs; regno++) { if (genode_fetch_register(regno, ®_content) == 0) supply_register(regcache, regno, ®_content); else @@ -631,17 +669,21 @@ void genode_store_registers(struct regcache *regcache, int regno) { if (verbose) log(__func__, ": regno=", regno); + const struct regs_info *regs_info = (*the_low_target.regs_info) (); + unsigned long reg_content = 0; if (regno == -1) { - for (regno = 0; regno < the_low_target.num_regs; regno++) { - if ((Genode::size_t)register_size(regno) <= sizeof(reg_content)) { + for (regno = 0; regno < regs_info->usrregs->num_regs; regno++) { + if ((Genode::size_t)register_size(regcache->tdesc, regno) <= + sizeof(reg_content)) { collect_register(regcache, regno, ®_content); genode_store_register(regno, reg_content); } } } else { - if ((Genode::size_t)register_size(regno) <= sizeof(reg_content)) { + if ((Genode::size_t)register_size(regcache->tdesc, regno) <= + sizeof(reg_content)) { collect_register(regcache, regno, ®_content); genode_store_register(regno, reg_content); } diff --git a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.h b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.h index fab5aef1b..d6d38d88c 100644 --- a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.h +++ b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.h @@ -43,4 +43,7 @@ int genode_fetch_register(int regno, unsigned long *reg_content); void genode_store_register(int regno, unsigned long reg_content); unsigned char genode_read_memory_byte(void *addr); +/* interface for cpu_thread_component.cc */ +void genode_set_initial_breakpoint_at(unsigned long addr); + #endif /* GENODE_LOW_H */ diff --git a/repos/ports/src/app/gdb_monitor/main.cc b/repos/ports/src/app/gdb_monitor/main.cc index 7646632c9..8ffe5946d 100644 --- a/repos/ports/src/app/gdb_monitor/main.cc +++ b/repos/ports/src/app/gdb_monitor/main.cc @@ -25,11 +25,11 @@ extern "C" int sigsuspend() { return -1; } /* * version.c */ -extern "C" const char version[] = "7.3.1"; +extern "C" const char version[] = "8.1.1"; extern "C" const char host_name[] = ""; -extern "C" int gdbserver_main(int argc, const char *argv[]); +extern int gdbserver_main(int argc, char *argv[]); extern Genode::Env *genode_env; @@ -38,7 +38,7 @@ void Libc::Component::construct(Libc::Env &env) genode_env = &env; int argc = 3; - const char *argv[] = { "gdbserver", "/dev/terminal", "target", 0 }; + char *argv[] = { "gdbserver", "/dev/terminal", "target", 0 }; Libc::with_libc([&] () { gdbserver_main(argc, argv); diff --git a/repos/ports/src/app/gdb_monitor/target.mk b/repos/ports/src/app/gdb_monitor/target.mk index a7970dcf0..e07f4c800 100644 --- a/repos/ports/src/app/gdb_monitor/target.mk +++ b/repos/ports/src/app/gdb_monitor/target.mk @@ -3,44 +3,90 @@ TARGET = gdb_monitor GDB_CONTRIB_DIR = $(call select_from_ports,gdb)/src/noux-pkg/gdb INC_DIR += $(GDB_CONTRIB_DIR)/include \ + $(GDB_CONTRIB_DIR)/gdb \ $(GDB_CONTRIB_DIR)/gdb/common \ $(GDB_CONTRIB_DIR)/gdb/gdbserver \ + $(GDB_CONTRIB_DIR)/gdb/gnulib/import \ $(GDB_CONTRIB_DIR)/gdb/regformats \ $(REP_DIR)/src/lib/gdbserver_libc_support \ $(PRG_DIR)/gdbserver \ $(PRG_DIR) -LIBS = libc libc_pipe \ +LIBS = stdcxx libc libc_pipe \ gdbserver_platform gdbserver_libc_support -SRC_C = event-loop.c \ - i386-low.c \ - i387-fp.c \ - inferiors.c \ - mem-break.c \ - remote-utils.c \ - regcache.c \ - server.c \ - signals.c \ - target.c \ - tracepoint.c \ - utils.c +# libiberty +SRC_C = argv.c \ + concat.c \ + crc32.c -SRC_C += linux-low.c +# gnulib +SRC_C += rawmemchr.c \ + strchrnul.c -CC_OPT += -DGDBSERVER -DPKGVERSION="\"7.3.1\"" -DREPORT_BUGS_TO="\"\"" +# gdb +SRC_CC += common/agent.cc \ + common/buffer.cc \ + common/cleanups.cc \ + common/common-debug.cc \ + common/common-exceptions.cc \ + common/common-utils.cc \ + common/environ.cc \ + common/errors.cc \ + common/filestuff.cc \ + common/format.cc \ + common/gdb_tilde_expand.cc \ + common/gdb_vecs.cc \ + common/job-control.cc \ + common/pathstuff.cc \ + common/posix-strerror.cc \ + common/print-utils.cc \ + common/ptid.cc \ + common/rsp-low.cc \ + common/signals.cc \ + common/tdesc.cc \ + common/vec.cc \ + common/xml-utils.cc \ + gdbserver/ax.cc \ + gdbserver/debug.cc \ + gdbserver/dll.cc \ + gdbserver/event-loop.cc \ + gdbserver/fork-child.cc \ + gdbserver/hostio.cc \ + gdbserver/i387-fp.cc \ + gdbserver/inferiors.cc \ + gdbserver/linux-low.cc \ + gdbserver/mem-break.cc \ + gdbserver/notif.cc \ + gdbserver/regcache.cc \ + gdbserver/remote-utils.cc \ + gdbserver/server.cc \ + gdbserver/symbol.cc \ + gdbserver/target.cc \ + gdbserver/tdesc.cc \ + gdbserver/tracepoint.cc \ + gdbserver/utils.cc \ + gdbserver/x86-low.cc \ + nat/fork-inferior.cc \ + nat/linux-ptrace.cc \ + nat/x86-dregs.cc \ + target/waitstatus.cc -CC_OPT_linux-low += -Wno-unused-function +# genode +SRC_CC += genode-low.cc \ + cpu_session_component.cc \ + cpu_thread_component.cc \ + region_map_component.cc \ + signal_handler_thread.cc \ + main.cc -SRC_CC = genode-low.cc \ - cpu_session_component.cc \ - cpu_thread_component.cc \ - region_map_component.cc \ - signal_handler_thread.cc \ - main.cc +CC_OPT += -DGDBSERVER -DPKGVERSION="\"8.1.1\"" -DREPORT_BUGS_TO="\"\"" +CC_OPT += -DHAVE_SYS_WAIT_H -DHAVE_SYS_PTRACE_H -DHAVE_DECL_PTRACE -DHAVE_TERMIOS +CC_OPT += -fpermissive -Wno-unused-function -vpath %.c $(GDB_CONTRIB_DIR)/gdb/common -vpath %.c $(GDB_CONTRIB_DIR)/gdb/gdbserver +vpath %.c $(GDB_CONTRIB_DIR)/gdb/gnulib/import +vpath %.c $(GDB_CONTRIB_DIR)/libiberty +vpath %.cc $(GDB_CONTRIB_DIR)/gdb vpath %.cc $(PRG_DIR)/gdbserver # diff --git a/repos/ports/src/lib/gdbserver_libc_support/elf/common.h b/repos/ports/src/lib/gdbserver_libc_support/elf/common.h deleted file mode 100644 index 7596de9e7..000000000 --- a/repos/ports/src/lib/gdbserver_libc_support/elf/common.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * \brief Dummy declarations of Linux-specific libc types and macros - * needed to build gdbserver - * \author Christian Prochaska - * \date 2011-09-01 - */ - -/* - * Copyright (C) 2011-2017 Genode Labs GmbH - * - * This file is part of the Genode OS framework, which is distributed - * under the terms of the GNU Affero General Public License version 3. - */ - -#ifndef ELF_COMMON_H -#define ELF_COMMON_H - -#define NT_X86_XSTATE 0x202 /* x86 extended state using xsave */ - -#endif diff --git a/repos/ports/src/lib/gdbserver_libc_support/sys/ptrace.h b/repos/ports/src/lib/gdbserver_libc_support/sys/ptrace.h index 93d0243c8..a39f7771b 100644 --- a/repos/ports/src/lib/gdbserver_libc_support/sys/ptrace.h +++ b/repos/ports/src/lib/gdbserver_libc_support/sys/ptrace.h @@ -39,7 +39,7 @@ enum __ptrace_request { PTRACE_GETREGSET = 0x4204, }; -extern long ptrace(enum __ptrace_request request, ...); +extern "C" long ptrace (enum __ptrace_request, pid_t, void*, void*); #endif /* SYS_PTRACE_H */ diff --git a/repos/ports/src/lib/gdbserver_platform-nova/spec/x86_32/low.cc b/repos/ports/src/lib/gdbserver_platform-nova/spec/x86_32/low.cc index 1d8a42ba9..f9ea45bd6 100644 --- a/repos/ports/src/lib/gdbserver_platform-nova/spec/x86_32/low.cc +++ b/repos/ports/src/lib/gdbserver_platform-nova/spec/x86_32/low.cc @@ -18,7 +18,7 @@ using namespace Genode; -extern "C" int genode_fetch_register(int regno, unsigned long *value) +int genode_fetch_register(int regno, unsigned long *value) { Thread_state ts; @@ -53,7 +53,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) } -extern "C" void genode_store_register(int regno, unsigned long value) +void genode_store_register(int regno, unsigned long value) { Thread_state ts; diff --git a/repos/ports/src/lib/gdbserver_platform-nova/spec/x86_64/low.cc b/repos/ports/src/lib/gdbserver_platform-nova/spec/x86_64/low.cc index 24cb9b84a..6ddb9298d 100644 --- a/repos/ports/src/lib/gdbserver_platform-nova/spec/x86_64/low.cc +++ b/repos/ports/src/lib/gdbserver_platform-nova/spec/x86_64/low.cc @@ -19,7 +19,7 @@ using namespace Genode; -extern "C" int genode_fetch_register(int regno, unsigned long *value) +int genode_fetch_register(int regno, unsigned long *value) { Thread_state ts; @@ -95,7 +95,7 @@ extern "C" int genode_fetch_register(int regno, unsigned long *value) } -extern "C" void genode_store_register(int regno, unsigned long value) +void genode_store_register(int regno, unsigned long value) { Thread_state ts; diff --git a/repos/ports/src/lib/gdbserver_platform/gdbserver_platform_helper.cc b/repos/ports/src/lib/gdbserver_platform/gdbserver_platform_helper.cc index 1105ced47..9e13f35d8 100644 --- a/repos/ports/src/lib/gdbserver_platform/gdbserver_platform_helper.cc +++ b/repos/ports/src/lib/gdbserver_platform/gdbserver_platform_helper.cc @@ -16,13 +16,9 @@ #include "cpu_session_component.h" #include "genode_child_resources.h" -extern "C" { -#define private _private #include "server.h" #include "linux-low.h" #include "genode-low.h" -#define _private private -} using namespace Genode; using namespace Gdb_monitor; @@ -37,9 +33,9 @@ Thread_state get_current_thread_state() { Cpu_session_component &csc = genode_child_resources()->cpu_session_component(); - ptid_t ptid = ((struct inferior_list_entry*)current_inferior)->id; + ptid_t ptid = current_thread->id; - Cpu_thread_client cpu_thread(csc.thread_cap(ptid.lwp)); + Cpu_thread_client cpu_thread(csc.thread_cap(ptid.lwp())); return cpu_thread.state(); } @@ -49,9 +45,9 @@ void set_current_thread_state(Thread_state thread_state) { Cpu_session_component &csc = genode_child_resources()->cpu_session_component(); - ptid_t ptid = ((struct inferior_list_entry*)current_inferior)->id; + ptid_t ptid = current_thread->id; - Cpu_thread_client cpu_thread(csc.thread_cap(ptid.lwp)); + Cpu_thread_client cpu_thread(csc.thread_cap(ptid.lwp())); cpu_thread.state(thread_state); } 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 cb5560d5a..705c89c1b 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 155208e..91537d6 100644 +index cfdfb0b..3afe712 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c -@@ -8467,6 +8467,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - tdep = xcalloc (1, sizeof (struct gdbarch_tdep)); +@@ -9289,6 +9289,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + tdep = XCNEW (struct 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 new file mode 100644 index 000000000..0bf65ce05 --- /dev/null +++ b/repos/ports/src/noux-pkg/gdb/patches/call_dummy_location.patch @@ -0,0 +1,23 @@ +call_dummy_location.patch + +From: Christian Prochaska + + +--- + gdb/i386-tdep.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c +index fe2453c..6c9fdf8 100644 +--- a/gdb/i386-tdep.c ++++ b/gdb/i386-tdep.c +@@ -8479,7 +8479,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. */ ++#if 0 /* the stack is not executable on a Genode target */ + set_gdbarch_call_dummy_location (gdbarch, ON_STACK); ++#endif + set_gdbarch_push_dummy_code (gdbarch, i386_push_dummy_code); + set_gdbarch_push_dummy_call (gdbarch, i386_push_dummy_call); + set_gdbarch_frame_align (gdbarch, i386_frame_align); diff --git a/repos/ports/src/noux-pkg/gdb/patches/gcc6.patch b/repos/ports/src/noux-pkg/gdb/patches/gcc6.patch deleted file mode 100644 index 191b0c3a8..000000000 --- a/repos/ports/src/noux-pkg/gdb/patches/gcc6.patch +++ /dev/null @@ -1,29 +0,0 @@ -gcc6.patch - -ChangeLog part removed to make the patch apply on Genode. - -From 24b4cf66a626566e7903813a2e0156778f4903f9 Mon Sep 17 00:00:00 2001 -From: Szabolcs Nagy -Date: Tue, 16 Jun 2015 13:35:33 +0100 -Subject: [PATCH] Fixes a compile time warnng about left shifting a negative - value. - - * arm-dis.c (print_insn_coprocessor): Avoid negative shift. ---- - opcodes/ChangeLog | 4 ++++ - opcodes/arm-dis.c | 2 +- - 2 files changed, 5 insertions(+), 1 deletion(-) - -diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c -index e9f4425..818847d 100644 ---- a/opcodes/arm-dis.c -+++ b/opcodes/arm-dis.c -@@ -3352,7 +3352,7 @@ print_insn_coprocessor (bfd_vma pc, - - /* Is ``imm'' a negative number? */ - if (imm & 0x40) -- imm |= (-1 << 7); -+ imm -= 0x80; - - func (stream, "%d", imm); - } 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 new file mode 100644 index 000000000..8b78239f1 --- /dev/null +++ b/repos/ports/src/noux-pkg/gdb/patches/gdb_x86_64.patch @@ -0,0 +1,102 @@ +gdb_x86_64.patch + +From: Christian Prochaska + + +--- + gdb/amd64-tdep.c | 13 +++++++++++++ + gdb/defs.h | 1 + + gdb/i386-tdep.c | 5 +++++ + gdb/osabi.c | 6 ++++++ + 4 files changed, 25 insertions(+) + +diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c +index e1f8862..314bf77 100644 +--- a/gdb/amd64-tdep.c ++++ b/gdb/amd64-tdep.c +@@ -50,6 +50,7 @@ + #include "osabi.h" + #include "x86-tdep.h" + ++#include "osabi.h" + #include "solib-svr4.h" + + /* Note that the AMD64 architecture was previously known as x86-64. +@@ -3296,6 +3297,13 @@ amd64_target_description (uint64_t xcr0, bool segments) + return *tdesc; + } + ++static void ++amd64_genode_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) ++{ ++ amd64_init_abi (info, gdbarch, ++ amd64_target_description (X86_XSTATE_SSE_MASK, false)); ++} ++ + void + _initialize_amd64_tdep (void) + { +@@ -3326,6 +3334,11 @@ _initialize_amd64_tdep (void) + selftests::record_xml_tdesc (a.xml, tdesc); + } + #endif /* GDB_SELF_TEST */ ++ ++ /* Genode */ ++ gdbarch_register_osabi(bfd_arch_i386, bfd_mach_x86_64, ++ GDB_OSABI_GENODE, amd64_genode_init_abi); ++ /* /Genode */ + } + + +diff --git a/gdb/defs.h b/gdb/defs.h +index fc42170..6a43bf4 100644 +--- a/gdb/defs.h ++++ b/gdb/defs.h +@@ -495,6 +495,7 @@ enum gdb_osabi + GDB_OSABI_LYNXOS178, + GDB_OSABI_NEWLIB, + GDB_OSABI_SDE, ++ GDB_OSABI_GENODE, + + GDB_OSABI_INVALID /* keep this last */ + }; +diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c +index 18e6e77..fe2453c 100644 +--- a/gdb/i386-tdep.c ++++ b/gdb/i386-tdep.c +@@ -9051,6 +9051,11 @@ Show Intel Memory Protection Extensions specific variables."), + gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_SVR4, + i386_svr4_init_abi); + ++ /* Genode */ ++ gdbarch_register_osabi(bfd_arch_i386, 0, GDB_OSABI_GENODE, ++ i386_elf_init_abi); ++ /* /Genode */ ++ + /* Initialize the i386-specific register groups. */ + i386_init_reggroups (); + +diff --git a/gdb/osabi.c b/gdb/osabi.c +index 7d0540b..a68eea6 100644 +--- a/gdb/osabi.c ++++ b/gdb/osabi.c +@@ -80,6 +80,7 @@ static const struct osabi_names gdb_osabi_names[] = + { "LynxOS178", NULL }, + { "Newlib", NULL }, + { "SDE", NULL }, ++ { "Genode", NULL }, + + { "", NULL } + }; +@@ -562,6 +563,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) ++ osabi = GDB_OSABI_GENODE; ++/* /Genode */ ++ + break; + + case ELFOSABI_FREEBSD: 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 5ddca3b25..3ec38f164 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/gdbserver_genode.patch +++ b/repos/ports/src/noux-pkg/gdb/patches/gdbserver_genode.patch @@ -4,95 +4,210 @@ From: Christian Prochaska --- - gdb/gdbserver/linux-arm-low.c | 13 +++++ - gdb/gdbserver/linux-low.c | 114 +++++++++++++++++++++++++++++++++++++++++ - gdb/gdbserver/linux-low.h | 2 + - gdb/gdbserver/linux-x86-low.c | 53 +++++++++++++++++++ - gdb/gdbserver/remote-utils.c | 12 ++++ - gdb/gdbserver/server.c | 30 +++++++++-- - gdb/gdbserver/server.h | 4 + - 7 files changed, 217 insertions(+), 11 deletions(-) + gdb/common/common-defs.h | 8 + + gdb/common/gdb_tilde_expand.c | 10 ++ + gdb/common/pathstuff.c | 2 + gdb/gdbserver/linux-aarch32-low.c | 4 + + gdb/gdbserver/linux-arm-low.c | 8 + + gdb/gdbserver/linux-low.c | 168 ++++++++++++++++++++++++++++++ + gdb/gdbserver/linux-low.h | 5 + + gdb/gdbserver/linux-x86-low.c | 111 +++++++++++++++++++- + gdb/gdbserver/linux-x86-tdesc-selftest.c | 31 ++++++ + gdb/gdbserver/linux-x86-tdesc.c | 8 + + gdb/gdbserver/remote-utils.c | 11 ++ + gdb/gdbserver/server.c | 36 ++++++ + gdb/gdbserver/server.h | 4 + + gdb/nat/fork-inferior.c | 4 - + gdb/nat/gdb_ptrace.h | 2 + gdb/nat/linux-ptrace.c | 17 +++ + gdb/nat/linux-ptrace.h | 4 + + 17 files changed, 418 insertions(+), 15 deletions(-) -diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c -index babb20c..23d9e60 100644 ---- a/gdb/gdbserver/linux-arm-low.c -+++ b/gdb/gdbserver/linux-arm-low.c -@@ -25,6 +25,9 @@ - #ifndef ELFMAG0 - #include - #endif -+#ifdef __GENODE__ -+#include -+#endif - #include +diff --git a/gdb/common/common-defs.h b/gdb/common/common-defs.h +index eb0ec21..4dc07ce 100644 +--- a/gdb/common/common-defs.h ++++ b/gdb/common/common-defs.h +@@ -28,7 +28,9 @@ + #undef PACKAGE_TARNAME - /* Defined in auto-generated files. */ -@@ -209,7 +212,11 @@ static const unsigned short thumb2_breakpoint[] = { 0xf7f0, 0xa000 }; + #ifdef GDBSERVER ++#ifndef __GENODE__ + #include "build-gnulib-gdbserver/config.h" ++#endif /* __GENODE__ */ + #else + #include "build-gnulib/config.h" + #endif +@@ -69,9 +71,11 @@ + #include /* for strcasecmp and strncasecmp */ + #endif + #include ++#ifndef __GENODE__ + #include +- ++#endif /* __GENODE__ */ + #include "ansidecl.h" ++#ifndef __GENODE__ + /* 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 +@@ -79,7 +83,7 @@ + is compatible with ATTRIBUTE_PRINTF, simply use it. */ + #undef ATTRIBUTE_PRINTF + #define ATTRIBUTE_PRINTF _GL_ATTRIBUTE_FORMAT_PRINTF +- ++#endif /* __GENODE__ */ + #include "libiberty.h" + #include "pathmax.h" + #include "gdb/signals.h" +diff --git a/gdb/common/gdb_tilde_expand.c b/gdb/common/gdb_tilde_expand.c +index fcb9796..bd77a83 100644 +--- a/gdb/common/gdb_tilde_expand.c ++++ b/gdb/common/gdb_tilde_expand.c +@@ -71,7 +71,12 @@ private: + std::string + gdb_tilde_expand (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 /* __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 +diff --git a/gdb/common/pathstuff.c b/gdb/common/pathstuff.c +index 8c4093f..db3c23d 100644 +--- a/gdb/common/pathstuff.c ++++ b/gdb/common/pathstuff.c +@@ -55,6 +55,7 @@ gdb_realpath (const char *filename) + does not exist locally), we rely instead on GetFullPathName to + perform the canonicalization. */ + ++#ifndef __GENODE__ + #if defined (_WIN32) + { + char buf[MAX_PATH]; +@@ -75,6 +76,7 @@ gdb_realpath (const char *filename) + return gdb::unique_xmalloc_ptr (rp); + } + #endif ++#endif /* __GENODE__ */ + + /* This system is a lost cause, just dup the buffer. */ + return gdb::unique_xmalloc_ptr (xstrdup (filename)); +diff --git a/gdb/gdbserver/linux-aarch32-low.c b/gdb/gdbserver/linux-aarch32-low.c +index 12c11a4..c42b5bb 100644 +--- a/gdb/gdbserver/linux-aarch32-low.c ++++ b/gdb/gdbserver/linux-aarch32-low.c +@@ -35,7 +35,11 @@ is used for gdbserver, so single threaded debugging should work OK, but for multi-threaded debugging we only insert the current ABI's breakpoint instruction. For now at least. */ +#ifdef __GENODE__ -+static const unsigned long arm_eabi_breakpoint = 0xe7ffdefe; ++#define arm_eabi_breakpoint 0xe7ffdefeUL +#else - static const unsigned long arm_eabi_breakpoint = 0xe7f001f0; + #define arm_eabi_breakpoint 0xe7f001f0UL +#endif - static int - arm_breakpoint_at (CORE_ADDR where) -@@ -306,6 +313,11 @@ static void - arm_arch_setup (void) - { - arm_hwcap = 0; -+ + #if (defined __ARM_EABI__ || defined __aarch64__) + static const unsigned long arm_breakpoint = arm_eabi_breakpoint; +diff --git a/gdb/gdbserver/linux-arm-low.c b/gdb/gdbserver/linux-arm-low.c +index 6c2dcea..b682f96 100644 +--- a/gdb/gdbserver/linux-arm-low.c ++++ b/gdb/gdbserver/linux-arm-low.c +@@ -30,6 +30,9 @@ + #include + #endif + #include "nat/gdb_ptrace.h" ++#ifdef __GENODE__ ++#include ++#endif + #include + #include + +@@ -878,6 +881,10 @@ arm_read_description (void) + /* Query hardware watchpoint/breakpoint capabilities. */ + arm_linux_init_hwbp_cap (pid); + +#ifndef __GENODE__ + + /* Genode: 'init_registers_arm_with_*()' functions not generated */ + if (arm_get_hwcap (&arm_hwcap) == 0) - { - init_registers_arm (); -@@ -347,6 +359,7 @@ arm_arch_setup (void) + return tdesc_arm; - return; +@@ -910,6 +917,7 @@ arm_read_description (void) + + return result; } +#endif /* The default configuration uses legacy FPA registers, probably simulated. */ diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c -index e597e2f..62215fc 100644 +index 7c396ae..c684d9b 100644 --- a/gdb/gdbserver/linux-low.c +++ b/gdb/gdbserver/linux-low.c -@@ -20,6 +20,10 @@ - #include "server.h" - #include "linux-low.h" - +@@ -27,6 +27,11 @@ + #include "nat/linux-waitpid.h" + #include "gdb_wait.h" + #include "nat/gdb_ptrace.h" ++ +#ifdef __GENODE__ +#include "genode-low.h" +#endif + - #include - #include - #include -@@ -606,6 +610,7 @@ linux_attach_lwp_1 (unsigned long lwpid, int initial) - ptid_t ptid; - struct lwp_info *new_lwp; - -+#ifndef __GENODE__ - if (ptrace (PTRACE_ATTACH, lwpid, 0, 0) != 0) - { - if (!initial) -@@ -621,6 +626,7 @@ linux_attach_lwp_1 (unsigned long lwpid, int initial) - error ("Cannot attach to lwp %ld: %s (%d)\n", lwpid, - strerror (errno), errno); - } + #include "nat/linux-ptrace.h" + #include "nat/linux-procfs.h" + #include "nat/linux-personality.h" +@@ -719,7 +724,11 @@ handle_extended_wait (struct lwp_info **orig_event_lwp, int wstat) + /* Set the event status. */ + event_lwp->waitstatus.kind = TARGET_WAITKIND_EXECD; + event_lwp->waitstatus.value.execd_pathname ++#ifdef __GENODE__ ++ = xstrdup ("target"); ++#else + = xstrdup (linux_proc_pid_to_exec_file (lwpid_of (event_thr))); +#endif - if (initial) - /* NOTE/FIXME: This lwp might have not been the tgid. */ -@@ -637,6 +643,9 @@ linux_attach_lwp_1 (unsigned long lwpid, int initial) - new_lwp = (struct lwp_info *) add_lwp (ptid); - add_thread (ptid, new_lwp); + /* Mark the exec status as pending. */ + event_lwp->stopped = 1; +@@ -1005,8 +1014,10 @@ linux_create_inferior (const char *program, + ptid_t ptid; + + { ++#ifndef __GENODE__ + maybe_disable_address_space_randomization restore_personality + (cs.disable_randomization); ++#endif /* __GENODE__ */ + std::string str_program_args = stringify_argv (program_args); + + pid = fork_inferior (program, +@@ -1054,12 +1065,17 @@ linux_attach_lwp (ptid_t ptid) + struct lwp_info *new_lwp; + int lwpid = ptid.lwp (); + ++#ifndef __GENODE__ + if (ptrace (PTRACE_ATTACH, lwpid, (PTRACE_TYPE_ARG3) 0, (PTRACE_TYPE_ARG4) 0) + != 0) + return errno; ++#endif + + new_lwp = add_lwp (ptid); +#ifdef __GENODE__ + new_lwp->stopped = 1; @@ -100,91 +215,117 @@ index e597e2f..62215fc 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; -@@ -675,6 +684,7 @@ linux_attach_lwp_1 (unsigned long lwpid, int initial) +@@ -1126,6 +1142,7 @@ linux_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; +#endif - } - void -@@ -689,6 +699,7 @@ linux_attach (unsigned long pid) - linux_attach_lwp_1 (pid, 1); - linux_add_process (pid, 1); + return 0; + } +@@ -1200,6 +1217,7 @@ linux_attach (unsigned long pid) + + proc = linux_add_process (pid, 1); +#ifndef __GENODE__ - if (!non_stop) - { - struct thread_info *thread; -@@ -698,6 +709,7 @@ linux_attach (unsigned long pid) - thread = find_thread_ptid (ptid_build (pid, pid, 0)); - thread->last_resume_kind = resume_stop; + /* 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)); +@@ -1247,6 +1265,7 @@ linux_attach (unsigned long pid) + gdb_assert (proc->tdesc != NULL); } -+#endif ++#endif return 0; } -@@ -812,7 +824,11 @@ linux_kill (int pid) - return 0; - } + +@@ -1507,14 +1526,21 @@ get_detach_signal (struct thread_info *thread) + + /* Detach from LWP. */ +#ifdef __GENODE__ -+int ++void +#else - static int -+#endif - linux_detach_one_lwp (struct inferior_list_entry *entry, void *args) + static void ++#endif /* __GENODE__ */ + linux_detach_one_lwp (struct lwp_info *lwp) { - struct thread_info *thread = (struct thread_info *) entry; -@@ -822,6 +838,7 @@ linux_detach_one_lwp (struct inferior_list_entry *entry, void *args) - if (ptid_get_pid (entry->id) != pid) - return 0; - + struct thread_info *thread = get_lwp_thread (lwp); +#ifndef __GENODE__ - /* If this process is stopped but is expecting a SIGSTOP, then make - sure we take care of that now. This isn't absolutely guaranteed - to collect the SIGSTOP, but is fairly likely to. */ -@@ -833,13 +850,16 @@ linux_detach_one_lwp (struct inferior_list_entry *entry, void *args) - linux_resume_one_lwp (lwp, 0, 0, NULL); - linux_wait_for_event (lwp->head.id, &wstat, __WALL); + int sig; ++#endif /* __GENODE__ */ + int lwpid; + + /* If there is a pending SIGSTOP, get rid of it. */ ++#ifndef __GENODE__ + if (lwp->stop_expected) + { + if (debug_threads) +@@ -1524,7 +1550,9 @@ linux_detach_one_lwp (struct lwp_info *lwp) + kill_lwp (lwpid_of (thread), SIGCONT); + lwp->stop_expected = 0; } +#endif - /* Flush any pending changes to the process's registers. */ - regcache_invalidate_one ((struct inferior_list_entry *) - get_lwp_thread (lwp)); - +#ifndef __GENODE__ - /* Finally, let it resume. */ - ptrace (PTRACE_DETACH, lwpid_of (lwp), 0, 0); + /* Pass on any pending signal for this thread. */ + sig = get_detach_signal (thread); + +@@ -1587,6 +1615,7 @@ linux_detach_one_lwp (struct lwp_info *lwp) + target_pid_to_str (ptid_of (thread)), + strsignal (sig)); + } +#endif delete_lwp (lwp); - return 0; -@@ -1071,6 +1091,10 @@ retry: + } +@@ -1874,6 +1903,7 @@ iterate_over_lwps (ptid_t filter, + static void + check_zombie_leaders (void) + { ++#ifndef __GENODE__ + for_each_process ([] (process_info *proc) { + pid_t leader_pid = pid_of (proc); + struct lwp_info *leader_lp; +@@ -1928,6 +1958,7 @@ check_zombie_leaders (void) + delete_lwp (leader_lp); + } + }); ++#endif /* __GENODE__ */ + } - if (WIFSTOPPED (*wstatp) && WSTOPSIG (*wstatp) == SIGTRAP) - { -+#ifdef __GENODE__ -+ /* no watchpoint support yet */ -+ child->stopped_by_watchpoint = 0; -+#else - if (the_low_target.stopped_by_watchpoint == NULL) + /* Callback for `find_thread'. Returns the first LWP that is not +@@ -2730,11 +2761,13 @@ linux_wait_for_event_filtered (ptid_t wait_ptid, ptid_t filter_ptid, + + if (ret > 0) { - child->stopped_by_watchpoint = 0; -@@ -1096,7 +1120,8 @@ retry: ++#ifndef __GENODE__ + if (debug_threads) + { + debug_printf ("LLW: waitpid %ld received %s\n", + (long) ret, status_to_str (*wstatp)); + } ++#endif /* __GENODE__ */ - current_inferior = saved_inferior; - } -- } -+#endif -+ } - - /* Store the STOP_PC, with adjustment applied. This depends on the - architecture being defined already (so that CHILD has a valid -@@ -2469,18 +2494,22 @@ linux_wait (ptid_t ptid, - if (debug_threads) - fprintf (stderr, "linux_wait: [%s]\n", target_pid_to_str (ptid)); + /* Filter all events. IOW, leave all events pending. We'll + randomly select an event LWP out of all that have events +@@ -3036,11 +3069,12 @@ linux_stabilize_threads (void) + static ptid_t + ignore_event (struct target_waitstatus *ourstatus) + { ++#ifndef __GENODE__ + /* If we got an event, there may still be others, as a single + SIGCHLD can indicate more than one child stopped. This forces + another target_wait call. */ + async_file_mark (); +- ++#endif /* __GENODE__ */ + ourstatus->kind = TARGET_WAITKIND_IGNORE; + return null_ptid; + } +@@ -3877,9 +3911,11 @@ linux_wait (ptid_t ptid, + { + ptid_t event_ptid; +#ifndef __GENODE__ /* Flush the async file first. */ @@ -192,22 +333,44 @@ index e597e2f..62215fc 100644 async_file_flush (); +#endif - event_ptid = linux_wait_1 (ptid, ourstatus, target_options); + do + { +@@ -3889,12 +3925,14 @@ linux_wait (ptid_t ptid, + && event_ptid == null_ptid + && ourstatus->kind == TARGET_WAITKIND_IGNORE); +#ifndef __GENODE__ /* If at least one stop was reported, there may be more. A single SIGCHLD can signal more than one child stop. */ if (target_is_async_p () && (target_options & TARGET_WNOHANG) != 0 - && !ptid_equal (event_ptid, null_ptid)) + && event_ptid != null_ptid) async_file_mark (); +#endif return event_ptid; } -@@ -2958,10 +2987,25 @@ lwp %ld wants to get out of fast tracepoint jump pad single-stepping\n", - lwp->stopped = 0; - lwp->stopped_by_watchpoint = 0; +@@ -3904,6 +3942,9 @@ linux_wait (ptid_t ptid, + static int + kill_lwp (unsigned long lwpid, int signo) + { ++#ifdef __GENODE__ ++ return kill (lwpid, signo); ++#else + int ret; + + errno = 0; +@@ -3915,6 +3956,7 @@ kill_lwp (unsigned long lwpid, int signo) + perror_with_name (("tkill")); + } + return ret; ++#endif + } + + void +@@ -4447,6 +4489,21 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp, + regcache_invalidate_thread (thread); + errno = 0; lwp->stepping = step; + +#ifdef __GENODE__ @@ -220,20 +383,57 @@ index e597e2f..62215fc 100644 + if (lwp->stop_expected) + return; + -+ genode_continue_thread(lwpid_of(lwp), step); ++ genode_continue_thread(lwpid_of(thread), step); + +#else - ptrace (step ? PTRACE_SINGLESTEP : PTRACE_CONT, lwpid_of (lwp), 0, ++ + if (step) + ptrace_request = PTRACE_SINGLESTEP; + else if (gdb_catching_syscalls_p (lwp)) +@@ -4459,6 +4516,7 @@ linux_resume_one_lwp_throw (struct lwp_info *lwp, /* Coerce to a uintptr_t first to avoid potential gcc warning of coercing an 8 byte integer to a 4 byte pointer. */ - (PTRACE_ARG4_TYPE) (uintptr_t) signal); + (PTRACE_TYPE_ARG4) (uintptr_t) signal); +#endif - current_inferior = saved_inferior; + current_thread = saved_thread; if (errno) -@@ -5009,6 +5053,13 @@ linux_core_of_thread (ptid_t ptid) +@@ -4496,7 +4554,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. */ +- ++#ifndef __GENODE__ + /* Don't assume anything if /proc/PID/status can't be read. */ + if (linux_proc_pid_is_trace_stopped_nowarn (lwpid_of (thread)) == 0) + { +@@ -4504,6 +4562,7 @@ check_ptrace_stopped_lwp_gone (struct lwp_info *lp) + lp->status_pending_p = 0; + return 1; + } ++#endif /* __GENODE__ */ + return 0; + } + +@@ -5374,6 +5433,7 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, + this process mode. */ + disable_regset (regsets_info, regset); + } ++#ifndef __GENODE__ + else if (errno == ENODATA) + { + /* ENODATA may be returned if the regset is currently +@@ -5386,6 +5446,7 @@ regsets_fetch_inferior_registers (struct regsets_info *regsets_info, + already gone, in which case we simply ignore attempts + to read its registers. */ + } ++#endif + else + { + char s[256]; +@@ -6566,6 +6627,13 @@ linux_read_loadmap (const char *annex, CORE_ADDR offset, static void - linux_process_qsupported (const char *query) + linux_process_qsupported (char **features, int count) { +#ifdef __GENODE__ + /* @@ -243,11 +443,27 @@ index e597e2f..62215fc 100644 + genode_stop_all_threads(); +#endif if (the_low_target.process_qsupported != NULL) - the_low_target.process_qsupported (query); + the_low_target.process_qsupported (features, count); } -@@ -5110,26 +5161,56 @@ linux_emit_ops (void) - static struct target_ops linux_target_ops = { +@@ -6691,6 +6759,7 @@ linux_get_min_fast_tracepoint_insn_len (void) + return (*the_low_target.get_min_fast_tracepoint_insn_len) (); + } + ++#ifndef __GENODE__ + /* Extract &phdr and num_phdr in the inferior. Return 0 on success. */ + + static int +@@ -7176,6 +7245,7 @@ linux_qxfer_libraries_svr4 (const char *annex, unsigned char *readbuf, + + return len; + } ++#endif /* __GENODE__ */ + + #ifdef HAVE_LINUX_BTRACE + +@@ -7436,25 +7506,52 @@ static struct target_ops linux_target_ops = { linux_create_inferior, + linux_post_create_inferior, linux_attach, +#ifndef __GENODE__ linux_kill, @@ -287,22 +503,34 @@ index e597e2f..62215fc 100644 linux_request_interrupt, +#ifndef __GENODE__ linux_read_auxv, + linux_supports_z_point_type, +#else + NULL, ++ NULL, +#endif linux_insert_point, linux_remove_point, +#ifndef __GENODE__ + linux_stopped_by_sw_breakpoint, + linux_supports_stopped_by_sw_breakpoint, + linux_stopped_by_hw_breakpoint, +@@ -7462,6 +7559,15 @@ static struct target_ops linux_target_ops = { + linux_supports_hardware_single_step, linux_stopped_by_watchpoint, linux_stopped_data_address, +#else + NULL, + NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, +#endif - #if defined(__UCLIBC__) && defined(HAS_NOMMU) - linux_read_offsets, - #else -@@ -5140,6 +5221,7 @@ static struct target_ops linux_target_ops = { + #if defined(__UCLIBC__) && defined(HAS_NOMMU) \ + && defined(PT_TEXT_ADDR) && defined(PT_DATA_ADDR) \ + && defined(PT_TEXT_END_ADDR) +@@ -7474,6 +7580,7 @@ static struct target_ops linux_target_ops = { #else NULL, #endif @@ -310,10 +538,10 @@ index e597e2f..62215fc 100644 linux_qxfer_spu, hostio_last_error_from_errno, linux_qxfer_osdata, -@@ -5148,13 +5230,28 @@ static struct target_ops linux_target_ops = { - linux_async, - linux_start_non_stop, - linux_supports_multi_process, +@@ -7486,14 +7593,34 @@ static struct target_ops linux_target_ops = { + linux_supports_vfork_events, + linux_supports_exec_events, + linux_handle_new_gdb_connection, +#else + NULL, + NULL, @@ -323,6 +551,10 @@ index e597e2f..62215fc 100644 + NULL, + NULL, + NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, +#endif #ifdef USE_THREAD_DB thread_db_handle_monitor_command, @@ -330,19 +562,21 @@ index e597e2f..62215fc 100644 NULL, #endif +#ifndef __GENODE__ - linux_core_of_thread, + linux_common_core_of_thread, + linux_read_loadmap, +#else + NULL, ++ NULL, +#endif linux_process_qsupported, +#ifndef __GENODE__ linux_supports_tracepoints, linux_read_pc, linux_write_pc, -@@ -5166,6 +5263,19 @@ static struct target_ops linux_target_ops = { - linux_stabilize_threads, - linux_install_fast_tracepoint_jump_pad, - linux_emit_ops +@@ -7525,7 +7652,34 @@ static struct target_ops linux_target_ops = { + linux_mntns_unlink, + linux_mntns_readlink, + linux_breakpoint_kind_from_pc, +#else + NULL, + NULL, @@ -354,64 +588,94 @@ index e597e2f..62215fc 100644 + NULL, + NULL, + NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++#endif + linux_sw_breakpoint_from_kind, ++#ifndef __GENODE__ + linux_proc_tid_get_name, + linux_breakpoint_kind_from_current_state, + linux_supports_software_single_step, +@@ -7536,6 +7690,14 @@ static struct target_ops linux_target_ops = { + #else + NULL, + #endif ++#else ++ NULL, ++ NULL, ++ NULL, ++ NULL, ++ NULL, + NULL -+#endif ++#endif /* __GENODE__ */ }; - static void -@@ -5187,7 +5297,9 @@ initialize_low (void) - set_breakpoint_data (the_low_target.breakpoint, - the_low_target.breakpoint_len); - linux_init_signals (); -+#ifndef __GENODE__ - linux_test_for_tracefork (); -+#endif #ifdef HAVE_LINUX_REGSETS - for (num_regsets = 0; target_regsets[num_regsets].size >= 0; num_regsets++) - ; +@@ -7557,8 +7719,10 @@ initialize_low (void) + memset (&sigchld_action, 0, sizeof (sigchld_action)); + set_target_ops (&linux_target_ops); + ++#ifndef __GENODE__ + linux_ptrace_init_warnings (); + linux_proc_init_warnings (); ++#endif + + sigchld_action.sa_handler = sigchld_handler; + sigemptyset (&sigchld_action.sa_mask); diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h -index d449e1b..0bbcbfd 100644 +index 79b3311..0b7f4ed 100644 --- a/gdb/gdbserver/linux-low.h +++ b/gdb/gdbserver/linux-low.h -@@ -22,7 +22,9 @@ - #endif +@@ -17,11 +17,16 @@ + along with this program. If not, see . */ + #include "nat/linux-nat.h" ++#ifndef __GENODE__ + #include "nat/gdb_thread_db.h" ++#endif #include + + #include "gdbthread.h" ++ +#ifndef __GENODE__ #include "gdb_proc_service.h" +#endif - #ifdef HAVE_LINUX_REGSETS - typedef void (*regset_fill_func) (struct regcache *, void *); + /* Included for ptrace type definitions. */ + #include "nat/linux-ptrace.h" diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c -index 82dcf83..e98e3bd 100644 +index 80b4380..b8984c9 100644 --- a/gdb/gdbserver/linux-x86-low.c +++ b/gdb/gdbserver/linux-x86-low.c -@@ -28,8 +28,17 @@ - #include "i386-xstate.h" - #include "elf/common.h" +@@ -31,7 +31,9 @@ + #include "nat/amd64-linux-siginfo.h" + #endif +#ifndef __GENODE__ #include "gdb_proc_service.h" +#endif + /* Don't include elf/common.h if linux/elf.h got included by + gdb_proc_service.h. */ + #ifndef ELFMAG0 +@@ -52,11 +54,23 @@ static struct target_desc *tdesc_amd64_linux_no_xml; + #endif + static struct target_desc *tdesc_i386_linux_no_xml; -+#ifdef __GENODE__ -+/* Defined in auto-generated file i386.c. */ -+void init_registers_i386 (void); -+static inline void init_registers_i386_linux(void) { init_registers_i386(); } -+void init_registers_i386_avx (void); -+static inline void init_registers_i386_avx_linux(void) { init_registers_i386_avx(); } -+#else - /* Defined in auto-generated file i386-linux.c. */ - void init_registers_i386_linux (void); - /* Defined in auto-generated file amd64-linux.c. */ -@@ -40,10 +49,24 @@ void init_registers_i386_avx_linux (void); - void init_registers_amd64_avx_linux (void); - /* Defined in auto-generated file i386-mmx-linux.c. */ - void init_registers_i386_mmx_linux (void); -+#endif - +- static unsigned char jump_insn[] = { 0xe9, 0, 0, 0, 0 }; + static unsigned char small_jump_insn[] = { 0x66, 0xe9, 0, 0 }; /* Backward compatibility for gdb without XML support. */ +#ifdef __GENODE__ @@ -430,45 +694,135 @@ index 82dcf83..e98e3bd 100644 static const char *xmltarget_i386_linux_no_xml = "@\ i386\ -@@ -57,7 +80,15 @@ static const char *xmltarget_amd64_linux_no_xml = "@\ +@@ -70,7 +84,17 @@ static const char *xmltarget_amd64_linux_no_xml = "@\ "; #endif +#endif /* __GENODE__ */ + +#ifdef __GENODE__ -+#ifndef __x86_64__ ++#ifdef __x86_64__ ++#include "amd64.h" ++#else +#include "i386.h" +#endif /* __x86_64__ */ +#else #include +#endif #include - #include + #include "nat/gdb_ptrace.h" #include -@@ -273,8 +304,10 @@ x86_fill_gregset (struct regcache *regcache, void *buf) +@@ -119,7 +143,11 @@ static /*const*/ int i386_regmap[] = + #define ORIG_EAX ORIG_RAX + #define REGSIZE 8 + +-static const int x86_64_regmap[] = ++static ++#ifndef __GENODE__ ++const ++#endif ++int x86_64_regmap[] = + { + RAX * 8, RBX * 8, RCX * 8, RDX * 8, + RSI * 8, RDI * 8, RBP * 8, RSP * 8, +@@ -132,6 +160,7 @@ static const int x86_64_regmap[] = + -1, -1, -1, -1, -1, -1, -1, -1, + -1, + -1, -1, -1, -1, -1, -1, -1, -1, ++#ifndef __GENODE__ + ORIG_RAX * 8, + #ifdef HAVE_STRUCT_USER_REGS_STRUCT_FS_BASE + 21 * 8, 22 * 8, +@@ -150,6 +179,7 @@ static const int x86_64_regmap[] = + -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, + -1 /* pkru */ ++#endif + }; + + #define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof (x86_64_regmap[0])) +@@ -191,6 +221,7 @@ is_64bit_tdesc (void) + + /* Called by libthread_db. */ + ++#ifndef __GENODE__ + ps_err_e + ps_get_thread_area (struct ps_prochandle *ph, + lwpid_t lwpid, int idx, void **base) +@@ -229,6 +260,7 @@ ps_get_thread_area (struct ps_prochandle *ph, + return PS_OK; + } + } ++#endif + + /* Get the thread area address. This is used to recognize which + thread is which when tracing with the in-process agent library. We +@@ -284,7 +316,11 @@ x86_cannot_store_register (int regno) + { + #ifdef __x86_64__ + if (is_64bit_tdesc ()) ++#ifdef __GENODE__ ++ return regno >= X86_64_NUM_REGS; ++#else + return 0; ++#endif /* GENODE */ + #endif + + return regno >= I386_NUM_REGS; +@@ -295,12 +331,30 @@ x86_cannot_fetch_register (int regno) + { + #ifdef __x86_64__ + if (is_64bit_tdesc ()) ++#ifdef __GENODE__ ++ return regno >= X86_64_NUM_REGS; ++#else + return 0; ++#endif /* GENODE */ + #endif + + return regno >= I386_NUM_REGS; + } + ++#ifdef __x86_64__ ++static int ++x86_64_cannot_store_register (int regno) ++{ ++ return regno >= X86_64_NUM_REGS; ++} ++ ++static int ++x86_64_cannot_fetch_register (int regno) ++{ ++ return regno >= X86_64_NUM_REGS; ++} ++#endif /* __x86_64__ */ ++ + static void + x86_fill_gregset (struct regcache *regcache, void *buf) + { +@@ -337,8 +391,10 @@ 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]); +#ifndef __GENODE__ collect_register_by_name (regcache, "orig_eax", - ((char *) buf) + ORIG_EAX * 4); + ((char *) buf) + ORIG_EAX * REGSIZE); +#endif } static void -@@ -295,8 +328,10 @@ x86_store_gregset (struct regcache *regcache, const void *buf) +@@ -372,8 +428,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]); +#ifndef __GENODE__ supply_register_by_name (regcache, "orig_eax", - ((char *) buf) + ORIG_EAX * 4); + ((char *) buf) + ORIG_EAX * REGSIZE); +#endif } static void -@@ -414,7 +449,15 @@ x86_set_pc (struct regcache *regcache, CORE_ADDR pc) +@@ -493,7 +551,15 @@ x86_set_pc (struct regcache *regcache, CORE_ADDR pc) } } @@ -477,14 +831,14 @@ index 82dcf83..e98e3bd 100644 + * serve as breakpoint instruction for the GDB monitor. Instead, the 'HLT' + * instruction gets used. It's a privileged instruction which triggers an + * exception when executed in user mode */ -+static const unsigned char x86_breakpoint[] = { 0xF4 }; ++static const gdb_byte x86_breakpoint[] = { 0xF4 }; +#else - static const unsigned char x86_breakpoint[] = { 0xCC }; + static const gdb_byte x86_breakpoint[] = { 0xCC }; +#endif #define x86_breakpoint_len 1 static int -@@ -423,7 +466,7 @@ x86_breakpoint_at (CORE_ADDR pc) +@@ -502,7 +568,7 @@ x86_breakpoint_at (CORE_ADDR pc) unsigned char c; (*the_target->read_memory) (pc, &c, 1); @@ -493,9 +847,73 @@ index 82dcf83..e98e3bd 100644 return 1; return 0; -@@ -2561,7 +2604,11 @@ struct linux_target_ops the_low_target = - x86_breakpoint, - x86_breakpoint_len, +@@ -669,6 +735,7 @@ x86_debug_reg_state (pid_t pid) + as debugging it with a 32-bit GDBSERVER, we do the 32-bit <-> 64-bit + conversion in-place ourselves. */ + ++#ifndef __GENODE__ + /* Convert a ptrace/host siginfo object, into/from the siginfo in the + layout of the inferiors' architecture. Returns true if any + conversion was done; false otherwise. If DIRECTION is 1, then copy +@@ -695,6 +762,7 @@ x86_siginfo_fixup (siginfo_t *ptrace, gdb_byte *inf, int direction) + + return 0; + } ++#endif + + static int use_xml; + +@@ -735,6 +803,13 @@ int have_ptrace_getfpxregs = + static const struct target_desc * + x86_linux_read_description (void) + { ++#ifdef __GENODE__ ++#ifdef __x86_64__ ++ return amd64_linux_read_description(X86_XSTATE_SSE_MASK, false); ++#else ++ return i386_linux_read_description(X86_XSTATE_SSE); ++#endif ++#else + unsigned int machine; + int is_elf64; + int xcr0_features; +@@ -850,7 +925,7 @@ x86_linux_read_description (void) + + return tdesc; + } +- ++#endif /* __GENODE__ */ + gdb_assert_not_reached ("failed to return tdesc"); + } + +@@ -925,13 +1000,24 @@ static struct regsets_info x86_regsets_info = + }; + + #ifdef __x86_64__ ++static struct usrregs_info amd64_linux_usrregs_info = ++ { ++ X86_64_NUM_REGS, ++ x86_64_regmap, ++ }; ++ + static struct regs_info amd64_linux_regs_info = + { + NULL, /* regset_bitmap */ ++#ifdef __GENODE__ ++ &amd64_linux_usrregs_info, ++#else + NULL, /* usrregs_info */ ++#endif + &x86_regsets_info + }; + #endif ++ + static struct usrregs_info i386_linux_usrregs_info = + { + I386_NUM_REGS, +@@ -2852,12 +2938,20 @@ struct linux_target_ops the_low_target = + NULL, /* breakpoint_kind_from_pc */ + x86_sw_breakpoint_from_kind, NULL, +#ifndef __GENODE__ 1, @@ -503,42 +921,176 @@ index 82dcf83..e98e3bd 100644 + 0, /* With the HLT instruction, the PC does not get incremented */ +#endif x86_breakpoint_at, + x86_supports_z_point_type, x86_insert_point, x86_remove_point, -@@ -2576,7 +2623,11 @@ struct linux_target_ops the_low_target = - x86_siginfo_fixup, - x86_linux_new_process, - x86_linux_new_thread, +#ifndef __GENODE__ + x86_stopped_by_watchpoint, ++#else ++ NULL, ++#endif + x86_stopped_data_address, + /* collect_ptrace_register/supply_ptrace_register are not needed in the + native i386 case (no registers smaller than an xfer unit), and are not +@@ -2865,13 +2959,22 @@ struct linux_target_ops the_low_target = + NULL, + NULL, + /* need to fix up i386 siginfo if host is amd64 */ ++#ifdef __GENODE__ ++ NULL, ++#else + x86_siginfo_fixup, ++#endif + x86_linux_new_process, + x86_linux_delete_process, + x86_linux_new_thread, + x86_linux_delete_thread, ++#ifndef __GENODE__ + x86_linux_new_fork, x86_linux_prepare_to_resume, +#else + NULL, ++ NULL, +#endif x86_linux_process_qsupported, x86_supports_tracepoints, x86_get_thread_area, +diff --git a/gdb/gdbserver/linux-x86-tdesc-selftest.c b/gdb/gdbserver/linux-x86-tdesc-selftest.c +index e840b77..c7d1e34 100644 +--- a/gdb/gdbserver/linux-x86-tdesc-selftest.c ++++ b/gdb/gdbserver/linux-x86-tdesc-selftest.c +@@ -21,6 +21,17 @@ + #include "common/selftest.h" + #include "x86-xstate.h" + ++#ifdef __GENODE__ ++/* Defined in auto-generated file i386.c. */ ++void init_registers_i386 (void); ++static inline void init_registers_i386_linux(void) { init_registers_i386(); } ++extern const struct target_desc *tdesc_i386_linux; ++ ++void init_registers_i386_avx (void); ++static inline void init_registers_i386_avx_linux(void) { init_registers_i386_avx(); } ++extern const struct target_desc *tdesc_i386_avx_linux; ++#else ++ + /* Defined in auto-generated file i386-linux.c. */ + void init_registers_i386_linux (void); + extern const struct target_desc *tdesc_i386_linux; +@@ -48,9 +59,20 @@ extern const struct target_desc *tdesc_i386_avx_mpx_avx512_pku_linux; + /* Defined in auto-generated file i386-mpx-linux.c. */ + void init_registers_i386_mpx_linux (void); + extern const struct target_desc *tdesc_i386_mpx_linux; ++#endif /* __GENODE__ */ + + #ifdef __x86_64__ + ++#ifdef __GENODE__ ++void init_registers_amd64 (void); ++static inline void init_registers_amd64_linux(void) { init_registers_amd64(); } ++extern const struct target_desc *tdesc_amd64_linux; ++ ++void init_registers_amd64_avx (void); ++static inline void init_registers_amd64_avx_linux(void) { init_registers_amd64_avx(); } ++extern const struct target_desc *tdesc_amd64_avx_linux; ++#else ++ + /* Defined in auto-generated file amd64-linux.c. */ + void init_registers_amd64_linux (void); + extern const struct target_desc *tdesc_amd64_linux; +@@ -87,6 +109,7 @@ extern const struct target_desc *tdesc_x32_avx_linux; + void init_registers_x32_avx_avx512_linux (void); + extern const struct target_desc *tdesc_x32_avx_avx512_linux; + ++#endif /* __GENODE__ */ + #endif + + namespace selftests { +@@ -157,27 +180,35 @@ void + initialize_low_tdesc () + { + init_registers_i386_linux (); ++#ifndef __GENODE__ + init_registers_i386_mmx_linux (); ++#endif /* __GENODE__ */ + init_registers_i386_avx_linux (); ++#ifndef __GENODE + init_registers_i386_mpx_linux (); + init_registers_i386_avx_mpx_linux (); + init_registers_i386_avx_avx512_linux (); + init_registers_i386_avx_mpx_avx512_pku_linux (); + + selftests::register_test ("i386-tdesc", selftests::tdesc::i386_tdesc_test); ++#endif /* __GENODE__ */ + + #ifdef __x86_64__ ++#ifndef __GENODE__ + init_registers_x32_linux (); + init_registers_x32_avx_linux (); + init_registers_x32_avx_avx512_linux (); ++#endif /* __GENODE__ */ + + init_registers_amd64_linux (); + init_registers_amd64_avx_linux (); ++#ifndef __GENODE__ + init_registers_amd64_mpx_linux (); + init_registers_amd64_avx_mpx_linux (); + init_registers_amd64_avx_avx512_linux (); + init_registers_amd64_avx_mpx_avx512_pku_linux (); + + selftests::register_test ("amd64-tdesc", selftests::tdesc::amd64_tdesc_test); ++#endif /* __GENODE__ */ + #endif + } +diff --git a/gdb/gdbserver/linux-x86-tdesc.c b/gdb/gdbserver/linux-x86-tdesc.c +index c3aa20c..e5a57c0 100644 +--- a/gdb/gdbserver/linux-x86-tdesc.c ++++ b/gdb/gdbserver/linux-x86-tdesc.c +@@ -87,7 +87,11 @@ i386_linux_read_description (uint64_t xcr0) + + if (*tdesc == NULL) + { ++#ifdef __GENODE__ ++ *tdesc = i386_create_target_description (xcr0, false); ++#else + *tdesc = i386_create_target_description (xcr0, true); ++#endif /* __GENODE__ */ + + init_target_desc (*tdesc, i386_expedite_regs); + } +@@ -118,7 +122,11 @@ amd64_linux_read_description (uint64_t xcr0, bool is_x32) + + if (*tdesc == NULL) + { ++#ifdef __GENODE__ ++ *tdesc = amd64_create_target_description (xcr0, is_x32, false, false); ++#else + *tdesc = amd64_create_target_description (xcr0, is_x32, true, true); ++#endif /* __GENODE__ */ + + init_target_desc (*tdesc, amd64_expedite_regs); + } diff --git a/gdb/gdbserver/remote-utils.c b/gdb/gdbserver/remote-utils.c -index 650ddf8..7a53e77 100644 +index 45d5c8d..7b6b1be 100644 --- a/gdb/gdbserver/remote-utils.c +++ b/gdb/gdbserver/remote-utils.c -@@ -21,6 +21,12 @@ - #include "server.h" - #include "terminal.h" - #include "target.h" +@@ -27,6 +27,12 @@ + #include "rsp-low.h" + #include "gdbthread.h" + #include + +#ifdef __GENODE__ +#include +#include "genode-low.h" +#endif + - #include - #include #if HAVE_SYS_IOCTL_H -@@ -106,8 +112,10 @@ struct sym_cache + #include + #endif +@@ -108,7 +114,10 @@ struct ui_file *gdb_stdlog; + + static int remote_is_stdio = 0; - int remote_debug = 0; - struct ui_file *gdb_stdlog; -- -static gdb_fildes_t remote_desc = INVALID_DESCRIPTOR; +#ifndef __GENODE__ +static @@ -548,37 +1100,72 @@ index 650ddf8..7a53e77 100644 /* FIXME headerize? */ diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c -index 2f4484f..124c98d 100644 +index bf6302b..b6a9494 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c -@@ -20,6 +20,11 @@ - - #include "server.h" - +@@ -28,6 +28,14 @@ + #if HAVE_SIGNAL_H + #include + #endif ++ +#ifdef __GENODE__ +#include "genode-low.h" +#include "linux-low.h" ++/* don't have the generated header with the declaration */ ++extern "C" char *strchrnul(const char *s, int c_in); +#endif + - #if HAVE_UNISTD_H - #include - #endif -@@ -2055,11 +2060,11 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len) + #include "gdb_vecs.h" + #include "gdb_wait.h" + #include "btrace-common.h" +@@ -70,7 +78,11 @@ static gdb_environ our_environ; + + /* We always try to start the inferior using a shell. */ + ++#ifdef __GENODE__ ++int startup_with_shell = 0; ++#else + int startup_with_shell = 1; ++#endif + + int server_waiting; + +@@ -1282,7 +1294,9 @@ handle_detach (char *own_buf) + need to hang around doing nothing, until the child is + gone. */ + join_inferior (process->pid); ++#ifndef __GENODE__ + exit (0); ++#endif /* __GENODE__ */ + } + } + } +@@ -3141,11 +3155,11 @@ handle_v_requests (char *own_buf, int packet_len, int *new_packet_len) return; } } - +#ifndef __GENODE__ - if (strncmp (own_buf, "vFile:", 6) == 0 + if (startswith (own_buf, "vFile:") && handle_vFile (own_buf, packet_len, new_packet_len)) return; - +#endif - if (strncmp (own_buf, "vAttach;", 8) == 0) + if (startswith (own_buf, "vAttach;")) { - if (!multi_process && target_running ()) -@@ -2449,7 +2454,11 @@ join_inferiors_callback (struct inferior_list_entry *entry) - } + if ((!extended_protocol || !cs.multi_process) && target_running ()) +@@ -3737,7 +3751,9 @@ captured_main (int argc, char *argv[]) + opened by remote_prepare. */ + notice_open_fds (); + ++#ifndef __GENODE__ + save_original_signals_state (false); ++#endif /* __GENODE__ */ + + /* We need to know whether the remote connection is stdio before + starting the inferior. Inferiors created in this scenario have +@@ -3942,7 +3958,11 @@ captured_main (int argc, char *argv[]) + /* Main function. */ int +#ifdef __GENODE__ @@ -587,29 +1174,20 @@ index 2f4484f..124c98d 100644 main (int argc, char *argv[]) +#endif { - int bad_attach; - int pid; -@@ -2754,6 +2763,9 @@ process_serial_event (void) + + TRY +@@ -4045,6 +4065,10 @@ process_serial_event (void) + } response_needed = 1; - i = 0; -+#ifdef __GENODE -+ if (debug_threads) printf("GDB command = %s\n", own_buf); ++#ifdef __GENODE__ ++ if (debug_threads) printf("GDB command = %s\n", cs.own_buf); +#endif - ch = own_buf[i++]; ++ + char ch = cs.own_buf[0]; switch (ch) { -@@ -2844,7 +2856,9 @@ process_serial_event (void) - gone. */ - for_each_inferior (&all_processes, - join_inferiors_callback); -+#ifndef __GENODE__ - exit (0); -+#endif - } - } - break; -@@ -3076,7 +3090,11 @@ process_serial_event (void) +@@ -4290,7 +4314,11 @@ process_serial_event (void) return 0; } else @@ -621,46 +1199,180 @@ index 2f4484f..124c98d 100644 case 'T': { -@@ -3140,14 +3158,16 @@ process_serial_event (void) - own_buf[0] = '\0'; +@@ -4365,7 +4393,9 @@ process_serial_event (void) + cs.own_buf[0] = '\0'; break; } - +#ifdef __GENODE__ -+ if (debug_threads) printf("GDBserver response = %s\n", own_buf); ++ if (debug_threads) printf("GDBserver response = %s\n", cs.own_buf); +#endif if (new_packet_len != -1) - putpkt_binary (own_buf, new_packet_len); + putpkt_binary (cs.own_buf, new_packet_len); else - putpkt (own_buf); - - response_needed = 0; -- -+#ifndef __GENODE__ - if (!extended_protocol && have_ran && !target_running ()) - { - /* In non-stop, defer exiting until GDB had a chance to query -@@ -3159,7 +3179,7 @@ process_serial_event (void) - exit (0); - } - } -- -+#endif - if (exit_requested) - return -1; - diff --git a/gdb/gdbserver/server.h b/gdb/gdbserver/server.h -index 77f5dd6..897abed 100644 +index 5e41e2f..fcffe77 100644 --- a/gdb/gdbserver/server.h +++ b/gdb/gdbserver/server.h -@@ -664,8 +664,8 @@ struct emit_ops - /* Returns the address of the get_raw_reg function in the IPA. */ - CORE_ADDR get_raw_reg_func_addr (void); +@@ -60,7 +60,11 @@ int vsnprintf(char *str, size_t size, const char *format, va_list ap); + #include "gdb_signals.h" + #include "target.h" + #include "mem-break.h" ++#ifdef __GENODE__ ++#include "common/environ.h" ++#else + #include "environ.h" ++#endif /* __GENODE__ */ --CORE_ADDR current_insn_ptr; --int emit_error; -+extern CORE_ADDR current_insn_ptr; -+extern int emit_error; + /* Target-specific functions */ - /* Version information, from version.c. */ - extern const char version[]; +diff --git a/gdb/nat/fork-inferior.c b/gdb/nat/fork-inferior.c +index ea71aad..9b789e7 100644 +--- a/gdb/nat/fork-inferior.c ++++ b/gdb/nat/fork-inferior.c +@@ -420,9 +420,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! */ +- ++#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 +diff --git a/gdb/nat/gdb_ptrace.h b/gdb/nat/gdb_ptrace.h +index bdd7621..45caf22 100644 +--- a/gdb/nat/gdb_ptrace.h ++++ b/gdb/nat/gdb_ptrace.h +@@ -129,6 +129,7 @@ + extern PTRACE_TYPE_RET ptrace(); + #endif + ++#ifndef __GENODE__ + /* Some systems, at least AIX and HP-UX have a ptrace with five + arguments. Since we never use the fifth argument, define a ptrace + macro that calls the real ptrace with the last argument set to +@@ -149,5 +150,6 @@ extern PTRACE_TYPE_RET ptrace(); + # define ptrace(request, pid, addr, data) \ + ptrace ((PTRACE_TYPE_ARG1) request, pid, addr, data) + #endif ++#endif /* __GENODE__ */ + + #endif /* gdb_ptrace.h */ +diff --git a/gdb/nat/linux-ptrace.c b/gdb/nat/linux-ptrace.c +index 1f21ef0..4538dc0 100644 +--- a/gdb/nat/linux-ptrace.c ++++ b/gdb/nat/linux-ptrace.c +@@ -36,6 +36,7 @@ static int supported_ptrace_options = -1; + std::string + linux_ptrace_attach_fail_reason (pid_t pid) + { ++#ifndef __GENODE__ + pid_t tracerpid = linux_proc_get_tracerpid_nowarn (pid); + std::string result; + +@@ -51,6 +52,7 @@ linux_ptrace_attach_fail_reason (pid_t pid) + (int) pid); + + return result; ++#endif + } + + /* See linux-ptrace.h. */ +@@ -73,12 +75,16 @@ linux_ptrace_attach_fail_reason_string (ptid_t ptid, int err) + /* Address of the 'ret' instruction in asm code block below. */ + EXTERN_C void linux_ptrace_test_ret_to_nx_instr (void); + ++#ifndef __GENODE__ + #include ++#endif + #include + #include +- ++#else ++#include + #endif /* defined __i386__ || defined __x86_64__ */ + ++#ifndef __GENODE__ + /* Test broken off-trunk Linux kernel patchset for NX support on i386. It was + removed in Fedora kernel 88fa1f0332d188795ed73d7ac2b1564e11a0b4cd. + +@@ -240,6 +246,7 @@ linux_ptrace_test_ret_to_nx (void) + "support detected!")); + #endif /* defined __i386__ || defined __x86_64__ */ + } ++#endif /* __GENODE__ */ + + /* Helper function to fork a process and make the child process call + the function FUNCTION, passing CHILD_STACK as parameter. +@@ -325,6 +332,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. */ +@@ -362,6 +370,7 @@ linux_check_ptrace_features (void) + my_waitpid (child_pid, &status, 0); + } + while (WIFSTOPPED (status)); ++#endif + } + + /* Determine if PTRACE_O_TRACESYSGOOD can be used to catch +@@ -479,6 +488,7 @@ linux_test_for_exitkill (int child_pid) + void + linux_enable_event_reporting (pid_t pid, int options) + { ++#ifndef __GENODE__ + /* Check if we have initialized the ptrace features for this + target. If not, do it now. */ + if (supported_ptrace_options == -1) +@@ -493,6 +503,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); ++#endif /* __GENODE__ */ + } + + /* Disable reporting of all currently supported ptrace events. */ +@@ -500,8 +511,10 @@ linux_enable_event_reporting (pid_t pid, int options) + void + linux_disable_event_reporting (pid_t pid) + { ++#ifndef __GENODE__ + /* Set the options. */ + ptrace (PTRACE_SETOPTIONS, pid, (PTRACE_TYPE_ARG3) 0, 0); ++#endif /* __GENODE__ */ + } + + /* Returns non-zero if PTRACE_OPTIONS is contained within +@@ -580,7 +593,9 @@ linux_ptrace_init_warnings (void) + return; + warned = 1; + ++#ifndef __GENODE__ + linux_ptrace_test_ret_to_nx (); ++#endif + } + + /* Extract extended ptrace event from wait status. */ +diff --git a/gdb/nat/linux-ptrace.h b/gdb/nat/linux-ptrace.h +index 98b44a8..178310e 100644 +--- a/gdb/nat/linux-ptrace.h ++++ b/gdb/nat/linux-ptrace.h +@@ -115,7 +115,11 @@ struct buffer; + way to go. That said, some architecture may get the si_code wrong, + and as such we're leaving fallback code in place. We'll remove + this after a while if no problem is reported. */ ++#ifdef __GENODE__ ++#define USE_SIGTRAP_SIGINFO 0 ++#else + #define USE_SIGTRAP_SIGINFO 1 ++#endif + + /* The x86 kernel gets some of the si_code values backwards, like + this: diff --git a/repos/ports/src/noux-pkg/gdb/patches/gdbserver_x86_64.patch b/repos/ports/src/noux-pkg/gdb/patches/gdbserver_x86_64.patch deleted file mode 100644 index aa7d91335..000000000 --- a/repos/ports/src/noux-pkg/gdb/patches/gdbserver_x86_64.patch +++ /dev/null @@ -1,169 +0,0 @@ -gdbserver_x86_64.patch - -From: Christian Prochaska - - ---- - gdb/gdbserver/linux-x86-low.c | 54 ++++++++++++++++++++++++++++++++++++++--- - 1 file changed, 50 insertions(+), 4 deletions(-) - -diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c -index e98e3bd..0ece728 100644 ---- a/gdb/gdbserver/linux-x86-low.c -+++ b/gdb/gdbserver/linux-x86-low.c -@@ -33,6 +33,12 @@ - #endif - - #ifdef __GENODE__ -+#ifdef __x86_64__ -+void init_registers_amd64 (void); -+static inline void init_registers_amd64_linux(void) { init_registers_amd64(); } -+void init_registers_amd64_avx (void); -+static inline void init_registers_amd64_avx_linux(void) { init_registers_amd64_avx(); } -+#endif /* __x64_64__ */ - /* Defined in auto-generated file i386.c. */ - void init_registers_i386 (void); - static inline void init_registers_i386_linux(void) { init_registers_i386(); } -@@ -83,7 +89,9 @@ static const char *xmltarget_amd64_linux_no_xml = "@\ - #endif /* __GENODE__ */ - - #ifdef __GENODE__ --#ifndef __x86_64__ -+#ifdef __x86_64__ -+#include "amd64.h" -+#else - #include "i386.h" - #endif /* __x86_64__ */ - #else -@@ -153,7 +161,11 @@ static /*const*/ int i386_regmap[] = - /* So code below doesn't have to care, i386 or amd64. */ - #define ORIG_EAX ORIG_RAX - --static const int x86_64_regmap[] = -+static -+#ifndef __GENODE__ -+const -+#endif -+int x86_64_regmap[] = - { - RAX * 8, RBX * 8, RCX * 8, RDX * 8, - RSI * 8, RDI * 8, RBP * 8, RSP * 8, -@@ -165,7 +177,9 @@ static const int x86_64_regmap[] = - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -+#ifndef __GENODE__ - ORIG_RAX * 8 -+#endif - }; - - #define X86_64_NUM_REGS (sizeof (x86_64_regmap) / sizeof (x86_64_regmap[0])) -@@ -188,6 +202,7 @@ static /*const*/ int i386_regmap[] = - - /* Called by libthread_db. */ - -+#ifndef __GENODE__ - ps_err_e - ps_get_thread_area (const struct ps_prochandle *ph, - lwpid_t lwpid, int idx, void **base) -@@ -225,6 +240,7 @@ ps_get_thread_area (const struct ps_prochandle *ph, - return PS_OK; - } - } -+#endif - - /* Get the thread area address. This is used to recognize which - thread is which when tracing with the in-process agent library. We -@@ -286,6 +302,20 @@ i386_cannot_fetch_register (int regno) - return regno >= I386_NUM_REGS; - } - -+#ifdef __x86_64__ -+static int -+x86_64_cannot_store_register (int regno) -+{ -+ return regno >= X86_64_NUM_REGS; -+} -+ -+static int -+x86_64_cannot_fetch_register (int regno) -+{ -+ return regno >= X86_64_NUM_REGS; -+} -+#endif /* __x86_64__ */ -+ - static void - x86_fill_gregset (struct regcache *regcache, void *buf) - { -@@ -728,6 +758,7 @@ x86_linux_prepare_to_resume (struct lwp_info *lwp) - compatible with the siginfo type exported by the 32-bit userspace - support. */ - -+#ifndef __GENODE__ - #ifdef __x86_64__ - - typedef int compat_int_t; -@@ -969,6 +1000,7 @@ x86_siginfo_fixup (siginfo_t *native, void *inf, int direction) - - return 0; - } -+#endif - - static int use_xml; - -@@ -1138,11 +1170,15 @@ static void - x86_arch_setup (void) - { - #ifdef __x86_64__ -+#ifdef __GENODE__ -+ int use_64bit = 1; -+#else - int pid = pid_of (get_thread_lwp (current_inferior)); - char *file = linux_child_pid_to_exec_file (pid); - int use_64bit = elf_64_file_p (file); - - free (file); -+#endif - - if (use_64bit < 0) - { -@@ -1152,19 +1188,25 @@ x86_arch_setup (void) - } - else if (use_64bit) - { -+#ifdef __GENODE__ -+ the_low_target.num_regs = X86_64_NUM_REGS; -+ the_low_target.regmap = x86_64_regmap; -+ the_low_target.cannot_fetch_register = x86_64_cannot_fetch_register; -+ the_low_target.cannot_store_register = x86_64_cannot_store_register; -+#else - /* Amd64 doesn't have HAVE_LINUX_USRREGS. */ - the_low_target.num_regs = -1; - the_low_target.regmap = NULL; - the_low_target.cannot_fetch_register = NULL; - the_low_target.cannot_store_register = NULL; -- -+#endif - /* Amd64 has 16 xmm regs. */ - num_xmm_registers = 16; - - x86_linux_update_xmltarget (); - return; - } --#endif -+#endif /* __x86_64__ */ - - /* Ok we have a 32-bit inferior. */ - -@@ -2620,7 +2662,11 @@ struct linux_target_ops the_low_target = - NULL, - NULL, - /* need to fix up i386 siginfo if host is amd64 */ -+#ifdef __GENODE__ -+ NULL, -+#else - x86_siginfo_fixup, -+#endif - x86_linux_new_process, - x86_linux_new_thread, - #ifndef __GENODE__ 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 68cbcf907..20d8498d8 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/noux_build.patch +++ b/repos/ports/src/noux-pkg/gdb/patches/noux_build.patch @@ -1,8 +1,19 @@ +noux_build.patch + +From: Christian Prochaska + + +--- + gdb/configure | 10 +++++----- + gdb/dwarf-index-write.c | 2 +- + sim/common/Make-common.in | 2 +- + 3 files changed, 7 insertions(+), 7 deletions(-) + diff --git a/gdb/configure b/gdb/configure -index 30e5e45..9c5ed7f 100755 +index 28756ed..a3d6fc2 100755 --- a/gdb/configure +++ b/gdb/configure -@@ -7917,11 +7917,11 @@ fi +@@ -6608,11 +6608,11 @@ fi # configuration. gdb_host_obs=posix-hdep.o @@ -18,7 +29,7 @@ index 30e5e45..9c5ed7f 100755 . $srcdir/configure.host -@@ -12919,7 +12919,7 @@ sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1); +@@ -13785,7 +13785,7 @@ sigjmp_buf env; while (! sigsetjmp (env, 1)) siglongjmp (env, 1); return 0; } _ACEOF @@ -27,24 +38,24 @@ index 30e5e45..9c5ed7f 100755 gdb_cv_func_sigsetjmp=yes else gdb_cv_func_sigsetjmp=no -diff --git a/missing b/missing -index 28055d2..031956f 100755 ---- a/missing -+++ b/missing -@@ -314,7 +314,7 @@ WARNING: \`$1' is $msg. You should only need it if - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. -- test -f $file || exit 1 -+ #test -f $file || exit 1 - touch $file - ;; - +diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c +index d283146..55bef80 100644 +--- a/gdb/dwarf-index-write.c ++++ b/gdb/dwarf-index-write.c +@@ -705,7 +705,7 @@ public: + gdb_assert (m_abbrev_table.empty ()); + const size_t name_count = m_name_to_value_set.size (); + m_bucket_table.resize +- (std::pow (2, std::ceil (std::log2 (name_count * 4 / 3)))); ++ (std::pow (2, std::ceil (log2 (name_count * 4 / 3)))); + 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/sim/common/Make-common.in b/sim/common/Make-common.in -index 351f4a0..9b68c87 100644 +index 1e61927..6263ece 100644 --- a/sim/common/Make-common.in +++ b/sim/common/Make-common.in -@@ -237,7 +237,7 @@ CSEARCH = -I. -I$(srcdir) -I../common -I$(srccom) \ +@@ -236,7 +236,7 @@ CSEARCH = -I. -I$(srcdir) -I../common -I$(srccom) \ -I../../bfd -I$(srcroot)/bfd \ -I../../opcodes -I$(srcroot)/opcodes \ @INCINTL@ diff --git a/repos/ports/src/noux-pkg/gdb/patches/series b/repos/ports/src/noux-pkg/gdb/patches/series index 62bdb462e..d9ea7dc12 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/series +++ b/repos/ports/src/noux-pkg/gdb/patches/series @@ -1,8 +1,6 @@ -siginfo.patch shared_library.patch arm_single_step.patch -x86_64.patch +gdb_x86_64.patch noux_build.patch gdbserver_genode.patch -gdbserver_x86_64.patch -gcc6.patch +call_dummy_location.patch 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 3a3683c12..353ec0ab6 100644 --- a/repos/ports/src/noux-pkg/gdb/patches/shared_library.patch +++ b/repos/ports/src/noux-pkg/gdb/patches/shared_library.patch @@ -6,26 +6,26 @@ Enable shared library support. --- gdb/amd64-tdep.c | 4 ++++ gdb/arm-tdep.c | 4 ++++ - gdb/configure.tgt | 5 ++++- + gdb/configure.tgt | 6 +++++- gdb/i386-tdep.c | 4 ++++ - 4 files changed, 16 insertions(+), 1 deletion(-) + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c -index 9b5d5bb..db3821a 100644 +index 190e086..e1f8862 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c -@@ -45,6 +45,8 @@ - #include "features/i386/amd64.c" - #include "features/i386/amd64-avx.c" +@@ -50,6 +50,8 @@ + #include "osabi.h" + #include "x86-tdep.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 -@@ -2465,6 +2467,8 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) - struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); - const struct target_desc *tdesc = info.target_desc; +@@ -3056,6 +3058,8 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch, + static const char *const stap_register_indirection_suffixes[] = { ")", + NULL }; + set_solib_svr4_fetch_link_map_offsets(gdbarch, svr4_lp64_fetch_link_map_offsets); + @@ -33,20 +33,20 @@ index 9b5d5bb..db3821a 100644 floating-point registers. */ tdep->sizeof_fpregset = I387_SIZEOF_FXSAVE; diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c -index bb52ad4..155208e 100644 +index fdfb360..cfdfb0b 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c -@@ -57,6 +57,8 @@ - - #include "features/arm-with-m.c" +@@ -73,6 +73,8 @@ + #include "selftest.h" + #endif +#include "solib-svr4.h" + static int arm_debug; /* Macros for setting and testing a bit in a minimal symbol that marks -@@ -8465,6 +8467,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - tdep = xcalloc (1, sizeof (struct gdbarch_tdep)); +@@ -9287,6 +9289,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + tdep = XCNEW (struct gdbarch_tdep); gdbarch = gdbarch_alloc (&info, tdep); + set_solib_svr4_fetch_link_map_offsets(gdbarch, svr4_ilp32_fetch_link_map_offsets); @@ -55,47 +55,49 @@ index bb52ad4..155208e 100644 These are gdbarch discriminators, like the OSABI. */ tdep->arm_abi = arm_abi; diff --git a/gdb/configure.tgt b/gdb/configure.tgt -index 5ab1554..ae57017 100644 +index f197160..cbdd010 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt -@@ -96,7 +96,7 @@ arm*-*-symbianelf*) +@@ -180,6 +180,7 @@ arm*-*-symbianelf*) ;; - arm*-*-* | thumb*-*-* | strongarm*-*-* | xscale-*-*) + arm*-*-*) # Target: ARM embedded system -- gdb_target_obs="arm-tdep.o" -+ gdb_target_obs="arm-tdep.o solib.o solib-svr4.o" ++ gdb_target_obs="solib-svr4.o" gdb_sim=../sim/arm/libsim.a ;; -@@ -623,6 +623,9 @@ x86_64-*-openbsd*) - i387-tdep.o i386bsd-tdep.o i386obsd-tdep.o \ - bsd-uthread.o corelow.o solib.o solib-svr4.o" +@@ -698,8 +699,11 @@ x86_64-*-dicos*) + dicos-tdep.o i386-dicos-tdep.o amd64-dicos-tdep.o" ;; -+x86_64-*-*) -+ gdb_target_obs="amd64-tdep.o i386-tdep.o i387-tdep.o solib.o solib-svr4.o" -+ ;; - xtensa*-*-linux*) gdb_target=linux - # Target: GNU/Linux Xtensa - gdb_target_obs="xtensa-tdep.o xtensa-config.o xtensa-linux-tdep.o \ + x86_64-*-elf*) +- gdb_target_obs="${i386_tobjs}" ++ gdb_target_obs="${amd64_tobjs} ${i386_tobjs} solib-svr4.o" + ;; ++x86_64-*-rtems*) ++ gdb_target_obs="amd64-tdep.o i386-tdep.o i387-tdep.o i386bsd-tdep.o" ++ ;; + x86_64-*-linux*) + # 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 5f4089b..3c13bea 100644 +index a6994aa..18e6e77 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c -@@ -60,6 +60,8 @@ - #include "features/i386/i386-avx.c" - #include "features/i386/i386-mmx.c" +@@ -65,6 +65,8 @@ + #include + #include +#include "solib-svr4.h" + /* Register names. */ static const char *i386_register_names[] = -@@ -7051,6 +7053,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) - tdep = XCALLOC (1, struct gdbarch_tdep); +@@ -8374,6 +8376,8 @@ i386_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) + tdep = XCNEW (struct gdbarch_tdep); gdbarch = gdbarch_alloc (&info, tdep); + set_solib_svr4_fetch_link_map_offsets(gdbarch, svr4_ilp32_fetch_link_map_offsets); + /* General-purpose registers. */ - tdep->gregset = NULL; tdep->gregset_reg_offset = NULL; + tdep->gregset_num_regs = I386_NUM_GREGS; diff --git a/repos/ports/src/noux-pkg/gdb/patches/siginfo.patch b/repos/ports/src/noux-pkg/gdb/patches/siginfo.patch deleted file mode 100644 index 673b84185..000000000 --- a/repos/ports/src/noux-pkg/gdb/patches/siginfo.patch +++ /dev/null @@ -1,279 +0,0 @@ -From 0bcbef9314d6679d1fbbb0114683d06de0196623 Mon Sep 17 00:00:00 2001 - -From: Christian Prochaska - -Message-Id: <0bcbef9314d6679d1fbbb0114683d06de0196623.1341578007.git.chris@arachsys.com> -From: Chris Webb -Date: Fri, 6 Jul 2012 13:18:58 +0100 -Subject: [PATCH] Replace struct siginfo with siginfo_t - -Glibc 2.16.0 removes the undocumented definition of 'struct siginfo' from -. This struct is also available as the POSIX-defined -siginfo_t, so replace all uses of struct siginfo with siginfo_t. - -Signed-off-by: Chris Webb ---- - gdb/amd64-linux-nat.c | 4 ++-- - gdb/arm-linux-nat.c | 2 +- - gdb/gdbserver/linux-low.c | 10 +++++----- - gdb/gdbserver/linux-low.h | 5 ++--- - gdb/gdbserver/linux-x86-low.c | 4 ++-- - gdb/ia64-linux-nat.c | 2 +- - gdb/linux-nat.c | 16 ++++++++-------- - gdb/linux-nat.h | 6 +++--- - gdb/ppc-linux-nat.c | 2 +- - gdb/procfs.c | 2 +- - 10 files changed, 26 insertions(+), 27 deletions(-) - -diff --git a/gdb/amd64-linux-nat.c b/gdb/amd64-linux-nat.c -index a869f85..7bae36d 100644 ---- a/gdb/amd64-linux-nat.c -+++ b/gdb/amd64-linux-nat.c -@@ -684,13 +684,13 @@ siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from) - INF. */ - - static int --amd64_linux_siginfo_fixup (struct siginfo *native, gdb_byte *inf, int direction) -+amd64_linux_siginfo_fixup (siginfo_t *native, gdb_byte *inf, int direction) - { - /* Is the inferior 32-bit? If so, then do fixup the siginfo - object. */ - if (gdbarch_addr_bit (get_frame_arch (get_current_frame ())) == 32) - { -- gdb_assert (sizeof (struct siginfo) == sizeof (compat_siginfo_t)); -+ gdb_assert (sizeof (siginfo_t) == sizeof (compat_siginfo_t)); - - if (direction == 0) - compat_siginfo_from_siginfo ((struct compat_siginfo *) inf, native); -diff --git a/gdb/arm-linux-nat.c b/gdb/arm-linux-nat.c -index 43f4fde..3ec2bfc 100644 ---- a/gdb/arm-linux-nat.c -+++ b/gdb/arm-linux-nat.c -@@ -1203,7 +1203,7 @@ arm_linux_remove_watchpoint (CORE_ADDR addr, int len, int rw, - static int - arm_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p) - { -- struct siginfo *siginfo_p = linux_nat_get_siginfo (inferior_ptid); -+ siginfo_t *siginfo_p = linux_nat_get_siginfo (inferior_ptid); - int slot = siginfo_p->si_errno; - - /* This must be a hardware breakpoint. */ -diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c -index 81b8540..e597e2f 100644 ---- a/gdb/gdbserver/linux-low.c -+++ b/gdb/gdbserver/linux-low.c -@@ -4693,7 +4693,7 @@ linux_qxfer_osdata (const char *annex, - layout of the inferiors' architecture. */ - - static void --siginfo_fixup (struct siginfo *siginfo, void *inf_siginfo, int direction) -+siginfo_fixup (siginfo_t *siginfo, void *inf_siginfo, int direction) - { - int done = 0; - -@@ -4705,9 +4705,9 @@ siginfo_fixup (struct siginfo *siginfo, void *inf_siginfo, int direction) - if (!done) - { - if (direction == 1) -- memcpy (siginfo, inf_siginfo, sizeof (struct siginfo)); -+ memcpy (siginfo, inf_siginfo, sizeof (siginfo_t)); - else -- memcpy (inf_siginfo, siginfo, sizeof (struct siginfo)); -+ memcpy (inf_siginfo, siginfo, sizeof (siginfo_t)); - } - } - -@@ -4716,8 +4716,8 @@ linux_xfer_siginfo (const char *annex, unsigned char *readbuf, - unsigned const char *writebuf, CORE_ADDR offset, int len) - { - int pid; -- struct siginfo siginfo; -- char inf_siginfo[sizeof (struct siginfo)]; -+ siginfo_t siginfo; -+ char inf_siginfo[sizeof (siginfo_t)]; - - if (current_inferior == NULL) - return -1; -diff --git a/gdb/gdbserver/linux-low.h b/gdb/gdbserver/linux-low.h -index 6635bc6..d449e1b 100644 ---- a/gdb/gdbserver/linux-low.h -+++ b/gdb/gdbserver/linux-low.h -@@ -21,6 +21,7 @@ - #include - #endif - -+#include - #include "gdb_proc_service.h" - - #ifdef HAVE_LINUX_REGSETS -@@ -46,8 +47,6 @@ struct regset_info - extern struct regset_info target_regsets[]; - #endif - --struct siginfo; -- - struct process_info_private - { - /* Arch-specific additions. */ -@@ -100,7 +99,7 @@ struct linux_target_ops - Returns true if any conversion was done; false otherwise. - If DIRECTION is 1, then copy from INF to NATIVE. - If DIRECTION is 0, copy from NATIVE to INF. */ -- int (*siginfo_fixup) (struct siginfo *native, void *inf, int direction); -+ int (*siginfo_fixup) (siginfo_t *native, void *inf, int direction); - - /* Hook to call when a new process is created or attached to. - If extra per-process architecture-specific data is needed, -diff --git a/gdb/gdbserver/linux-x86-low.c b/gdb/gdbserver/linux-x86-low.c -index 69c6b57..82dcf83 100644 ---- a/gdb/gdbserver/linux-x86-low.c -+++ b/gdb/gdbserver/linux-x86-low.c -@@ -906,13 +906,13 @@ siginfo_from_compat_siginfo (siginfo_t *to, compat_siginfo_t *from) - INF. */ - - static int --x86_siginfo_fixup (struct siginfo *native, void *inf, int direction) -+x86_siginfo_fixup (siginfo_t *native, void *inf, int direction) - { - #ifdef __x86_64__ - /* Is the inferior 32-bit? If so, then fixup the siginfo object. */ - if (register_size (0) == 4) - { -- if (sizeof (struct siginfo) != sizeof (compat_siginfo_t)) -+ if (sizeof (siginfo_t) != sizeof (compat_siginfo_t)) - fatal ("unexpected difference in siginfo"); - - if (direction == 0) -diff --git a/gdb/ia64-linux-nat.c b/gdb/ia64-linux-nat.c -index 0f88e14..02482b2 100644 ---- a/gdb/ia64-linux-nat.c -+++ b/gdb/ia64-linux-nat.c -@@ -640,7 +640,7 @@ static int - ia64_linux_stopped_data_address (struct target_ops *ops, CORE_ADDR *addr_p) - { - CORE_ADDR psr; -- struct siginfo *siginfo_p; -+ siginfo_t *siginfo_p; - struct regcache *regcache = get_current_regcache (); - - siginfo_p = linux_nat_get_siginfo (inferior_ptid); -diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c -index 44a2a21..791d7b2 100644 ---- a/gdb/linux-nat.c -+++ b/gdb/linux-nat.c -@@ -214,7 +214,7 @@ static void (*linux_nat_new_thread) (ptid_t); - /* The method to call, if any, when the siginfo object needs to be - converted between the layout returned by ptrace, and the layout in - the architecture of the inferior. */ --static int (*linux_nat_siginfo_fixup) (struct siginfo *, -+static int (*linux_nat_siginfo_fixup) (siginfo_t *, - gdb_byte *, - int); - -@@ -3945,7 +3945,7 @@ linux_nat_mourn_inferior (struct target_ops *ops) - layout of the inferiors' architecture. */ - - static void --siginfo_fixup (struct siginfo *siginfo, gdb_byte *inf_siginfo, int direction) -+siginfo_fixup (siginfo_t *siginfo, gdb_byte *inf_siginfo, int direction) - { - int done = 0; - -@@ -3957,9 +3957,9 @@ siginfo_fixup (struct siginfo *siginfo, gdb_byte *inf_siginfo, int direction) - if (!done) - { - if (direction == 1) -- memcpy (siginfo, inf_siginfo, sizeof (struct siginfo)); -+ memcpy (siginfo, inf_siginfo, sizeof (siginfo_t)); - else -- memcpy (inf_siginfo, siginfo, sizeof (struct siginfo)); -+ memcpy (inf_siginfo, siginfo, sizeof (siginfo_t)); - } - } - -@@ -3969,8 +3969,8 @@ linux_xfer_siginfo (struct target_ops *ops, enum target_object object, - const gdb_byte *writebuf, ULONGEST offset, LONGEST len) - { - int pid; -- struct siginfo siginfo; -- gdb_byte inf_siginfo[sizeof (struct siginfo)]; -+ siginfo_t siginfo; -+ gdb_byte inf_siginfo[sizeof (siginfo_t)]; - - gdb_assert (object == TARGET_OBJECT_SIGNAL_INFO); - gdb_assert (readbuf || writebuf); -@@ -5784,7 +5784,7 @@ linux_nat_set_new_thread (struct target_ops *t, void (*new_thread) (ptid_t)) - inferior. */ - void - linux_nat_set_siginfo_fixup (struct target_ops *t, -- int (*siginfo_fixup) (struct siginfo *, -+ int (*siginfo_fixup) (siginfo_t *, - gdb_byte *, - int)) - { -@@ -5793,7 +5793,7 @@ linux_nat_set_siginfo_fixup (struct target_ops *t, - } - - /* Return the saved siginfo associated with PTID. */ --struct siginfo * -+siginfo_t * - linux_nat_get_siginfo (ptid_t ptid) - { - struct lwp_info *lp = find_lwp_pid (ptid); -diff --git a/gdb/linux-nat.h b/gdb/linux-nat.h -index 42cb2fc..422db28 100644 ---- a/gdb/linux-nat.h -+++ b/gdb/linux-nat.h -@@ -60,7 +60,7 @@ struct lwp_info - - /* Non-zero si_signo if this LWP stopped with a trap. si_addr may - be the address of a hardware watchpoint. */ -- struct siginfo siginfo; -+ siginfo_t siginfo; - - /* STOPPED_BY_WATCHPOINT is non-zero if this LWP stopped with a data - watchpoint trap. */ -@@ -160,7 +160,7 @@ void linux_nat_set_new_thread (struct target_ops *, void (*) (ptid_t)); - that ptrace returns, and the layout in the architecture of the - inferior. */ - void linux_nat_set_siginfo_fixup (struct target_ops *, -- int (*) (struct siginfo *, -+ int (*) (siginfo_t *, - gdb_byte *, - int)); - -@@ -169,7 +169,7 @@ void linux_nat_set_siginfo_fixup (struct target_ops *, - void linux_nat_switch_fork (ptid_t new_ptid); - - /* Return the saved siginfo associated with PTID. */ --struct siginfo *linux_nat_get_siginfo (ptid_t ptid); -+siginfo_t *linux_nat_get_siginfo (ptid_t ptid); - - /* Compute and return the processor core of a given thread. */ - int linux_nat_core_of_thread_1 (ptid_t ptid); -diff --git a/gdb/ppc-linux-nat.c b/gdb/ppc-linux-nat.c -index 6f11715..3a3de07 100644 ---- a/gdb/ppc-linux-nat.c -+++ b/gdb/ppc-linux-nat.c -@@ -2161,7 +2161,7 @@ ppc_linux_thread_exit (struct thread_info *tp, int silent) - static int - ppc_linux_stopped_data_address (struct target_ops *target, CORE_ADDR *addr_p) - { -- struct siginfo *siginfo_p; -+ siginfo_t *siginfo_p; - - siginfo_p = linux_nat_get_siginfo (inferior_ptid); - -diff --git a/gdb/procfs.c b/gdb/procfs.c -index 5d7cb23..ea52d97 100644 ---- a/gdb/procfs.c -+++ b/gdb/procfs.c -@@ -263,7 +263,7 @@ typedef struct sigaction gdb_sigaction_t; - #ifdef HAVE_PR_SIGINFO64_T - typedef pr_siginfo64_t gdb_siginfo_t; - #else --typedef struct siginfo gdb_siginfo_t; -+typedef siginfo_t gdb_siginfo_t; - #endif - - /* On mips-irix, praddset and prdelset are defined in such a way that diff --git a/repos/ports/src/noux-pkg/gdb/patches/x86_64.patch b/repos/ports/src/noux-pkg/gdb/patches/x86_64.patch deleted file mode 100644 index 272908920..000000000 --- a/repos/ports/src/noux-pkg/gdb/patches/x86_64.patch +++ /dev/null @@ -1,80 +0,0 @@ -gdb_x86_64.diff - -From: Christian Prochaska - - ---- - gdb/amd64-tdep.c | 5 +++++ - gdb/defs.h | 1 + - gdb/i386-tdep.c | 5 +++++ - gdb/osabi.c | 6 ++++++ - 4 files changed, 17 insertions(+) - -diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c -index db3821a..5f5e165 100644 ---- a/gdb/amd64-tdep.c -+++ b/gdb/amd64-tdep.c -@@ -2581,6 +2581,11 @@ void _initialize_amd64_tdep (void); - void - _initialize_amd64_tdep (void) - { -+ /* Genode */ -+ gdbarch_register_osabi(bfd_arch_i386, bfd_mach_x86_64, -+ GDB_OSABI_GENODE, amd64_init_abi); -+ /* /Genode */ -+ - initialize_tdesc_amd64 (); - initialize_tdesc_amd64_avx (); - } -diff --git a/gdb/defs.h b/gdb/defs.h -index 9531c5a..7c7258f 100644 ---- a/gdb/defs.h -+++ b/gdb/defs.h -@@ -996,6 +996,7 @@ enum gdb_osabi - GDB_OSABI_DICOS, - GDB_OSABI_DARWIN, - GDB_OSABI_SYMBIAN, -+ GDB_OSABI_GENODE, - - GDB_OSABI_INVALID /* keep this last */ - }; -diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c -index 3c13bea..3aaeec5 100644 ---- a/gdb/i386-tdep.c -+++ b/gdb/i386-tdep.c -@@ -7367,6 +7367,11 @@ is \"default\"."), - gdbarch_register_osabi (bfd_arch_i386, 0, GDB_OSABI_GO32, - i386_go32_init_abi); - -+ /* Genode */ -+ gdbarch_register_osabi(bfd_arch_i386, 0, GDB_OSABI_GENODE, -+ i386_elf_init_abi); -+ /* /Genode */ -+ - /* Initialize the i386-specific register groups. */ - i386_init_reggroups (); - -diff --git a/gdb/osabi.c b/gdb/osabi.c -index a264924..c5e1775 100644 ---- a/gdb/osabi.c -+++ b/gdb/osabi.c -@@ -73,6 +73,7 @@ static const char * const gdb_osabi_names[] = - "DICOS", - "Darwin", - "Symbian", -+ "Genode", - - "" - }; -@@ -522,6 +523,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) -+ osabi = GDB_OSABI_GENODE; -+/* /Genode */ -+ - break; - - case ELFOSABI_FREEBSD: diff --git a/repos/ports/src/noux-pkg/gdb/target.inc b/repos/ports/src/noux-pkg/gdb/target.inc index 71bdf37ac..2623219e3 100644 --- a/repos/ports/src/noux-pkg/gdb/target.inc +++ b/repos/ports/src/noux-pkg/gdb/target.inc @@ -8,7 +8,7 @@ CONFIGURE_ARGS += --without-expat CPPFLAGS += -DHAVE_LIBEXPAT=1 CFLAGS += -Wno-error=sizeof-pointer-memaccess -Wno-error=unused-value -LIBS += ncurses expat +LIBS += stdcxx ncurses expat # workaround for problems with makeinfo version 5 MAKE_ENV += "MAKEINFO=true" diff --git a/repos/ports/src/noux-pkg/gdb_arm/target.mk b/repos/ports/src/noux-pkg/gdb_arm/target.mk index 618cb1437..16734dc63 100644 --- a/repos/ports/src/noux-pkg/gdb_arm/target.mk +++ b/repos/ports/src/noux-pkg/gdb_arm/target.mk @@ -1,4 +1,20 @@ PROGRAM_PREFIX = genode-arm- GDB_TARGET = arm-none-eabi +# +# We link libraries to the final binaries using the 'LIBS' variable. But +# unfortunately, the gdb build system has hardcoded some libs such as '-lm'. +# To satisfy the linker, we provide dummy archives. +# + +LDFLAGS += -L$(PWD) + +.SECONDARY: dummy_libs +dummy_libs: libm.a + +libm.a: + $(VERBOSE)$(AR) -rc $@ + +Makefile: dummy_libs + include $(PRG_DIR)/../gdb/target.inc