Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions lldb/docs/use/formatting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ A complete list of currently supported format string variables is listed below:
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``module.file.basename`` | The basename of the current module (shared library or executable) |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``module.file.fullpath`` | The basename of the current module (shared library or executable) |
| ``module.file.fullpath`` | The path of the current module (shared library or executable) |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``process.file.basename`` | The basename of the file for the process |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``process.file.fullpath`` | The fullname of the file for the process |
| ``process.file.fullpath`` | The path of the file for the process |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``process.id`` | The process ID native to the system on which the inferior runs. |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
Expand All @@ -141,6 +141,10 @@ A complete list of currently supported format string variables is listed below:
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``target.arch`` | The architecture of the current target |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``target.file.basename`` | The basename of the current current target |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``target.file.fullpath`` | The path of the current current target |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``script.target:python_func`` | Use a Python function to generate a piece of textual output |
+---------------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| ``script.process:python_func`` | Use a Python function to generate a piece of textual output |
Expand Down
1 change: 1 addition & 0 deletions lldb/include/lldb/Core/FormatEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ struct Entry {
ScriptThread,
ThreadInfo,
TargetArch,
TargetFile,
ScriptTarget,
ModuleFile,
File,
Expand Down
18 changes: 17 additions & 1 deletion lldb/source/Core/FormatEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ constexpr Definition g_thread_child_entries[] = {
Definition("completed-expression", EntryType::ThreadCompletedExpression)};

constexpr Definition g_target_child_entries[] = {
Definition("arch", EntryType::TargetArch)};
Definition("arch", EntryType::TargetArch),
Entry::DefinitionWithChildren("file", EntryType::TargetFile,
g_file_child_entries)};

#define _TO_STR2(_val) #_val
#define _TO_STR(_val) _TO_STR2(_val)
Expand Down Expand Up @@ -322,6 +324,7 @@ const char *FormatEntity::Entry::TypeToCString(Type t) {
ENUM_TO_CSTR(ScriptThread);
ENUM_TO_CSTR(ThreadInfo);
ENUM_TO_CSTR(TargetArch);
ENUM_TO_CSTR(TargetFile);
ENUM_TO_CSTR(ScriptTarget);
ENUM_TO_CSTR(ModuleFile);
ENUM_TO_CSTR(File);
Expand Down Expand Up @@ -1469,6 +1472,19 @@ bool FormatEntity::Format(const Entry &entry, Stream &s,
}
return false;

case Entry::Type::TargetFile:
if (exe_ctx) {
Target *target = exe_ctx->GetTargetPtr();
if (target) {
Module *exe_module = target->GetExecutableModulePointer();
if (exe_module) {
if (DumpFile(s, exe_module->GetFileSpec(), (FileKind)entry.number))
return true;
}
}
}
return false;

case Entry::Type::ScriptTarget:
if (exe_ctx) {
Target *target = exe_ctx->GetTargetPtr();
Expand Down
3 changes: 3 additions & 0 deletions lldb/unittests/Core/FormatEntityTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ constexpr llvm::StringRef lookupStrings[] = {
"${thread.return-value}",
"${thread.completed-expression}",
"${target.arch}",
"${target.file.basename}",
"${target.file.dirname}",
"${target.file.fullpath}",
"${var.dummy-var-to-test-wildcard}"};

TEST(FormatEntity, LookupAllEntriesInTree) {
Expand Down
Loading