Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
8fee1565
Commit
8fee1565
authored
9 years ago
by
Nat Goodspeed
Browse files
Options
Downloads
Patches
Plain Diff
MAINT-5232: Use LLError::Log::demangle() to log LLSingleton classes.
parent
3f52cefc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/llcommon/llsingleton.cpp
+17
-11
17 additions, 11 deletions
indra/llcommon/llsingleton.cpp
indra/llcommon/llsingleton.h
+7
-3
7 additions, 3 deletions
indra/llcommon/llsingleton.h
with
24 additions
and
14 deletions
indra/llcommon/llsingleton.cpp
+
17
−
11
View file @
8fee1565
...
@@ -111,13 +111,13 @@ void LLSingletonBase::pop_initializing()
...
@@ -111,13 +111,13 @@ void LLSingletonBase::pop_initializing()
if
(
list
.
empty
())
if
(
list
.
empty
())
{
{
logerrs
(
"Underflow in stack of currently-initializing LLSingletons at "
,
logerrs
(
"Underflow in stack of currently-initializing LLSingletons at "
,
typeid
(
*
this
).
name
(),
"::getInstance()"
);
demangle
(
typeid
(
*
this
).
name
()
).
c_str
()
,
"::getInstance()"
);
}
}
if
(
list
.
back
()
!=
this
)
if
(
list
.
back
()
!=
this
)
{
{
logerrs
(
"Push/pop mismatch in stack of currently-initializing LLSingletons: "
,
logerrs
(
"Push/pop mismatch in stack of currently-initializing LLSingletons: "
,
typeid
(
*
this
).
name
(),
"::getInstance() trying to pop "
,
demangle
(
typeid
(
*
this
).
name
()
).
c_str
()
,
"::getInstance() trying to pop "
,
typeid
(
*
list
.
back
()).
name
());
demangle
(
typeid
(
*
list
.
back
()).
name
())
.
c_str
())
;
}
}
// Here we're sure that list.back() == this. Whew, pop it.
// Here we're sure that list.back() == this. Whew, pop it.
list
.
pop_back
();
list
.
pop_back
();
...
@@ -148,7 +148,7 @@ void LLSingletonBase::capture_dependency(EInitState initState)
...
@@ -148,7 +148,7 @@ void LLSingletonBase::capture_dependency(EInitState initState)
{
{
// 'found' is an iterator; *found is an LLSingletonBase*; **found
// 'found' is an iterator; *found is an LLSingletonBase*; **found
// is the actual LLSingletonBase instance.
// is the actual LLSingletonBase instance.
out
<<
typeid
(
**
found
).
name
()
<<
" -> "
;
out
<<
demangle
(
typeid
(
**
found
).
name
()
)
<<
" -> "
;
}
}
// We promise to capture dependencies from both the constructor
// We promise to capture dependencies from both the constructor
// and the initSingleton() method, so an LLSingleton's instance
// and the initSingleton() method, so an LLSingleton's instance
...
@@ -161,7 +161,8 @@ void LLSingletonBase::capture_dependency(EInitState initState)
...
@@ -161,7 +161,8 @@ void LLSingletonBase::capture_dependency(EInitState initState)
// Decide which log helper to call based on initState. They have
// Decide which log helper to call based on initState. They have
// identical signatures.
// identical signatures.
((
initState
==
CONSTRUCTING
)
?
logerrs
:
logwarns
)
((
initState
==
CONSTRUCTING
)
?
logerrs
:
logwarns
)
(
"LLSingleton circularity: "
,
out
.
str
().
c_str
(),
typeid
(
*
this
).
name
(),
""
);
(
"LLSingleton circularity: "
,
out
.
str
().
c_str
(),
demangle
(
typeid
(
*
this
).
name
()).
c_str
(),
""
);
}
}
else
else
{
{
...
@@ -232,12 +233,12 @@ void LLSingletonBase::cleanupAll()
...
@@ -232,12 +233,12 @@ void LLSingletonBase::cleanupAll()
}
}
catch
(
const
std
::
exception
&
e
)
catch
(
const
std
::
exception
&
e
)
{
{
logwarns
(
"Exception in "
,
typeid
(
*
sp
).
name
(),
logwarns
(
"Exception in "
,
demangle
(
typeid
(
*
sp
).
name
()
).
c_str
()
,
"::cleanupSingleton(): "
,
e
.
what
());
"::cleanupSingleton(): "
,
e
.
what
());
}
}
catch
(...)
catch
(...)
{
{
logwarns
(
"Unknown exception in "
,
typeid
(
*
sp
).
name
(),
logwarns
(
"Unknown exception in "
,
demangle
(
typeid
(
*
sp
).
name
()
).
c_str
()
,
"::cleanupSingleton()"
);
"::cleanupSingleton()"
);
}
}
}
}
...
@@ -252,14 +253,14 @@ void LLSingletonBase::deleteAll()
...
@@ -252,14 +253,14 @@ void LLSingletonBase::deleteAll()
{
{
// Capture the class name first: in case of exception, don't count on
// Capture the class name first: in case of exception, don't count on
// being able to extract it later.
// being able to extract it later.
const
char
*
name
=
typeid
(
*
sp
).
name
();
const
std
::
string
name
=
demangle
(
typeid
(
*
sp
).
name
()
)
;
try
try
{
{
// Call static method through instance function pointer.
// Call static method through instance function pointer.
if
(
!
sp
->
mDeleteSingleton
)
if
(
!
sp
->
mDeleteSingleton
)
{
{
// This Should Not Happen... but carry on.
// This Should Not Happen... but carry on.
logwarns
(
name
,
"::mDeleteSingleton not initialized!"
);
logwarns
(
name
.
c_str
()
,
"::mDeleteSingleton not initialized!"
);
}
}
else
else
{
{
...
@@ -270,11 +271,11 @@ void LLSingletonBase::deleteAll()
...
@@ -270,11 +271,11 @@ void LLSingletonBase::deleteAll()
}
}
catch
(
const
std
::
exception
&
e
)
catch
(
const
std
::
exception
&
e
)
{
{
logwarns
(
"Exception in "
,
name
,
"::deleteSingleton(): "
,
e
.
what
());
logwarns
(
"Exception in "
,
name
.
c_str
()
,
"::deleteSingleton(): "
,
e
.
what
());
}
}
catch
(...)
catch
(...)
{
{
logwarns
(
"Unknown exception in "
,
name
,
"::deleteSingleton()"
);
logwarns
(
"Unknown exception in "
,
name
.
c_str
()
,
"::deleteSingleton()"
);
}
}
}
}
}
}
...
@@ -348,3 +349,8 @@ void LLSingletonBase::logwarns(const char* p1, const char* p2, const char* p3, c
...
@@ -348,3 +349,8 @@ void LLSingletonBase::logwarns(const char* p1, const char* p2, const char* p3, c
std
::
cerr
<<
p1
<<
p2
<<
p3
<<
p4
<<
std
::
endl
;
std
::
cerr
<<
p1
<<
p2
<<
p3
<<
p4
<<
std
::
endl
;
}
}
}
}
std
::
string
LLSingletonBase
::
demangle
(
const
char
*
mangled
)
{
return
LLError
::
Log
::
demangle
(
mangled
);
}
This diff is collapsed.
Click to expand it.
indra/llcommon/llsingleton.h
+
7
−
3
View file @
8fee1565
...
@@ -104,6 +104,7 @@ class LLSingletonBase: private boost::noncopyable
...
@@ -104,6 +104,7 @@ class LLSingletonBase: private boost::noncopyable
// delegate LL_WARNS() logging to llsingleton.cpp
// delegate LL_WARNS() logging to llsingleton.cpp
static
void
logwarns
(
const
char
*
p1
,
const
char
*
p2
=
""
,
static
void
logwarns
(
const
char
*
p1
,
const
char
*
p2
=
""
,
const
char
*
p3
=
""
,
const
char
*
p4
=
""
);
const
char
*
p3
=
""
,
const
char
*
p4
=
""
);
static
std
::
string
demangle
(
const
char
*
mangled
);
// obtain canonical ref_ptr_t
// obtain canonical ref_ptr_t
static
ref_ptr_t
get_master_refcount
();
static
ref_ptr_t
get_master_refcount
();
...
@@ -337,11 +338,13 @@ class LLSingleton : public LLSingletonBase
...
@@ -337,11 +338,13 @@ class LLSingleton : public LLSingletonBase
{
{
case
UNINITIALIZED
:
case
UNINITIALIZED
:
// should never be uninitialized at this point
// should never be uninitialized at this point
logerrs
(
"Uninitialized singleton "
,
typeid
(
DERIVED_TYPE
).
name
());
logerrs
(
"Uninitialized singleton "
,
demangle
(
typeid
(
DERIVED_TYPE
).
name
()).
c_str
());
return
NULL
;
return
NULL
;
case
CONSTRUCTING
:
case
CONSTRUCTING
:
logerrs
(
"Tried to access singleton "
,
typeid
(
DERIVED_TYPE
).
name
(),
logerrs
(
"Tried to access singleton "
,
demangle
(
typeid
(
DERIVED_TYPE
).
name
()).
c_str
(),
" from singleton constructor!"
);
" from singleton constructor!"
);
return
NULL
;
return
NULL
;
...
@@ -361,7 +364,8 @@ class LLSingleton : public LLSingletonBase
...
@@ -361,7 +364,8 @@ class LLSingleton : public LLSingletonBase
break
;
break
;
case
DELETED
:
case
DELETED
:
logwarns
(
"Trying to access deleted singleton "
,
typeid
(
DERIVED_TYPE
).
name
(),
logwarns
(
"Trying to access deleted singleton "
,
demangle
(
typeid
(
DERIVED_TYPE
).
name
()).
c_str
(),
" -- creating new instance"
);
" -- creating new instance"
);
SingletonLifetimeManager
::
construct
();
SingletonLifetimeManager
::
construct
();
// same as first time construction
// same as first time construction
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment