diff -Nru gdb-8.1/debian/changelog gdb-8.1/debian/changelog --- gdb-8.1/debian/changelog 2018-04-09 09:31:42.000000000 +0000 +++ gdb-8.1/debian/changelog 2019-05-28 20:26:52.000000000 +0000 @@ -1,3 +1,9 @@ +gdb (8.1-0ubuntu4) bionic; urgency=medium + + * Fix tagged pointer support. LP: #1830796 + + -- Manoj Iyer Tue, 28 May 2019 15:26:52 -0500 + gdb (8.1-0ubuntu3) bionic; urgency=medium * Update, taken from the gdb-8.1-branch 20180409. diff -Nru gdb-8.1/debian/patches/Fix-tagged-pointer-support.patch gdb-8.1/debian/patches/Fix-tagged-pointer-support.patch --- gdb-8.1/debian/patches/Fix-tagged-pointer-support.patch 1970-01-01 00:00:00.000000000 +0000 +++ gdb-8.1/debian/patches/Fix-tagged-pointer-support.patch 2019-05-28 20:25:53.000000000 +0000 @@ -0,0 +1,120 @@ +From 8727de56b0dbe25b7b4a3bd04f72ac41992463ed Mon Sep 17 00:00:00 2001 +From: Omair Javaid +Date: Tue, 1 May 2018 06:31:32 +0500 +Subject: [PATCH] Fix tagged pointer support + +This patch fixes tagged pointer support for AArch64 GDB. Linux kernel +debugging failure was reported after tagged pointer support was committed. + +After a discussion around best path forward to manage tagged pointers +on GDB side we are going to disable tagged pointers support for +aarch64-none-elf-gdb because for non-linux applications we cant be +sure if tagged pointers will be used by MMU or not. + +Also for aarch64-linux-gdb we are going to sign extend user-space +address after clearing tag bits. This will help debug both kernel +and user-space addresses based on information from linux kernel +documentation given below: + +According to AArch64 memory map: +https://www.kernel.org/doc/Documentation/arm64/memory.txt + +"User addresses have bits 63:48 set to 0 while the kernel addresses have +the same bits set to 1." + +According to AArch64 tagged pointers document: +https://www.kernel.org/doc/Documentation/arm64/tagged-pointers.txt + +The kernel configures the translation tables so that translations made +via TTBR0 (i.e. userspace mappings) have the top byte (bits 63:56) of +the virtual address ignored by the translation hardware. This frees up +this byte for application use. + +Running gdb testsuite after applying this patch introduces no regressions +and tagged pointer test cases still pass. + +gdb/ChangeLog: +2018-05-10 Omair Javaid + + PR gdb/23127 + * aarch64-linux-tdep.c (aarch64_linux_init_abi): Add call to + set_gdbarch_significant_addr_bit. + * aarch64-tdep.c (aarch64_gdbarch_init): Remove call to + set_gdbarch_significant_addr_bit. + * utils.c (address_significant): Update to sign extend addr. +--- + gdb/ChangeLog | 9 +++++++++ + gdb/aarch64-linux-tdep.c | 5 +++++ + gdb/aarch64-tdep.c | 5 ----- + gdb/utils.c | 14 +++++++++----- + 4 files changed, 23 insertions(+), 10 deletions(-) + +--- a/gdb/ChangeLog ++++ b/gdb/ChangeLog +@@ -1,3 +1,12 @@ ++2018-05-10 Omair Javaid ++ ++ PR gdb/23127 ++ * aarch64-linux-tdep.c (aarch64_linux_init_abi): Add call to ++ set_gdbarch_significant_addr_bit. ++ * aarch64-tdep.c (aarch64_gdbarch_init): Remove call to ++ set_gdbarch_significant_addr_bit. ++ * utils.c (address_significant): Update to sign extend addr. ++ + 2018-03-01 Sergio Durigan Junior + + PR gdb/22907 +--- a/gdb/aarch64-linux-tdep.c ++++ b/gdb/aarch64-linux-tdep.c +@@ -1062,6 +1062,11 @@ aarch64_linux_init_abi (struct gdbarch_i + /* Syscall record. */ + tdep->aarch64_syscall_record = aarch64_linux_syscall_record; + ++ /* The top byte of a user space address known as the "tag", ++ is ignored by the kernel and can be regarded as additional ++ data associated with the address. */ ++ set_gdbarch_significant_addr_bit (gdbarch, 56); ++ + /* Initialize the aarch64_linux_record_tdep. */ + /* These values are the size of the type that will be used in a system + call. They are obtained from Linux Kernel source. */ +--- a/gdb/aarch64-tdep.c ++++ b/gdb/aarch64-tdep.c +@@ -2970,11 +2970,6 @@ aarch64_gdbarch_init (struct gdbarch_inf + set_tdesc_pseudo_register_reggroup_p (gdbarch, + aarch64_pseudo_register_reggroup_p); + +- /* The top byte of an address is known as the "tag" and is +- ignored by the kernel, the hardware, etc. and can be regarded +- as additional data associated with the address. */ +- set_gdbarch_significant_addr_bit (gdbarch, 56); +- + /* ABI */ + set_gdbarch_short_bit (gdbarch, 16); + set_gdbarch_int_bit (gdbarch, 32); +--- a/gdb/utils.c ++++ b/gdb/utils.c +@@ -2730,14 +2730,18 @@ When set, debugging messages will be mar + CORE_ADDR + address_significant (gdbarch *gdbarch, CORE_ADDR addr) + { +- /* Truncate address to the significant bits of a target address, +- avoiding shifts larger or equal than the width of a CORE_ADDR. +- The local variable ADDR_BIT stops the compiler reporting a shift +- overflow when it won't occur. */ ++ /* Clear insignificant bits of a target address and sign extend resulting ++ address, avoiding shifts larger or equal than the width of a CORE_ADDR. ++ The local variable ADDR_BIT stops the compiler reporting a shift overflow ++ when it won't occur. */ + int addr_bit = gdbarch_significant_addr_bit (gdbarch); + + if (addr_bit < (sizeof (CORE_ADDR) * HOST_CHAR_BIT)) +- addr &= ((CORE_ADDR) 1 << addr_bit) - 1; ++ { ++ CORE_ADDR sign = (CORE_ADDR) 1 << (addr_bit - 1); ++ addr &= ((CORE_ADDR) 1 << addr_bit) - 1; ++ addr = (addr ^ sign) - sign; ++ } + + return addr; + } diff -Nru gdb-8.1/debian/patches/series gdb-8.1/debian/patches/series --- gdb-8.1/debian/patches/series 2018-04-09 09:31:42.000000000 +0000 +++ gdb-8.1/debian/patches/series 2019-05-28 20:24:12.000000000 +0000 @@ -16,3 +16,4 @@ #infinity-notes.diff gcore-bash.patch +Fix-tagged-pointer-support.patch