From 5ddc5963ce06ecea574e90ca503a3ee598522d8f Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Fri, 4 Dec 2009 13:08:01 +0100 Subject: support multiline data output from scripts run under the grapher This is accompanied by support for multiline output in hover text. * grapher/StapParser.cxx (ioCallback): Read data 'til the end of line character, not just '\n'. Be careful to use I/O functions that don't treat '\n' specially. * grapher/StapParser.hxx: ditto * grapher/CairoWidget.cxx (CairoTextBox::draw): Perform line breaks for hover text. * testsuite/systemtap.examples/general/grapher.stp: Do multiline output of keyboard events. Also, fix longstanding breaking in the pty probe. --- grapher/StapParser.hxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'grapher/StapParser.hxx') diff --git a/grapher/StapParser.hxx b/grapher/StapParser.hxx index a77ad1bc..4f1cbd5a 100644 --- a/grapher/StapParser.hxx +++ b/grapher/StapParser.hxx @@ -14,10 +14,11 @@ class StapParser GraphWidget* _widget; int _errFd; int _inFd; + unsigned char _lineEndChar; public: StapParser(Gtk::Window* win, GraphWidget* widget) : _win(win), _widget(widget), _errFd(-1), - _inFd(-1) + _inFd(-1), _lineEndChar('\n') { } void parseData(std::tr1::shared_ptr gdata, -- cgit From f669d095ba7fe5a623b31abc05b4f6664059803b Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Mon, 7 Dec 2009 19:19:45 +0100 Subject: add copyright and license to grapher files --- grapher/StapParser.hxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'grapher/StapParser.hxx') diff --git a/grapher/StapParser.hxx b/grapher/StapParser.hxx index 4f1cbd5a..476b0071 100644 --- a/grapher/StapParser.hxx +++ b/grapher/StapParser.hxx @@ -1,3 +1,11 @@ +// systemtap grapher +// Copyright (C) 2009 Red Hat Inc. +// +// This file is part of systemtap, and is free software. You can +// redistribute it and/or modify it under the terms of the GNU General +// Public License (GPL); either version 2, or (at your option) any +// later version. + #include "GraphData.hxx" #include "GraphWidget.hxx" -- cgit From cfd482078cd4805076cc6fd7e4e8642b97a03b25 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 8 Dec 2009 12:44:03 +0100 Subject: refactor list of data sets out of GraphWidget into a global data structure. Also, add a sigc signal for broadcasting data set changes. * grapher/GraphData.hxx (GraphDataList) new typedef (getGraphData, graphDataSignal): new functions * grapher/Graph.hxx (DatasetList): remove typedef in favor of systemtap::GraphDataList * grapher/GraphWidget.cxx (GraphWidget, onGraphDataChanged): Use graphDataSignal to notice new data sets that need to be added. Use the global data set list instead of one embedded in GraphWidget. * grapher/StapParser.hxx: delete the _widget member; use signals to broadcast that there are new data sets instead of calling into the widget. --- grapher/StapParser.hxx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'grapher/StapParser.hxx') diff --git a/grapher/StapParser.hxx b/grapher/StapParser.hxx index 476b0071..eba8a7af 100644 --- a/grapher/StapParser.hxx +++ b/grapher/StapParser.hxx @@ -7,7 +7,6 @@ // later version. #include "GraphData.hxx" -#include "GraphWidget.hxx" #include namespace systemtap @@ -19,14 +18,12 @@ class StapParser DataMap _dataSets; CSVData _csv; Gtk::Window* _win; - GraphWidget* _widget; int _errFd; int _inFd; unsigned char _lineEndChar; public: - StapParser(Gtk::Window* win, - GraphWidget* widget) : _win(win), _widget(widget), _errFd(-1), - _inFd(-1), _lineEndChar('\n') + StapParser(Gtk::Window* win) + : _win(win), _errFd(-1), _inFd(-1), _lineEndChar('\n') { } void parseData(std::tr1::shared_ptr gdata, -- cgit From 8cabc8bcdcd22e8726734f1a18f23ed7d9c19e9f Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 8 Dec 2009 23:17:47 +0100 Subject: grapher: start of a dialog for displaying active stap processes The names of active scripts are displayed in a list; mock buttons suggest being able to stop and restart them. * grapher/processwindow.glade: new file * grapher/Makefile.am: add processwindow.glade to installed files * grapher/StapParser.hxx (StapProcess): new class (StapParser): factor out members that are now in StapProcess (ioCallback): Use the new childDied signal instead of aborting the whole grapher when a child dies. * grapher/grapher.cxx (ProcModelColumns, ProcWindow): classes for displaying stap process window. (GrapherWindow::on_menu_proc_window): new function --- grapher/StapParser.hxx | 77 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 54 insertions(+), 23 deletions(-) (limited to 'grapher/StapParser.hxx') diff --git a/grapher/StapParser.hxx b/grapher/StapParser.hxx index eba8a7af..cfb807a8 100644 --- a/grapher/StapParser.hxx +++ b/grapher/StapParser.hxx @@ -9,30 +9,61 @@ #include "GraphData.hxx" #include +#include + +#include + namespace systemtap { -class StapParser -{ - std::string _buffer; - typedef std::map > DataMap; - DataMap _dataSets; - CSVData _csv; - Gtk::Window* _win; - int _errFd; - int _inFd; - unsigned char _lineEndChar; -public: - StapParser(Gtk::Window* win) - : _win(win), _errFd(-1), _inFd(-1), _lineEndChar('\n') + // arguments and script for a stap process + struct StapProcess { - } - void parseData(std::tr1::shared_ptr gdata, - int64_t time, const std::string& dataString); - bool ioCallback(Glib::IOCondition ioCondition); - bool errIoCallback(Glib::IOCondition ioCondition); - int getErrFd() { return _errFd; } - void setErrFd(int fd) { _errFd = fd; } - int getInFd() { return _inFd; } - void setInFd(int fd) { _inFd = fd; } -}; + StapProcess(pid_t pid_ = -1) : pid(pid_) {} + std::string stapArgs; + std::string script; + std::string scriptArgs; + // arguments passed from a single array, like from the command line. + char **argv; + // -1 if the grapher is reading from stdin + pid_t pid; + }; + + class StapParser + { + std::string _buffer; + typedef std::map > DataMap; + DataMap _dataSets; + CSVData _csv; + int _errFd; + int _inFd; + unsigned char _lineEndChar; + std::tr1::shared_ptr _process; + public: + StapParser() + : _errFd(-1), _inFd(-1), _lineEndChar('\n') + { + } + void parseData(std::tr1::shared_ptr gdata, + int64_t time, const std::string& dataString); + bool ioCallback(Glib::IOCondition ioCondition); + bool errIoCallback(Glib::IOCondition ioCondition); + int getErrFd() const { return _errFd; } + void setErrFd(int fd) { _errFd = fd; } + int getInFd() const { return _inFd; } + void setInFd(int fd) { _inFd = fd; } + pid_t getPid() const + { + if (_process) + return _process->pid; + else + return -1; + } + std::tr1::shared_ptr getProcess() { return _process; } + void setProcess(std::tr1::shared_ptr process) + { + _process = process; + } + }; + + sigc::signal& childDiedSignal(); } -- cgit From 3e1613e1f7ab589089e8ed5a504330bb9cb128db Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Wed, 9 Dec 2009 22:09:39 +0100 Subject: show the status of stap processes in the process window Also, the "kill" button now works. * grapher/StapParser.hxx (_ioConnection, _errIoConnection): new members for sigc connections. (initIo): New function (parsers, parserListChangedSignal): new variables * grapher/StapParser.cxx (ioCallback): disconnect signals when child dies (initIo): new function * grapher/grapher.cxx (StapLauncher): eliminate death callback in favor of childDied signal. Use global parsers list (ProcWindow::_listSelection): new member (ProcWindow::show, hide, onParserListChanged, onSelectionChanged, onKill): new functions (ProcWindow::ProcWindow): Set up cell renderer for status icon * grapher/processwindow.glade: labels for display script and stap arguments --- grapher/StapParser.hxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'grapher/StapParser.hxx') diff --git a/grapher/StapParser.hxx b/grapher/StapParser.hxx index cfb807a8..4dd711e6 100644 --- a/grapher/StapParser.hxx +++ b/grapher/StapParser.hxx @@ -38,6 +38,8 @@ namespace systemtap int _inFd; unsigned char _lineEndChar; std::tr1::shared_ptr _process; + sigc::connection _ioConnection; + sigc::connection _errIoConnection; public: StapParser() : _errFd(-1), _inFd(-1), _lineEndChar('\n') @@ -63,7 +65,13 @@ namespace systemtap { _process = process; } + void initIo(int inFd, int errFd); }; sigc::signal& childDiedSignal(); + + typedef std::vector > ParserList; + extern ParserList parsers; + + sigc::signal& parserListChangedSignal(); } -- cgit From 1b9fad80af5504ef03c2a88504dbc47bea003721 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Thu, 10 Dec 2009 21:34:27 +0100 Subject: 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. --- grapher/StapParser.hxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'grapher/StapParser.hxx') 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 _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 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& childDiedSignal(); -- cgit From e47f92ea31a605802c59541ca325ffd567c45ca4 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Fri, 11 Dec 2009 14:03:47 +0100 Subject: grapher: implement restarting a stap process * grapher/StapParser.cxx (StapParser::disconnect): new function * grapher/StapParser.hxx (StapProcess::StapProcess): initialize argv to 0 * grapher/grapher.cxx (StapLauncher::setArgs): Set argv to 0 (StapLauncher launch, launchUsingParser): Refactor launch(), extracting function a that (re)launches a stap process using an existing parser. (StapLauncher::onChildDied): call disconnect() on dead parser. (GrapherWindow::_graphicalLauncher, setGraphicalLauncher): delete member, replacing with... (graphicalLauncher): new variable (ProcModelColumns): Store parser object in the list model instead of just a StapProcess object. (ProcWindow::onRestart): new function (ProcWindow::refresh): Preserve the list selection when the process list is refreshed. (ProcWindow::onSelectionChanged): Manage the restart button's state. --- grapher/StapParser.hxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'grapher/StapParser.hxx') diff --git a/grapher/StapParser.hxx b/grapher/StapParser.hxx index 24e84fc9..169533b6 100644 --- a/grapher/StapParser.hxx +++ b/grapher/StapParser.hxx @@ -18,7 +18,7 @@ namespace systemtap // arguments and script for a stap process struct StapProcess { - StapProcess(pid_t pid_ = -1) : pid(pid_) {} + StapProcess(pid_t pid_ = -1) : argv(0), pid(pid_) {} std::string stapArgs; std::string script; std::string scriptArgs; @@ -67,6 +67,7 @@ namespace systemtap _process = process; } void initIo(int inFd, int errFd, bool catchHUP); + void disconnect(); }; sigc::signal& childDiedSignal(); -- cgit