From: Philippe E. <ph...@us...> - 2002-03-16 21:14:31
|
Update of /cvsroot/oprofile/oprofile/oprof_report In directory usw-pr-cvs1:/tmp/cvs-serv8378/oprofile/oprof_report Modified Files: Makefile.in oprof_report.cpp oprof_report.h Added Files: hotspot_view.cpp hotspot_view.h Log Message: oprof_report : add HotspotView --- NEW FILE: hotspot_view.cpp --- /* COPYRIGHT (C) 2002 Philippe Elie * This program 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 2 of the License, or (at your option) * any later version. * * This program 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 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <stdio.h> #include <string> #include <qvariant.h> #include <qpainter.h> #include "../pp/opf_filter.h" #include "hotspot_view.h" /** * HotspotView - ctor * * create an HotspotView */ HotspotView::HotspotView(QWidget * parent) : QWidget(parent) { setBackgroundMode(QWidget::PaletteBase); setBackgroundColor(QColor(80, 255, 80)); } /** * paintEvent - handle painting event * * for now a simple and inneficient algorithm is used * all things are redrawn and we don't try to cache them */ /* TODO: axis painting, check why to paintEvent occur is some circumstances */ void HotspotView::paintEvent(QPaintEvent *) { if (symbols.size() == 0) return; size_t last_sample_idx = symbols.back()->last; if (last_sample_idx == 0) return; // for now I show only the vma range which get samples, not the // application vma range, this is discussable. bfd_vma start_vma = samples->get_samples(0).vma; bfd_vma end_vma = samples->get_samples(last_sample_idx - 1).vma; unsigned long vma_range = end_vma - start_vma; // Horizontal axis : how many vma address per pixel. double nr_vma_per_pel = double(vma_range) / width(); // vertical axis: how many sample nr per pixel. // this algorithm is very costly, use it for now because it is simple // more efficient will to iterate on samples rather to iterate on vma. u32 max_val = 0; std::vector<u32> samples_nr(width()); for (size_t i = 0 ; i < samples_nr.size() ; ++i) { bfd_vma start = bfd_vma((i * nr_vma_per_pel) + start_vma); bfd_vma end = bfd_vma(start + nr_vma_per_pel); if (end > end_vma) end = end_vma; if (end == start) end = start + 1; // humm if (end != start) { for ( ; start != end ; ++start) { // get all sample belonging to this vma const sample_entry * sample = samples->find_sample(start); if (sample) samples_nr[i] += sample->counter[0]; } } if (samples_nr[i] > max_val) max_val = samples_nr[i]; } double nr_sample_per_pel = double(height()) / max_val; QPainter paint; paint.begin(this); for (size_t i = 0 ; i < samples_nr.size() ; ++i) { paint.drawLine(i, height(), i, height() - (samples_nr[i] * nr_sample_per_pel)); } paint.end(); } /** * do_create() - handle data change */ void HotspotView::do_create(const samples_files_t * samples_) { samples = samples_; samples->select_symbols(symbols, 0, 0.0, false, true); } /** * do_destroy() - handle data change */ void HotspotView::do_destroy() { symbols.clear(); update(); } --- NEW FILE: hotspot_view.h --- /* COPYRIGHT (C) 2002 Philippe Elie * This program 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 2 of the License, or (at your option) * any later version. * * This program 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 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple * Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef HOTSPOT_VIEW_H #define HOTSPOT_VIEW_H #include <vector> #include <qwidget.h> #include "op_view.h" class QListView; class samples_files_t; class symbol_entry; class HotspotView : public QWidget, public OpView { public: HotspotView(QWidget * parent); /// reimplemented void paintEvent(QPaintEvent *); void do_create(const samples_files_t *); void do_destroy(); private: std::vector <const symbol_entry *> symbols; const samples_files_t * samples; }; #endif /* !HOTSPOT_VIEW_H */ Index: Makefile.in =================================================================== RCS file: /cvsroot/oprofile/oprofile/oprof_report/Makefile.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.in 9 Mar 2002 01:26:52 -0000 1.2 +++ Makefile.in 16 Mar 2002 21:14:27 -0000 1.3 @@ -33,9 +33,9 @@ # ui is modified all ui files are modified. OP_REPORT_UI_OBJS=ui/oprof_report.base.o ui/oprof_report.base.moc.o OP_REPORT_OBJS=oprof_report.o oprof_report.moc.o oprof_report_main.o \ - oprofpp_view.o ../events/op_events.o ../events/op_events_desc.o \ - ../dae/opd_util.o ../util/string_manip.o ../util/file_manip.o ../util/misc.o \ - ../pp/oprofpp_util.o ../pp/opf_container.o + oprofpp_view.o hotspot_view.o ../events/op_events.o \ + ../events/op_events_desc.o ../dae/opd_util.o ../util/string_manip.o \ + ../util/file_manip.o ../util/misc.o ../pp/oprofpp_util.o ../pp/opf_container.o # We do not put $(OP_REPORT_UI_OBJS) as dependency of oprof_report (make don't # know how to rebuild it at this point) but it works due to side effect between @@ -61,13 +61,15 @@ $(CXX) $(CXXFLAGS) -c $< -o $@ oprofpp_view.o: oprofpp_view.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ +hotspot_view.o: hotspot_view.cpp + $(CXX) $(CXXFLAGS) -c $< -o $@ # generate qt moc code for subclass oprof_report.moc.cpp: oprof_report.h ui/oprof_report.base.h $(MOC) -o oprof_report.moc.cpp oprof_report.h # dependencies -ALL_SOURCES = oprof_report_main.cpp oprof_report.cpp oprof_report.moc.cpp oprofpp_view.cpp +ALL_SOURCES = oprof_report_main.cpp oprof_report.cpp oprof_report.moc.cpp oprofpp_view.cpp hotspot_view.cpp include ../Rules.make Index: oprof_report.cpp =================================================================== RCS file: /cvsroot/oprofile/oprofile/oprof_report/oprof_report.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- oprof_report.cpp 9 Mar 2002 00:48:45 -0000 1.1 +++ oprof_report.cpp 16 Mar 2002 21:14:27 -0000 1.2 @@ -14,19 +14,19 @@ * Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <vector> #include <iostream> #include <qfiledialog.h> #include <qtabwidget.h> +#include <qlayout.h> #include "../pp/opf_filter.h" #include "../util/file_manip.h" #include "oprof_report.h" #include "oprofpp_view.h" +#include "hotspot_view.h" using std::string; -using std::vector; using std::cerr; /** @@ -36,9 +36,10 @@ : oprof_report_base(0, 0, false, 0), oprofpp_view(new OprofppView(oprofpp_view_widget)), - hotspot_view(0/*new HotspotView()*/), + hotspot_view(new HotspotView(hotspot_tab)), samples_files(0) { + hotspot_tabLayout->addWidget(hotspot_view, 0, 0, 0); } /** @@ -59,9 +60,13 @@ string temp_filename = strip_filename_suffix(filename); string app_name = extract_app_name(basename(temp_filename), lib_name); + /* TODO: on which counter we want to work must be user selectable. + * for now let's as it but do not worry me about zero samples + * details bug. */ + int counter = -1; + /* TODO: oprofpp_util.cpp, opf_container.cpp: handle all error * through exception */ - int counter = -1; try { opp_samples_files samples_file(temp_filename, counter); @@ -95,7 +100,8 @@ void oprof_report::destroy_all_view() { oprofpp_view->destroy(); - //hotspot_view->destroy(); + // destroy is ambiguous TODO: rename OpView::create, destroy + hotspot_view->OpView::destroy(); } /** @@ -105,7 +111,7 @@ * * Select a file or directory. The selection is returned; * an empty string if the selection was cancelled. - * TODO: share with oprof_start + * TODO: this must become a samples files folder */ static string const do_open_file_or_dir(string const & base_dir, bool dir_only) { @@ -157,7 +163,7 @@ if (new_tab->name() == QString("oprofpp_tab")) { oprofpp_view->create(samples_files); } else if (new_tab->name() == QString("hotspot_tab")) { - //hotspot_view->create(); + hotspot_view->OpView::create(samples_files); } } } Index: oprof_report.h =================================================================== RCS file: /cvsroot/oprofile/oprofile/oprof_report/oprof_report.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- oprof_report.h 9 Mar 2002 00:48:45 -0000 1.1 +++ oprof_report.h 16 Mar 2002 21:14:27 -0000 1.2 @@ -23,7 +23,7 @@ class samples_files_t; class OprofppView; -class OprofppHotspot; +class HotspotView; /** * oprofpp_report - the main class of the oprof_report application. @@ -62,7 +62,7 @@ OprofppView * oprofpp_view; /// the (feel to write it) hotspot view handling - OprofppHotspot* hotspot_view; + HotspotView * hotspot_view; samples_files_t * samples_files; }; |