llvm-project/lldb/source/Commands
David Spickett 2937b28218 Reland "[lldb] Remove non address bits when looking up memory regions"
This reverts commit 0df522969a.

Additional checks are added to fix the detection of the last memory region
in GetMemoryRegions or repeating the "memory region" command when the
target has non-address bits.

Normally you keep reading from address 0, looking up each region's end
address until you get LLDB_INVALID_ADDR as the region end address.
(0xffffffffffffffff)

This is what the remote will return once you go beyond the last mapped region:
[0x0000fffffffdf000-0x0001000000000000) rw- [stack]
[0x0001000000000000-0xffffffffffffffff) ---

Problem is that when we "fix" the lookup address, we remove some bits
from it. On an AArch64 system we have 48 bit virtual addresses, so when
we fix the end address of the [stack] region the result is 0.
So we loop back to the start.

[0x0000fffffffdf000-0x0001000000000000) rw- [stack]
[0x0000000000000000-0x0000000000400000) ---

To fix this I added an additional check for the last range.
If the end address of the region is different once you apply
FixDataAddress, we are at the last region.

Since the end of the last region will be the last valid mappable
address, plus 1. That 1 will be removed by the ABI plugin.

The only side effect is that on systems with non-address bits, you
won't get that last catch all unmapped region from the max virtual
address up to 0xf...f.

[0x0000fffff8000000-0x0000fffffffdf000) ---
[0x0000fffffffdf000-0x0001000000000000) rw- [stack]
<ends here>

Though in some way this is more correct because that region is not
just unmapped, it's not mappable at all.

No extra testing is needed because this is already covered by
TestMemoryRegion.py, I simply forgot to run it on system that had
both top byte ignore and pointer authentication.

This change has been tested on a qemu VM with top byte ignore,
memory tagging and pointer authentication enabled.

Reviewed By: omjavaid

Differential Revision: https://reviews.llvm.org/D115508
2022-02-10 10:42:49 +00:00
..
CMakeLists.txt [lldb] Make lldbVersion a full fledged library 2021-12-08 15:14:34 -08:00
CommandCompletions.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectApropos.cpp Add a "command container" hierarchy to allow users to add container nodes. 2021-10-18 15:29:24 -07:00
CommandObjectApropos.h
CommandObjectBreakpoint.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectBreakpoint.h
CommandObjectBreakpointCommand.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectBreakpointCommand.h
CommandObjectCommands.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectCommands.h
CommandObjectDisassemble.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectDisassemble.h [lldb] Use C++11 default member initializers 2021-06-09 09:43:13 -07:00
CommandObjectExpression.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectExpression.h
CommandObjectFrame.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectFrame.h
CommandObjectGUI.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
CommandObjectGUI.h
CommandObjectHelp.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectHelp.h [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectLanguage.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
CommandObjectLanguage.h
CommandObjectLog.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectLog.h
CommandObjectMemory.cpp Reland "[lldb] Remove non address bits when looking up memory regions" 2022-02-10 10:42:49 +00:00
CommandObjectMemory.h
CommandObjectMemoryTag.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectMemoryTag.h [lldb][AArch64] Add "memory tag read" command 2021-06-24 17:35:45 +01:00
CommandObjectMultiword.cpp [lldb] Remove unused AproposAllSubCommands (NFC) 2022-01-02 11:30:51 -08:00
CommandObjectPlatform.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectPlatform.h
CommandObjectPlugin.cpp [lldb] Remove redundant calls to set eReturnStatusFailed 2021-06-17 14:39:35 +01:00
CommandObjectPlugin.h
CommandObjectProcess.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectProcess.h
CommandObjectQuit.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
CommandObjectQuit.h
CommandObjectRegexCommand.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectRegexCommand.h [lldb] Move ScriptCommand and RegexCommand under Commands (NFC) 2020-09-01 17:33:39 -07:00
CommandObjectRegister.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectRegister.h
CommandObjectReproducer.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectReproducer.h
CommandObjectScript.cpp [lldb] Replace default bodies of special member functions with = default; 2021-07-02 11:31:16 -07:00
CommandObjectScript.h [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectSession.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectSession.h
CommandObjectSettings.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectSettings.h
CommandObjectSource.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectSource.h
CommandObjectStats.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectStats.h
CommandObjectTarget.cpp [lldb] Rename Logging.h to LLDBLog.h and clean up includes 2022-02-03 14:47:01 +01:00
CommandObjectTarget.h
CommandObjectThread.cpp [lldb] [Commands] Implement "thread siginfo" 2022-02-02 19:31:44 +01:00
CommandObjectThread.h
CommandObjectThreadUtil.cpp [lldb] Remove redundant calls to set eReturnStatusFailed 2021-06-17 14:39:35 +01:00
CommandObjectThreadUtil.h [trace][intel-pt] Create basic SB API 2021-06-17 15:14:47 -07:00
CommandObjectTrace.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectTrace.h [trace][intel-pt] Implement trace start and trace stop 2021-03-30 17:31:37 -07:00
CommandObjectType.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectType.h
CommandObjectVersion.cpp [lldb] Make lldbVersion a full fledged library 2021-12-08 15:14:34 -08:00
CommandObjectVersion.h
CommandObjectWatchpoint.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectWatchpoint.h
CommandObjectWatchpointCommand.cpp [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
CommandObjectWatchpointCommand.h
CommandOptionsProcessLaunch.cpp [lldb/Commands] Add command options for ScriptedProcess to ProcessLaunch 2021-03-23 18:24:47 +01:00
CommandOptionsProcessLaunch.h [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
Options.td [lldb] Add option to show memory tags in memory read output 2022-01-26 14:40:39 +00:00
OptionsBase.td