]> git.ipfire.org Git - people/ms/ipfire-3.x.git/blob - gdb/patches/gdb-6.3-ia64-gcore-speedup-20050714.patch
Merge remote-tracking branch 'stevee/audit'
[people/ms/ipfire-3.x.git] / gdb / patches / gdb-6.3-ia64-gcore-speedup-20050714.patch
1 2005-07-14 Jeff Johnsotn <jjohnstn@redhat.com>
2
3 * linux-nat.c (linux_nat_xfer_memory): Incorporate Fujitsu
4 work-around to use /proc/mem for storage, but to fall-back
5 to PTRACE for ia64 rse register areas.
6 * ia64-linux-nat.c (ia64_rse_slot_num): New static function.
7 (ia64_rse_skip_regs): Ditto.
8 (ia64_linux_check_stack_region): New function.
9
10 Index: gdb-6.8.50.20090803/gdb/linux-nat.c
11 ===================================================================
12 --- gdb-6.8.50.20090803.orig/gdb/linux-nat.c 2009-08-04 06:29:55.000000000 +0200
13 +++ gdb-6.8.50.20090803/gdb/linux-nat.c 2009-08-04 06:30:53.000000000 +0200
14 @@ -4495,15 +4495,38 @@ linux_xfer_partial (struct target_ops *o
15 offset &= ((ULONGEST) 1 << addr_bit) - 1;
16 }
17
18 -#ifndef NATIVE_XFER_UNWIND_TABLE
19 - /* FIXME: For ia64, we cannot currently use linux_proc_xfer_memory
20 - for accessing thread storage. Revert when Bugzilla 147436
21 - is fixed. */
22 xfer = linux_proc_xfer_partial (ops, object, annex, readbuf, writebuf,
23 offset, len);
24 if (xfer != 0)
25 - return xfer;
26 + {
27 +#ifdef NATIVE_XFER_UNWIND_TABLE
28 + struct mem_region range;
29 + range.lo = memaddr;
30 + range.hi = memaddr + len;
31 +
32 + /* FIXME: For ia64, we cannot currently use
33 + linux_proc_xfer_partial for accessing rse register storage.
34 + Revert when Bugzilla 147436 is fixed. */
35 +#ifdef NATIVE_XFER_UNWIND_TABLE
36 + extern int ia64_linux_check_stack_region (struct lwp_info *lwp,
37 + void *range);
38 +#endif
39 + if (iterate_over_lwps (ia64_linux_check_stack_region, &range) != NULL)
40 + { /* This region contains ia64 rse registers, we have to re-read. */
41 + int xxfer;
42 +
43 + /* Re-read register stack area. */
44 + xxfer = super_xfer_partial (ops, object, annex,
45 + readbuf + (range.lo - memaddr),
46 + writebuf + (range.lo - memaddr),
47 + offset + (range.lo - memaddr),
48 + range.hi - range.lo);
49 + if (xxfer == 0)
50 + xfer = 0;
51 + }
52 #endif
53 + return xfer;
54 + }
55
56 return super_xfer_partial (ops, object, annex, readbuf, writebuf,
57 offset, len);
58 Index: gdb-6.8.50.20090803/gdb/ia64-linux-nat.c
59 ===================================================================
60 --- gdb-6.8.50.20090803.orig/gdb/ia64-linux-nat.c 2009-02-23 01:03:49.000000000 +0100
61 +++ gdb-6.8.50.20090803/gdb/ia64-linux-nat.c 2009-08-04 06:30:53.000000000 +0200
62 @@ -809,6 +809,64 @@ ia64_linux_xfer_partial (struct target_o
63
64 void _initialize_ia64_linux_nat (void);
65
66 +/*
67 + * Note: taken from ia64_tdep.c
68 + *
69 + */
70 +
71 +static __inline__ unsigned long
72 +ia64_rse_slot_num (unsigned long addr)
73 +{
74 + return (addr >> 3) & 0x3f;
75 +}
76 +
77 +/* Skip over a designated number of registers in the backing
78 + store, remembering every 64th position is for NAT. */
79 +static __inline__ unsigned long
80 +ia64_rse_skip_regs (unsigned long addr, long num_regs)
81 +{
82 + long delta = ia64_rse_slot_num(addr) + num_regs;
83 +
84 + if (num_regs < 0)
85 + delta -= 0x3e;
86 + return addr + ((num_regs + delta/0x3f) << 3);
87 +}
88 +
89 +/*
90 + * Check mem_region is stack or not. If stack, /proc/<pid>/mem cannot return
91 + * expected value.
92 + */
93 +int ia64_linux_check_stack_region(struct lwp_info *ti, struct mem_region *range)
94 +{
95 + CORE_ADDR addr;
96 + int error;
97 + unsigned long bsp, cfm, bspstore;
98 + long sof;
99 + pid_t pid = ptid_get_lwp(ti->ptid);
100 + bsp = ptrace(PTRACE_PEEKUSER, pid, PT_AR_BSP ,NULL);
101 + if (bsp == (unsigned long)-1) {
102 + return 1;
103 + }
104 + /* stack is allocated by one-segment, not separated into several segments.
105 + So, we only have to check whether bsp is in *range* or not. */
106 + if((range->lo <= bsp) && (bsp <= range->hi)) {
107 + bspstore = ptrace(PTRACE_PEEKUSER, pid, PT_AR_BSPSTORE, NULL);
108 + cfm = ptrace(PTRACE_PEEKUSER, pid, PT_CFM, NULL);
109 + sof = cfm & 0x3f;
110 + bsp = ia64_rse_skip_regs(bsp, -sof);
111 + range->lo = bspstore;
112 + range->hi = bsp;
113 + /* we have to check the size of dirty register stack area */
114 + /*
115 + fprintf_unfiltered(gdb_stdlog, "<%d> <%p> <%lx> <%p> <%p>\n",
116 + pid, bsp, sof, range->lo, range->hi);
117 + */
118 + return 1;
119 + }
120 +
121 + return 0;
122 +}
123 +
124 void
125 _initialize_ia64_linux_nat (void)
126 {