Index: lldb/include/lldb/Target/Process.h =================================================================== --- lldb/include/lldb/Target/Process.h +++ lldb/include/lldb/Target/Process.h @@ -77,6 +77,8 @@ Args GetExtraStartupCommands() const; void SetExtraStartupCommands(const Args &args); FileSpec GetPythonOSPluginPath() const; + uint32_t GetVirtualAddressableBits() const; + void SetVirtualAddressableBits(uint32_t bits); void SetPythonOSPluginPath(const FileSpec &file); bool GetIgnoreBreakpointsInExpressions() const; void SetIgnoreBreakpointsInExpressions(bool ignore); @@ -1330,6 +1332,17 @@ virtual void DidExit() {} + lldb::addr_t GetCodeAddressMask(); + lldb::addr_t GetDataAddressMask(); + + void SetCodeAddressMask(lldb::addr_t code_address_mask) { + m_code_address_mask = code_address_mask; + } + + void SetDataAddressMask(lldb::addr_t data_address_mask) { + m_data_address_mask = data_address_mask; + } + /// Get the Modification ID of the process. /// /// \return @@ -2878,6 +2891,13 @@ /// from looking up or creating things during or after a finalize call. std::atomic m_finalizing; + /// Mask for code an data addresses. The default value (0) means no mask is + /// set. + /// @{ + lldb::addr_t m_code_address_mask = 0; + lldb::addr_t m_data_address_mask = 0; + /// @} + bool m_clear_thread_plans_on_stop; bool m_force_next_event_delivery; lldb::StateType m_last_broadcast_state; /// This helps with the Public event Index: lldb/source/Target/Process.cpp =================================================================== --- lldb/source/Target/Process.cpp +++ lldb/source/Target/Process.cpp @@ -200,6 +200,16 @@ return m_collection_sp->GetPropertyAtIndexAsFileSpec(nullptr, idx); } +uint32_t ProcessProperties::GetVirtualAddressableBits() const { + const uint32_t idx = ePropertyVirtualAddressableBits; + return m_collection_sp->GetPropertyAtIndexAsUInt64( + nullptr, idx, g_process_properties[idx].default_uint_value); +} + +void ProcessProperties::SetVirtualAddressableBits(uint32_t bits) { + const uint32_t idx = ePropertyVirtualAddressableBits; + m_collection_sp->SetPropertyAtIndexAsUInt64(nullptr, idx, bits); +} void ProcessProperties::SetPythonOSPluginPath(const FileSpec &file) { const uint32_t idx = ePropertyPythonOSPluginPath; m_collection_sp->SetPropertyAtIndexAsFileSpec(nullptr, idx, file); @@ -5547,6 +5557,36 @@ m_queue_list_stop_id = 0; } +lldb::addr_t Process::GetCodeAddressMask() { + if (m_code_address_mask == 0) { + uint32_t number_of_addressable_bits = GetVirtualAddressableBits(); + if (number_of_addressable_bits != 0) { + lldb::addr_t address_mask = ~((1ULL << number_of_addressable_bits) - 1); + SetCodeAddressMask(address_mask); + } + } + + if (m_code_address_mask == 0) + return -1; // All bits are used for addressing. + + return m_code_address_mask; +} + +lldb::addr_t Process::GetDataAddressMask() { + if (m_data_address_mask == 0) { + uint32_t number_of_addressable_bits = GetVirtualAddressableBits(); + if (number_of_addressable_bits != 0) { + lldb::addr_t address_mask = ~((1ULL << number_of_addressable_bits) - 1); + SetDataAddressMask(address_mask); + } + } + + if (m_data_address_mask == 0) + return -1; // All bits are used for addressing. + + return m_data_address_mask; +} + void Process::DidExec() { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_PROCESS)); LLDB_LOGF(log, "Process::%s()", __FUNCTION__); Index: lldb/source/Target/TargetProperties.td =================================================================== --- lldb/source/Target/TargetProperties.td +++ lldb/source/Target/TargetProperties.td @@ -233,6 +233,9 @@ def SteppingRunsAllThreads: Property<"run-all-threads", "Boolean">, DefaultFalse, Desc<"If true, stepping operations will run all threads. This is equivalent to setting the run-mode option to 'all-threads'.">; + def VirtualAddressableBits: Property<"virtual-addressable-bits", "UInt64">, + DefaultUnsignedValue<0>, + Desc<"The number of bits used for addressing. If the value is 39, then bits 0..38 are used for addressing. The default value of 0 means unspecified.">; } let Definition = "platform" in {