3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-09 07:33:24 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2019-06-03 19:50:25 -07:00 committed by Nuno Lopes
parent 2788f72bbb
commit 9262908ebb
30 changed files with 191 additions and 341 deletions

View file

@ -19,6 +19,9 @@ Notes:
#include "util/gparams.h"
#include "util/dictionary.h"
#include "util/trace.h"
#include <mutex>
static std::mutex gparams_mux;
extern void gparams_register_modules();
@ -110,14 +113,12 @@ public:
}
void reset() {
#pragma omp critical (gparams)
{
m_params.reset();
for (auto & kv : m_module_params) {
dealloc(kv.m_value);
}
m_module_params.reset();
std::lock_guard<std::mutex> lock(gparams_mux);
m_params.reset();
for (auto & kv : m_module_params) {
dealloc(kv.m_value);
}
m_module_params.reset();
}
// -----------------------------------------------
@ -327,8 +328,8 @@ public:
void set(char const * name, char const * value) {
bool error = false;
std::string error_msg;
#pragma omp critical (gparams)
{
std::lock_guard<std::mutex> lock(gparams_mux);
try {
symbol m, p;
normalize(name, m, p);
@ -379,8 +380,8 @@ public:
std::string r;
bool error = false;
std::string error_msg;
#pragma omp critical (gparams)
{
std::lock_guard<std::mutex> lock(gparams_mux);
try {
symbol m, p;
normalize(name, m, p);
@ -426,8 +427,8 @@ public:
params_ref get_module(symbol const & module_name) {
params_ref result;
params_ref * ps = nullptr;
#pragma omp critical (gparams)
{
std::lock_guard<std::mutex> lock(gparams_mux);
if (m_module_params.find(module_name, ps)) {
result.copy(*ps);
}
@ -446,8 +447,8 @@ public:
// -----------------------------------------------
void display(std::ostream & out, unsigned indent, bool smt2_style, bool include_descr) {
#pragma omp critical (gparams)
{
std::lock_guard<std::mutex> lock(gparams_mux);
out << "Global parameters\n";
get_param_descrs().display(out, indent + 4, smt2_style, include_descr);
out << "\n";
@ -469,44 +470,40 @@ public:
}
void display_modules(std::ostream & out) {
#pragma omp critical (gparams)
{
for (auto & kv : get_module_param_descrs()) {
out << "[module] " << kv.m_key;
char const * descr = nullptr;
if (get_module_descrs().find(kv.m_key, descr)) {
out << ", description: " << descr;
}
out << "\n";
std::lock_guard<std::mutex> lock(gparams_mux);
for (auto & kv : get_module_param_descrs()) {
out << "[module] " << kv.m_key;
char const * descr = nullptr;
if (get_module_descrs().find(kv.m_key, descr)) {
out << ", description: " << descr;
}
out << "\n";
}
}
void display_module(std::ostream & out, symbol const & module_name) {
bool error = false;
std::string error_msg;
#pragma omp critical (gparams)
{
try {
param_descrs * d = nullptr;
if (!get_module_param_descrs().find(module_name, d)) {
std::stringstream strm;
strm << "unknown module '" << module_name << "'";
throw exception(strm.str());
}
out << "[module] " << module_name;
char const * descr = nullptr;
if (get_module_descrs().find(module_name, descr)) {
out << ", description: " << descr;
}
out << "\n";
d->display(out, 4, false);
std::lock_guard<std::mutex> lock(gparams_mux);
try {
param_descrs * d = nullptr;
if (!get_module_param_descrs().find(module_name, d)) {
std::stringstream strm;
strm << "unknown module '" << module_name << "'";
throw exception(strm.str());
}
catch (z3_exception & ex) {
// Exception cannot cross critical section boundaries.
error = true;
error_msg = ex.msg();
out << "[module] " << module_name;
char const * descr = nullptr;
if (get_module_descrs().find(module_name, descr)) {
out << ", description: " << descr;
}
out << "\n";
d->display(out, 4, false);
}
catch (z3_exception & ex) {
// Exception cannot cross critical section boundaries.
error = true;
error_msg = ex.msg();
}
if (error)
throw exception(std::move(error_msg));
@ -515,8 +512,8 @@ public:
void display_parameter(std::ostream & out, char const * name) {
bool error = false;
std::string error_msg;
#pragma omp critical (gparams)
{
std::lock_guard<std::mutex> lock(gparams_mux);
try {
symbol m, p;
normalize(name, m, p);