本文整理汇总了C++中eh函数的典型用法代码示例。如果您正苦于以下问题:C++ eh函数的具体用法?C++ eh怎么用?C++ eh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了eh函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv, const char** envp)
{
// Setup Google Breakpad exception handler
#ifdef Q_OS_LINUX
google_breakpad::ExceptionHandler eh("/tmp", NULL, Utils::exceptionHandler, NULL, true);
#endif
#ifdef Q_OS_MAC
google_breakpad::ExceptionHandler eh("/tmp", NULL, Utils::exceptionHandler, NULL, true, NULL);
#endif
QApplication app(argc, argv);
app.setWindowIcon(QIcon(":/phantomjs-icon.png"));
app.setApplicationName("PhantomJS");
app.setOrganizationName("Ofi Labs");
app.setOrganizationDomain("www.ofilabs.com");
app.setApplicationVersion(PHANTOMJS_VERSION_STRING);
// Prepare the "env" singleton using the environment variables
Env::instance()->parse(envp);
// Get the Phantom singleton
Phantom *phantom = Phantom::instance();
// Registering an alternative Message Handler
Utils::printDebugMessages = phantom->printDebugMessages();
qInstallMsgHandler(Utils::messageHandler);
signal(SIGALRM, timeout);
FILE *in;
in = fopen("timeout.txt", "r");
if (in) {
int t;
fscanf(in, "%d", &t);
alarm(t);
fclose(in);
}
// Start script execution
if (phantom->execute()) {
app.exec();
}
alarm(0);
// End script execution: delete the phantom singleton and set execution return value
int retVal = phantom->returnValue();
delete phantom;
return retVal;
}
示例2: RequireFeature
static cell_t RequireFeature(IPluginContext *pContext, const cell_t *params)
{
FeatureType type = (FeatureType)params[1];
char *name;
pContext->LocalToString(params[2], &name);
if (sharesys->TestFeature(pContext->GetRuntime(), type, name) != FeatureStatus_Available)
{
char buffer[255];
char *msg = buffer;
char default_message[255];
SMPlugin *pPlugin = scripts->FindPluginByContext(pContext->GetContext());
DetectExceptions eh(pContext);
g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 3);
if (eh.HasException())
buffer[0] = '\0';
if (buffer[0] == '\0') {
g_pSM->Format(default_message, sizeof(default_message), "Feature \"%s\" not available", name);
msg = default_message;
}
pPlugin->SetErrorState(Plugin_Error, "%s", msg);
if (!eh.HasException())
pContext->ReportFatalError("%s", msg);
return 0;
}
return 1;
}
示例3: Z3_algebraic_eval
int Z3_API Z3_algebraic_eval(Z3_context c, Z3_ast p, unsigned n, Z3_ast a[]) {
Z3_TRY;
LOG_Z3_algebraic_eval(c, p, n, a);
RESET_ERROR_CODE();
polynomial::manager & pm = mk_c(c)->pm();
polynomial_ref _p(pm);
polynomial::scoped_numeral d(pm.m());
expr2polynomial converter(mk_c(c)->m(), pm, 0, true);
if (!converter.to_polynomial(to_expr(p), _p, d) ||
static_cast<unsigned>(max_var(_p)) >= n) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
algebraic_numbers::manager & _am = am(c);
scoped_anum_vector as(_am);
if (!to_anum_vector(c, n, a, as)) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
{
cancel_eh<algebraic_numbers::manager> eh(_am);
api::context::set_interruptable si(*(mk_c(c)), eh);
scoped_timer timer(mk_c(c)->params().m_timeout, &eh);
vector_var2anum v2a(as);
int r = _am.eval_sign_at(_p, v2a);
if (r > 0) return 1;
else if (r < 0) return -1;
else return 0;
}
Z3_CATCH_RETURN(0);
}
示例4: SetFailState
static cell_t SetFailState(IPluginContext *pContext, const cell_t *params)
{
char *str;
SMPlugin *pPlugin;
pContext->LocalToString(params[1], &str);
pPlugin = scripts->FindPluginByContext(pContext->GetContext());
if (params[0] == 1)
{
pPlugin->SetErrorState(Plugin_Failed, "%s", str);
return pContext->ThrowNativeErrorEx(SP_ERROR_ABORTED, "%s", str);
}
else
{
char buffer[2048];
{
DetectExceptions eh(pContext);
g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 1);
if (eh.HasException()) {
pPlugin->SetErrorState(Plugin_Failed, "%s", str);
return 0;
}
pPlugin->SetErrorState(Plugin_Failed, "%s", buffer);
pContext->ReportFatalError("%s", buffer);
return 0;
}
}
return 0;
}
示例5: _solver_check
static Z3_lbool _solver_check(Z3_context c, Z3_solver s, unsigned num_assumptions, Z3_ast const assumptions[]) {
for (unsigned i = 0; i < num_assumptions; i++) {
if (!is_expr(to_ast(assumptions[i]))) {
SET_ERROR_CODE(Z3_INVALID_ARG, "assumption is not an expression");
return Z3_L_UNDEF;
}
}
expr * const * _assumptions = to_exprs(assumptions);
unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
unsigned rlimit = to_solver(s)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit());
bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false);
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
api::context::set_interruptable si(*(mk_c(c)), eh);
lbool result;
{
scoped_ctrl_c ctrlc(eh, false, use_ctrl_c);
scoped_timer timer(timeout, &eh);
scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit);
try {
result = to_solver_ref(s)->check_sat(num_assumptions, _assumptions);
}
catch (z3_exception & ex) {
to_solver_ref(s)->set_reason_unknown(eh);
if (!mk_c(c)->m().canceled()) {
mk_c(c)->handle_exception(ex);
}
return Z3_L_UNDEF;
}
}
if (result == l_undef) {
to_solver_ref(s)->set_reason_unknown(eh);
}
return static_cast<Z3_lbool>(result);
}
示例6: _settings
Server::Server(Settings& settings) :
_settings(settings),
_admMessageQueue(new Tools::SimpleMessageQueue(1))
{
Tools::debug << "Server::Server()\n";
this->_rcon = new Rcon::Rcon(*this);
this->_resourceManager = new Database::ResourceManager(*this);
this->_clientManager = new ClientManagement::ClientManager(*this, *this->_admMessageQueue);
this->_game = new Game::Game(*this, *this->_admMessageQueue);
Network::Network::NewConnectionHandler
nch(std::bind(&ClientManagement::ClientManager::HandleNewClient,
this->_clientManager,
std::placeholders::_1,
std::placeholders::_2));
Network::Network::PacketHandler
ph(std::bind(&ClientManagement::ClientManager::HandlePacket,
this->_clientManager,
std::placeholders::_1,
std::placeholders::_2));
Network::Network::ErrorHandler
eh(std::bind(&ClientManagement::ClientManager::HandleClientError,
this->_clientManager,
std::placeholders::_1));
this->_network = new Network::Network(*this, nch, ph, eh);
}
示例7: main
int main(int argc, char* argv[]) {
google_breakpad::MinidumpDescriptor descriptor(".");
google_breakpad::ExceptionHandler eh(descriptor, NULL, DumpCallback,
NULL, true, -1);
Crash();
return 0;
}
示例8: execute
virtual void execute(cmd_context & ctx) {
if (m_target == 0)
throw cmd_exception("invalid simplify command, argument expected");
expr_ref r(ctx.m());
proof_ref pr(ctx.m());
if (m_params.get_bool("som", false))
m_params.set_bool("flat", true);
th_rewriter s(ctx.m(), m_params);
unsigned cache_sz;
unsigned num_steps = 0;
unsigned timeout = m_params.get_uint("timeout", UINT_MAX);
unsigned rlimit = m_params.get_uint("rlimit", UINT_MAX);
bool failed = false;
cancel_eh<reslimit> eh(ctx.m().limit());
{
scoped_rlimit _rlimit(ctx.m().limit(), rlimit);
scoped_ctrl_c ctrlc(eh);
scoped_timer timer(timeout, &eh);
cmd_context::scoped_watch sw(ctx);
try {
s(m_target, r, pr);
}
catch (z3_error & ex) {
throw ex;
}
catch (z3_exception & ex) {
ctx.regular_stream() << "(error \"simplifier failed: " << ex.msg() << "\")" << std::endl;
failed = true;
r = m_target;
}
cache_sz = s.get_cache_size();
num_steps = s.get_num_steps();
s.cleanup();
}
if (m_params.get_bool("print", true)) {
ctx.display(ctx.regular_stream(), r);
ctx.regular_stream() << std::endl;
}
if (!failed && m_params.get_bool("print_proofs", false)) {
ast_smt_pp pp(ctx.m());
pp.set_logic(ctx.get_logic().str().c_str());
pp.display_expr_smt2(ctx.regular_stream(), pr.get());
ctx.regular_stream() << std::endl;
}
if (m_params.get_bool("print_statistics", false)) {
shared_occs s1(ctx.m());
if (!failed)
s1(r);
unsigned long long max_mem = memory::get_max_used_memory();
unsigned long long mem = memory::get_allocation_size();
ctx.regular_stream() << "(:time " << std::fixed << std::setprecision(2) << ctx.get_seconds() << " :num-steps " << num_steps
<< " :memory " << std::fixed << std::setprecision(2) << static_cast<double>(mem)/static_cast<double>(1024*1024)
<< " :max-memory " << std::fixed << std::setprecision(2) << static_cast<double>(max_mem)/static_cast<double>(1024*1024)
<< " :cache-size: " << cache_sz
<< " :num-nodes-before " << get_num_exprs(m_target);
if (!failed)
ctx.regular_stream() << " :num-shared " << s1.num_shared() << " :num-nodes " << get_num_exprs(r);
ctx.regular_stream() << ")" << std::endl;
}
}
示例9: Z3_algebraic_roots
Z3_ast_vector Z3_API Z3_algebraic_roots(Z3_context c, Z3_ast p, unsigned n, Z3_ast a[]) {
Z3_TRY;
LOG_Z3_algebraic_roots(c, p, n, a);
RESET_ERROR_CODE();
polynomial::manager & pm = mk_c(c)->pm();
polynomial_ref _p(pm);
polynomial::scoped_numeral d(pm.m());
expr2polynomial converter(mk_c(c)->m(), pm, 0, true);
if (!converter.to_polynomial(to_expr(p), _p, d) ||
static_cast<unsigned>(max_var(_p)) >= n + 1) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
algebraic_numbers::manager & _am = am(c);
scoped_anum_vector as(_am);
if (!to_anum_vector(c, n, a, as)) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
scoped_anum_vector roots(_am);
{
cancel_eh<algebraic_numbers::manager> eh(_am);
api::context::set_interruptable si(*(mk_c(c)), eh);
scoped_timer timer(mk_c(c)->params().m_timeout, &eh);
vector_var2anum v2a(as);
_am.isolate_roots(_p, v2a, roots);
}
Z3_ast_vector_ref* result = alloc(Z3_ast_vector_ref, mk_c(c)->m());
mk_c(c)->save_object(result);
for (unsigned i = 0; i < roots.size(); i++) {
result->m_ast_vector.push_back(au(c).mk_numeral(roots.get(i), false));
}
RETURN_Z3(of_ast_vector(result));
Z3_CATCH_RETURN(0);
}
示例10: Z3_check_and_get_model
Z3_lbool Z3_API Z3_check_and_get_model(Z3_context c, Z3_model * m) {
Z3_TRY;
LOG_Z3_check_and_get_model(c, m);
RESET_ERROR_CODE();
CHECK_SEARCHING(c);
cancel_eh<smt::kernel> eh(mk_c(c)->get_smt_kernel());
api::context::set_interruptable(*(mk_c(c)), eh);
flet<bool> _model(mk_c(c)->fparams().m_model, true);
lbool result;
try {
model_ref _m;
result = mk_c(c)->check(_m);
if (m) {
if (_m) {
Z3_model_ref * m_ref = alloc(Z3_model_ref);
m_ref->m_model = _m;
// Must bump reference counter for backward compatibility reasons.
// Don't need to invoke save_object, since the counter was bumped
m_ref->inc_ref();
*m = of_model(m_ref);
}
else {
*m = 0;
}
}
}
catch (z3_exception & ex) {
mk_c(c)->handle_exception(ex);
RETURN_Z3_check_and_get_model static_cast<Z3_lbool>(l_undef);
}
RETURN_Z3_check_and_get_model static_cast<Z3_lbool>(result);
Z3_CATCH_RETURN(Z3_L_UNDEF);
}
示例11: _tactic_apply
static Z3_apply_result _tactic_apply(Z3_context c, Z3_tactic t, Z3_goal g, params_ref p) {
goal_ref new_goal;
new_goal = alloc(goal, *to_goal_ref(g));
Z3_apply_result_ref * ref = alloc(Z3_apply_result_ref, mk_c(c)->m());
mk_c(c)->save_object(ref);
unsigned timeout = p.get_uint("timeout", UINT_MAX);
bool use_ctrl_c = p.get_bool("ctrl_c", false);
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
to_tactic_ref(t)->updt_params(p);
api::context::set_interruptable si(*(mk_c(c)), eh);
{
scoped_ctrl_c ctrlc(eh, false, use_ctrl_c);
scoped_timer timer(timeout, &eh);
try {
exec(*to_tactic_ref(t), new_goal, ref->m_subgoals, ref->m_mc, ref->m_pc, ref->m_core);
return of_apply_result(ref);
}
catch (z3_exception & ex) {
mk_c(c)->handle_exception(ex);
return 0;
}
}
}
示例12: kDebug
void KNewStuff2Test::entryTest()
{
kDebug() << "-- test kns2 entry class";
QDomDocument doc;
QFile f(QString("%1/testdata/entry.xml").arg(KNSSRCDIR));
if (!f.open(QIODevice::ReadOnly)) {
kDebug() << "Error loading entry file.";
quitTest();
}
if (!doc.setContent(&f)) {
kDebug() << "Error parsing entry file.";
f.close();
quitTest();
}
f.close();
KNS::EntryHandler eh(doc.documentElement());
KNS::Entry e = eh.entry();
kDebug() << "-- xml->entry test result: " << eh.isValid();
KNS::EntryHandler eh2(e);
QDomElement exml = eh2.entryXML();
kDebug() << "-- entry->xml test result: " << eh.isValid();
if (!eh.isValid()) {
quitTest();
} else {
QTextStream out(stdout);
out << exml;
}
}
示例13: PrintHintText
static cell_t PrintHintText(IPluginContext *pContext, const cell_t *params)
{
int client = params[1];
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
if (!pPlayer)
{
return pContext->ThrowNativeError("Client index %d is invalid", client);
}
if (!pPlayer->IsInGame())
{
return pContext->ThrowNativeError("Client %d is not in game", client);
}
g_SourceMod.SetGlobalTarget(client);
char buffer[254];
{
DetectExceptions eh(pContext);
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
if (eh.HasException())
return 0;
}
if (!g_HL2.HintTextMsg(client, buffer))
{
return pContext->ThrowNativeError("Could not send a usermessage");
}
return 1;
}
示例14: LogToFileEx
static cell_t LogToFileEx(IPluginContext *pContext, const cell_t *params)
{
char *file;
pContext->LocalToString(params[1], &file);
char path[PLATFORM_MAX_PATH];
g_pSM->BuildPath(Path_Game, path, sizeof(path), "%s", file);
FILE *fp = fopen(path, "at");
if (!fp)
{
return pContext->ThrowNativeError("Could not open file \"%s\"", path);
}
char buffer[2048];
{
DetectExceptions eh(pContext);
g_pSM->SetGlobalTarget(SOURCEMOD_SERVER_LANGUAGE);
g_pSM->FormatString(buffer, sizeof(buffer), pContext, params, 2);
if (eh.HasException()) {
fclose(fp);
return 0;
}
}
g_Logger.LogToOpenFile(fp, "%s", buffer);
fclose(fp);
return 1;
}
示例15: execute
virtual void execute(cmd_context& ctx) {
if (m_target == 0) {
throw cmd_exception("invalid query command, argument expected");
}
datalog::context& dlctx = m_dl_ctx->get_dl_context();
set_background(ctx);
dlctx.updt_params(m_params);
unsigned timeout = m_params.get_uint(":timeout", UINT_MAX);
cancel_eh<datalog::context> eh(dlctx);
lbool status = l_undef;
{
scoped_ctrl_c ctrlc(eh);
scoped_timer timer(timeout, &eh);
cmd_context::scoped_watch sw(ctx);
try {
status = dlctx.query(m_target);
}
catch (z3_error & ex) {
throw ex;
}
catch (z3_exception& ex) {
ctx.regular_stream() << "(error \"query failed: " << ex.msg() << "\")" << std::endl;
}
dlctx.cleanup();
}
switch (status) {
case l_false:
ctx.regular_stream() << "unsat\n";
print_certificate(ctx);
break;
case l_true:
ctx.regular_stream() << "sat\n";
print_answer(ctx);
print_certificate(ctx);
break;
case l_undef:
ctx.regular_stream() << "unknown\n";
switch(dlctx.get_status()) {
case datalog::INPUT_ERROR:
break;
case datalog::MEMOUT:
ctx.regular_stream() << "memory bounds exceeded\n";
break;
case datalog::TIMEOUT:
ctx.regular_stream() << "timeout\n";
break;
case datalog::OK:
break;
default:
UNREACHABLE();
}
break;
}
print_statistics(ctx);
m_target = 0;
}