[rtems-tools commit] Add a lock model to support different lock models when tracing.
Chris Johns
chrisj at rtems.org
Tue Sep 29 10:28:58 UTC 2015
Module: rtems-tools
Branch: master
Commit: e3df1295573cda06994d06a9b9fa12137fde584a
Changeset: http://git.rtems.org/rtems-tools/commit/?id=e3df1295573cda06994d06a9b9fa12137fde584a
Author: Chris Johns <chrisj at rtems.org>
Date: Tue Sep 29 20:26:38 2015 +1000
Add a lock model to support different lock models when tracing.
Logging to a file requires a 'trace' lock model be used. The 'trace'
lock model holds the lock for the entire trace time, for example
the entry or exit tracing.
---
linkers/rtems-tld.cpp | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/linkers/rtems-tld.cpp b/linkers/rtems-tld.cpp
index 714c9ee..a2a6e23 100644
--- a/linkers/rtems-tld.cpp
+++ b/linkers/rtems-tld.cpp
@@ -171,6 +171,7 @@ namespace rld
struct generator
{
std::string name; /**< The name of this wrapper. */
+ std::string lock_model; /**< The lock model if provided, default "alloc". */
std::string lock_local; /**< Code template to declare a local lock variable. */
std::string lock_acquire; /**< The lock acquire if provided. */
std::string lock_release; /**< The lock release if provided. */
@@ -595,6 +596,7 @@ namespace rld
* # ret-trace The wrapper call made to log the return value if the funciton
* is being traced. This call is made without the lock being held
* if a lock is defined.
+ * # lock-model The wrapper code lock model. Models are 'alloc', or capture'.
* # lock-local The wrapper code to declare a local lock variable.
* # lock-acquire The wrapper code to acquire the lock.
* # lock-release The wrapper code to release the lock.
@@ -665,6 +667,8 @@ namespace rld
parse (config, section, "defines", "define", defines);
parse (config, section, "code-blocks", "code", code, false);
+ if (section.has_record ("lock-model"))
+ lock_model = rld::dequote (section.get_record_item ("lock-model"));
if (section.has_record ("lock-local"))
lock_local = rld::dequote (section.get_record_item ("lock-local"));
if (section.has_record ("lock-acquire"))
@@ -1310,7 +1314,8 @@ namespace rld
c.write_line(l);
}
- if (!generator_.lock_release.empty ())
+ if (!generator_.lock_release.empty () &&
+ (generator_.lock_model.empty () || (generator_.lock_model == "alloc")))
c.write_line(generator_.lock_release);
if (!generator_.entry_trace.empty ())
@@ -1334,6 +1339,9 @@ namespace rld
}
}
+ if (!generator_.lock_release.empty () && generator_.lock_model == "trace")
+ c.write_line(generator_.lock_release);
+
l.clear ();
if (sig.has_ret ())
@@ -1362,7 +1370,8 @@ namespace rld
c.write_line(l);
}
- if (!generator_.lock_release.empty ())
+ if (!generator_.lock_release.empty () &&
+ (generator_.lock_model.empty () || (generator_.lock_model == "alloc")))
c.write_line(generator_.lock_release);
if (!generator_.exit_trace.empty ())
@@ -1379,9 +1388,14 @@ namespace rld
l = rld::find_replace (l, "@RET_SIZE@", "sizeof(" + sig.ret + ')');
l = rld::find_replace (l, "@RET_LABEL@", "ret");
c.write_line(l);
- c.write_line(" return ret;");
}
+ if (!generator_.lock_release.empty ())
+ c.write_line(generator_.lock_release);
+
+ if (sig.has_ret ())
+ c.write_line(" return ret;");
+
c.write_line("}");
}
}
More information about the vc
mailing list