Skip to content

Commit a251b49

Browse files
committed
[lldb][FreeBSD] Add FreeBSD specific AT_HWCAP2 value
While adding register fields I realised that the AUXV values for Linux and FreeBSD disagree here. So I've added a FreeBSD specific HWCAP2 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 982e902 commit a251b49

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ 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.
26+
///
27+
/// Linux and FreeBSD values diverge, so the FreeBSD classes will convert
28+
/// some entries to the Linux AT_ value so that LLDB only has to use
29+
/// the constants listed here when asking the AuxVector for a value.
2630
enum EntryType {
2731
AUXV_AT_NULL = 0, ///< End of auxv.
2832
AUXV_AT_IGNORE = 1, ///< Ignore entry.
@@ -39,6 +43,11 @@ class AuxVector {
3943
AUXV_AT_EUID = 12, ///< Effective UID.
4044
AUXV_AT_GID = 13, ///< GID.
4145
AUXV_AT_EGID = 14, ///< Effective GID.
46+
47+
// At this point Linux and FreeBSD diverge and many of the following values
48+
// are Linux specific. If you use them make sure you are in Linux specific
49+
// code or they have the same value on other platforms.
50+
4251
AUXV_AT_CLKTCK = 17, ///< Clock frequency (e.g. times(2)).
4352
AUXV_AT_PLATFORM = 15, ///< String identifying platform.
4453
AUXV_AT_HWCAP =
@@ -60,6 +69,10 @@ class AuxVector {
6069
AUXV_AT_L1D_CACHESHAPE = 35,
6170
AUXV_AT_L2_CACHESHAPE = 36,
6271
AUXV_AT_L3_CACHESHAPE = 37,
72+
73+
// Platform specific values which may overlap the Linux values.
74+
75+
AUXV_FREEBSD_AT_HWCAP = 25, ///< FreeBSD specific AT_HWCAP value.
6376
};
6477

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

0 commit comments

Comments
 (0)