Skip to content

Commit

Permalink
devel/gdb: unlock and fix port
Browse files Browse the repository at this point in the history
  • Loading branch information
servizig committed Jan 26, 2024
1 parent 23efbf2 commit c98f7d6
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 129 deletions.
2 changes: 1 addition & 1 deletion ports/devel/gdb/STATUS
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
LOCK
PORT
Last attempt: 11.2
Last success: 11.2
35 changes: 33 additions & 2 deletions ports/devel/gdb/dragonfly/amd64-dfly-nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "amd64-bsd-nat.h"
#include "x86-nat.h"
#include "gdbsupport/x86-xstate.h"


class amd64_dfly_nat_target final
: public amd64_bsd_nat_target<dfly_nat_target>
Expand All @@ -51,6 +50,9 @@ class amd64_dfly_nat_target final
#if defined(HAVE_PT_GETDBREGS) && defined(USE_SIGTRAP_SIGINFO)
bool supports_stopped_by_hw_breakpoint () override;
#endif

protected:
void post_startup_inferior (ptid_t) override;
};

static amd64_dfly_nat_target the_amd64_dfly_nat_target;
Expand Down Expand Up @@ -246,7 +248,36 @@ amd64_dfly_nat_target::supports_stopped_by_hw_breakpoint ()
#endif

void
_initialize_amd64dfly_nat (void)
amd64_dfly_nat_target::post_startup_inferior (ptid_t pid)
{
#ifdef PT_GET_EVENT_MASK
int events;

if (ptrace (PT_GET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events,
sizeof (events)) == -1)
perror_with_name (("ptrace (PT_GET_EVENT_MASK)"));
events |= PTRACE_FORK | PTRACE_LWP;
#ifdef PTRACE_VFORK
events |= PTRACE_VFORK;
#endif
if (ptrace (PT_SET_EVENT_MASK, pid, (PTRACE_TYPE_ARG3)&events,
sizeof (events)) == -1)
perror_with_name (("ptrace (PT_SET_EVENT_MASK)"));
#else
#ifdef TDP_RFPPWAIT
if (ptrace (PT_FOLLOW_FORK, pid, (PTRACE_TYPE_ARG3)0, 1) == -1)
perror_with_name (("ptrace (PT_FOLLOW_FORK)"));
#endif
#ifdef PT_LWP_EVENTS
if (ptrace (PT_LWP_EVENTS, pid, (PTRACE_TYPE_ARG3)0, 1) == -1)
perror_with_name (("ptrace (PT_LWP_EVENTS)"));
#endif
#endif
}

void _initialize_amd64dfly_nat ();
void
_initialize_amd64dfly_nat ()
{
int offset;

Expand Down
9 changes: 5 additions & 4 deletions ports/devel/gdb/dragonfly/amd64-dfly-tdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ amd64fbsd_sigtramp_p (struct frame_info *this_frame)
address of the associated sigcontext structure. */

static CORE_ADDR
amd64dfly_sigcontext_addr (struct frame_info *this_frame)
amd64dfly_sigcontext_addr (struct frame_info_ptr this_frame)
{
struct gdbarch *gdbarch = get_frame_arch (this_frame);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
Expand All @@ -81,7 +81,7 @@ amd64dfly_sigcontext_addr (struct frame_info *this_frame)
sp = extract_unsigned_integer (buf, 8, byte_order);
return sp + 16;
}


/* Mapping between the general-purpose registers in `struct reg'
format and GDB's register cache layout.
Expand Down Expand Up @@ -175,7 +175,7 @@ static int amd64dfly_jmp_buf_reg_offset[] =
static void
amd64dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
i386_gdbarch_tdep *tdep = gdbarch_tdep<i386_gdbarch_tdep> (gdbarch);

/* Generic DragonFly support. */
dfly_init_abi (info, gdbarch);
Expand Down Expand Up @@ -222,8 +222,9 @@ amd64dfly_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
#endif
}

void _initialize_amd64dfly_tdep ();
void
_initialize_amd64dfly_tdep (void)
_initialize_amd64dfly_tdep ()
{
gdbarch_register_osabi (bfd_arch_i386, bfd_mach_x86_64,
GDB_OSABI_DRAGONFLY, amd64dfly_init_abi);
Expand Down
11 changes: 6 additions & 5 deletions ports/devel/gdb/dragonfly/dfly-nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
/* Return the name of a file that can be opened to get the symbols for
the child process identified by PID. */

char *
const char *
dfly_nat_target::pid_to_exec_file (int pid)
{
ssize_t len;
Expand Down Expand Up @@ -122,7 +122,7 @@ dfly_nat_target::find_memory_regions (find_memory_region_ftype func,
error (_("Couldn't open %s."), mapfilename.c_str ());

if (info_verbose)
fprintf_filtered (gdb_stdout,
gdb_printf (gdb_stdout,
"Reading memory regions from %s\n", mapfilename.c_str ());

/* Now iterate until end-of-file. */
Expand All @@ -136,7 +136,7 @@ dfly_nat_target::find_memory_regions (find_memory_region_ftype func,

if (info_verbose)
{
fprintf_filtered (gdb_stdout,
gdb_printf (gdb_stdout,
"Save segment, %ld bytes at %s (%c%c%c)\n",
size, paddress (target_gdbarch (), start),
read ? 'r' : '-',
Expand All @@ -146,7 +146,7 @@ dfly_nat_target::find_memory_regions (find_memory_region_ftype func,

/* Invoke the callback function to create the corefile segment.
Pass MODIFIED as true, we do not know the real modification state. */
func (start, size, read, write, exec, 1, obfd);
func (start, size, read, write, exec, 1, false, obfd);
}

return 0;
Expand All @@ -166,8 +166,9 @@ dfly_nat_add_target (struct target_ops *t)
/* Provide a prototype to silence -Wmissing-prototypes. */
extern initialize_file_ftype _initialize_dfly_nat;

void _initialize_dfly_nat ();
void
_initialize_dfly_nat (void)
_initialize_dfly_nat ()
{
/* XXX: todo add_setshow_boolean_cmd() */
}
2 changes: 1 addition & 1 deletion ports/devel/gdb/dragonfly/dfly-nat.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class dfly_nat_target : public inf_ptrace_target
{
public:
char *pid_to_exec_file (int pid) override;
const char *pid_to_exec_file (int pid) override;

int find_memory_regions (find_memory_region_ftype func, void *data) override;

Expand Down
Loading

0 comments on commit c98f7d6

Please sign in to comment.