[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: After debugging, updating, and testing on aarch64-unbuntu, x86_64-macos, and arm64-macos, I have created a new PR with this commit plus an additional commit to fix the issues I found on the different platforms. https://github.com/llvm/llvm-project/pull/83663 https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: I think I'm going open a new PR with the base class address masking added to the patch. I think having these API and the unwritten caveat is "they may be no-ops if you're using an ABI that doesn't do FixAddress" is going to confuse people. I still want to investigate why my API test failed on aarch64 linux because I didn't expect that, it's possible there's something else going on. But the ABI thing is definitely something I think should be addressed. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: It does occur to me that I'm going to need to only run this API test on targets which have a FixAddress method in their ABI, the base class own't do it. Maybe it should have a base class impl that can be overridden, and use the Process masks if they are set. (they're all initialized to 0 which is an impossible mask value (no address bits)) The base class impl would need to be overridden for different architectures, e.g. on AArch64 where TBI or MTE are used, in addition to clearing/setting the top byte, we need to use b55 to determine if the non-address bits are set to 1 or 0. On armv7 the 0th bit can be used for metadata on TypeCode fixes, etc. But still I'd expect the lldb-aarch64-ubuntu bot to have had a FixAddress impl in its ABI. will check out when I build it up. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: Temporarily reverted this change while I investigate why the tests failed on all the linux bots (lldb-x86_64-debian, lldb-arm-ubuntu, lldb-aarch64-ubuntu), I'll build up in a VM and debug. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda closed https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/9] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/JDevlieghere approved this pull request. LGTM but please fix the formatting issue before merging. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/8] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda edited https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -33,18 +33,26 @@ void AddressableBits::SetHighmemAddressableBits( m_high_memory_addr_bits = highmem_addressing_bits; } +addr_t AddressableBits::AddressableBitToMask(uint32_t addressable_bits) { + assert(addressable_bits <= sizeof(addr_t) * 8); jasonmolenda wrote: I forgot that I was duplicating the addressable-bits-to-mask calculation in Process.cpp when I read the settings values. I pushed a change to use the new static method in AddressableBits which includes the assert. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/7] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/6] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/5] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff 86f6caa562255f81b93e72a501a926b17f5ad244 dceaef27675b724309f353aa22999563cf036cd3 -- lldb/test/API/python_api/process/address-masks/main.c lldb/include/lldb/API/SBProcess.h lldb/include/lldb/Utility/AddressableBits.h lldb/include/lldb/lldb-enumerations.h lldb/source/API/SBProcess.cpp lldb/source/Utility/AddressableBits.cpp `` View the diff from clang-format here. ``diff diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index e2a6922724..b60a0c3591 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -488,8 +488,8 @@ public: /// /// \param[in] num_bits /// Number of bits that are used for addressing. - /// For example, a value of 42 indicates that the low 42 bits are relevant for - /// addressing, and that higher-order bits may be used for various + /// For example, a value of 42 indicates that the low 42 bits are relevant + /// for addressing, and that higher-order bits may be used for various /// metadata like pointer authentication, Type Byte Ignore, etc. /// /// \param[in] addr_range `` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/4] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -1255,6 +1255,95 @@ lldb::SBFileSpec SBProcess::GetCoreFile() { return SBFileSpec(core_file); } +addr_t SBProcess::GetAddressMask(AddressMaskType type, + AddressMaskRange addr_range) { + LLDB_INSTRUMENT_VA(this, type, addr_range); + addr_t default_mask = 0; jasonmolenda wrote: A mask value of 0 would be an invalid address mask -- no bits are used for addressing. The variable name "default_mask" was a poor choice. But explicitly returning LLDB_INVALID_ADDRESS_MASK if we don't find any value might be the correct choice, it would mean you passed an invalid enum argument (or the SBProcess can't access its Process) https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,118 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start DavidSpickett wrote: This choice of mask can be important for example on AArch32 systems. Where instructions ... ...to get the actual address. Whereas eAddressMaskTypeData would not. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -33,18 +33,26 @@ void AddressableBits::SetHighmemAddressableBits( m_high_memory_addr_bits = highmem_addressing_bits; } +addr_t AddressableBits::AddressableBitToMask(uint32_t addressable_bits) { + assert(addressable_bits <= sizeof(addr_t) * 8); DavidSpickett wrote: If we're in release mode, this assert isn't here. Is it possible for the user to set addresable_bits to > 64 via `settings set`? If they do it's a bit of a garbage in garbage out situation, but wondering if we could add a check at that level too, or already have. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -1255,6 +1255,95 @@ lldb::SBFileSpec SBProcess::GetCoreFile() { return SBFileSpec(core_file); } +addr_t SBProcess::GetAddressMask(AddressMaskType type, + AddressMaskRange addr_range) { + LLDB_INSTRUMENT_VA(this, type, addr_range); + addr_t default_mask = 0; DavidSpickett wrote: Wouldn't we need a `LLDB_INVALID_ADDRESS_MASK` as well? It can happen that the address mask is valid, and has a value of 0. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,118 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods description of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods description of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods description of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods description of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// On Darwin and similar systems, the addressable bits are expressed + /// as the number of low order bits that are relevant to addressing, + /// instead of a more general address mask. + /// This method calculates the correct mask value for a given number + /// of low order addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods description of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. + /// A value of 42 indicates that the low 42 bits are relevant for + /// addressing, and that higher order bits may be used for various + /// metadata like pointer authentication, Type Byte Ignore, etc. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods description of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void + SetAddressableBits(AddressMaskType type, uint32_t num_bits, + AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Clear the non-addressable bits of an \a addr value and return a DavidSpickett wrote: non-address bits https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
hawkinsw wrote: > Thanks for the second round of feedback @hawkinsw . Let me try to read the > Doxygen docs a little more closely tonight and see if the references I threw > in there might actually do what I hoped they would. I briefly looked at the > Doxygen docs to see the Grouping feature and got a little overwhelmed and > wasn't sure what the expected formatting would be. Not a problem at all! Just trying to help!! Will https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -1255,6 +1255,95 @@ lldb::SBFileSpec SBProcess::GetCoreFile() { return SBFileSpec(core_file); } +addr_t SBProcess::GetAddressMask(AddressMaskType type, + AddressMaskRange addr_range) { + LLDB_INSTRUMENT_VA(this, type, addr_range); JDevlieghere wrote: `lldb-instr` always puts a newline after `LLDB_INSTRUMENT_VA`. We should do the same here to be consistent with the rest of the SB API. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -1255,6 +1255,95 @@ lldb::SBFileSpec SBProcess::GetCoreFile() { return SBFileSpec(core_file); } +addr_t SBProcess::GetAddressMask(AddressMaskType type, + AddressMaskRange addr_range) { + LLDB_INSTRUMENT_VA(this, type, addr_range); + addr_t default_mask = 0; JDevlieghere wrote: Would it be worth making this a constant (e.g. `LLDB_DEFAULT_ADDRESS_MASK`) so that callers can verify whether they were given a valid address mask? https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: Thanks for the second round of feedback @hawkinsw . Let me try to read the Doxygen docs a little more closely tonight and see if the references I threw in there might actually do what I hoped they would. I briefly looked at the Doxygen docs to see the Grouping feature and got a little overwhelmed and wasn't sure what the expected formatting would be. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/3] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. jasonmolenda wrote: I need to read the Doxygen documentation more closely, I just made this up when I was trying to update to having references to these two documentation paragraphs, I don't know if it would render as anything meaningful. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. jasonmolenda wrote: Thanks, let me rewrite it to say "darwin likes addressable bits" directly :) On Linux the kernel provides a mask to apply to addresses to remove metadata, it's the most general representation so that's what we use internally in lldb. But with Darwin on AArch64, we're only concerned with the low order number of bits that are used for addressing -- the addressable bits. It's possible to calculate the mask incorrectly (I'm fixing my own bug with addressable-bits==64 in this patch), so I want to provide API for environments like Darwin where that's what the data they'll have from the OS etc. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. + /// A value of 42 indicates that the low 42 bits are relevant for + /// addressing, and that higher order bits may be used for various hawkinsw wrote: ```suggestion /// addressing, and that higher-order bits may be used for various ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. + /// A value of 42 indicates that the low 42 bits are relevant for + /// addressing, and that higher order bits may be used for various + /// metadata like pointer authentication, Type Byte Ignore, etc. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. hawkinsw wrote: Can our Doxygen system make a reference to the documentation for these named constants? Just a question. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. + /// A value of 42 indicates that the low 42 bits are relevant for hawkinsw wrote: ```suggestion /// For example, a value of 42 indicates that the low 42 bits are relevant for ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. + /// A value of 42 indicates that the low 42 bits are relevant for + /// addressing, and that higher order bits may be used for various + /// metadata like pointer authentication, Type Byte Ignore, etc. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void + SetAddressableBits(AddressMaskType type, uint32_t num_bits, + AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Clear the non-addressable bits of an \a addr value and return a + /// virtual address in memory. + /// + /// Bits that are not used in addressing may be used for other purposes; + /// pointer authentication, or metadata in the top byte, or the 0th bit + /// of armv7 code addresses to indicate arm/thumb are common examples. + /// + /// \param[in] addr + /// The address that should be cleared of non-addressable bits. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument.
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have hawkinsw wrote: ```suggestion /// On some architectures (e.g., AArch64), it is possible to have ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. hawkinsw wrote: ```suggestion /// See \ref Mask Address Methods description of this argument. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/hawkinsw commented: As I said before, I really appreciate you doing such in-depth documentation. I hope these little suggestions help! https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,117 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// \{ + /// \group Mask Address Methods + /// + /// \a type + /// All of the methods in this group take \a type argument + /// which is an AddressMaskType enum value. + /// There can be different address masks for code addresses and + /// data addresses, this argument can select which to get/set, + /// or to use when clearing non-addressable bits from an address. + /// On AArch32 code with arm+thumb code, where instructions start + /// on even addresses, the 0th bit may be used to indicate that + /// a function is thumb code. On such a target, the eAddressMaskTypeCode + /// may clear the 0th bit from an address to get the actual address. + /// + /// \a addr_range + /// Many of the methods in this group take an \a addr_range argument + /// which is an AddressMaskRange enum value. + /// Needing to specify the address range is highly unusual, and the + /// default argument can be used in nearly all circumstances. + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing. It is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, so we need to maintain two different sets of address masks + /// to debug this correctly. + + /// Get the current address mask that will be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAny is often a suitable value when code and + /// data masks are the same on a given target. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// See \ref Mask Address Methods descripton of this argument. + /// eAddressMaskTypeAll is often a suitable value when the + /// same mask is being set for both code and data. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// See \ref Mask Address Methods descripton of this argument. + /// This will default to eAddressMaskRangeLow which is the + /// only set of masks used normally. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation instead of a mask, but lldb + /// internally represents this as a mask. This method calculates + /// the addressing mask that lldb uses that number of addressable bits. hawkinsw wrote: I am not 100% sure what you are attempting to convey here (and it may be perfectly correct), but I am having a hard time parsing this sentence. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/hawkinsw edited https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
jasonmolenda wrote: Thanks so much for reading through these @DavidSpickett and @hawkinsw ! @adrian-prantl and @JDevlieghere suggested using a doxygen group for this set of methods and having the long definitions of `type` and `addr_range` a single time, referring back to them from the individual methods, I wasn't thrilled with all that duplicated text either. I think I did this well enough? https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda updated https://github.com/llvm/llvm-project/pull/83095 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH 1/2] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + ///
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and hawkinsw wrote: ```suggestion /// as heap, etc. In that case, the eAddressMaskRangeLow and ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/hawkinsw edited https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. hawkinsw wrote: ```suggestion /// are word aligned, the code mask might clear the low 2 bits. ``` https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/hawkinsw commented: I really appreciate the thorough documentation you wrote for these new functions. Because there is so much overlap in the documentation between the functions, could we refactor it somehow (not sure how?) so that any future change could be more easily tracked? Just a question. Again, I appreciate your thorough documentation! Will https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be + /// specified. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation insted of a mask; this method calculates + /// the addressing mask that lldb uses internally from that number. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. e.g. the low 42 + /// bits may be the only ones used for addressing, and high bits may + /// store metadata and should be ignored by lldb. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be + /// specified. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation insted of a mask; this method calculates + /// the addressing mask that lldb uses internally from that number. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] num_bits + /// Number of bits that are used for addressing. e.g. the low 42 DavidSpickett wrote: Maybe phrase this like: e.g. 42 means that the least significant 42 bits are used for The important thing here is that this is not total bits used for addressing, this is a range from bit 0 to some N. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be + /// specified. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation insted of a mask; this method calculates + /// the addressing mask that lldb uses internally from that number. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. DavidSpickett wrote: "so the low 2 bits of the PC are always zero" Otherwise it's a bit of a "so what" statement. Mention the PC so it's more obvious that the code mask would be different in this case. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
@@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be + /// specified. + void SetAddressMask( + lldb::AddressMaskType type, lldb::addr_t mask, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the number of bits used for addressing in this Process. + /// + /// In some environments, the number of bits that are used for addressing + /// is the natural representation insted of a mask; this method calculates DavidSpickett wrote: "this method uses that number to calculate the addressing mask that lldb uses internally." So that "that number" unambiguously refers to the number of addressable bits. https://github.com/llvm/llvm-project/pull/83095 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
llvmbot wrote: @llvm/pr-subscribers-lldb Author: Jason Molenda (jasonmolenda) Changes I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- Full diff: https://github.com/llvm/llvm-project/pull/83095.diff 8 Files Affected: - (modified) lldb/include/lldb/API/SBProcess.h (+123) - (modified) lldb/include/lldb/Utility/AddressableBits.h (+3) - (modified) lldb/include/lldb/lldb-enumerations.h (+14) - (modified) lldb/source/API/SBProcess.cpp (+89) - (modified) lldb/source/Utility/AddressableBits.cpp (+10-2) - (added) lldb/test/API/python_api/process/address-masks/Makefile (+3) - (added) lldb/test/API/python_api/process/address-masks/TestAddressMasks.py (+64) - (added) lldb/test/API/python_api/process/address-masks/main.c (+5) ``diff diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always + /// zero. + /// + /// \param[in] mask + /// The address mask to set. Bits which are not used for addressing + /// should be set to 1 in the mask. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is being set. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be + /// specified. + void SetAddressMask( + lldb::AddressMaskType
[Lldb-commits] [lldb] [lldb] Add SBProcess methods for get/set/use address masks (PR #83095)
https://github.com/jasonmolenda created https://github.com/llvm/llvm-project/pull/83095 I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 >From dae16776e8c97158e8965e4d0e950cd2ce836f75 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Mon, 26 Feb 2024 18:05:27 -0800 Subject: [PATCH] [lldb] Add SBProcess methods for get/set/use address masks I'm reviving a patch from phabracator, https://reviews.llvm.org/D155905 which was approved but I wasn't thrilled with all the API I was adding to SBProcess for all of the address mask types / memory regions. In this update, I added enums to control type address mask type (code, data, any) and address space specifiers (low, high, all) with defaulted arguments for the most common case. This patch is also fixing a bug in the "addressable bits to address mask" calculation I added in AddressableBits::SetProcessMasks. If lldb were told that 64 bits are valid for addressing, this method would overflow the calculation and set an invalid mask. Added tests to check this specific bug while I was adding these APIs. rdar://123530562 --- lldb/include/lldb/API/SBProcess.h | 123 ++ lldb/include/lldb/Utility/AddressableBits.h | 3 + lldb/include/lldb/lldb-enumerations.h | 14 ++ lldb/source/API/SBProcess.cpp | 89 + lldb/source/Utility/AddressableBits.cpp | 12 +- .../python_api/process/address-masks/Makefile | 3 + .../process/address-masks/TestAddressMasks.py | 64 + .../python_api/process/address-masks/main.c | 5 + 8 files changed, 311 insertions(+), 2 deletions(-) create mode 100644 lldb/test/API/python_api/process/address-masks/Makefile create mode 100644 lldb/test/API/python_api/process/address-masks/TestAddressMasks.py create mode 100644 lldb/test/API/python_api/process/address-masks/main.c diff --git a/lldb/include/lldb/API/SBProcess.h b/lldb/include/lldb/API/SBProcess.h index 4f92a41f3028a2..7e9ad7d9a274f2 100644 --- a/lldb/include/lldb/API/SBProcess.h +++ b/lldb/include/lldb/API/SBProcess.h @@ -407,6 +407,129 @@ class LLDB_API SBProcess { /// the process isn't loaded from a core file. lldb::SBFileSpec GetCoreFile(); + /// Get the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be requested, or most commonly, + /// eAddressMaskTypeAny can be requested and the least specific + /// mask will be fetched. e.g. on a target where instructions + /// are word aligned, the Code mask might clear the low 2 bits. + /// + /// \param[in] addr_range + /// Specify whether the address mask for high or low address spaces + /// is requested. + /// It is highly unusual to have different address masks in high + /// or low memory, and by default the eAddressMaskRangeLow is the + /// only one used for both types of addresses, the default value for + /// this argument is the correct one. + /// + /// On some architectures like AArch64, it is possible to have + /// different page table setups for low and high memory, so different + /// numbers of bits relevant to addressing, and it is possible to have + /// a program running in one half of memory and accessing the other + /// as heap, etc. In that case the eAddressMaskRangeLow and + /// eAddressMaskRangeHigh will have different masks that must be handled. + /// + /// \return + /// The address mask currently in use. Bits which are not used + /// for addressing will be set to 1 in the mask. + lldb::addr_t GetAddressMask( + lldb::AddressMaskType type, + lldb::AddressMaskRange addr_range = lldb::eAddressMaskRangeLow); + + /// Set the current address mask that can be applied to addresses + /// before reading from memory. + /// + /// \param[in] type + /// lldb may have different address masks for code and data + /// addresses. Either can be set, or most commonly, + /// eAddressMaskTypeAll can be set for both types of addresses. + /// An example where they could be different is a target where + /// instructions are word aligned, so the low 2 bits are always +