aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbarenblat@galois.com>2014-02-06 10:52:23 -0800
committerGravatar Benjamin Barenblat <bbarenblat@galois.com>2014-02-06 10:52:23 -0800
commite0da0c68a6ebb68d7f087520ed5a2b8a28e8edc5 (patch)
tree491213382b7254b2e5cde0ac20c98fda3dc86dae
parent28dd2b967cc9853d034d2374e4f1adbe305fef8a (diff)
Python: Make 'report_name_base' optional in calls to 'Tracer'
-rw-r--r--bindings/python/ppamltracer.py32
1 files changed, 27 insertions, 5 deletions
diff --git a/bindings/python/ppamltracer.py b/bindings/python/ppamltracer.py
index dde85a3..e8b7863 100644
--- a/bindings/python/ppamltracer.py
+++ b/bindings/python/ppamltracer.py
@@ -1,5 +1,5 @@
# ppamltracer -- Python bindings to ppamltracer
-# Copyright (C) 2013 Galois, Inc.
+# Copyright (C) 2013, 2014 Galois, Inc.
#
# This library is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@@ -85,7 +85,13 @@ _sizeof_ppaml_tracer_t = \
_sizeof_ppaml_phase_t = ctypes.c_size_t.in_dll(_lib, "ppaml_phase_t_size").value
def _ppaml_tracer_init(tracer, report_name_base):
- result = _lib.ppaml_tracer_init(tracer, report_name_base)
+ if report_name_base is None:
+ _initialize = _lib.ppaml_tracer_init_from_env
+ _initialize_args = [tracer]
+ else:
+ _initialize = _lib.ppaml_tracer_init
+ _initialize_args = [tracer, report_name_base]
+ result = _initialize(*_initialize_args)
if result == 0:
return None
elif result == 1:
@@ -96,6 +102,8 @@ def _ppaml_tracer_init(tracer, report_name_base):
raise OTFWriterResolutionError()
elif result == 4:
raise OTFWriterProcessDefinitionError("main")
+ elif result == 5:
+ raise UndefinedTracerBasePathError()
else:
_warn_unexpected_return_code()
raise TracerError()
@@ -165,12 +173,13 @@ class Tracer(object):
"""
- def __init__(self, report_name_base):
+ def __init__(self, report_name_base=None):
"""Create a new tracer.
The tracer will create an Open Trace Format report during program
- execution. The multiple files of the report will all start with the
- specified base name.
+ execution. If report_name_base is specified, the multiple files of the
+ report will all start with report_name_base; otherwise, they will start
+ with the contents of the PPAMLTRACER_TRACE_BASE environment variable.
"""
self._report_name_base = report_name_base
@@ -273,6 +282,19 @@ class TracerError(Exception):
"""A generic ppamltracer error."""
pass
+class ConfigurationError(TracerError):
+ """An error related to tracer configuration."""
+ pass
+
+class UndefinedTracerBasePathError(ConfigurationError):
+ """Signals an attempt to initialize a tracer with an undefined basepath.
+
+ """
+
+ def __init__(self):
+ super(UndefinedTracerBasePathError, self).__init__(
+ "attempted to configure tracer with undefined base path")
+
class OTFError(TracerError):
"""An error related to Open Trace Format input and output."""
pass