Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ApplicationCore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ChimeraTK Mirror
ApplicationCore
Commits
f6de4a13
Commit
f6de4a13
authored
2 years ago
by
Martin Christoph Hierholzer
Browse files
Options
Downloads
Patches
Plain Diff
simplify debugging TestableMode
parent
59ad2613
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/TestableMode.h
+18
-1
18 additions, 1 deletion
include/TestableMode.h
src/ConnectionMaker.cc
+2
-0
2 additions, 0 deletions
src/ConnectionMaker.cc
src/TestFacility.cc
+1
-1
1 addition, 1 deletion
src/TestFacility.cc
src/TestableMode.cc
+20
-3
20 additions, 3 deletions
src/TestableMode.cc
with
41 additions
and
5 deletions
include/TestableMode.h
+
18
−
1
View file @
f6de4a13
...
...
@@ -15,6 +15,10 @@
#include
<map>
#include
<mutex>
namespace
ChimeraTK
{
class
ConnectionMaker
;
}
namespace
ChimeraTK
::
detail
{
struct
TestableMode
{
/** Special exception class which will be thrown if tests with the testable
...
...
@@ -68,7 +72,7 @@ namespace ChimeraTK::detail {
/** Test if the testable mode mutex is locked by the current thread.
*
* This function should generally not be used in user code. */
bool
testLock
();
[[
nodiscard
]]
bool
testLock
()
const
;
[[
nodiscard
]]
bool
canStep
()
const
{
return
counter
!=
0
;
}
...
...
@@ -211,6 +215,9 @@ namespace ChimeraTK::detail {
* output of the testable mode. Will return "*UNKNOWN_THREAD*" if the name for the given ID has not yet been set.
*/
std
::
string
threadName
(
const
boost
::
thread
::
id
&
threadId
=
boost
::
this_thread
::
get_id
());
bool
_debugDecorating
{
false
};
friend
class
ChimeraTK
::
ConnectionMaker
;
};
/********************************************************************************************************************/
...
...
@@ -224,6 +231,11 @@ namespace ChimeraTK::detail {
AccessorPair
<
T
>
other
,
const
VariableNetworkNode
&
producer
,
const
VariableNetworkNode
&
consumer
)
{
if
(
not
enabled
)
return
other
;
if
(
_debugDecorating
)
{
std
::
cout
<<
" Decorating pair "
<<
producer
.
getQualifiedName
()
<<
"["
<<
other
.
first
->
getId
()
<<
"] -> "
<<
consumer
.
getQualifiedName
()
<<
"["
<<
other
.
second
->
getId
()
<<
"]"
<<
std
::
endl
;
}
// create variable IDs
size_t
varId
=
detail
::
TestableMode
::
getNextVariableId
();
size_t
varIdReturn
;
...
...
@@ -264,6 +276,11 @@ namespace ChimeraTK::detail {
return
other
;
}
if
(
_debugDecorating
)
{
std
::
cout
<<
" Decorating single "
<<
(
direction
==
DecoratorType
::
READ
?
"consumer "
:
"feeder "
)
<<
name
<<
"["
<<
other
->
getId
()
<<
"]"
<<
std
::
endl
;
}
if
(
varId
==
0
)
{
varId
=
detail
::
TestableMode
::
getNextVariableId
();
}
...
...
This diff is collapsed.
Click to expand it.
src/ConnectionMaker.cc
+
2
−
0
View file @
f6de4a13
...
...
@@ -121,6 +121,8 @@ namespace ChimeraTK {
void
ConnectionMaker
::
connect
()
{
debug
(
"Calling Connect..."
);
_app
.
getTestableMode
().
_debugDecorating
=
_debugConnections
;
debug
(
" Preparing trigger networks"
);
debug
(
" Collecting triggers"
);
std
::
set
<
Model
::
ProcessVariableProxy
>
triggers
;
...
...
This diff is collapsed.
Click to expand it.
src/TestFacility.cc
+
1
−
1
View file @
f6de4a13
...
...
@@ -86,7 +86,7 @@ namespace ChimeraTK {
for
(
auto
&
pv
:
pvManager
->
getAllProcessVariables
())
{
if
(
!
pv
->
isReadable
())
continue
;
callForTypeNoVoid
(
pv
->
getValueType
(),
[
&
](
auto
t
)
{
typedef
decltype
(
t
)
UserType
;
using
UserType
=
decltype
(
t
);
this
->
getArray
<
UserType
>
(
pv
->
getName
()).
readNonBlocking
();
});
}
...
...
This diff is collapsed.
Click to expand it.
src/TestableMode.cc
+
20
−
3
View file @
f6de4a13
...
...
@@ -27,13 +27,30 @@ namespace ChimeraTK::detail {
}
/*********************************************************************************************************************/
bool
TestableMode
::
testLock
()
{
bool
TestableMode
::
testLock
()
const
{
if
(
not
enabled
)
return
false
;
return
getLockObject
().
owns_lock
();
}
/*********************************************************************************************************************/
namespace
{
/// This is a trick to make sure the exception is never caught, not even by the BOOST test framework.
void
terminateTestStalled
()
{
struct
TestStalled
:
std
::
exception
{
[[
nodiscard
]]
const
char
*
what
()
const
noexcept
override
{
return
"Test stalled."
;
}
};
try
{
throw
TestStalled
();
}
catch
(...)
{
std
::
terminate
();
}
}
}
// namespace
/*********************************************************************************************************************/
void
TestableMode
::
lock
(
const
std
::
string
&
name
)
{
// don't do anything if testable mode is not enabled
if
(
not
enabled
)
return
;
...
...
@@ -66,7 +83,7 @@ namespace ChimeraTK::detail {
<<
std
::
endl
;
// LCOV_EXCL_LINE
// throw a specialised exception to make sure whoever catches it really knows what he does...
t
hrow
Test
s
Stalled
();
// LCOV_EXCL_LINE
t
erminate
TestStalled
();
// LCOV_EXCL_LINE
}
// LCOV_EXCL_LINE
// check if the last owner of the mutex was this thread, which may be a hint
...
...
@@ -118,7 +135,7 @@ namespace ChimeraTK::detail {
// Check for modules waiting for initial values (prints nothing if there are no such modules)
Application
::
getInstance
().
circularDependencyDetector
.
printWaiters
();
// throw a specialised exception to make sure whoever catches it really knows what he does...
t
hrow
Test
s
Stalled
();
t
erminate
TestStalled
();
}
}
else
{
...
...
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