~ubuntu-branches/ubuntu/raring/libavg/raring-proposed

« back to all changes in this revision

Viewing changes to .pc/conditionalise-x86-asm.patch/src/base/Exception.cpp

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-02-20 12:28:46 UTC
  • mfrom: (26.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20130220122846-lg5fmup89fsl4978
Tags: 1.7.1-3
Fix building against multiarched python.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
//  libavg - Media Playback Engine. 
 
3
//  Copyright (C) 2003-2011 Ulrich von Zadow
 
4
//
 
5
//  This library is free software; you can redistribute it and/or
 
6
//  modify it under the terms of the GNU Lesser General Public
 
7
//  License as published by the Free Software Foundation; either
 
8
//  version 2 of the License, or (at your option) any later version.
 
9
//
 
10
//  This library is distributed in the hope that it will be useful,
 
11
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
//  Lesser General Public License for more details.
 
14
//
 
15
//  You should have received a copy of the GNU Lesser General Public
 
16
//  License along with this library; if not, write to the Free Software
 
17
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
//
 
19
//  Current versions can be found at www.libavg.de
 
20
//
 
21
 
 
22
#include "Exception.h"
 
23
#include "Backtrace.h"
 
24
#include "Logger.h"
 
25
#include "OSHelper.h"
 
26
 
 
27
#include <cstdlib>
 
28
#include <sstream>
 
29
 
 
30
using namespace std;
 
31
 
 
32
namespace avg {
 
33
 
 
34
Exception::Exception(int code, const string& sErr)
 
35
    : m_Code (code),
 
36
      m_sErr (sErr)
 
37
{
 
38
}
 
39
 
 
40
Exception::Exception(const Exception& ex)
 
41
    : m_Code (ex.getCode()),
 
42
      m_sErr (ex.getStr())
 
43
{
 
44
}
 
45
 
 
46
Exception::~Exception()
 
47
{
 
48
}
 
49
 
 
50
int Exception::getCode() const
 
51
{
 
52
    return m_Code;
 
53
}
 
54
 
 
55
const string& Exception::getStr() const
 
56
{
 
57
    return m_sErr;
 
58
}
 
59
 
 
60
void fatalError(const string& sMsg)
 
61
{
 
62
    AVG_TRACE(Logger::ERROR, "Internal error: "+sMsg+" Aborting.");
 
63
    exit(-1);
 
64
}
 
65
 
 
66
void debugBreak()
 
67
{
 
68
#ifdef _WIN32
 
69
    __asm int 3;
 
70
#else
 
71
    asm("int $3");
 
72
#endif
 
73
}
 
74
 
 
75
void avgAssert(bool b, const char * pszFile, int line, const char * pszReason)
 
76
{
 
77
    if (!b) {
 
78
        string sDummy;
 
79
        static bool bBreak = getEnv("AVG_BREAK_ON_ASSERT", sDummy);
 
80
        if (bBreak) {
 
81
            debugBreak();
 
82
        } else {
 
83
            stringstream ss;
 
84
            ss << "Assertion failed in " << pszFile << ": " << line << endl;
 
85
            if (pszReason) {
 
86
                ss << "Reason: " << pszReason << endl;
 
87
            }
 
88
            dumpBacktrace();
 
89
            throw(Exception(AVG_ERR_ASSERT_FAILED, ss.str()));
 
90
        }
 
91
    }
 
92
}
 
93
 
 
94
}