1 /* Functions specific to running gdb native on IA-64 running
4 Copyright (C) 1999-2022 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
27 #include "ia64-tdep.h"
28 #include "linux-nat.h"
31 #include "nat/gdb_ptrace.h"
32 #include "gdbsupport/gdb_wait.h"
36 #include <sys/syscall.h>
39 #include <asm/ptrace_offsets.h>
40 #include <sys/procfs.h>
42 /* Prototypes for supply_gregset etc. */
45 #include "inf-ptrace.h"
47 class ia64_linux_nat_target final
: public linux_nat_target
50 /* Add our register access methods. */
51 void fetch_registers (struct regcache
*, int) override
;
52 void store_registers (struct regcache
*, int) override
;
54 enum target_xfer_status
xfer_partial (enum target_object object
,
57 const gdb_byte
*writebuf
,
58 ULONGEST offset
, ULONGEST len
,
59 ULONGEST
*xfered_len
) override
;
61 /* Override watchpoint routines. */
63 /* The IA-64 architecture can step over a watch point (without
64 triggering it again) if the "dd" (data debug fault disable) bit
65 in the processor status word is set.
67 This PSR bit is set in
68 ia64_linux_nat_target::stopped_by_watchpoint when the code there
69 has determined that a hardware watchpoint has indeed been hit.
70 The CPU will then be able to execute one instruction without
71 triggering a watchpoint. */
72 bool have_steppable_watchpoint () override
{ return true; }
74 int can_use_hw_breakpoint (enum bptype
, int, int) override
;
75 bool stopped_by_watchpoint () override
;
76 bool stopped_data_address (CORE_ADDR
*) override
;
77 int insert_watchpoint (CORE_ADDR
, int, enum target_hw_bp_type
,
78 struct expression
*) override
;
79 int remove_watchpoint (CORE_ADDR
, int, enum target_hw_bp_type
,
80 struct expression
*) override
;
81 /* Override linux_nat_target low methods. */
82 void low_new_thread (struct lwp_info
*lp
) override
;
83 bool low_status_is_event (int status
) override
;
85 void enable_watchpoints_in_psr (ptid_t ptid
);
88 static ia64_linux_nat_target the_ia64_linux_nat_target
;
90 /* These must match the order of the register names.
92 Some sort of lookup table is needed because the offsets associated
93 with the registers are all over the board. */
95 static int u_offsets
[] =
97 /* general registers */
98 -1, /* gr0 not available; i.e, it's always zero. */
130 /* gr32 through gr127 not directly available via the ptrace interface. */
131 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
132 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
133 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
134 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
135 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
136 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
137 /* Floating point registers */
138 -1, -1, /* f0 and f1 not available (f0 is +0.0 and f1 is +1.0). */
265 /* Predicate registers - we don't fetch these individually. */
266 -1, -1, -1, -1, -1, -1, -1, -1,
267 -1, -1, -1, -1, -1, -1, -1, -1,
268 -1, -1, -1, -1, -1, -1, -1, -1,
269 -1, -1, -1, -1, -1, -1, -1, -1,
270 -1, -1, -1, -1, -1, -1, -1, -1,
271 -1, -1, -1, -1, -1, -1, -1, -1,
272 -1, -1, -1, -1, -1, -1, -1, -1,
273 -1, -1, -1, -1, -1, -1, -1, -1,
274 /* branch registers */
283 /* Virtual frame pointer and virtual return address pointer. */
285 /* other registers */
288 PT_CR_IPSR
, /* psr */
290 /* kernel registers not visible via ptrace interface (?) */
291 -1, -1, -1, -1, -1, -1, -1, -1,
293 -1, -1, -1, -1, -1, -1, -1, -1,
299 -1, /* Not available: FCR, IA32 floating control register. */
301 -1, /* Not available: EFLAG */
302 -1, /* Not available: CSD */
303 -1, /* Not available: SSD */
304 -1, /* Not available: CFLG */
305 -1, /* Not available: FSR */
306 -1, /* Not available: FIR */
307 -1, /* Not available: FDR */
315 -1, /* Not available: ITC */
316 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
317 -1, -1, -1, -1, -1, -1, -1, -1, -1,
321 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
322 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
323 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
324 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
325 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
326 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
328 /* nat bits - not fetched directly; instead we obtain these bits from
329 either rnat or unat or from memory. */
330 -1, -1, -1, -1, -1, -1, -1, -1,
331 -1, -1, -1, -1, -1, -1, -1, -1,
332 -1, -1, -1, -1, -1, -1, -1, -1,
333 -1, -1, -1, -1, -1, -1, -1, -1,
334 -1, -1, -1, -1, -1, -1, -1, -1,
335 -1, -1, -1, -1, -1, -1, -1, -1,
336 -1, -1, -1, -1, -1, -1, -1, -1,
337 -1, -1, -1, -1, -1, -1, -1, -1,
338 -1, -1, -1, -1, -1, -1, -1, -1,
339 -1, -1, -1, -1, -1, -1, -1, -1,
340 -1, -1, -1, -1, -1, -1, -1, -1,
341 -1, -1, -1, -1, -1, -1, -1, -1,
342 -1, -1, -1, -1, -1, -1, -1, -1,
343 -1, -1, -1, -1, -1, -1, -1, -1,
344 -1, -1, -1, -1, -1, -1, -1, -1,
345 -1, -1, -1, -1, -1, -1, -1, -1,
349 ia64_register_addr (struct gdbarch
*gdbarch
, int regno
)
353 if (regno
< 0 || regno
>= gdbarch_num_regs (gdbarch
))
354 error (_("Invalid register number %d."), regno
);
356 if (u_offsets
[regno
] == -1)
359 addr
= (CORE_ADDR
) u_offsets
[regno
];
365 ia64_cannot_fetch_register (struct gdbarch
*gdbarch
, int regno
)
368 || regno
>= gdbarch_num_regs (gdbarch
)
369 || u_offsets
[regno
] == -1;
373 ia64_cannot_store_register (struct gdbarch
*gdbarch
, int regno
)
375 /* Rationale behind not permitting stores to bspstore...
377 The IA-64 architecture provides bspstore and bsp which refer
378 memory locations in the RSE's backing store. bspstore is the
379 next location which will be written when the RSE needs to write
380 to memory. bsp is the address at which r32 in the current frame
381 would be found if it were written to the backing store.
383 The IA-64 architecture provides read-only access to bsp and
384 read/write access to bspstore (but only when the RSE is in
385 the enforced lazy mode). It should be noted that stores
386 to bspstore also affect the value of bsp. Changing bspstore
387 does not affect the number of dirty entries between bspstore
388 and bsp, so changing bspstore by N words will also cause bsp
389 to be changed by (roughly) N as well. (It could be N-1 or N+1
390 depending upon where the NaT collection bits fall.)
392 OTOH, the Linux kernel provides read/write access to bsp (and
393 currently read/write access to bspstore as well). But it
394 is definitely the case that if you change one, the other
395 will change at the same time. It is more useful to gdb to
396 be able to change bsp. So in order to prevent strange and
397 undesirable things from happening when a dummy stack frame
398 is popped (after calling an inferior function), we allow
399 bspstore to be read, but not written. (Note that popping
400 a (generic) dummy stack frame causes all registers that
401 were previously read from the inferior process to be written
405 || regno
>= gdbarch_num_regs (gdbarch
)
406 || u_offsets
[regno
] == -1
407 || regno
== IA64_BSPSTORE_REGNUM
;
411 supply_gregset (struct regcache
*regcache
, const gregset_t
*gregsetp
)
414 const greg_t
*regp
= (const greg_t
*) gregsetp
;
416 for (regi
= IA64_GR0_REGNUM
; regi
<= IA64_GR31_REGNUM
; regi
++)
418 regcache
->raw_supply (regi
, regp
+ (regi
- IA64_GR0_REGNUM
));
421 /* FIXME: NAT collection bits are at index 32; gotta deal with these
424 regcache
->raw_supply (IA64_PR_REGNUM
, regp
+ 33);
426 for (regi
= IA64_BR0_REGNUM
; regi
<= IA64_BR7_REGNUM
; regi
++)
428 regcache
->raw_supply (regi
, regp
+ 34 + (regi
- IA64_BR0_REGNUM
));
431 regcache
->raw_supply (IA64_IP_REGNUM
, regp
+ 42);
432 regcache
->raw_supply (IA64_CFM_REGNUM
, regp
+ 43);
433 regcache
->raw_supply (IA64_PSR_REGNUM
, regp
+ 44);
434 regcache
->raw_supply (IA64_RSC_REGNUM
, regp
+ 45);
435 regcache
->raw_supply (IA64_BSP_REGNUM
, regp
+ 46);
436 regcache
->raw_supply (IA64_BSPSTORE_REGNUM
, regp
+ 47);
437 regcache
->raw_supply (IA64_RNAT_REGNUM
, regp
+ 48);
438 regcache
->raw_supply (IA64_CCV_REGNUM
, regp
+ 49);
439 regcache
->raw_supply (IA64_UNAT_REGNUM
, regp
+ 50);
440 regcache
->raw_supply (IA64_FPSR_REGNUM
, regp
+ 51);
441 regcache
->raw_supply (IA64_PFS_REGNUM
, regp
+ 52);
442 regcache
->raw_supply (IA64_LC_REGNUM
, regp
+ 53);
443 regcache
->raw_supply (IA64_EC_REGNUM
, regp
+ 54);
447 fill_gregset (const struct regcache
*regcache
, gregset_t
*gregsetp
, int regno
)
450 greg_t
*regp
= (greg_t
*) gregsetp
;
452 #define COPY_REG(_idx_,_regi_) \
453 if ((regno == -1) || regno == _regi_) \
454 regcache->raw_collect (_regi_, regp + _idx_)
456 for (regi
= IA64_GR0_REGNUM
; regi
<= IA64_GR31_REGNUM
; regi
++)
458 COPY_REG (regi
- IA64_GR0_REGNUM
, regi
);
461 /* FIXME: NAT collection bits at index 32? */
463 COPY_REG (33, IA64_PR_REGNUM
);
465 for (regi
= IA64_BR0_REGNUM
; regi
<= IA64_BR7_REGNUM
; regi
++)
467 COPY_REG (34 + (regi
- IA64_BR0_REGNUM
), regi
);
470 COPY_REG (42, IA64_IP_REGNUM
);
471 COPY_REG (43, IA64_CFM_REGNUM
);
472 COPY_REG (44, IA64_PSR_REGNUM
);
473 COPY_REG (45, IA64_RSC_REGNUM
);
474 COPY_REG (46, IA64_BSP_REGNUM
);
475 COPY_REG (47, IA64_BSPSTORE_REGNUM
);
476 COPY_REG (48, IA64_RNAT_REGNUM
);
477 COPY_REG (49, IA64_CCV_REGNUM
);
478 COPY_REG (50, IA64_UNAT_REGNUM
);
479 COPY_REG (51, IA64_FPSR_REGNUM
);
480 COPY_REG (52, IA64_PFS_REGNUM
);
481 COPY_REG (53, IA64_LC_REGNUM
);
482 COPY_REG (54, IA64_EC_REGNUM
);
485 /* Given a pointer to a floating point register set in /proc format
486 (fpregset_t *), unpack the register contents and supply them as gdb's
487 idea of the current floating point register values. */
490 supply_fpregset (struct regcache
*regcache
, const fpregset_t
*fpregsetp
)
494 const gdb_byte f_zero
[16] = { 0 };
495 const gdb_byte f_one
[16] =
496 { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
498 /* Kernel generated cores have fr1==0 instead of 1.0. Older GDBs
499 did the same. So ignore whatever might be recorded in fpregset_t
500 for fr0/fr1 and always supply their expected values. */
502 /* fr0 is always read as zero. */
503 regcache
->raw_supply (IA64_FR0_REGNUM
, f_zero
);
504 /* fr1 is always read as one (1.0). */
505 regcache
->raw_supply (IA64_FR1_REGNUM
, f_one
);
507 for (regi
= IA64_FR2_REGNUM
; regi
<= IA64_FR127_REGNUM
; regi
++)
509 from
= (const char *) &((*fpregsetp
)[regi
- IA64_FR0_REGNUM
]);
510 regcache
->raw_supply (regi
, from
);
514 /* Given a pointer to a floating point register set in /proc format
515 (fpregset_t *), update the register specified by REGNO from gdb's idea
516 of the current floating point register set. If REGNO is -1, update
520 fill_fpregset (const struct regcache
*regcache
,
521 fpregset_t
*fpregsetp
, int regno
)
525 for (regi
= IA64_FR0_REGNUM
; regi
<= IA64_FR127_REGNUM
; regi
++)
527 if ((regno
== -1) || (regno
== regi
))
528 regcache
->raw_collect (regi
, &((*fpregsetp
)[regi
- IA64_FR0_REGNUM
]));
532 #define IA64_PSR_DB (1UL << 24)
533 #define IA64_PSR_DD (1UL << 39)
536 ia64_linux_nat_target::enable_watchpoints_in_psr (ptid_t ptid
)
538 struct regcache
*regcache
= get_thread_regcache (this, ptid
);
541 regcache_cooked_read_unsigned (regcache
, IA64_PSR_REGNUM
, &psr
);
542 if (!(psr
& IA64_PSR_DB
))
544 psr
|= IA64_PSR_DB
; /* Set the db bit - this enables hardware
545 watchpoints and breakpoints. */
546 regcache_cooked_write_unsigned (regcache
, IA64_PSR_REGNUM
, psr
);
550 static long debug_registers
[8];
553 store_debug_register (ptid_t ptid
, int idx
, long val
)
561 (void) ptrace (PT_WRITE_U
, tid
, (PTRACE_TYPE_ARG3
) (PT_DBR
+ 8 * idx
), val
);
565 store_debug_register_pair (ptid_t ptid
, int idx
, long *dbr_addr
,
569 store_debug_register (ptid
, 2 * idx
, *dbr_addr
);
571 store_debug_register (ptid
, 2 * idx
+ 1, *dbr_mask
);
575 is_power_of_2 (int val
)
580 for (i
= 0; i
< 8 * sizeof (val
); i
++)
584 return onecount
<= 1;
588 ia64_linux_nat_target::insert_watchpoint (CORE_ADDR addr
, int len
,
589 enum target_hw_bp_type type
,
590 struct expression
*cond
)
593 long dbr_addr
, dbr_mask
;
594 int max_watchpoints
= 4;
596 if (len
<= 0 || !is_power_of_2 (len
))
599 for (idx
= 0; idx
< max_watchpoints
; idx
++)
601 dbr_mask
= debug_registers
[idx
* 2 + 1];
602 if ((dbr_mask
& (0x3UL
<< 62)) == 0)
604 /* Exit loop if both r and w bits clear. */
609 if (idx
== max_watchpoints
)
612 dbr_addr
= (long) addr
;
613 dbr_mask
= (~(len
- 1) & 0x00ffffffffffffffL
); /* construct mask to match */
614 dbr_mask
|= 0x0800000000000000L
; /* Only match privilege level 3 */
618 dbr_mask
|= (1L << 62); /* Set w bit */
621 dbr_mask
|= (1L << 63); /* Set r bit */
624 dbr_mask
|= (3L << 62); /* Set both r and w bits */
630 debug_registers
[2 * idx
] = dbr_addr
;
631 debug_registers
[2 * idx
+ 1] = dbr_mask
;
633 for (const lwp_info
*lp
: all_lwps ())
635 store_debug_register_pair (lp
->ptid
, idx
, &dbr_addr
, &dbr_mask
);
636 enable_watchpoints_in_psr (lp
->ptid
);
643 ia64_linux_nat_target::remove_watchpoint (CORE_ADDR addr
, int len
,
644 enum target_hw_bp_type type
,
645 struct expression
*cond
)
648 long dbr_addr
, dbr_mask
;
649 int max_watchpoints
= 4;
651 if (len
<= 0 || !is_power_of_2 (len
))
654 for (idx
= 0; idx
< max_watchpoints
; idx
++)
656 dbr_addr
= debug_registers
[2 * idx
];
657 dbr_mask
= debug_registers
[2 * idx
+ 1];
658 if ((dbr_mask
& (0x3UL
<< 62)) && addr
== (CORE_ADDR
) dbr_addr
)
660 debug_registers
[2 * idx
] = 0;
661 debug_registers
[2 * idx
+ 1] = 0;
665 for (const lwp_info
*lp
: all_lwps ())
666 store_debug_register_pair (lp
->ptid
, idx
, &dbr_addr
, &dbr_mask
);
675 ia64_linux_nat_target::low_new_thread (struct lwp_info
*lp
)
680 for (i
= 0; i
< 8; i
++)
682 if (debug_registers
[i
] != 0)
684 store_debug_register (lp
->ptid
, i
, debug_registers
[i
]);
688 enable_watchpoints_in_psr (lp
->ptid
);
692 ia64_linux_nat_target::stopped_data_address (CORE_ADDR
*addr_p
)
696 struct regcache
*regcache
= get_current_regcache ();
698 if (!linux_nat_get_siginfo (inferior_ptid
, &siginfo
))
701 if (siginfo
.si_signo
!= SIGTRAP
702 || (siginfo
.si_code
& 0xffff) != 0x0004 /* TRAP_HWBKPT */)
705 regcache_cooked_read_unsigned (regcache
, IA64_PSR_REGNUM
, &psr
);
706 psr
|= IA64_PSR_DD
; /* Set the dd bit - this will disable the watchpoint
707 for the next instruction. */
708 regcache_cooked_write_unsigned (regcache
, IA64_PSR_REGNUM
, psr
);
710 *addr_p
= (CORE_ADDR
) siginfo
.si_addr
;
715 ia64_linux_nat_target::stopped_by_watchpoint ()
718 return stopped_data_address (&addr
);
722 ia64_linux_nat_target::can_use_hw_breakpoint (enum bptype type
,
723 int cnt
, int othertype
)
729 /* Fetch register REGNUM from the inferior. */
732 ia64_linux_fetch_register (struct regcache
*regcache
, int regnum
)
734 struct gdbarch
*gdbarch
= regcache
->arch ();
737 PTRACE_TYPE_RET
*buf
;
741 /* r0 cannot be fetched but is always zero. */
742 if (regnum
== IA64_GR0_REGNUM
)
744 const gdb_byte zero
[8] = { 0 };
746 gdb_assert (sizeof (zero
) == register_size (gdbarch
, regnum
));
747 regcache
->raw_supply (regnum
, zero
);
751 /* fr0 cannot be fetched but is always zero. */
752 if (regnum
== IA64_FR0_REGNUM
)
754 const gdb_byte f_zero
[16] = { 0 };
756 gdb_assert (sizeof (f_zero
) == register_size (gdbarch
, regnum
));
757 regcache
->raw_supply (regnum
, f_zero
);
761 /* fr1 cannot be fetched but is always one (1.0). */
762 if (regnum
== IA64_FR1_REGNUM
)
764 const gdb_byte f_one
[16] =
765 { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0xff, 0, 0, 0, 0, 0, 0 };
767 gdb_assert (sizeof (f_one
) == register_size (gdbarch
, regnum
));
768 regcache
->raw_supply (regnum
, f_one
);
772 if (ia64_cannot_fetch_register (gdbarch
, regnum
))
774 regcache
->raw_supply (regnum
, NULL
);
778 pid
= get_ptrace_pid (regcache
->ptid ());
780 /* This isn't really an address, but ptrace thinks of it as one. */
781 addr
= ia64_register_addr (gdbarch
, regnum
);
782 size
= register_size (gdbarch
, regnum
);
784 gdb_assert ((size
% sizeof (PTRACE_TYPE_RET
)) == 0);
785 buf
= (PTRACE_TYPE_RET
*) alloca (size
);
787 /* Read the register contents from the inferior a chunk at a time. */
788 for (i
= 0; i
< size
/ sizeof (PTRACE_TYPE_RET
); i
++)
791 buf
[i
] = ptrace (PT_READ_U
, pid
, (PTRACE_TYPE_ARG3
)addr
, 0);
793 error (_("Couldn't read register %s (#%d): %s."),
794 gdbarch_register_name (gdbarch
, regnum
),
795 regnum
, safe_strerror (errno
));
797 addr
+= sizeof (PTRACE_TYPE_RET
);
799 regcache
->raw_supply (regnum
, buf
);
802 /* Fetch register REGNUM from the inferior. If REGNUM is -1, do this
803 for all registers. */
806 ia64_linux_nat_target::fetch_registers (struct regcache
*regcache
, int regnum
)
810 regnum
< gdbarch_num_regs (regcache
->arch ());
812 ia64_linux_fetch_register (regcache
, regnum
);
814 ia64_linux_fetch_register (regcache
, regnum
);
817 /* Store register REGNUM into the inferior. */
820 ia64_linux_store_register (const struct regcache
*regcache
, int regnum
)
822 struct gdbarch
*gdbarch
= regcache
->arch ();
825 PTRACE_TYPE_RET
*buf
;
829 if (ia64_cannot_store_register (gdbarch
, regnum
))
832 pid
= get_ptrace_pid (regcache
->ptid ());
834 /* This isn't really an address, but ptrace thinks of it as one. */
835 addr
= ia64_register_addr (gdbarch
, regnum
);
836 size
= register_size (gdbarch
, regnum
);
838 gdb_assert ((size
% sizeof (PTRACE_TYPE_RET
)) == 0);
839 buf
= (PTRACE_TYPE_RET
*) alloca (size
);
841 /* Write the register contents into the inferior a chunk at a time. */
842 regcache
->raw_collect (regnum
, buf
);
843 for (i
= 0; i
< size
/ sizeof (PTRACE_TYPE_RET
); i
++)
846 ptrace (PT_WRITE_U
, pid
, (PTRACE_TYPE_ARG3
)addr
, buf
[i
]);
848 error (_("Couldn't write register %s (#%d): %s."),
849 gdbarch_register_name (gdbarch
, regnum
),
850 regnum
, safe_strerror (errno
));
852 addr
+= sizeof (PTRACE_TYPE_RET
);
856 /* Store register REGNUM back into the inferior. If REGNUM is -1, do
857 this for all registers. */
860 ia64_linux_nat_target::store_registers (struct regcache
*regcache
, int regnum
)
864 regnum
< gdbarch_num_regs (regcache
->arch ());
866 ia64_linux_store_register (regcache
, regnum
);
868 ia64_linux_store_register (regcache
, regnum
);
871 /* Implement the xfer_partial target_ops method. */
873 enum target_xfer_status
874 ia64_linux_nat_target::xfer_partial (enum target_object object
,
876 gdb_byte
*readbuf
, const gdb_byte
*writebuf
,
877 ULONGEST offset
, ULONGEST len
,
878 ULONGEST
*xfered_len
)
880 if (object
== TARGET_OBJECT_UNWIND_TABLE
&& readbuf
!= NULL
)
882 static long gate_table_size
;
886 /* Probe for the table size once. */
887 if (gate_table_size
== 0)
888 gate_table_size
= syscall (__NR_getunwind
, NULL
, 0);
889 if (gate_table_size
< 0)
890 return TARGET_XFER_E_IO
;
892 if (offset
>= gate_table_size
)
893 return TARGET_XFER_EOF
;
895 tmp_buf
= (gdb_byte
*) alloca (gate_table_size
);
896 res
= syscall (__NR_getunwind
, tmp_buf
, gate_table_size
);
898 return TARGET_XFER_E_IO
;
899 gdb_assert (res
== gate_table_size
);
901 if (offset
+ len
> gate_table_size
)
902 len
= gate_table_size
- offset
;
904 memcpy (readbuf
, tmp_buf
+ offset
, len
);
906 return TARGET_XFER_OK
;
909 return linux_nat_target::xfer_partial (object
, annex
, readbuf
, writebuf
,
910 offset
, len
, xfered_len
);
913 /* For break.b instruction ia64 CPU forgets the immediate value and generates
914 SIGILL with ILL_ILLOPC instead of more common SIGTRAP with TRAP_BRKPT.
915 ia64 does not use gdbarch_decr_pc_after_break so we do not have to make any
916 difference for the signals here. */
919 ia64_linux_nat_target::low_status_is_event (int status
)
921 return WIFSTOPPED (status
) && (WSTOPSIG (status
) == SIGTRAP
922 || WSTOPSIG (status
) == SIGILL
);
925 void _initialize_ia64_linux_nat ();
927 _initialize_ia64_linux_nat ()
929 /* Register the target. */
930 linux_target
= &the_ia64_linux_nat_target
;
931 add_inf_child_target (&the_ia64_linux_nat_target
);