mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: printStack: offsets are size_t
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -28,7 +28,7 @@ License
|
||||
#include "OStringStream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "IFstream.H"
|
||||
#include "readHexLabel.H"
|
||||
#include "ReadHex.H"
|
||||
|
||||
#include <cxxabi.h>
|
||||
#include <execinfo.h>
|
||||
@ -100,8 +100,8 @@ void printSourceFileAndLine
|
||||
unsigned long offset = ulong(info.dli_fbase);
|
||||
|
||||
IStringStream addressStr(address.substr(2));
|
||||
label addressValue = readHexLabel(addressStr);
|
||||
label relativeAddress = addressValue-offset;
|
||||
long addressValue = ReadHex<long>(addressStr);
|
||||
long relativeAddress = addressValue-offset;
|
||||
|
||||
// Reconstruct hex word from address
|
||||
OStringStream nStream;
|
||||
@ -211,7 +211,7 @@ void error::printStack(Ostream& os)
|
||||
{
|
||||
string offsetString(line.substr(0, line.find('-')));
|
||||
IStringStream offsetStr(offsetString);
|
||||
addressMap.insert(libPath, readHexLabel(offsetStr));
|
||||
addressMap.insert(libPath, ReadHex<label>(offsetStr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
76
src/OpenFOAM/db/IOstreams/Sstreams/ReadHex.C
Normal file
76
src/OpenFOAM/db/IOstreams/Sstreams/ReadHex.C
Normal file
@ -0,0 +1,76 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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 Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Read a non-delimited hex label
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ReadHex.H"
|
||||
#include <cctype>
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
T Foam::ReadHex(ISstream& is)
|
||||
{
|
||||
// Takes into account that 'a' (or 'A') is 10
|
||||
static const int alphaOffset = toupper('A') - 10;
|
||||
// Takes into account that '0' is 0
|
||||
static const int zeroOffset = int('0');
|
||||
|
||||
char c = 0;
|
||||
|
||||
// Get next non-whitespace character
|
||||
while (is.get(c) && isspace(c))
|
||||
{}
|
||||
|
||||
register T result = 0;
|
||||
do
|
||||
{
|
||||
if (isspace(c) || c == 0) break;
|
||||
|
||||
if (!isxdigit(c))
|
||||
{
|
||||
FatalIOErrorIn("ReadHex(ISstream&)", is)
|
||||
<< "Illegal hex digit: '" << c << "'"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
result <<= 4;
|
||||
|
||||
if (isdigit(c))
|
||||
{
|
||||
result += int(c) - zeroOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += toupper(c) - alphaOffset;
|
||||
}
|
||||
} while (is.get(c));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
63
src/OpenFOAM/db/IOstreams/Sstreams/ReadHex.H
Normal file
63
src/OpenFOAM/db/IOstreams/Sstreams/ReadHex.H
Normal file
@ -0,0 +1,63 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM 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 Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
InNamespace
|
||||
Foam
|
||||
|
||||
Description
|
||||
Read a hex integer from an input stream
|
||||
|
||||
SourceFiles
|
||||
ReadHex.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ReadHex_H
|
||||
#define ReadHex_H
|
||||
|
||||
#include "ISstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
//- Read a hex label from an input stream
|
||||
template<class T>
|
||||
T ReadHex(ISstream&);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ReadHex.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -27,48 +27,13 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "readHexLabel.H"
|
||||
#include <cctype>
|
||||
#include "ReadHex.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::readHexLabel(ISstream& is)
|
||||
{
|
||||
// Takes into account that 'a' (or 'A') is 10
|
||||
static const label alphaOffset = toupper('A') - 10;
|
||||
// Takes into account that '0' is 0
|
||||
static const label zeroOffset = int('0');
|
||||
|
||||
char c = 0;
|
||||
|
||||
// Get next non-whitespace character
|
||||
while (is.get(c) && isspace(c))
|
||||
{}
|
||||
|
||||
register label result = 0;
|
||||
do
|
||||
{
|
||||
if (isspace(c) || c == 0) break;
|
||||
|
||||
if (!isxdigit(c))
|
||||
{
|
||||
FatalIOErrorIn("readHexLabel(ISstream&)", is)
|
||||
<< "Illegal hex digit: '" << c << "'"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
|
||||
result <<= 4;
|
||||
|
||||
if (isdigit(c))
|
||||
{
|
||||
result += int(c) - zeroOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += toupper(c) - alphaOffset;
|
||||
}
|
||||
} while (is.get(c));
|
||||
|
||||
return result;
|
||||
return ReadHex<label>(is);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user