Skip to content

Commit 2f48a1f

Browse files
[lldb][FreeBSD] Add FreeBSD specific AT_HWCAP value (#84147)
While adding register fields I realised that the AUXV values for Linux and FreeBSD disagree here. So I've added a FreeBSD specific HWCAP value that I can use from FreeBSD specific code. The alternative is translating GetAuxValue calls depending on platform, which requires that we know what we are at all times. Another way would be to convert the entries' values when we construct the AuxVector but the platform specific call that reads the data just returns a raw array. So adding another layer here is more disruption.
1 parent 5b66b6a commit 2f48a1f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lldb/source/Plugins/Process/Utility/AuxVector.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class AuxVector {
2020
AuxVector(const lldb_private::DataExtractor &data);
2121

2222
/// Constants describing the type of entry.
23-
/// On Linux, running "LD_SHOW_AUXV=1 ./executable" will spew AUX
23+
/// On Linux and FreeBSD, running "LD_SHOW_AUXV=1 ./executable" will spew AUX
2424
/// information. Added AUXV prefix to avoid potential conflicts with system-
25-
/// defined macros
25+
/// defined macros. For FreeBSD, the numbers can be found in sys/elf_common.h.
2626
enum EntryType {
2727
AUXV_AT_NULL = 0, ///< End of auxv.
2828
AUXV_AT_IGNORE = 1, ///< Ignore entry.
@@ -39,6 +39,11 @@ class AuxVector {
3939
AUXV_AT_EUID = 12, ///< Effective UID.
4040
AUXV_AT_GID = 13, ///< GID.
4141
AUXV_AT_EGID = 14, ///< Effective GID.
42+
43+
// At this point Linux and FreeBSD diverge and many of the following values
44+
// are Linux specific. If you use them make sure you are in Linux specific
45+
// code or they have the same value on other platforms.
46+
4247
AUXV_AT_CLKTCK = 17, ///< Clock frequency (e.g. times(2)).
4348
AUXV_AT_PLATFORM = 15, ///< String identifying platform.
4449
AUXV_AT_HWCAP =
@@ -60,6 +65,10 @@ class AuxVector {
6065
AUXV_AT_L1D_CACHESHAPE = 35,
6166
AUXV_AT_L2_CACHESHAPE = 36,
6267
AUXV_AT_L3_CACHESHAPE = 37,
68+
69+
// Platform specific values which may overlap the Linux values.
70+
71+
AUXV_FREEBSD_AT_HWCAP = 25, ///< FreeBSD specific AT_HWCAP value.
6372
};
6473

6574
std::optional<uint64_t> GetAuxValue(enum EntryType entry_type) const;

0 commit comments

Comments
 (0)