Re: [native AAarch64 GNU/Linux] Access debug register mirror from the corresponding process.

Yufeng Zhang
2013-02-13T18:57:00Z

[-- Attachment #1: Type: text/plain, Size: 588 bytes --]

On 02/13/13 16:01, Pedro Alves wrote:
> On 02/13/2013 03:21 PM, Marcus Shawcroft wrote:
>>> I'll send you an aarch64 version of this patch, unless you've
>>> already started porting the necessary bits over.
>>
>> We were just about to get started... but if you have a patch in hand
>> that would be great!
>
> Here it is. Completely untested, of course. But hopefully not
> too far off.

Not far off at all; thanks! I have tested your patch and made some
further changes; please find the attached patch. The two patches
together seem to be working.

Thanks,
Yufeng

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: aarch64-fix.diff --]
[-- Type: text/x-patch; name=aarch64-fix.diff, Size: 2038 bytes --]

diff --git a/gdb/aarch64-linux-nat.c b/gdb/aarch64-linux-nat.c
index 89055f4..846f156 100644
--- a/gdb/aarch64-linux-nat.c
+++ b/gdb/aarch64-linux-nat.c
@@ -336,7 +336,7 @@ struct aarch64_dr_update_callback_param
unsigned int idx;
};

-/* Callback for linux_nat_iterate_watchpoint_lwps. Records the
+/* Callback for iterate_over_lwps. Records the
information about the change of one hardware breakpoint/watchpoint
setting for the thread LWP.
The information is passed in via PTR.
@@ -410,12 +410,12 @@ aarch64_notify_debug_reg_change (const struct aarch64_debug_reg_state *state,
int is_watchpoint, unsigned int idx)
{
struct aarch64_dr_update_callback_param param;
+ ptid_t pid_ptid = pid_to_ptid (ptid_get_pid (inferior_ptid));

param.is_watchpoint = is_watchpoint;
param.idx = idx;

- linux_nat_iterate_watchpoint_lwps (debug_reg_change_callback,
- (void *) &param);
+ iterate_over_lwps (pid_ptid, debug_reg_change_callback, (void *) &param);
}

/* Print the values of the cached breakpoint/watchpoint registers. */
@@ -739,8 +739,8 @@ aarch64_linux_new_fork (struct lwp_info *parent, pid_t child_pid)
removed together. */

parent_pid = ptid_get_pid (parent->ptid);
- parent_state = i386_debug_reg_state (parent_pid);
- child_state = i386_debug_reg_state (child_pid);
+ parent_state = aarch64_get_debug_reg_state (parent_pid);
+ child_state = aarch64_get_debug_reg_state (child_pid);
*child_state = *parent_state;
}
\f
@@ -1540,10 +1540,6 @@ _initialize_aarch64_linux_nat (void)
t->to_stopped_data_address = aarch64_linux_stopped_data_address;
t->to_watchpoint_addr_within_range =
aarch64_linux_watchpoint_addr_within_range;
- if (aarch64_inferior_data == NULL)
- aarch64_inferior_data
- = register_inferior_data_with_cleanup (NULL,
- aarch64_inferior_data_cleanup);

/* Override the GNU/Linux inferior startup hook. */
super_post_startup_inferior = t->to_post_startup_inferior;