This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[Patch + 1] Add support for hw bp on darwin
- From: Tristan Gingold <gingold at adacore dot com>
- To: "gdb-patches at sourceware dot org ml" <gdb-patches at sourceware dot org>
- Date: Thu, 3 Oct 2013 11:46:11 +0200
- Subject: [Patch + 1] Add support for hw bp on darwin
- Authentication-results: sourceware.org; auth=none
- References: <3BC47A45-C26F-4CD8-862A-232E461D781E at adacore dot com>
On Sep 30, 2013, at 4:06 PM, Tristan Gingold <gingold@adacore.com> wrote:
> Hi,
>
> most of the code was already present; so I just added the code to
> register the handlers, tested on both 32 and 64 bit binaries.
Humm, apparently I didn't tested enough on 64 bit binaries... There
were a few unexpected casts.
I also removed some trailing spaces and verbosity in some error messages.
Committed to trunk.
Tristan.
2013-10-03 Tristan Gingold <gingold@adacore.com>
* i386-darwin-nat.c (i386_darwin_dr_set): Fix argument type.
Remove verbose error reporting. Use detected state to
thread_set_state call.
(i386_darwin_dr_get): Fix return type. Remove verbose error
report.
Remove trailing spaces.
diff --git a/gdb/i386-darwin-nat.c b/gdb/i386-darwin-nat.c
index 66ea943..742ceda 100644
--- a/gdb/i386-darwin-nat.c
+++ b/gdb/i386-darwin-nat.c
@@ -263,7 +263,7 @@ i386_darwin_store_inferior_registers (struct target_ops *ops,
/* Support for debug registers, boosted mostly from i386-linux-nat.c. */
static void
-i386_darwin_dr_set (int regnum, uint32_t value)
+i386_darwin_dr_set (int regnum, CORE_ADDR value)
{
int current_pid;
thread_t current_thread;
@@ -280,14 +280,7 @@ i386_darwin_dr_set (int regnum, uint32_t value)
dr_count = x86_DEBUG_STATE_COUNT;
ret = thread_get_state (current_thread, x86_DEBUG_STATE,
(thread_state_t) &dr_regs, &dr_count);
-
- if (ret != KERN_SUCCESS)
- {
- printf_unfiltered (_("Error reading debug registers "
- "thread 0x%x via thread_get_state\n"),
- (int) current_thread);
- MACH_CHECK_ERROR (ret);
- }
+ MACH_CHECK_ERROR (ret);
switch (dr_regs.dsh.flavor)
{
@@ -353,19 +346,13 @@ i386_darwin_dr_set (int regnum, uint32_t value)
#endif
}
- ret = thread_set_state (current_thread, x86_DEBUG_STATE,
- (thread_state_t) &dr_regs, dr_count);
+ ret = thread_set_state (current_thread, dr_regs.dsh.flavor,
+ (thread_state_t) &dr_regs.uds, dr_count);
- if (ret != KERN_SUCCESS)
- {
- printf_unfiltered (_("Error writing debug registers "
- "thread 0x%x via thread_get_state\n"),
- (int) current_thread);
- MACH_CHECK_ERROR (ret);
- }
+ MACH_CHECK_ERROR (ret);
}
-static uint32_t
+static CORE_ADDR
i386_darwin_dr_get (int regnum)
{
thread_t current_thread;
@@ -382,14 +369,7 @@ i386_darwin_dr_get (int regnum)
dr_count = x86_DEBUG_STATE_COUNT;
ret = thread_get_state (current_thread, x86_DEBUG_STATE,
(thread_state_t) &dr_regs, &dr_count);
-
- if (ret != KERN_SUCCESS)
- {
- printf_unfiltered (_("Error reading debug registers "
- "thread 0x%x via thread_get_state\n"),
- (int) current_thread);
- MACH_CHECK_ERROR (ret);
- }
+ MACH_CHECK_ERROR (ret);
switch (dr_regs.dsh.flavor)
{
@@ -605,14 +585,14 @@ darwin_set_sstep (thread_t thread, int enable)
case x86_THREAD_STATE32:
{
__uint32_t bit = enable ? X86_EFLAGS_T : 0;
-
+
if (enable && i386_darwin_sstep_at_sigreturn (®s))
return;
if ((regs.uts.ts32.__eflags & X86_EFLAGS_T) == bit)
return;
regs.uts.ts32.__eflags
= (regs.uts.ts32.__eflags & ~X86_EFLAGS_T) | bit;
- kret = thread_set_state (thread, x86_THREAD_STATE,
+ kret = thread_set_state (thread, x86_THREAD_STATE,
(thread_state_t) ®s, count);
MACH_CHECK_ERROR (kret);
}
@@ -628,7 +608,7 @@ darwin_set_sstep (thread_t thread, int enable)
return;
regs.uts.ts64.__rflags
= (regs.uts.ts64.__rflags & ~X86_EFLAGS_T) | bit;
- kret = thread_set_state (thread, x86_THREAD_STATE,
+ kret = thread_set_state (thread, x86_THREAD_STATE,
(thread_state_t) ®s, count);
MACH_CHECK_ERROR (kret);
}