Skip to content

Commit d36bf06

Browse files
committed
add user_regs for linux on arm
This struct is used for `PTRACE_GETREGS` & `PTRACE_SETREGS`. We mirror the name used in `glibc`. This struct is called `pt_regs` in the kernel. glibc uses a single array `uregs` instead of individual fields. The `asm/ptrace.h` header defined by the linux kernel defines macros to access the individual registers. Instead of `uregs` we just define the registers as individual fields.
1 parent 216a428 commit d36bf06

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

libc-test/build.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3811,7 +3811,9 @@ fn test_linux(target: &str) {
38113811
// https://github.com/torvalds/linux/commit/dc8eeef73b63ed8988224ba6b5ed19a615163a7f
38123812
(struct_ == "sockaddr_vm" && field == "svm_zero") ||
38133813
// the `ifr_ifru` field is an anonymous union
3814-
(struct_ == "ifreq" && field == "ifr_ifru")
3814+
(struct_ == "ifreq" && field == "ifr_ifru") ||
3815+
// glibc uses a single array `uregs` instead of individual fields.
3816+
(struct_ == "user_regs" && arm)
38153817
});
38163818

38173819
cfg.skip_roundtrip(move |s| match s {

src/unix/linux_like/linux/gnu/b32/arm/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,27 @@ s! {
191191
pub arm_cpsr: ::c_ulong,
192192
pub fault_address: ::c_ulong,
193193
}
194+
195+
pub struct user_regs {
196+
pub arm_r0: ::c_ulong,
197+
pub arm_r1: ::c_ulong,
198+
pub arm_r2: ::c_ulong,
199+
pub arm_r3: ::c_ulong,
200+
pub arm_r4: ::c_ulong,
201+
pub arm_r5: ::c_ulong,
202+
pub arm_r6: ::c_ulong,
203+
pub arm_r7: ::c_ulong,
204+
pub arm_r8: ::c_ulong,
205+
pub arm_r9: ::c_ulong,
206+
pub arm_r10: ::c_ulong,
207+
pub arm_fp: ::c_ulong,
208+
pub arm_ip: ::c_ulong,
209+
pub arm_sp: ::c_ulong,
210+
pub arm_lr: ::c_ulong,
211+
pub arm_pc: ::c_ulong,
212+
pub arm_cpsr: ::c_ulong,
213+
pub arm_orig_r0: ::c_ulong,
214+
}
194215
}
195216

196217
pub const VEOF: usize = 4;

0 commit comments

Comments
 (0)