[Lldb-commits] [lldb] 276c0bd - [lldb][ExpressionParser][NFCI] Log pointers as hex (#91989)
via lldb-commits
lldb-commits at lists.llvm.org
Mon May 13 10:47:44 PDT 2024
Author: Michael Buch
Date: 2024-05-13T18:47:39+01:00
New Revision: 276c0bd4b386cc6b9d91e5e44ca7b053c11f13b5
URL: https://github.com/llvm/llvm-project/commit/276c0bd4b386cc6b9d91e5e44ca7b053c11f13b5
DIFF: https://github.com/llvm/llvm-project/commit/276c0bd4b386cc6b9d91e5e44ca7b053c11f13b5.diff
LOG: [lldb][ExpressionParser][NFCI] Log pointers as hex (#91989)
This ensures that we log pointers as lower-case hex. E.g., instead of:
```
LayoutRecordType on (ASTContext*)0x000000010E78D600 'scratch ASTContext' for (RecordDecl*)0x000000010E797
```
we now log:
```
LayoutRecordType on (ASTContext*)0x000000010e78d600 'scratch ASTContext' for (RecordDecl*)0x000000010e797
```
Which is consistent with how the AST dump gets emitted into the log.
This makes it easier to correlate pointers we log from LLDB and pointers
that are part of any AST dumps in the same `expr` log.
Added:
Modified:
lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
index 30b50df79da90..44071d1ea71c7 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp
@@ -313,8 +313,8 @@ CompilerType ClangASTImporter::DeportType(TypeSystemClang &dst,
return {};
LLDB_LOG(log,
- " [ClangASTImporter] DeportType called on ({0}Type*){1} "
- "from (ASTContext*){2} to (ASTContext*){3}",
+ " [ClangASTImporter] DeportType called on ({0}Type*){1:x} "
+ "from (ASTContext*){2:x} to (ASTContext*){3:x}",
src_type.GetTypeName(), src_type.GetOpaqueQualType(),
&src_ctxt->getASTContext(), &dst.getASTContext());
@@ -334,8 +334,8 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
clang::ASTContext *src_ctx = &decl->getASTContext();
LLDB_LOG(log,
- " [ClangASTImporter] DeportDecl called on ({0}Decl*){1} from "
- "(ASTContext*){2} to (ASTContext*){3}",
+ " [ClangASTImporter] DeportDecl called on ({0}Decl*){1:x} from "
+ "(ASTContext*){2:x} to (ASTContext*){3:x}",
decl->getDeclKindName(), decl, src_ctx, dst_ctx);
DeclContextOverride decl_context_override;
@@ -352,8 +352,8 @@ clang::Decl *ClangASTImporter::DeportDecl(clang::ASTContext *dst_ctx,
return nullptr;
LLDB_LOG(log,
- " [ClangASTImporter] DeportDecl deported ({0}Decl*){1} to "
- "({2}Decl*){3}",
+ " [ClangASTImporter] DeportDecl deported ({0}Decl*){1:x} to "
+ "({2}Decl*){3:x}",
decl->getDeclKindName(), decl, result->getDeclKindName(), result);
return result;
@@ -637,8 +637,8 @@ bool ClangASTImporter::importRecordLayoutFromOrigin(
clang::ASTContext &dest_ctx = record->getASTContext();
LLDB_LOG(log,
- "LayoutRecordType on (ASTContext*){0} '{1}' for (RecordDecl*)"
- "{2} [name = '{3}']",
+ "LayoutRecordType on (ASTContext*){0:x} '{1}' for (RecordDecl*)"
+ "{2:x} [name = '{3}']",
&dest_ctx,
TypeSystemClang::GetASTContext(&dest_ctx)->getDisplayName(), record,
record->getName());
@@ -703,7 +703,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin(
if (log) {
LLDB_LOG(log, "LRT returned:");
- LLDB_LOG(log, "LRT Original = (RecordDecl*){0}",
+ LLDB_LOG(log, "LRT Original = (RecordDecl*){0:x}",
static_cast<const void *>(origin_record.decl));
LLDB_LOG(log, "LRT Size = {0}", size);
LLDB_LOG(log, "LRT Alignment = {0}", alignment);
@@ -711,11 +711,11 @@ bool ClangASTImporter::importRecordLayoutFromOrigin(
for (RecordDecl::field_iterator fi = record->field_begin(),
fe = record->field_end();
fi != fe; ++fi) {
- LLDB_LOG(log,
- "LRT (FieldDecl*){0}, Name = '{1}', Type = '{2}', Offset = "
- "{3} bits",
- *fi, fi->getName(), fi->getType().getAsString(),
- field_offsets[*fi]);
+ LLDB_LOG(
+ log,
+ "LRT (FieldDecl*){0:x}, Name = '{1}', Type = '{2}', Offset = "
+ "{3} bits",
+ *fi, fi->getName(), fi->getType().getAsString(), field_offsets[*fi]);
}
DeclFromParser<const CXXRecordDecl> parser_cxx_record =
DynCast<const CXXRecordDecl>(parser_record);
@@ -734,7 +734,7 @@ bool ClangASTImporter::importRecordLayoutFromOrigin(
DynCast<CXXRecordDecl>(base_record);
LLDB_LOG(log,
- "LRT {0}(CXXRecordDecl*){1}, Name = '{2}', Offset = "
+ "LRT {0}(CXXRecordDecl*){1:x}, Name = '{2}', Offset = "
"{3} chars",
(is_virtual ? "Virtual " : ""), base_cxx_record.decl,
base_cxx_record.decl->getName(),
@@ -1025,7 +1025,7 @@ void ClangASTImporter::ForgetDestination(clang::ASTContext *dst_ast) {
Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log,
- " [ClangASTImporter] Forgetting destination (ASTContext*){0}",
+ " [ClangASTImporter] Forgetting destination (ASTContext*){0:x}",
dst_ast);
m_metadata_map.erase(dst_ast);
@@ -1039,7 +1039,7 @@ void ClangASTImporter::ForgetSource(clang::ASTContext *dst_ast,
LLDB_LOG(log,
" [ClangASTImporter] Forgetting source->dest "
- "(ASTContext*){0}->(ASTContext*){1}",
+ "(ASTContext*){0:x}->(ASTContext*){1:x}",
src_ast, dst_ast);
if (!md)
@@ -1164,9 +1164,10 @@ void ClangASTImporter::ASTImporterDelegate::ImportDefinitionTo(
from_named_decl->printName(name_stream);
name_stream.flush();
}
- LLDB_LOG(log_ast, "==== [ClangASTImporter][TUDecl: {0}] Imported "
- "({1}Decl*){2}, named {3} (from "
- "(Decl*){4})",
+ LLDB_LOG(log_ast,
+ "==== [ClangASTImporter][TUDecl: {0:x}] Imported "
+ "({1}Decl*){2:x}, named {3} (from "
+ "(Decl*){4:x})",
static_cast<void *>(to->getTranslationUnitDecl()),
from->getDeclKindName(), static_cast<void *>(to), name_string,
static_cast<void *>(from));
@@ -1294,14 +1295,15 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
from_named_decl->printName(name_stream);
name_stream.flush();
- LLDB_LOG(log,
- " [ClangASTImporter] Imported ({0}Decl*){1}, named {2} (from "
- "(Decl*){3}), metadata {4}",
- from->getDeclKindName(), to, name_string, from, user_id);
+ LLDB_LOG(
+ log,
+ " [ClangASTImporter] Imported ({0}Decl*){1:x}, named {2} (from "
+ "(Decl*){3:x}), metadata {4}",
+ from->getDeclKindName(), to, name_string, from, user_id);
} else {
LLDB_LOG(log,
- " [ClangASTImporter] Imported ({0}Decl*){1} (from "
- "(Decl*){2}), metadata {3}",
+ " [ClangASTImporter] Imported ({0}Decl*){1:x} (from "
+ "(Decl*){2:x}), metadata {3}",
from->getDeclKindName(), to, from, user_id);
}
}
@@ -1321,8 +1323,8 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
LLDB_LOG(log,
" [ClangASTImporter] Propagated origin "
- "(Decl*){0}/(ASTContext*){1} from (ASTContext*){2} to "
- "(ASTContext*){3}",
+ "(Decl*){0:x}/(ASTContext*){1:x} from (ASTContext*){2:x} to "
+ "(ASTContext*){3:x}",
origin.decl, origin.ctx, &from->getASTContext(),
&to->getASTContext());
}
@@ -1335,7 +1337,7 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
LLDB_LOG(log,
" [ClangASTImporter] Decl has no origin information in "
- "(ASTContext*){0}",
+ "(ASTContext*){0:x}",
&from->getASTContext());
}
@@ -1356,7 +1358,7 @@ void ClangASTImporter::ASTImporterDelegate::Imported(clang::Decl *from,
LLDB_LOG(log,
" [ClangASTImporter] Sourced origin "
- "(Decl*){0}/(ASTContext*){1} into (ASTContext*){2}",
+ "(Decl*){0:x}/(ASTContext*){1:x} into (ASTContext*){2:x}",
from, m_source_ctx, &to->getASTContext());
}
diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index 75493eb10d731..82a7a2cc3f1ef 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
@@ -193,7 +193,7 @@ TagDecl *ClangASTSource::FindCompleteType(const TagDecl *decl) {
if (!namespace_map)
return nullptr;
- LLDB_LOGV(log, " CTD Inspecting namespace map{0} ({1} entries)",
+ LLDB_LOGV(log, " CTD Inspecting namespace map{0:x} ({1} entries)",
namespace_map.get(), namespace_map->size());
for (const ClangASTImporter::NamespaceMapItem &item : *namespace_map) {
@@ -265,7 +265,7 @@ void ClangASTSource::CompleteType(TagDecl *tag_decl) {
if (log) {
LLDB_LOG(log,
" CompleteTagDecl on (ASTContext*){0} Completing "
- "(TagDecl*){1} named {2}",
+ "(TagDecl*){1:x} named {2}",
m_clang_ast_context->getDisplayName(), tag_decl,
tag_decl->getName());
@@ -292,7 +292,7 @@ void ClangASTSource::CompleteType(clang::ObjCInterfaceDecl *interface_decl) {
Log *log = GetLog(LLDBLog::Expressions);
LLDB_LOG(log,
- " [CompleteObjCInterfaceDecl] on (ASTContext*){0} '{1}' "
+ " [CompleteObjCInterfaceDecl] on (ASTContext*){0:x} '{1}' "
"Completing an ObjCInterfaceDecl named {1}",
m_ast_context, m_clang_ast_context->getDisplayName(),
interface_decl->getName());
@@ -385,7 +385,7 @@ void ClangASTSource::FindExternalLexicalDecls(
if (log) {
if (const NamedDecl *context_named_decl = dyn_cast<NamedDecl>(context_decl))
LLDB_LOG(log,
- "FindExternalLexicalDecls on (ASTContext*){0} '{1}' in "
+ "FindExternalLexicalDecls on (ASTContext*){0:x} '{1}' in "
"'{2}' ({3}Decl*){4}",
m_ast_context, m_clang_ast_context->getDisplayName(),
context_named_decl->getNameAsString().c_str(),
@@ -393,14 +393,14 @@ void ClangASTSource::FindExternalLexicalDecls(
static_cast<const void *>(context_decl));
else if (context_decl)
LLDB_LOG(log,
- "FindExternalLexicalDecls on (ASTContext*){0} '{1}' in "
+ "FindExternalLexicalDecls on (ASTContext*){0:x} '{1}' in "
"({2}Decl*){3}",
m_ast_context, m_clang_ast_context->getDisplayName(),
context_decl->getDeclKindName(),
static_cast<const void *>(context_decl));
else
LLDB_LOG(log,
- "FindExternalLexicalDecls on (ASTContext*){0} '{1}' in a "
+ "FindExternalLexicalDecls on (ASTContext*){0:x} '{1}' in a "
"NULL context",
m_ast_context, m_clang_ast_context->getDisplayName());
}
@@ -410,7 +410,7 @@ void ClangASTSource::FindExternalLexicalDecls(
if (!original.Valid())
return;
- LLDB_LOG(log, " FELD Original decl {0} (Decl*){1:x}:\n{2}",
+ LLDB_LOG(log, " FELD Original decl (ASTContext*){0:x} (Decl*){1:x}:\n{2}",
static_cast<void *>(original.ctx),
static_cast<void *>(original.decl),
ClangUtil::DumpDecl(original.decl));
@@ -508,19 +508,19 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
if (!context.m_decl_context)
LLDB_LOG(log,
"ClangASTSource::FindExternalVisibleDecls on "
- "(ASTContext*){0} '{1}' for '{2}' in a NULL DeclContext",
+ "(ASTContext*){0:x} '{1}' for '{2}' in a NULL DeclContext",
m_ast_context, m_clang_ast_context->getDisplayName(), name);
else if (const NamedDecl *context_named_decl =
dyn_cast<NamedDecl>(context.m_decl_context))
LLDB_LOG(log,
"ClangASTSource::FindExternalVisibleDecls on "
- "(ASTContext*){0} '{1}' for '{2}' in '{3}'",
+ "(ASTContext*){0:x} '{1}' for '{2}' in '{3}'",
m_ast_context, m_clang_ast_context->getDisplayName(), name,
context_named_decl->getName());
else
LLDB_LOG(log,
"ClangASTSource::FindExternalVisibleDecls on "
- "(ASTContext*){0} '{1}' for '{2}' in a '{3}'",
+ "(ASTContext*){0:x} '{1}' for '{2}' in a '{3}'",
m_ast_context, m_clang_ast_context->getDisplayName(), name,
context.m_decl_context->getDeclKindName());
}
@@ -542,7 +542,7 @@ void ClangASTSource::FindExternalVisibleDecls(NameSearchContext &context) {
if (!context.m_namespace_map->empty()) {
if (log && log->GetVerbose())
- LLDB_LOG(log, " CAS::FEVD Registering namespace map {0} ({1} entries)",
+ LLDB_LOG(log, " CAS::FEVD Registering namespace map {0:x} ({1} entries)",
context.m_namespace_map.get(), context.m_namespace_map->size());
NamespaceDecl *clang_namespace_decl =
@@ -918,7 +918,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
ConstString selector_name(ss.GetString());
LLDB_LOG(log,
- "ClangASTSource::FindObjCMethodDecls on (ASTContext*){0} '{1}' "
+ "ClangASTSource::FindObjCMethodDecls on (ASTContext*){0:x} '{1}' "
"for selector [{2} {3}]",
m_ast_context, m_clang_ast_context->getDisplayName(),
interface_decl->getName(), selector_name);
@@ -1062,7 +1062,7 @@ void ClangASTSource::FindObjCMethodDecls(NameSearchContext &context) {
LLDB_LOG(log,
"CAS::FOPD trying origin "
- "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
+ "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}...",
complete_interface_decl, &complete_iface_decl->getASTContext());
FindObjCMethodDeclsWithOrigin(context, complete_interface_decl,
@@ -1199,7 +1199,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
LLDB_LOG(log,
"ClangASTSource::FindObjCPropertyAndIvarDecls on "
- "(ASTContext*){0} '{1}' for '{2}.{3}'",
+ "(ASTContext*){0:x} '{1}' for '{2}.{3}'",
m_ast_context, m_clang_ast_context->getDisplayName(),
parser_iface_decl->getName(), context.m_decl_name.getAsString());
@@ -1208,7 +1208,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
LLDB_LOG(log,
"CAS::FOPD couldn't find the property on origin "
- "(ObjCInterfaceDecl*){0}/(ASTContext*){1}, searching "
+ "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}, searching "
"elsewhere...",
origin_iface_decl.decl, &origin_iface_decl->getASTContext());
@@ -1233,7 +1233,7 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
LLDB_LOG(log,
"CAS::FOPD trying origin "
- "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
+ "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}...",
complete_iface_decl.decl, &complete_iface_decl->getASTContext());
FindObjCPropertyAndIvarDeclsWithOrigin(context, complete_iface_decl);
@@ -1265,8 +1265,8 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
break;
LLDB_LOG(log,
- "CAS::FOPD[{0}] trying module "
- "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
+ "CAS::FOPD[{0:x}] trying module "
+ "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}...",
interface_decl_from_modules.decl,
&interface_decl_from_modules->getASTContext());
@@ -1309,8 +1309,8 @@ void ClangASTSource::FindObjCPropertyAndIvarDecls(NameSearchContext &context) {
break;
LLDB_LOG(log,
- "CAS::FOPD[{0}] trying runtime "
- "(ObjCInterfaceDecl*){0}/(ASTContext*){1}...",
+ "CAS::FOPD[{0:x}] trying runtime "
+ "(ObjCInterfaceDecl*){0:x}/(ASTContext*){1:x}...",
interface_decl_from_runtime.decl,
&interface_decl_from_runtime->getASTContext());
@@ -1329,7 +1329,7 @@ void ClangASTSource::LookupInNamespace(NameSearchContext &context) {
ClangASTImporter::NamespaceMapSP namespace_map =
m_ast_importer_sp->GetNamespaceMap(namespace_context);
- LLDB_LOGV(log, " CAS::FEVD Inspecting namespace map {0} ({1} entries)",
+ LLDB_LOGV(log, " CAS::FEVD Inspecting namespace map {0:x} ({1} entries)",
namespace_map.get(), namespace_map->size());
if (!namespace_map)
@@ -1366,7 +1366,7 @@ void ClangASTSource::CompleteNamespaceMap(
if (log) {
if (parent_map && parent_map->size())
LLDB_LOG(log,
- "CompleteNamespaceMap on (ASTContext*){0} '{1}' Searching "
+ "CompleteNamespaceMap on (ASTContext*){0:x} '{1}' Searching "
"for namespace {2} in namespace {3}",
m_ast_context, m_clang_ast_context->getDisplayName(), name,
parent_map->begin()->second.GetName());
More information about the lldb-commits
mailing list