From: "Jérôme Duval" <jerome.duval@gmail.com>
To: gdb-patches@sourceware.org
Cc: "Jérôme Duval" <jerome.duval@gmail.com>
Subject: [PATCH 4/8] gdbserver: Update Haiku support for 16.x
Date: Thu, 12 Mar 2026 18:23:32 +0100 [thread overview]
Message-ID: <20260312172336.15450-5-jerome.duval@gmail.com> (raw)
In-Reply-To: <20260312172336.15450-1-jerome.duval@gmail.com>
---
gdbserver/haiku-amd64-low.cc | 8 ++++----
gdbserver/haiku-low.cc | 30 ++++++++++++++++++------------
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/gdbserver/haiku-amd64-low.cc b/gdbserver/haiku-amd64-low.cc
index 0e6e0ade..3503d5ce 100644
--- a/gdbserver/haiku-amd64-low.cc
+++ b/gdbserver/haiku-amd64-low.cc
@@ -155,7 +155,7 @@ haiku_amd64_target::fetch_registers (struct regcache *regcache, int regno)
{
char regs[sizeof (x86_64_debug_cpu_state)];
- if (haiku_nat::get_cpu_state (ptid_of (current_thread), ®s) < 0)
+ if (haiku_nat::get_cpu_state (current_thread->id, ®s) < 0)
{
/* This happens when the inferior is killed by another process
while being stopped. The nub port has been deleted, so we cannot
@@ -196,7 +196,7 @@ haiku_amd64_target::store_registers (struct regcache *regcache, int regno)
{
char regs[sizeof (x86_64_debug_cpu_state)];
- if (haiku_nat::get_cpu_state (ptid_of (current_thread), ®s) < 0)
+ if (haiku_nat::get_cpu_state (current_thread->id, ®s) < 0)
{
haiku_nat_debug_printf ("Failed to get actual CPU state: %s",
strerror (errno));
@@ -220,7 +220,7 @@ haiku_amd64_target::store_registers (struct regcache *regcache, int regno)
}
}
- if (haiku_nat::set_cpu_state (ptid_of (current_thread), ®s) < 0)
+ if (haiku_nat::set_cpu_state (current_thread->id, ®s) < 0)
perror_with_name (("haiku_nat::set_cpu_state"));
}
@@ -248,7 +248,7 @@ haiku_amd64_target::low_arch_setup (process_info *process)
target_desc *tdesc = amd64_create_target_description (X86_XSTATE_AVX_MASK,
false, false, false);
- init_target_desc (tdesc, amd64_expedite_regs);
+ init_target_desc (tdesc, amd64_expedite_regs, GDB_OSABI_HAIKU);
process->tdesc = tdesc;
}
diff --git a/gdbserver/haiku-low.cc b/gdbserver/haiku-low.cc
index 41295d58..b0551b8f 100644
--- a/gdbserver/haiku-low.cc
+++ b/gdbserver/haiku-low.cc
@@ -168,7 +168,7 @@ haiku_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
/* Add at least the child's main thread. Otherwise, gdbserver would
think we have no more inferiors attached and quit. */
- add_thread (ptid_t (pid, 0, pid), nullptr);
+ find_process_pid (pid)->add_thread (ptid_t (pid, 0, pid), nullptr);
};
client_state &cs = get_client_state ();
@@ -193,7 +193,7 @@ haiku_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
thread that was not fully initialized during the attach stage. */
if (wptid.tid () != 0 && !find_thread_ptid (wptid)
&& ourstatus->kind () != TARGET_WAITKIND_THREAD_EXITED)
- add_thread (wptid, nullptr);
+ find_process_pid (wptid.pid())->add_thread (wptid, nullptr);
switch (ourstatus->kind ())
{
@@ -247,7 +247,9 @@ haiku_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
return wptid;
break;
case TARGET_WAITKIND_THREAD_EXITED:
- remove_thread (find_thread_ptid (wptid));
+ {
+ thread_info *info = find_thread_ptid (wptid);
+ info->process ()->remove_thread (info);
if (cs.report_thread_events)
return wptid;
@@ -255,6 +257,7 @@ haiku_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
/* The thread is dead so we cannot resume the the same wptid. */
wptid = ptid;
break;
+ }
default:
gdb_assert_not_reached ("Unknown stopped status");
}
@@ -272,7 +275,7 @@ haiku_process_target::wait (ptid_t ptid, struct target_waitstatus *ourstatus,
int
haiku_process_target::kill (process_info *process)
{
- if (haiku_nat::kill (pid_of (process)) < 0)
+ if (haiku_nat::kill (process->pid) < 0)
return -1;
mourn (process);
@@ -284,7 +287,7 @@ haiku_process_target::kill (process_info *process)
int
haiku_process_target::detach (process_info *process)
{
- if (haiku_nat::detach (pid_of (process)) < 0)
+ if (haiku_nat::detach (process->pid) < 0)
return -1;
mourn (process);
@@ -296,7 +299,10 @@ haiku_process_target::detach (process_info *process)
void
haiku_process_target::mourn (struct process_info *proc)
{
- for_each_thread (pid_of (proc), remove_thread);
+ proc->for_each_thread ([proc] (thread_info *thread)
+ {
+ proc->remove_thread (thread);
+ });
remove_process (proc);
}
@@ -306,7 +312,7 @@ haiku_process_target::mourn (struct process_info *proc)
void
haiku_process_target::join (int pid)
{
- gdb::handle_eintr (-1, ::waitpid, pid, nullptr, 0);
+ gdb::waitpid (pid, nullptr, 0);
}
/* Implement the thread_alive target_ops method. */
@@ -323,7 +329,7 @@ int
haiku_process_target::read_memory (CORE_ADDR memaddr, unsigned char *myaddr,
int size)
{
- if (haiku_nat::read_memory (pid_of (current_process ()), memaddr, myaddr,
+ if (haiku_nat::read_memory (current_process ()->pid, memaddr, myaddr,
&size)
< 0)
{
@@ -340,7 +346,7 @@ int
haiku_process_target::write_memory (CORE_ADDR memaddr,
const unsigned char *myaddr, int size)
{
- if (haiku_nat::write_memory (pid_of (current_process ()), memaddr, myaddr,
+ if (haiku_nat::write_memory (current_process ()->pid, memaddr, myaddr,
&size)
< 0)
{
@@ -361,7 +367,7 @@ haiku_process_target::request_interrupt ()
if (thread == nullptr)
return;
- ::kill (pid_of (thread), SIGINT);
+ ::kill (thread->id.pid(), SIGINT);
}
/* Implement the read_offsets target_ops method. */
@@ -369,7 +375,7 @@ haiku_process_target::request_interrupt ()
int
haiku_process_target::read_offsets (CORE_ADDR *text, CORE_ADDR *data)
{
- if (haiku_nat::read_offsets (pid_of (current_process ()), text, data) < 0)
+ if (haiku_nat::read_offsets (current_process ()->pid, text, data) < 0)
return 0;
return 1;
}
@@ -438,7 +444,7 @@ haiku_process_target::start_non_stop (bool enable)
bool
haiku_process_target::thread_stopped (thread_info *thread)
{
- return haiku_nat::thread_stopped (ptid_of (thread));
+ return haiku_nat::thread_stopped (thread->id);
}
/* Implement the pid_to_exec_file target_ops method. */
--
2.43.0
next prev parent reply other threads:[~2026-03-12 17:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-12 17:23 [PATCH 0/8] Support for Haiku/x86-64 in GDB Jérôme Duval
2026-03-12 17:23 ` [PATCH 1/8] gdbserver: Initial Haiku support Jérôme Duval
2026-03-12 19:06 ` Kevin Buettner
2026-03-12 17:23 ` [PATCH 2/8] gdb: " Jérôme Duval
2026-03-12 18:31 ` Eli Zaretskii
2026-03-12 17:23 ` [PATCH 3/8] gdb: Update Haiku support for 16.x Jérôme Duval
2026-03-12 17:23 ` Jérôme Duval [this message]
2026-03-12 17:23 ` [PATCH 5/8] gdb: Update Haiku support for 17.x Jérôme Duval
2026-03-12 17:58 ` Tom Tromey
2026-03-12 17:23 ` [PATCH 6/8] gdbserver: " Jérôme Duval
2026-03-12 17:23 ` [PATCH 7/8] gdb: Update Haiku support for 18.x Jérôme Duval
2026-03-12 17:23 ` [PATCH 8/8] gdbserver: " Jérôme Duval
2026-03-12 17:37 ` [PATCH 0/8] Support for Haiku/x86-64 in GDB Tom Tromey
[not found] ` <CAPZRpdPY4Uzwu5BinMEDcU=0SQEXU0ca31-p_X_ZOJzdGcobkQ@mail.gmail.com>
2026-03-12 21:42 ` Trung Nguyen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260312172336.15450-5-jerome.duval@gmail.com \
--to=jerome.duval@gmail.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox