summaryrefslogtreecommitdiffstats
path: root/grapher
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-12-10 21:34:27 +0100
committerTim Moore <timoore@redhat.com>2009-12-10 21:34:27 +0100
commit1b9fad80af5504ef03c2a88504dbc47bea003721 (patch)
tree316616e898f5c4b7375759ac857d3eca1b4beac5 /grapher
parentb35632fd3d2547414c80023c5c60c847e3dc92ea (diff)
downloadsystemtap-steved-1b9fad80af5504ef03c2a88504dbc47bea003721.tar.gz
systemtap-steved-1b9fad80af5504ef03c2a88504dbc47bea003721.tar.xz
systemtap-steved-1b9fad80af5504ef03c2a88504dbc47bea003721.zip
grapher: integrate graph events from stdin with the stap process framework.
This was the original way to do graphing and had bitrotted some. * grapher/StapParser.cxx (initIO): new catchHUP argument (ioCallback): Only disconnect signals, etc. on IN_HUP if catchHUP is true. (errIoCallback): Write error messages to stderr, not stdout. * grapher/grapher.cxx (StapLauncher::launch): Don't catchHUP on our stap process children. (ProcWindow::refresh): Display something reasonable for the stap "process" that is feeding stdin. (main): Use StapParser::initIO to initialize parser reading from stdin.
Diffstat (limited to 'grapher')
-rw-r--r--grapher/StapParser.cxx31
-rw-r--r--grapher/StapParser.hxx5
-rw-r--r--grapher/grapher.cxx17
3 files changed, 32 insertions, 21 deletions
diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx
index a9a5109a..2513680b 100644
--- a/grapher/StapParser.cxx
+++ b/grapher/StapParser.cxx
@@ -86,9 +86,12 @@ vector<string> commaSplit(const boost::sub_range<Glib::ustring>& range)
using namespace boost;
if (ioCondition & Glib::IO_HUP)
{
- childDiedSignal().emit(getPid());
- _ioConnection.disconnect();
- _errIoConnection.disconnect();
+ if (_catchHUP)
+ {
+ childDiedSignal().emit(getPid());
+ _ioConnection.disconnect();
+ _errIoConnection.disconnect();
+ }
return true;
}
if ((ioCondition & Glib::IO_IN) == 0)
@@ -261,22 +264,28 @@ vector<string> commaSplit(const boost::sub_range<Glib::ustring>& range)
cerr << "StapParser: error reading from stderr!\n";
return true;
}
- if (write(STDOUT_FILENO, buf, bytes_read) < 0)
+ if (write(STDERR_FILENO, buf, bytes_read) < 0)
;
return true;
}
- void StapParser::initIo(int inFd, int errFd)
+ void StapParser::initIo(int inFd, int errFd, bool catchHUP)
{
_inFd = inFd;
_errFd = errFd;
+ _catchHUP = catchHUP;
+ Glib::IOCondition inCond = Glib::IO_IN;
+ if (catchHUP)
+ inCond |= Glib::IO_HUP;
+ if (_errFd >= 0)
+ {
+ _errIoConnection = Glib::signal_io()
+ .connect(sigc::mem_fun(*this, &StapParser::errIoCallback),
+ _errFd, Glib::IO_IN);
+ }
_ioConnection = Glib::signal_io()
- .connect(sigc::mem_fun(*this, &StapParser::errIoCallback),
- _errFd,
- Glib::IO_IN);
- _errIoConnection = Glib::signal_io()
.connect(sigc::mem_fun(*this, &StapParser::ioCallback),
- _inFd,
- Glib::IO_IN | Glib::IO_HUP);
+ _inFd, inCond);
+
}
}
diff --git a/grapher/StapParser.hxx b/grapher/StapParser.hxx
index 4dd711e6..24e84fc9 100644
--- a/grapher/StapParser.hxx
+++ b/grapher/StapParser.hxx
@@ -37,12 +37,13 @@ namespace systemtap
int _errFd;
int _inFd;
unsigned char _lineEndChar;
+ bool _catchHUP;
std::tr1::shared_ptr<StapProcess> _process;
sigc::connection _ioConnection;
sigc::connection _errIoConnection;
public:
StapParser()
- : _errFd(-1), _inFd(-1), _lineEndChar('\n')
+ : _errFd(-1), _inFd(-1), _lineEndChar('\n'), _catchHUP(false)
{
}
void parseData(std::tr1::shared_ptr<GraphDataBase> gdata,
@@ -65,7 +66,7 @@ namespace systemtap
{
_process = process;
}
- void initIo(int inFd, int errFd);
+ void initIo(int inFd, int errFd, bool catchHUP);
};
sigc::signal<void, pid_t>& childDiedSignal();
diff --git a/grapher/grapher.cxx b/grapher/grapher.cxx
index e3d5289a..6dead221 100644
--- a/grapher/grapher.cxx
+++ b/grapher/grapher.cxx
@@ -293,7 +293,7 @@ int StapLauncher::launch()
sp->setProcess(proc);
parsers.push_back(sp);
parserListChangedSignal().emit();
- sp->initIo(pipefd[0], pipefd[2]);
+ sp->initIo(pipefd[0], pipefd[2], false);
return childPid;
}
@@ -422,14 +422,19 @@ void ProcWindow::refresh()
++spitr)
{
shared_ptr<StapProcess> sp = (*spitr)->getProcess();
+ Gtk::TreeModel::iterator litr = _listStore->append();
+ Gtk::TreeModel::Row row = *litr;
if (sp)
{
- Gtk::TreeModel::iterator litr = _listStore->append();
- Gtk::TreeModel::Row row = *litr;
row[_modelColumns._iconName] = sp->pid >= 0 ? "gtk-yes" : "gtk-no";
row[_modelColumns._scriptName] = sp->script;
row[_modelColumns._proc] = sp;
}
+ else
+ {
+ row[_modelColumns._iconName] = "gtk-yes";
+ row[_modelColumns._scriptName] = "standard input";
+ }
}
}
@@ -615,11 +620,7 @@ int main(int argc, char** argv)
if (argc == 2 && !std::strcmp(argv[1], "-"))
{
tr1::shared_ptr<StapParser> sp = launcher.makeStapParser();
- sp->setInFd(STDIN_FILENO);
- Glib::signal_io().connect(sigc::mem_fun(sp.get(),
- &StapParser::ioCallback),
- STDIN_FILENO,
- Glib::IO_IN | Glib::IO_HUP);
+ sp->initIo(STDIN_FILENO, -1, true);
}
else if (argc > 1)
{