/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ 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 .
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "IStringStream.H"
#include "OStringStream.H"
#include "OSspecific.H"
#include "IFstream.H"
#include "readHexLabel.H"
#include
#include
#include
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
string pOpen(const string &cmd, label line=0)
{
const int MAX = 1000;
FILE *cmdPipe = popen(cmd.c_str(), "r");
if (cmdPipe)
{
// Read line number of lines
for (label cnt = 0; cnt <= line; cnt++)
{
char buffer[MAX];
char* s = fgets(buffer, MAX-1, cmdPipe);
if (s == NULL)
{
return "";
}
if (cnt == line)
{
string str(buffer);
return str.substr(0, str.size()-1);
}
}
pclose(cmdPipe);
}
return "";
}
// use popen to call addr2line (using bfd.h directly would have
// meant relinking everything)
void printSourceFileAndLine
(
Ostream& os,
const HashTable