ENH: Foam::name() of memory address

- returns the memory address formatted in hexadecimal, which can be
  useful for detailed information
This commit is contained in:
Mark Olesen
2019-08-12 10:46:29 +02:00
committed by Andrew Heather
parent 3870b1d43c
commit 3c07a1bb6f
25 changed files with 109 additions and 104 deletions

View File

@ -2,10 +2,10 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation | Copyright (C) 2011 OpenFoam Foundation
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,8 +41,8 @@ using namespace Foam;
template<class T> template<class T>
void printAddress(const UList<T>& list) void printAddress(const UList<T>& list)
{ {
Info<< "list addr: " << uintptr_t(&list) Info<< "list addr: " << name(&list)
<< " data addr: " << uintptr_t(list.cdata()) << nl; << " data addr: " << name(list.cdata()) << nl;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -50,7 +50,7 @@ void printInfo
Info<< " size=\"" << lst.size() << "\""; Info<< " size=\"" << lst.size() << "\"";
if (lst.cdata()) if (lst.cdata())
{ {
Info<< " ptr=\"" << uintptr_t(lst.cdata()) << "\""; Info<< " ptr=\"" << name(lst.cdata()) << "\"";
} }
else else
{ {
@ -76,7 +76,7 @@ void printInfo
<< "\" capacity=\"" << lst.capacity() << "\""; << "\" capacity=\"" << lst.capacity() << "\"";
if (lst.cdata()) if (lst.cdata())
{ {
Info<< " ptr=\"" << uintptr_t(lst.cdata()) << "\""; Info<< " ptr=\"" << name(lst.cdata()) << "\"";
} }
else else
{ {

View File

@ -50,7 +50,7 @@ Ostream& printInfo(const FixedList<List<T>, N>& list)
Info<< list << " addresses:"; Info<< list << " addresses:";
for (unsigned i = 0; i < N; ++i) for (unsigned i = 0; i < N; ++i)
{ {
Info<< " " << uintptr_t(list[i].cdata()); Info<< ' ' << name(list[i].cdata());
} }
Info<< nl; Info<< nl;
return Info; return Info;
@ -211,7 +211,7 @@ int main(int argc, char *argv[])
// Addresses don't change with swap // Addresses don't change with swap
Info<< "mem: " Info<< "mem: "
<< uintptr_t(list1.data()) << " " << uintptr_t(list2.data()) << nl; << name(list1.data()) << " " << name(list2.data()) << nl;
list1.swap(list2); list1.swap(list2);
Info<< "The swap() method" << nl; Info<< "The swap() method" << nl;
@ -219,7 +219,7 @@ int main(int argc, char *argv[])
<< "list2: " << list2 << nl; << "list2: " << list2 << nl;
Info<< "mem: " Info<< "mem: "
<< uintptr_t(list1.data()) << " " << uintptr_t(list2.data()) << nl; << name(list1.data()) << " " << name(list2.data()) << nl;
Swap(list1, list2); Swap(list1, list2);
Info<< "The Swap() function" << nl; Info<< "The Swap() function" << nl;
@ -227,7 +227,7 @@ int main(int argc, char *argv[])
<< "list2: " << list2 << nl; << "list2: " << list2 << nl;
Info<< "mem: " Info<< "mem: "
<< uintptr_t(list1.data()) << " " << uintptr_t(list2.data()) << nl; << name(list1.data()) << " " << name(list2.data()) << nl;
Info<< "====" << nl; Info<< "====" << nl;

View File

@ -2,10 +2,8 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\ / A nd | Copyright (C) 2011-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -45,7 +43,7 @@ void printTable(const HashPtrTable<T>& table)
Info<< iter.key() << " = "; Info<< iter.key() << " = ";
if (ptr) if (ptr)
{ {
Info<< *ptr << " (" << uintptr_t(ptr) << ")"; Info<< *ptr << " (" << name(ptr) << ")";
} }
else else
{ {

View File

@ -172,7 +172,7 @@ int main(int argc, char *argv[])
if (iter.good()) if (iter.good())
{ {
Info<< "have " << k << nl Info<< "have " << k << nl
<< " addr: " << uintptr_t(*iter) << nl << " addr: " << name(*iter) << nl
<< " info: " << (*iter)->info() << nl << " info: " << (*iter)->info() << nl
<< " info: " << iter->info() << nl << " info: " << iter->info() << nl
<< " incr: " << iter->increment() << nl << " incr: " << iter->increment() << nl
@ -214,7 +214,7 @@ int main(int argc, char *argv[])
if (iter1.good()) if (iter1.good())
{ {
Info<< "have " << k << nl Info<< "have " << k << nl
<< " addr: " << uintptr_t(*iter1) << nl << " addr: " << name(*iter1) << nl
<< " info: " << (*iter1)->info() << nl << " info: " << (*iter1)->info() << nl
<< " info: " << iter1->info() << nl << " info: " << iter1->info() << nl
<< " incr: " << iter1->increment() << nl << " incr: " << iter1->increment() << nl
@ -225,7 +225,7 @@ int main(int argc, char *argv[])
if (iter2.good()) if (iter2.good())
{ {
Info<< "have " << k << nl Info<< "have " << k << nl
<< " addr: " << uintptr_t(*iter2) << nl << " addr: " << name(*iter2) << nl
<< " info: " << (*iter2)->info() << nl << " info: " << (*iter2)->info() << nl
<< " info: " << iter2->info() << nl << " info: " << iter2->info() << nl
// Good: does not compile // Good: does not compile
@ -237,7 +237,7 @@ int main(int argc, char *argv[])
if (iter3.good()) if (iter3.good())
{ {
Info<< "have " << k << nl Info<< "have " << k << nl
<< " addr: " << uintptr_t(*iter3) << nl << " addr: " << name(*iter3) << nl
<< " info: " << (*iter3)->info() << nl << " info: " << (*iter3)->info() << nl
<< " info: " << iter3->info() << nl << " info: " << iter3->info() << nl
// Good: does not compile // Good: does not compile

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,7 +69,7 @@ void reportDetail(const IOobjectList& objects)
} }
Info<< key << " (" << io->headerClassName() Info<< key << " (" << io->headerClassName()
<< ") = addr " << uintptr_t(io) << nl; << ") = addr " << name(io) << nl;
if (count != 1) if (count != 1)
{ {

View File

@ -36,7 +36,7 @@ template<class T>
Ostream& print(const IjkField<T>& fld) Ostream& print(const IjkField<T>& fld)
{ {
Info<< static_cast<const Field<T>&>(fld).size() Info<< static_cast<const Field<T>&>(fld).size()
<< " addr:" << uintptr_t(fld.cdata()) << ' ' << fld.sizes() << ' ' << " addr:" << name(fld.cdata()) << ' ' << fld.sizes() << ' '
<< flatOutput(fld); << flatOutput(fld);
return Info; return Info;
@ -149,15 +149,15 @@ int main(int argc, char *argv[])
Info<< nl Info<< nl
<< "Before transfer: addr:" << uintptr_t(field1.data()) << "Before transfer: addr:" << name(field1.data())
<< " size:" << field1.size() << nl; << " size:" << field1.size() << nl;
Field<scalar> sfield1(std::move(field1)); Field<scalar> sfield1(std::move(field1));
field1.clear(); field1.clear();
Info<< "After transfer to regular field" << nl Info<< "After transfer to regular field" << nl
<< " source:" << uintptr_t(field1.data()) << nl << " source:" << name(field1.data()) << nl
<< " target:" << uintptr_t(sfield1.data()) << nl << " target:" << name(sfield1.data()) << nl
<< "Values" << "Values"
<< " source:"; << " source:";
print(field1) << nl; print(field1) << nl;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -47,15 +47,15 @@ using namespace Foam;
template<class T> template<class T>
void printAddress(const UList<T>& list) void printAddress(const UList<T>& list)
{ {
Info<< "list addr: " << uintptr_t(&list) Info<< "list addr: " << name(&list)
<< " data addr: " << uintptr_t(list.cdata()) << nl; << " data addr: " << name(list.cdata()) << nl;
} }
template<class T> template<class T>
void printAddress(const SLList<T>& list) void printAddress(const SLList<T>& list)
{ {
Info<< "list addr: " << uintptr_t(&list) Info<< "list addr: " << name(&list)
<< " data addr: ???" << nl; << " data addr: ???" << nl;
} }

View File

@ -244,8 +244,8 @@ int main(int argc, char *argv[])
<< "Number of elements = " << tab << S.size() << nl << "Number of elements = " << tab << S.size() << nl
<< "Number of rows/columns = " << tab << S.sizes() << nl << "Number of rows/columns = " << tab << S.sizes() << nl
<< "Matrix is empty = " << tab << Switch(S.empty()) << nl << "Matrix is empty = " << tab << Switch(S.empty()) << nl
<< "Constant pointer = " << tab << uintptr_t(S.cdata()) << nl << "Constant pointer = " << tab << name(S.cdata()) << nl
<< "Pointer = " << tab << uintptr_t(S.data()) << nl << "Pointer = " << tab << name(S.data()) << nl
<< nl; << nl;
horizontalLine(); horizontalLine();

View File

@ -107,7 +107,7 @@ Ostream& printAddr
for (label i=0; i < len; ++i) for (label i=0; i < len; ++i)
{ {
os << "addr=" << uintptr_t(list(i)) << nl; os << "addr=" << name(list(i)) << nl;
} }
// End delimiter // End delimiter
@ -193,7 +193,7 @@ Ostream& print
{ {
const T* ptr = list(i); const T* ptr = list(i);
os << "unused " << uintptr_t(ptr) << nl; os << "unused " << name(ptr) << nl;
} }
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -23,7 +23,6 @@ License
Description Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include <iostream> #include <iostream>
@ -42,7 +41,7 @@ void printTable(const PtrMap<T>& table)
Info<< iter.key() << " = "; Info<< iter.key() << " = ";
if (ptr) if (ptr)
{ {
Info<< *ptr << " (" << uintptr_t(ptr) << ")"; Info<< *ptr << " (" << name(ptr) << ")";
} }
else else
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation | Copyright (C) 2011-2016 OpenFOAM Foundation
@ -41,8 +41,8 @@ using namespace Foam;
template<class T> template<class T>
void printAddress(const UList<T>& list) void printAddress(const UList<T>& list)
{ {
Info<< "list addr: " << uintptr_t(&list) Info<< "list addr: " << name(&list)
<< " data addr: " << uintptr_t(list.cdata()) << nl; << " data addr: " << name(list.cdata()) << nl;
} }

View File

@ -75,8 +75,8 @@ void printTuple2(const Tuple2<word, word>& t)
{ {
Info<< "tuple: " << t << nl; Info<< "tuple: " << t << nl;
Info<< "first @: " << uintptr_t(t.first().data()) << nl; Info<< "first @: " << name(t.first().data()) << nl;
Info<< "second @: " << uintptr_t(t.second().data()) << nl; Info<< "second @: " << name(t.second().data()) << nl;
} }
@ -85,8 +85,8 @@ void printTuple2(const Pair<word>& t)
{ {
Info<< "tuple: " << t << nl; Info<< "tuple: " << t << nl;
Info<< "first @: " << uintptr_t(t.first().data()) << nl; Info<< "first @: " << name(t.first().data()) << nl;
Info<< "second @: " << uintptr_t(t.second().data()) << nl; Info<< "second @: " << name(t.second().data()) << nl;
} }
@ -191,30 +191,30 @@ int main()
word word1("hello"); word word1("hello");
word word2("word"); word word2("word");
Info<< "create with " << word1 << " @ " << uintptr_t(word1.data()) Info<< "create with " << word1 << " @ " << name(word1.data())
<< " " << word2 << " @ " << uintptr_t(word2.data()) << nl; << " " << word2 << " @ " << name(word2.data()) << nl;
Tuple2<word, word> tup(std::move(word2), std::move(word1)); Tuple2<word, word> tup(std::move(word2), std::move(word1));
printTuple2(tup); printTuple2(tup);
Info<< "input is now " << word1 << " @ " << uintptr_t(word1.data()) Info<< "input is now " << word1 << " @ " << name(word1.data())
<< " " << word2 << " @ " << uintptr_t(word2.data()) << nl; << " " << word2 << " @ " << name(word2.data()) << nl;
} }
{ {
word word1("hello"); word word1("hello");
word word2("word"); word word2("word");
Info<< "create with " << word1 << " @ " << uintptr_t(word1.data()) Info<< "create with " << word1 << " @ " << name(word1.data())
<< " " << word2 << " @ " << uintptr_t(word2.data()) << nl; << " " << word2 << " @ " << name(word2.data()) << nl;
Pair<word> tup(std::move(word2), std::move(word1)); Pair<word> tup(std::move(word2), std::move(word1));
printTuple2(tup); printTuple2(tup);
Info<< "input is now " << word1 << " @ " << uintptr_t(word1.data()) Info<< "input is now " << word1 << " @ " << name(word1.data())
<< " " << word2 << " @ " << uintptr_t(word2.data()) << nl; << " " << word2 << " @ " << name(word2.data()) << nl;
} }
Info<< "\nEnd\n" << endl; Info<< "\nEnd\n" << endl;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,7 +46,7 @@ using namespace Foam;
template<class ListType> template<class ListType>
void print(const ListType& list) void print(const ListType& list)
{ {
Info << flatOutput(list) << " data addr: " << uintptr_t(list.cdata()) << nl; Info << flatOutput(list) << " data addr: " << name(list.cdata()) << nl;
} }

View File

@ -85,7 +85,7 @@ int main(int argc, char *argv[])
const labelList* plist = list; const labelList* plist = list;
Info<<"pointer: " << uintptr_t(plist) << nl Info<<"pointer: " << name(plist) << nl
<<"content: " << *plist << nl; <<"content: " << *plist << nl;
Info<<"create: " << autoPtr<labelList>::New(10, label(-1))() Info<<"create: " << autoPtr<labelList>::New(10, label(-1))()
@ -107,17 +107,17 @@ int main(int argc, char *argv[])
{ {
auto source = identity(8); auto source = identity(8);
Info<<"move construct from " Info<<"move construct from "
<< flatOutput(source) << " @ " << uintptr_t(source.cdata()) << flatOutput(source) << " @ " << name(source.cdata())
<< nl << nl; << nl << nl;
auto list = autoPtr<labelList>::New(std::move(source)); auto list = autoPtr<labelList>::New(std::move(source));
Info<<"created: " Info<<"created: "
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata()) << flatOutput(*list) << " @ " << name(list->cdata())
<< nl << nl; << nl << nl;
Info<<"orig: " Info<<"orig: "
<< flatOutput(source) << " @ " << uintptr_t(source.cdata()) << flatOutput(source) << " @ " << name(source.cdata())
<< nl << nl; << nl << nl;
} }
@ -154,7 +154,7 @@ int main(int argc, char *argv[])
auto list = autoPtr<labelList>::New(identity(8)); auto list = autoPtr<labelList>::New(identity(8));
Info<<"forward to function from " Info<<"forward to function from "
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata()) << flatOutput(*list) << " @ " << name(list->cdata())
<< nl << nl; << nl << nl;
testTransfer2(std::move(list)); testTransfer2(std::move(list));
@ -164,7 +164,7 @@ int main(int argc, char *argv[])
if (list) if (list)
{ {
Info<< nl Info<< nl
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata()) << flatOutput(*list) << " @ " << name(list->cdata())
<< nl; << nl;
} }
else else
@ -202,7 +202,7 @@ int main(int argc, char *argv[])
auto list = autoPtr<labelList>::New(identity(8)); auto list = autoPtr<labelList>::New(identity(8));
Info<<"forward to function from " Info<<"forward to function from "
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata()) << flatOutput(*list) << " @ " << name(list->cdata())
<< nl << nl; << nl << nl;
testTransfer2(std::move(list)); testTransfer2(std::move(list));
@ -212,7 +212,7 @@ int main(int argc, char *argv[])
if (list.valid()) if (list.valid())
{ {
Info<< nl Info<< nl
<< flatOutput(*list) << " @ " << uintptr_t(list->cdata()) << flatOutput(*list) << " @ " << name(list->cdata())
<< nl; << nl;
} }
else else

View File

@ -78,8 +78,8 @@ int main()
Info Info
<< "\nVerify memory addesses are identical:" << nl << "\nVerify memory addesses are identical:" << nl
<< "macro " << uintptr_t(Foam::FOAMversion) << nl << "macro " << name(Foam::FOAMversion) << nl
<< "namespace " << uintptr_t(&(foamVersion::version[0])) << nl; << "namespace " << name(&(foamVersion::version[0])) << nl;
// Test extraction // Test extraction

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -37,7 +37,7 @@ Ostream& printInfo(const hashedWordList& list, bool withAddr=false)
Info<< flatOutput(list) << nl << list.lookup() << nl; Info<< flatOutput(list) << nl << list.lookup() << nl;
if (withAddr) if (withAddr)
{ {
Info<< "addr=" << uintptr_t(list.cdata()) << nl; Info<< "addr=" << name(list.cdata()) << nl;
} }
return Info; return Info;

View File

@ -57,12 +57,12 @@ void printInfo(const UList<T>& list)
{ {
std::cout std::cout
<< nl << nl
<< "List : addr: " << uintptr_t(&list) << "List : addr: " << name(&list)
<< " (null: " << isNull(list) << ")" << nl << " (null: " << isNull(list) << ")" << nl
<< " size: " << list.size() << " empty: " << list.empty() << nl << " size: " << list.size() << " empty: " << list.empty() << nl
<< " data: " << uintptr_t(list.cdata()) << " data: " << name(list.cdata())
<< " begin=" << uintptr_t(list.begin()) << " begin=" << name(list.begin())
<< " end=" << uintptr_t(list.end()) << nl; << " end=" << name(list.end()) << nl;
Info<< list << nl; Info<< list << nl;
} }
@ -78,7 +78,7 @@ int main()
SimpleClass& refToClass(*ptrToClass); SimpleClass& refToClass(*ptrToClass);
std::cout std::cout
<< "nullObject addr=" << uintptr_t(&(nullObjectPtr)) << nl << "nullObject addr=" << name(&(nullObjectPtr)) << nl
<< " sizeof(nullObject) = " << sizeof(NullObject::nullObject) << nl << " sizeof(nullObject) = " << sizeof(NullObject::nullObject) << nl
<< " sizeof(void*) = " << sizeof(void*) << nl << " sizeof(void*) = " << sizeof(void*) << nl
<< " sizeof(labelList) = " << sizeof(labelList) << nl << " sizeof(labelList) = " << sizeof(labelList) << nl
@ -86,7 +86,7 @@ int main()
std::cout std::cout
<< "nullObject" << nl << "nullObject" << nl
<< " pointer:" << uintptr_t(nullObjectPtr->pointer()) << nl << " pointer:" << name(nullObjectPtr->pointer()) << nl
<< " value:" << nullObjectPtr->value() << nl << nl; << " value:" << nullObjectPtr->value() << nl << nl;
if (notNull(ptrToClass)) if (notNull(ptrToClass))

View File

@ -2,10 +2,8 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd. \\ / A nd | Copyright (C) 2011-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -46,7 +44,7 @@ void printInfo(const tmp<T>& tmpItem)
{ {
Info<< "tmp valid:" << tmpItem.valid() Info<< "tmp valid:" << tmpItem.valid()
<< " isTmp:" << tmpItem.isTmp() << " isTmp:" << tmpItem.isTmp()
<< " addr: " << uintptr_t(tmpItem.get()); << " addr: " << name(tmpItem.get());
if (tmpItem.valid()) if (tmpItem.valid())
{ {

View File

@ -212,8 +212,8 @@ Foam::PackedList<Width> Foam::reorder
} }
// Verify addresses (for movable refs) // Verify addresses (for movable refs)
// Info<< "reordered in " << uintptr_t(input.storage().cdata()) << nl // Info<< "reordered in " << name(input.storage().cdata()) << nl
// << "reordered out " << uintptr_t(output.storage().cdata()) << nl; // << "reordered out " << name(output.storage().cdata()) << nl;
return output; return output;
} }
@ -230,7 +230,7 @@ void Foam::inplaceReorder
input = reorder(oldToNew, input, prune); input = reorder(oldToNew, input, prune);
// Verify address (for movable refs) // Verify address (for movable refs)
// Info<< "now have " << uintptr_t(input.storage().cdata()) << nl; // Info<< "now have " << name(input.storage().cdata()) << nl;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -61,16 +61,14 @@ Foam::dlLibraryTable::~dlLibraryTable()
{ {
if (libPtrs_[i]) if (libPtrs_[i])
{ {
if (debug) DebugInFunction
{ << "Closing " << libNames_[i]
InfoInFunction << " with handle " << name(libPtrs_[i]) << nl;
<< "Closing " << libNames_[i]
<< " with handle " << uintptr_t(libPtrs_[i]) << endl;
}
if (!dlClose(libPtrs_[i])) if (!dlClose(libPtrs_[i]))
{ {
WarningInFunction<< "Failed closing " << libNames_[i] WarningInFunction<< "Failed closing " << libNames_[i]
<< " with handle " << uintptr_t(libPtrs_[i]) << endl; << " with handle " << name(libPtrs_[i]) << endl;
} }
} }
} }
@ -92,12 +90,9 @@ bool Foam::dlLibraryTable::open
void* ptr = dlOpen(fileName(libName).expand(), verbose); void* ptr = dlOpen(fileName(libName).expand(), verbose);
if (debug) DebugInFunction
{ << "Opened " << libName
InfoInFunction << " resulting in handle " << name(ptr) << endl;
<< "Opened " << libName
<< " resulting in handle " << uintptr_t(ptr) << endl;
}
if (ptr) if (ptr)
{ {
@ -138,12 +133,9 @@ bool Foam::dlLibraryTable::close
return false; return false;
} }
if (debug) DebugInFunction
{ << "Closing " << libName
InfoInFunction << " with handle " << name(libPtrs_[index]) << nl;
<< "Closing " << libName
<< " with handle " << uintptr_t(libPtrs_[index]) << endl;
}
const bool ok = dlClose(libPtrs_[index]); const bool ok = dlClose(libPtrs_[index]);

View File

@ -62,7 +62,8 @@ word name(const Scalar val)
{ {
std::ostringstream buf; std::ostringstream buf;
buf << val; buf << val;
return buf.str();
return word(buf.str(), false); // Needs no stripping
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011 OpenFOAM Foundation | Copyright (C) 2011 OpenFOAM Foundation
@ -28,6 +28,7 @@ License
#include "word.H" #include "word.H"
#include "debug.H" #include "debug.H"
#include <cctype> #include <cctype>
#include <sstream>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -170,4 +171,15 @@ Foam::word Foam::operator&(const word& a, const word& b)
} }
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
Foam::word Foam::name(const void* ptr)
{
std::ostringstream buf;
buf << "0x" << std::hex << uintptr_t(ptr);
return word(buf.str(), false); // Needs no stripping
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -228,6 +228,11 @@ word operator&(const word& a, const word& b);
// * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * * //
//- A word representation of a memory address as hexadecimal.
// No special handling of nullptr (renders as 0x0)
word name(const void* ptr);
//- Extract name (as a word) from an object, typically using its name() method. //- Extract name (as a word) from an object, typically using its name() method.
template<class T> template<class T>
struct nameOp struct nameOp

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2015-2018 OpenCFD Ltd. \\ / A nd | Copyright (C) 2015-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation | Copyright (C) 2011-2017 OpenFOAM Foundation
@ -658,10 +658,10 @@ Foam::label Foam::ptscotchDecomp::decompose
{ {
Pout<< "SCOTCH_dgraphBuild with:" << nl Pout<< "SCOTCH_dgraphBuild with:" << nl
<< "xadjSize-1 : " << xadjSize-1 << nl << "xadjSize-1 : " << xadjSize-1 << nl
<< "xadj : " << uintptr_t(xadj) << nl << "xadj : " << name(xadj) << nl
<< "velotab : " << uintptr_t(velotab.begin()) << nl << "velotab : " << name(velotab.begin()) << nl
<< "adjncySize : " << adjncySize << nl << "adjncySize : " << adjncySize << nl
<< "adjncy : " << uintptr_t(adjncy) << nl << "adjncy : " << name(adjncy) << nl
<< endl; << endl;
} }