Fix aarch64 build problem (RHBZ 1932645, Kevin Buettner).

This commit is contained in:
Kevin Buettner 2021-02-24 14:25:14 -07:00
parent a1361a0b59
commit f923d71406
6 changed files with 97 additions and 7 deletions

View File

@ -406,3 +406,7 @@ Patch099: gdb-rhbz1912985-libstdc++-assert.patch
# Backport fix for rawhide build error (RH BZ 1930528).
Patch100: gdb-rhbz1930528-fix-gnulib-build-error.patch
# [aarch64] Backport fix for aarch64-linux-hw-point.c build problem
# (RH BZ 1932645).
Patch101: gdb-rhbz1932645-aarch64-ptrace-header-order.patch

View File

@ -98,3 +98,4 @@
%patch098 -p1
%patch099 -p1
%patch100 -p1
%patch101 -p1

View File

@ -98,3 +98,4 @@ gdb-rhbz1553104-s390x-arch12-test.patch
gdb-rhbz1905996-fix-off-by-one-error-in-ada_fold_name.patch
gdb-rhbz1912985-libstdc++-assert.patch
gdb-rhbz1930528-fix-gnulib-build-error.patch
gdb-rhbz1932645-aarch64-ptrace-header-order.patch

View File

@ -0,0 +1,69 @@
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
From: Kevin Buettner <kevinb@redhat.com>
Date: Wed, 24 Feb 2021 13:19:08 -0700
Subject: gdb-rhbz1932645-aarch64-ptrace-header-order.patch
;; [aarch64] Backport fix for aarch64-linux-hw-point.c build problem
;; (RH BZ 1932645).
Fix aarch64-linux-hw-point.c build problem
Due to a recent glibc header file change, the file
nat/aarch64-linux-hw-point.c no longer builds on Fedora rawhide.
An enum for PTRACE_SYSEMU is now provided by <sys/ptrace.h>. In the
past, PTRACE_SYSEMU was defined only in <asm/ptrace.h>. This is
what it looks like...
In <asm/ptrace.h>:
#define PTRACE_SYSEMU 31
In <sys/ptrace.h>:
enum __ptrace_request
{
...
PTRACE_SYSEMU = 31,
#define PT_SYSEMU PTRACE_SYSEMU
...
}
When <asm/ptrace.h> and <sys/ptrace.h> are both included in a source
file, we run into the following build problem when the former is
included before the latter:
In file included from nat/aarch64-linux-hw-point.c:26:
/usr/include/sys/ptrace.h:86:3: error: expected identifier before numeric constant
86 | PTRACE_SYSEMU = 31,
| ^~~~~~~~~~~~~
(There are more errors after this one too.)
The file builds without error when <asm/ptrace.h> is included after
<sys/ptrace.h>. I found that this is already done in
nat/aarch64-sve-linux-ptrace.h (which is included by
nat/aarch64-linux-ptrace.c).
I've tested this change on Fedora rawhide and Fedora 33, both
running on an aarch64 machine.
gdb/ChangeLog:
* nat/aarch64-linux-hw-point.c: Include <asm/ptrace.h> after
<sys/ptrace.h>.
diff --git a/gdb/nat/aarch64-linux-hw-point.c b/gdb/nat/aarch64-linux-hw-point.c
--- a/gdb/nat/aarch64-linux-hw-point.c
+++ b/gdb/nat/aarch64-linux-hw-point.c
@@ -23,8 +23,8 @@
#include "aarch64-linux-hw-point.h"
#include <sys/uio.h>
-#include <asm/ptrace.h>
#include <sys/ptrace.h>
+#include <asm/ptrace.h>
#include <elf.h>
/* Number of hardware breakpoints/watchpoints the target supports.

View File

@ -45,14 +45,18 @@ diff --git a/gdb/NEWS b/gdb/NEWS
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -572,6 +572,24 @@ c_value_print (struct value *val, struct ui_file *stream,
@@ -572,6 +572,28 @@ c_value_print (struct value *val, struct ui_file *stream,
else
{
/* normal case */
+ if (type->code () == TYPE_CODE_PTR
+ && 1 == is_dynamic_type (type))
+ {
+ CORE_ADDR addr = value_as_address (val);
+ CORE_ADDR addr;
+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (type)))
+ addr = value_address (val);
+ else
+ addr = value_as_address (val);
+
+ /* We resolve the target-type only when the
+ pointer is associated. */
@ -1005,7 +1009,7 @@ diff --git a/gdb/testsuite/gdb.fortran/vla-value.exp b/gdb/testsuite/gdb.fortran
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -565,6 +565,21 @@ whatis_exp (const char *exp, int show)
@@ -565,6 +565,25 @@ whatis_exp (const char *exp, int show)
printf_filtered (" */\n");
}
@ -1016,7 +1020,11 @@ diff --git a/gdb/typeprint.c b/gdb/typeprint.c
+ if (type->code () == TYPE_CODE_PTR
+ && is_dynamic_type (type) == 1)
+ {
+ CORE_ADDR addr = value_as_address (val);
+ CORE_ADDR addr;
+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE(type)))
+ addr = value_address (val);
+ else
+ addr = value_as_address (val);
+
+ if (addr != 0
+ && type_not_associated (type) == 0)
@ -1030,15 +1038,19 @@ diff --git a/gdb/typeprint.c b/gdb/typeprint.c
diff --git a/gdb/valops.c b/gdb/valops.c
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1553,6 +1553,15 @@ value_ind (struct value *arg1)
@@ -1553,6 +1553,19 @@ value_ind (struct value *arg1)
if (base_type->code () == TYPE_CODE_PTR)
{
struct type *enc_type;
+ CORE_ADDR addr;
+
+ if (type_not_associated (base_type))
+ error (_("Attempt to take contents of a not associated pointer."));
+
+ CORE_ADDR addr = value_as_address (arg1);
+ if (NULL != TYPE_DATA_LOCATION (TYPE_TARGET_TYPE (base_type)))
+ addr = value_address (arg1);
+ else
+ addr = value_as_address (arg1);
+
+ if (addr != 0)
+ TYPE_TARGET_TYPE (base_type) =

View File

@ -37,7 +37,7 @@ Version: 10.1
# The release always contains a leading reserved number, start it at 1.
# `upstream' is not a part of `name' to stay fully rpm dependencies compatible for the testing.
Release: 8%{?dist}
Release: 9%{?dist}
License: GPLv3+ and GPLv3+ with exceptions and GPLv2+ and GPLv2+ with exceptions and GPL+ and LGPLv2+ and LGPLv3+ and BSD and Public Domain and GFDL
# Do not provide URL for snapshots as the file lasts there only for 2 days.
@ -1195,6 +1195,9 @@ fi
%endif
%changelog
* Wed Feb 24 2021 Kevin Buettner <kevinb@redhat.com> - 10.1-9
- Fix aarch64 build problem (RHBZ 1932645, Kevin Buettner).
* Fri Feb 19 2021 Jan Kratochvil <jan.kratochvil@redhat.com> - 10.1-8
- Fix gdb-vla-intel-fortran-vla-strings.patch for compatiblity with GraalVM.