From 6fb95a63ecfa32b1524790ee42695f19773f2174 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 20 Oct 2009 22:14:00 +0200 Subject: Change stap parser to use an input file descriptor other than stdin * grapher/StapParser.hxx (_inFd, getInFd, setInFd): new member and fuctions * grapher/StapParser.cxx (ioCallback): Use _inFd variable instead of stdin. * grapher/grapher.cxx (StapLauncher::launch): Don't read input from stap on stdin; use the the read end of the pipe. --- grapher/StapParser.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'grapher/StapParser.cxx') diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx index 9bb9b9c9..eea85006 100644 --- a/grapher/StapParser.cxx +++ b/grapher/StapParser.cxx @@ -70,7 +70,7 @@ vector commaSplit(const boost::sub_range& range) return true; char buf[256]; ssize_t bytes_read = 0; - bytes_read = read(STDIN_FILENO, buf, sizeof(buf) - 1); + bytes_read = read(_inFd, buf, sizeof(buf) - 1); if (bytes_read <= 0) { _win.hide(); -- cgit From 4bf8ba6e4fc0a950301e5debedababa834ea0d10 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 21 Oct 2009 17:05:59 +0200 Subject: More refactoring for multiple stap processes. * grapher/StapParser.hxx (StapParser): Change _win and _widget from references to pointers. * grapher/StapParser.cxx (ioCallback): Ditto. * grapher/grapher.cxx (StapLauncher, GraphicalStapLauncher): Rewrite to make GraphicalStapLauncher a derived class of StapLauncher. (main): Accept graphing data from stdin with a "-" argument. --- grapher/StapParser.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'grapher/StapParser.cxx') diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx index eea85006..249836d3 100644 --- a/grapher/StapParser.cxx +++ b/grapher/StapParser.cxx @@ -63,7 +63,7 @@ vector commaSplit(const boost::sub_range& range) using namespace boost; if (ioCondition & Glib::IO_HUP) { - _win.hide(); + _win->hide(); return true; } if ((ioCondition & Glib::IO_IN) == 0) @@ -73,7 +73,7 @@ vector commaSplit(const boost::sub_range& range) bytes_read = read(_inFd, buf, sizeof(buf) - 1); if (bytes_read <= 0) { - _win.hide(); + _win->hide(); return true; } buf[bytes_read] = '\0'; @@ -108,7 +108,7 @@ vector commaSplit(const boost::sub_range& range) dataSet->color[2] = (hexColor & 0xff) / 255.0; dataSet->scale = scale; _dataSets.insert(std::make_pair(setName, dataSet)); - _widget.addGraphData(dataSet); + _widget->addGraphData(dataSet); } else if (style == "discreet") { @@ -120,7 +120,7 @@ vector commaSplit(const boost::sub_range& range) dataSet->color[2] = (hexColor & 0xff) / 255.0; dataSet->scale = scale; _dataSets.insert(std::make_pair(setName, dataSet)); - _widget.addGraphData(dataSet); + _widget->addGraphData(dataSet); } } else if ((found = find_first(dataString, "%CSV:"))) @@ -219,7 +219,7 @@ vector commaSplit(const boost::sub_range& range) bytes_read = read(_errFd, buf, sizeof(buf) - 1); if (bytes_read <= 0) { - _win.hide(); + _win->hide(); return true; } if (write(STDOUT_FILENO, buf, bytes_read) < 0) -- cgit From 1fc4d13df3342b10003c27bc0bc8bd196ecd5622 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 28 Oct 2009 18:57:50 +0100 Subject: Fix regression of parsing grapher options * grapher/StapParser.hxx (ioCallback): Test return value from findTaggedValue properly. --- grapher/StapParser.cxx | 56 +++++++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'grapher/StapParser.cxx') diff --git a/grapher/StapParser.cxx b/grapher/StapParser.cxx index 249836d3..9e42dab6 100644 --- a/grapher/StapParser.cxx +++ b/grapher/StapParser.cxx @@ -156,18 +156,15 @@ vector commaSplit(const boost::sub_range& range) shared_ptr gdata = itr->second; string decl; // Hack: scan from the beginning of dataString again - if (findTaggedValue(dataString, "%Title:", decl) - != string::npos) + if (findTaggedValue(dataString, "%Title:", decl)) { gdata->title = decl; } - else if (findTaggedValue(dataString, "%XAxisTitle:", decl) - != string::npos) + else if (findTaggedValue(dataString, "%XAxisTitle:", decl)) { gdata->xAxisText = decl; } - else if (findTaggedValue(dataString, "%YAxisTitle:", decl) - != string::npos) + else if (findTaggedValue(dataString, "%YAxisTitle:", decl)) { gdata->yAxisText = decl; } @@ -179,29 +176,32 @@ vector commaSplit(const boost::sub_range& range) stream >> ymax; gdata->scale = ymax; } - - if (!_csv.elements.empty()) - { - vector tokens = commaSplit(dataString); - int i = 0; - double time; - vector::iterator tokIter = tokens.begin(); - std::istringstream timeStream(*tokIter++); - timeStream >> time; - for (vector::iterator e = tokens.end(); - tokIter != e; - ++tokIter, ++i) - { - parseData(_csv.elements[i].second, time, *tokIter); - } - } else - { - double time; - string data; - stream >> time >> data; - parseData(itr->second, time, data); - } + { + if (!_csv.elements.empty()) + { + vector tokens = commaSplit(dataString); + int i = 0; + double time; + vector::iterator tokIter = tokens.begin(); + std::istringstream timeStream(*tokIter++); + timeStream >> time; + for (vector::iterator e = tokens.end(); + tokIter != e; + ++tokIter, ++i) + { + parseData(_csv.elements[i].second, time, + *tokIter); + } + } + else + { + double time; + string data; + stream >> time >> data; + parseData(itr->second, time, data); + } + } } } _buffer.erase(0, ret + 1); -- cgit