Skip to content

Commit 0f83012

Browse files
committed
Add linux_get_hwcap
Tidy up calls to read HWCAP (and HWCAP2) by adding common functions, removing the PPC and AArch64 specific versions. The only function difference is in aarch64_linux_core_read_description - if the hwcap read fails it now return a valid description instead of nullptr. gdb/ChangeLog: 2019-03-25 Alan Hayward <[email protected]> * aarch64-linux-nat.c (aarch64_linux_nat_target::read_description): Call linux_get_hwcap. * aarch64-linux-tdep.c (aarch64_linux_core_read_description): Likewise. (aarch64_linux_get_hwcap): Remove function. * aarch64-linux-tdep.h (aarch64_linux_get_hwcap): Remove declaration. * arm-linux-nat.c (arm_linux_nat_target::read_description):Call linux_get_hwcap. * arm-linux-tdep.c (arm_linux_core_read_description): Likewise. * linux-tdep.c (linux_get_hwcap): Add function. (linux_get_hwcap2): Likewise. * linux-tdep.h (linux_get_hwcap): Add declaration. (linux_get_hwcap2): Likewise. * ppc-linux-nat.c (ppc_linux_get_hwcap): Remove function. (ppc_linux_get_hwcap2): Likewise. (ppc_linux_nat_target::region_ok_for_hw_watchpoint): Call linux_get_hwcap. (ppc_linux_nat_target::insert_watchpoint): Likewise. (ppc_linux_nat_target::watchpoint_addr_within_range): Likewise. (ppc_linux_nat_target::read_description): Likewise. * ppc-linux-tdep.c (ppc_linux_core_read_description): Likewise. * s390-linux-nat.c: Likewise. * s390-linux-tdep.c (s390_core_read_description): Likewise.
1 parent 796d629 commit 0f83012

12 files changed

+75
-71
lines changed

gdb/ChangeLog

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
2019-03-25 Alan Hayward <[email protected]>
2+
3+
* aarch64-linux-nat.c (aarch64_linux_nat_target::read_description):
4+
Call linux_get_hwcap.
5+
* aarch64-linux-tdep.c (aarch64_linux_core_read_description):
6+
Likewise.
7+
(aarch64_linux_get_hwcap): Remove function.
8+
* aarch64-linux-tdep.h (aarch64_linux_get_hwcap): Remove
9+
declaration.
10+
* arm-linux-nat.c (arm_linux_nat_target::read_description):Call
11+
linux_get_hwcap.
12+
* arm-linux-tdep.c (arm_linux_core_read_description): Likewise.
13+
* linux-tdep.c (linux_get_hwcap): Add function.
14+
(linux_get_hwcap2): Likewise.
15+
* linux-tdep.h (linux_get_hwcap): Add declaration.
16+
(linux_get_hwcap2): Likewise.
17+
* ppc-linux-nat.c (ppc_linux_get_hwcap): Remove function.
18+
(ppc_linux_get_hwcap2): Likewise.
19+
(ppc_linux_nat_target::region_ok_for_hw_watchpoint): Call
20+
linux_get_hwcap.
21+
(ppc_linux_nat_target::insert_watchpoint): Likewise.
22+
(ppc_linux_nat_target::watchpoint_addr_within_range): Likewise.
23+
(ppc_linux_nat_target::read_description): Likewise.
24+
* ppc-linux-tdep.c (ppc_linux_core_read_description): Likewise.
25+
* s390-linux-nat.c: Likewise.
26+
* s390-linux-tdep.c (s390_core_read_description): Likewise.
27+
128
2019-03-24 Tom Tromey <[email protected]>
229

330
* ada-lang.c (standard_lookup): Simplify initialization.

gdb/aarch64-linux-nat.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#include <asm/ptrace.h>
4343

4444
#include "gregset.h"
45+
#include "linux-tdep.h"
4546

4647
/* Defines ps_err_e, struct ps_prochandle. */
4748
#include "gdb_proc_service.h"
@@ -641,11 +642,10 @@ aarch64_linux_nat_target::read_description ()
641642
if (ret == 0)
642643
return tdesc_arm_with_neon;
643644

644-
CORE_ADDR hwcap = 0;
645-
bool pauth_p = aarch64_linux_get_hwcap (this, &hwcap)
646-
&& (hwcap & AARCH64_HWCAP_PACA);
645+
CORE_ADDR hwcap = linux_get_hwcap (this);
647646

648-
return aarch64_read_description (aarch64_sve_get_vq (tid), pauth_p);
647+
return aarch64_read_description (aarch64_sve_get_vq (tid),
648+
hwcap & AARCH64_HWCAP_PACA);
649649
}
650650

651651
/* Convert a native/host siginfo object, into/from the siginfo in the

gdb/aarch64-linux-tdep.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -655,13 +655,10 @@ static const struct target_desc *
655655
aarch64_linux_core_read_description (struct gdbarch *gdbarch,
656656
struct target_ops *target, bfd *abfd)
657657
{
658-
CORE_ADDR aarch64_hwcap = 0;
659-
660-
if (!aarch64_linux_get_hwcap (target, &aarch64_hwcap))
661-
return nullptr;
658+
CORE_ADDR hwcap = linux_get_hwcap (target);
662659

663660
return aarch64_read_description (aarch64_linux_core_read_vq (gdbarch, abfd),
664-
aarch64_hwcap & AARCH64_HWCAP_PACA);
661+
hwcap & AARCH64_HWCAP_PACA);
665662
}
666663

667664
/* Implementation of `gdbarch_stap_is_single_operand', as defined in
@@ -1439,15 +1436,6 @@ aarch64_linux_gcc_target_options (struct gdbarch *gdbarch)
14391436
return NULL;
14401437
}
14411438

1442-
/* See aarch64-linux-tdep.h. */
1443-
1444-
bool
1445-
aarch64_linux_get_hwcap (struct target_ops *target, CORE_ADDR *hwcap)
1446-
{
1447-
*hwcap = 0;
1448-
return target_auxv_search (target, AT_HWCAP, hwcap) == 1;
1449-
}
1450-
14511439
static void
14521440
aarch64_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
14531441
{

gdb/aarch64-linux-tdep.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,4 @@ extern const struct regset aarch64_linux_fpregset;
4242
/* Matches HWCAP_PACA in kernel header arch/arm64/include/uapi/asm/hwcap.h. */
4343
#define AARCH64_HWCAP_PACA (1 << 30)
4444

45-
/* Fetch the AT_HWCAP entry from the auxv vector for the given TARGET. */
46-
bool aarch64_linux_get_hwcap (struct target_ops *target, CORE_ADDR *hwcap);
47-
4845
#endif /* AARCH64_LINUX_TDEP_H */

gdb/arm-linux-nat.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ ps_get_thread_area (struct ps_prochandle *ph,
533533
const struct target_desc *
534534
arm_linux_nat_target::read_description ()
535535
{
536-
CORE_ADDR arm_hwcap = 0;
536+
CORE_ADDR arm_hwcap = linux_get_hwcap (this);
537537

538538
if (have_ptrace_getregset == TRIBOOL_UNKNOWN)
539539
{
@@ -551,11 +551,6 @@ arm_linux_nat_target::read_description ()
551551
have_ptrace_getregset = TRIBOOL_TRUE;
552552
}
553553

554-
if (target_auxv_search (this, AT_HWCAP, &arm_hwcap) != 1)
555-
{
556-
return this->beneath ()->read_description ();
557-
}
558-
559554
if (arm_hwcap & HWCAP_IWMMXT)
560555
return tdesc_arm_with_iwmmxt;
561556

gdb/arm-linux-tdep.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -730,10 +730,7 @@ arm_linux_core_read_description (struct gdbarch *gdbarch,
730730
struct target_ops *target,
731731
bfd *abfd)
732732
{
733-
CORE_ADDR arm_hwcap = 0;
734-
735-
if (target_auxv_search (target, AT_HWCAP, &arm_hwcap) != 1)
736-
return NULL;
733+
CORE_ADDR arm_hwcap = linux_get_hwcap (target);
737734

738735
if (arm_hwcap & HWCAP_VFP)
739736
{

gdb/linux-tdep.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2462,6 +2462,28 @@ linux_displaced_step_location (struct gdbarch *gdbarch)
24622462
return addr;
24632463
}
24642464

2465+
/* See linux-tdep.h. */
2466+
2467+
CORE_ADDR
2468+
linux_get_hwcap (struct target_ops *target)
2469+
{
2470+
CORE_ADDR field;
2471+
if (target_auxv_search (target, AT_HWCAP, &field) != 1)
2472+
return 0;
2473+
return field;
2474+
}
2475+
2476+
/* See linux-tdep.h. */
2477+
2478+
CORE_ADDR
2479+
linux_get_hwcap2 (struct target_ops *target)
2480+
{
2481+
CORE_ADDR field;
2482+
if (target_auxv_search (target, AT_HWCAP2, &field) != 1)
2483+
return 0;
2484+
return field;
2485+
}
2486+
24652487
/* Display whether the gcore command is using the
24662488
/proc/PID/coredump_filter file. */
24672489

gdb/linux-tdep.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,12 @@ extern void linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch);
6161

6262
extern int linux_is_uclinux (void);
6363

64+
/* Fetch the AT_HWCAP entry from the auxv vector for the given TARGET. On
65+
error, 0 is returned. */
66+
extern CORE_ADDR linux_get_hwcap (struct target_ops *target);
67+
68+
/* Fetch the AT_HWCAP2 entry from the auxv vector for the given TARGET. On
69+
error, 0 is returned. */
70+
extern CORE_ADDR linux_get_hwcap2 (struct target_ops *target);
71+
6472
#endif /* linux-tdep.h */

gdb/ppc-linux-nat.c

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,31 +1554,6 @@ store_ppc_registers (const struct regcache *regcache, int tid)
15541554
function to fail most of the time, so we ignore them. */
15551555
}
15561556

1557-
/* Fetch the AT_HWCAP entry from the aux vector. */
1558-
static CORE_ADDR
1559-
ppc_linux_get_hwcap (void)
1560-
{
1561-
CORE_ADDR field;
1562-
1563-
if (target_auxv_search (current_top_target (), AT_HWCAP, &field) != 1)
1564-
return 0;
1565-
1566-
return field;
1567-
}
1568-
1569-
/* Fetch the AT_HWCAP2 entry from the aux vector. */
1570-
1571-
static CORE_ADDR
1572-
ppc_linux_get_hwcap2 (void)
1573-
{
1574-
CORE_ADDR field;
1575-
1576-
if (target_auxv_search (current_top_target (), AT_HWCAP2, &field) != 1)
1577-
return 0;
1578-
1579-
return field;
1580-
}
1581-
15821557
/* The cached DABR value, to install in new threads.
15831558
This variable is used when the PowerPC HWDEBUG ptrace
15841559
interface is not available. */
@@ -1735,7 +1710,7 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
17351710
takes two hardware watchpoints though. */
17361711
if (len > 1
17371712
&& hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_RANGE
1738-
&& ppc_linux_get_hwcap () & PPC_FEATURE_BOOKE)
1713+
&& linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE)
17391714
return 2;
17401715
/* Check if the processor provides DAWR interface. */
17411716
if (hwdebug_info.features & PPC_DEBUG_FEATURE_DATA_BP_DAWR)
@@ -1755,7 +1730,7 @@ ppc_linux_nat_target::region_ok_for_hw_watchpoint (CORE_ADDR addr, int len)
17551730
ptrace interface, DAC-based processors (i.e., embedded processors) will
17561731
use addresses aligned to 4-bytes due to the way the read/write flags are
17571732
passed in the old ptrace interface. */
1758-
else if (((ppc_linux_get_hwcap () & PPC_FEATURE_BOOKE)
1733+
else if (((linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE)
17591734
&& (addr + len) > (addr & ~3) + 4)
17601735
|| (addr + len) > (addr & ~7) + 8)
17611736
return 0;
@@ -2294,7 +2269,7 @@ ppc_linux_nat_target::insert_watchpoint (CORE_ADDR addr, int len,
22942269
long dabr_value;
22952270
long read_mode, write_mode;
22962271

2297-
if (ppc_linux_get_hwcap () & PPC_FEATURE_BOOKE)
2272+
if (linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE)
22982273
{
22992274
/* PowerPC 440 requires only the read/write flags to be passed
23002275
to the kernel. */
@@ -2497,9 +2472,9 @@ ppc_linux_nat_target::watchpoint_addr_within_range (CORE_ADDR addr,
24972472
int mask;
24982473

24992474
if (have_ptrace_hwdebug_interface ()
2500-
&& ppc_linux_get_hwcap () & PPC_FEATURE_BOOKE)
2475+
&& linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE)
25012476
return start <= addr && start + length >= addr;
2502-
else if (ppc_linux_get_hwcap () & PPC_FEATURE_BOOKE)
2477+
else if (linux_get_hwcap (current_top_target ()) & PPC_FEATURE_BOOKE)
25032478
mask = 3;
25042479
else
25052480
mask = 7;
@@ -2637,8 +2612,8 @@ ppc_linux_nat_target::read_description ()
26372612

26382613
features.wordsize = ppc_linux_target_wordsize (tid);
26392614

2640-
CORE_ADDR hwcap = ppc_linux_get_hwcap ();
2641-
CORE_ADDR hwcap2 = ppc_linux_get_hwcap2 ();
2615+
CORE_ADDR hwcap = linux_get_hwcap (current_top_target ());
2616+
CORE_ADDR hwcap2 = linux_get_hwcap2 (current_top_target ());
26422617

26432618
if (have_ptrace_getsetvsxregs
26442619
&& (hwcap & PPC_FEATURE_HAS_VSX))

gdb/ppc-linux-tdep.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,10 +1601,7 @@ ppc_linux_core_read_description (struct gdbarch *gdbarch,
16011601
if (vsx)
16021602
features.vsx = true;
16031603

1604-
CORE_ADDR hwcap;
1605-
1606-
if (target_auxv_search (target, AT_HWCAP, &hwcap) != 1)
1607-
hwcap = 0;
1604+
CORE_ADDR hwcap = linux_get_hwcap (target);
16081605

16091606
features.isa205 = ppc_linux_has_isa205 (hwcap);
16101607

0 commit comments

Comments
 (0)