This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] [AArch64 Linux] Get rid of top byte from tagged address


Pedro Alves <palves@redhat.com> writes:

> I'm fine with doing this if it's what arm/linaro folks want,
> though personally (with absolutely no experience in this) I have
> reservations about whether stripping the top byte in the special
> case of memory accesses is a good idea, since it may puzzle folks
> when they pass such pointers/addresses in registers/structures and
> things don't magically work then (and then gdb masks the problem when
> folks try to diagnose it, as in "but I can access the object
> via "p *s->ptr", why isn't this working???  bad gdb.").
>
> So I think this should be documented in the manual somewhere.

I don't understand how does GDB affect the program.  ARMv8 architecture
supports tagged address for data values, and top byte of virtual address
is ignored in some cases,

  struct s s1;
  s1.i = 1234;
  struct s *p1 = &s1;
  struct s *p2 = &s1;
  uint64_t t = (uint64_t) p2;

  t |= 0xf000000000000000ULL;
  p2 = (struct s *) t;

  printf ("%p %d\n", p2, p2->i);

The program output is "0xf000ffffc2e51720 1234".

However, linux kernel applies an restriction that top one byte should be
zero when user space passes address to syscall or access /proc file
system.  When GDB debugs inferior, it needs to either pass address to
kernel through syscall (ptrace) or access /proc, kernel complains on the
address.  The point of this patch is to keep tagged bits in VA, and only
get rid of them at the point when the address is to be passed to kernel.
GDB has no problem debugging the example above,

(gdb) p p2
$1 = (struct s *) 0xf000fffffffff500
(gdb) p *p2
$2 = {i = 1234}
(gdb) p p2->i
$3 = 1234

-- 
Yao (齐尧)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]