llvm-project/lldb/source/Commands
Greg Clayton 529a3d87a7 [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute.
Resubmission of https://reviews.llvm.org/D130309 with the 2 patches that fixed the linux buildbot, and new windows fixes.

The FileSpec APIs allow users to modify instance variables directly by getting a non const reference to the directory and filename instance variables. This makes it impossible to control all of the times the FileSpec object is modified so we can clear cached member variables like m_resolved and with an upcoming patch caching if the file is relative or absolute. This patch modifies the APIs of FileSpec so no one can modify the directory or filename instance variables directly by adding set accessors and by removing the get accessors that are non const.

Many clients were using FileSpec::GetCString(...) which returned a unique C string from a ConstString'ified version of the result of GetPath() which returned a std::string. This caused many locations to use this convenient function incorrectly and could cause many strings to be added to the constant string pool that didn't need to. Most clients were converted to using FileSpec::GetPath().c_str() when possible. Other clients were modified to use the newly renamed version of this function which returns an actualy ConstString:

ConstString FileSpec::GetPathAsConstString(bool denormalize = true) const;

This avoids the issue where people were getting an already uniqued "const char *" that came from a ConstString only to put the "const char *" back into a "ConstString" object. By returning the ConstString instead of a "const char *" clients can be more efficient with the result.

The patch:
- Removes the non const GetDirectory() and GetFilename() get accessors
- Adds set accessors to replace the above functions: SetDirectory() and SetFilename().
- Adds ClearDirectory() and ClearFilename() to replace usage of the FileSpec::GetDirectory().Clear()/FileSpec::GetFilename().Clear() call sites
- Fixed all incorrect usage of FileSpec::GetCString() to use FileSpec::GetPath().c_str() where appropriate, and updated other call sites that wanted a ConstString to use the newly returned ConstString appropriately and efficiently.

Differential Revision: https://reviews.llvm.org/D130549
2022-07-28 13:28:26 -07:00
..
CMakeLists.txt [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07: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 [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectBreakpoint.h
CommandObjectBreakpointCommand.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectBreakpointCommand.h
CommandObjectCommands.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectCommands.h
CommandObjectDisassemble.cpp [lldb] Remove redundant member initialization (NFC) 2022-07-24 12:27:09 -07:00
CommandObjectDisassemble.h [trace] Add a flag to the decoder to output the instruction type 2022-07-12 16:23:03 -07:00
CommandObjectExpression.cpp [lldb] Remove redundant member initialization (NFC) 2022-07-24 12:27:09 -07:00
CommandObjectExpression.h
CommandObjectFrame.cpp Use value instead of getValue (NFC) 2022-07-15 20:03:13 -07:00
CommandObjectFrame.h
CommandObjectGUI.cpp Have CommandObjectParsed check for "commands that take no arguments". 2022-06-27 15:14:41 -07:00
CommandObjectGUI.h
CommandObjectHelp.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectHelp.h [lldb] Fix modernize-use-equals-default warnings (NFC) 2022-06-17 15:08:02 -07: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 [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute. 2022-07-28 13:28:26 -07:00
CommandObjectLog.h
CommandObjectMemory.cpp [lldb] Remove redundant member initialization (NFC) 2022-07-24 12:27:09 -07:00
CommandObjectMemory.h
CommandObjectMemoryTag.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectMemoryTag.h [lldb][AArch64] Add "memory tag read" command 2021-06-24 17:35:45 +01:00
CommandObjectMultiword.cpp Add a repeat command option for "thread backtrace --count N". 2022-02-14 15:48:06 -08:00
CommandObjectPlatform.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectPlatform.h
CommandObjectPlugin.cpp [lldb] Remove redundant calls to set eReturnStatusFailed 2021-06-17 14:39:35 +01:00
CommandObjectPlugin.h
CommandObjectProcess.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectProcess.h
CommandObjectQuit.cpp Have CommandObjectParsed check for "commands that take no arguments". 2022-06-27 15:14:41 -07:00
CommandObjectQuit.h
CommandObjectRegexCommand.cpp CommandObjectRegexCommand shouldn't put two commands on the history stack. 2022-06-03 11:34:53 -07:00
CommandObjectRegexCommand.h [lldb] Fix (unintentional) recursion in CommandObjectRegexCommand 2022-02-23 12:34:14 -08:00
CommandObjectRegister.cpp [lldb] Always use APFloat for FP dumping 2022-07-27 14:30:35 +02:00
CommandObjectRegister.h
CommandObjectReproducer.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectReproducer.h
CommandObjectScript.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectScript.h [lldb] Fix modernize-use-equals-default warnings (NFC) 2022-06-17 15:08:02 -07:00
CommandObjectSession.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectSession.h
CommandObjectSettings.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectSettings.h
CommandObjectSource.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectSource.h
CommandObjectStats.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectStats.h
CommandObjectTarget.cpp [NFC] Improve FileSpec internal APIs and usage in preparation for adding caching of resolved/absolute. 2022-07-28 13:28:26 -07:00
CommandObjectTarget.h
CommandObjectThread.cpp [trace][intel pt] Introduce wall clock time for each trace item 2022-07-26 12:05:23 -07:00
CommandObjectThread.h
CommandObjectThreadUtil.cpp [trace] Fix errors when handling command arguments 2022-06-28 17:54:30 -07:00
CommandObjectThreadUtil.h [trace] Fix errors when handling command arguments 2022-06-28 17:54:30 -07:00
CommandObjectTrace.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectTrace.h [trace][intel-pt] Implement trace start and trace stop 2021-03-30 17:31:37 -07:00
CommandObjectType.cpp [lldb][NFCI] Refactor regex filtering logic in CommandObjectTypeFormatterList 2022-07-21 09:22:40 -07:00
CommandObjectType.h
CommandObjectVersion.cpp Have CommandObjectParsed check for "commands that take no arguments". 2022-06-27 15:14:41 -07:00
CommandObjectVersion.h
CommandObjectWatchpoint.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectWatchpoint.h
CommandObjectWatchpointCommand.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandObjectWatchpointCommand.h
CommandOptionArgumentTable.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandOptionsProcessLaunch.cpp [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00
CommandOptionsProcessLaunch.h [Commands] Remove redundant member initialization (NFC) 2022-01-23 11:07:14 -08:00
Options.td [trace][intel pt] Introduce wall clock time for each trace item 2022-07-26 12:05:23 -07:00
OptionsBase.td [lldb] Refactor command option enum values (NFC) 2022-07-14 21:18:07 -07:00