diff options
author | Severin Gehwolf | 2011-02-11 18:37:54 +0000 |
---|---|---|
committer | Severin Gehwolf | 2011-02-11 18:37:54 +0000 |
commit | 1d22a9500219d8292d6315cd99400af3596035dd (patch) | |
tree | e609cf6450d85e430e4b9a2d079c4dc4408e6339 /oprofile | |
parent | 352ff45e5bed35b73832866ecce2441b12c2d180 (diff) | |
download | org.eclipse.linuxtools-1d22a9500219d8292d6315cd99400af3596035dd.tar.gz org.eclipse.linuxtools-1d22a9500219d8292d6315cd99400af3596035dd.tar.xz org.eclipse.linuxtools-1d22a9500219d8292d6315cd99400af3596035dd.zip |
2011-02-11 Severin Gehwolf <sgehwolf@redhat.com>
* natives/linux/opxml: Remove opxml.
Diffstat (limited to 'oprofile')
33 files changed, 36 insertions, 4431 deletions
diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/ChangeLog b/oprofile/org.eclipse.linuxtools.oprofile.core/ChangeLog index bb4658afb8..88084c8dab 100644 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/ChangeLog +++ b/oprofile/org.eclipse.linuxtools.oprofile.core/ChangeLog @@ -1,3 +1,39 @@ +2011-02-11 Severin Gehwolf <sgehwolf@redhat.com> + + * natives/linux/opxml: Remove opxml. + * natives/linux/opxml/.svnignore: Removed. + * natives/linux/opxml/imageheader.cc: Removed. + * natives/linux/opxml/imageheader.h: Removed. + * natives/linux/opxml/Makefile: Removed. + * natives/linux/opxml/move_opxml.sh: Removed. + * natives/linux/opxml/opinfo.cc: Removed. + * natives/linux/opxml/opinfo.h: Removed. + * natives/linux/opxml/oprofiledb.cc: Removed. + * natives/linux/opxml/oprofiledb.h: Removed. + * natives/linux/opxml/opxml.cc: Removed. + * natives/linux/opxml/oxmlstream.h: Removed. + * natives/linux/opxml/profileimage.cc: Removed. + * natives/linux/opxml/profileimage.h: Removed. + * natives/linux/opxml/README: Removed. + * natives/linux/opxml/sample.cc: Removed. + * natives/linux/opxml/sample.h: Removed. + * natives/linux/opxml/samplefile.cc: Removed. + * natives/linux/opxml/samplefile.h: Removed. + * natives/linux/opxml/session.cc: Removed. + * natives/linux/opxml/session.h: Removed. + * natives/linux/opxml/sevent.cc: Removed. + * natives/linux/opxml/sevent.h: Removed. + * natives/linux/opxml/stable.cc: Removed. + * natives/linux/opxml/stable.h: Removed. + * natives/linux/opxml/symbol.cc: Removed. + * natives/linux/opxml/symbol.h: Removed. + * natives/linux/opxml/xmlbuf.cc: Removed. + * natives/linux/opxml/xmlbuf.h: Removed. + * natives/linux/opxml/xmlfmt.cc: Removed. + * natives/linux/opxml/xmlfmt.h: Removed. + * natives/linux/opxml/xmltag.cc: Removed. + * natives/linux/opxml/xmltag.h: + 2011-02-10 Severin Gehwolf <sgehwolf@redhat.com> * META-INF/MANIFEST.MF: Add Eclipse-BundleShape: dir. diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/.svnignore b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/.svnignore deleted file mode 100644 index 5366501966..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/.svnignore +++ /dev/null @@ -1,15 +0,0 @@ -opxml.o -stable.o -oprofiledb.o -symbol.o -sample.o -session.o -samplefile.o -imageheader.o -opinfo.o -xmlfmt.o -xmlbuf.o -xmltag.o -sevent.o -profileimage.o -opxml diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/Makefile b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/Makefile deleted file mode 100644 index e532b37a61..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -# Makefile for Eclipse Oprofile wrapper library -# Written by Keith Seitz <keiths@redhat.com> -# Edited by Kent Sebastian <ksebasti@redhat.com> -# -# Copyright (c) 2004,2008 Red Hat, Inc. - -CFLAGS += -g -Wall -CXXFLAGS = $(CFLAGS) - -OPROFILE_LIBS = -lop -lodb -loputil++ -loputil -BFD_LIBRARY = -lbfd -LIBIBERTY = -liberty -OTHER_LIBS = $(BFD_LIBRARY) -EXTRA_LIBS = $(OPROFILE_LIBS) $(OTHER_LIBS) $(LIBIBERTY) - -OPXML = opxml -OPXML_OBJS = opxml.o -OPROFILE_LIB_OBJS = stable.o oprofiledb.o symbol.o sample.o \ - session.o samplefile.o imageheader.o opinfo.o \ - xmlfmt.o xmlbuf.o xmltag.o \ - sevent.o profileimage.o - -all: $(OPXML) - -$(OPXML): $(OPROFILE_LIB_OBJS) $(OPXML_OBJS) - $(CXX) -o $(OPXML) $(OPXML_OBJS) $(OPROFILE_LIB_OBJS) \ - $(EXTRA_LIBS) - -clean: - $(RM) $(OPROFILE_LIB_OBJS) $(OPXML) $(OPXML_OBJS) $(OPXML_EXEC) *~ - -install: - sh move_opxml.sh - -# Dependencies -opxml.o: oxmlstream.h opinfo.h session.h sample.h sevent.h opxml.cc - -imageheader.o: xmlfmt.h imageheader.h imageheader.cc -imageheader.h: samplefile.h - -opinfo.o: opinfo.h opinfo.cc -opinfo.h: - -oprofiledb.o: oprofiledb.h sample.h stable.h oprofiledb.cc -oprofiledb.h: xmlbuf.h xmlfmt.h - -oxmlstream.h: xmlbuf.h xmlfmt.h - -profileimage.o: xmlfmt.h profileimage.h profileimage.cc sample.h -profileimage.h: samplefile.h - -sample.o: xmlfmt.h sample.h sample.cc symbol.h symbol.cc -sample.h: - -samplefile.o: sample.h stable.h xmlfmt.h samplefile.h samplefile.cc -samplefile.h: oprofiledb.h - -session.o: sevent.h opinfo.h xmlfmt.h session.h session.cc -session.h: samplefile.h - -sevent.o: session.h xmlfmt.h sevent.h sevent.cc -sevent.h: profileimage.h - -stable.o: stable.h symbol.h stable.cc -stable.h: - -symbol.o: xmlfmt.h symbol.h symbol.cc -symbol.h: sample.h - -xmlbuf.o: xmltag.h xmlbuf.h xmlbuf.cc -xmlbuf.h: - -xmlfmt.o: xmlbuf.h xmlfmt.h xmlfmt.cc -xmlfmt.h: - -xmltag.o: xmltag.h xmltag.cc -xmltag.h: - diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/README b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/README deleted file mode 100644 index 6a027ed9f9..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/README +++ /dev/null @@ -1,8 +0,0 @@ -opxml requires 4 packages to be compiled: - -* oprofile -* oprofile-devel -* binutils-devel -* binutils-static - -These packages may vary in name and some may be combined across distributions. diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/imageheader.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/imageheader.cc deleted file mode 100644 index 6f7c62539a..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/imageheader.cc +++ /dev/null @@ -1,56 +0,0 @@ -/* imageheader - a class which represents the "header" information for a given - image. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "imageheader.h" -#include "xmlfmt.h" - -using namespace std; - -imageheader::imageheader (const samplefile* sfile) - : _sfile (sfile) -{ -} - -ostream& -operator<< (ostream& os, const imageheader* ihdr) -{ - return os << startt ("header") - << startt ("cpu_type") << ihdr->get_cpu () << endt - << startt ("count") << ihdr->get_count () << endt - << startt ("event") << ihdr->get_event () << endt - << startt ("unit-mask") << ihdr->get_unit_mask () << endt - << startt ("cpu-speed") << ihdr->get_cpu_speed () << endt - << endt; -} - diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/imageheader.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/imageheader.h deleted file mode 100644 index beaa80a6d9..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/imageheader.h +++ /dev/null @@ -1,69 +0,0 @@ -/* imageheader - a class which represents the "header" info for a given - image. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _IMAGEHEADER_H -#define _IMAGEHEADER_H -#include <ostream> -#include <string> - -#include "samplefile.h" - -class imageheader -{ - public: - // Constructor - pass in the oprofile header - imageheader (const samplefile* sfile); - - // Returns the cpu type - inline std::string get_cpu (void) const { return _sfile->get_cpu (); }; - - // Returns the event collected - inline std::string get_event (void) const { return _sfile->get_event (); }; - - // Returns the count - inline std::string get_count (void) const { return _sfile->get_count (); }; - - // Returns the unit mask used during collection - inline std::string get_unit_mask (void) const { return _sfile->get_unit_mask (); }; - - // Returns an approx cpu speed - // FIXME: SUCK? - inline double get_cpu_speed (void) const { return 0.00; }; - - private: - const samplefile* _sfile; -}; - -std::ostream& operator<< (std::ostream& os, const imageheader* ihdr); -#endif // !_SFILEHEADER_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/move_opxml.sh b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/move_opxml.sh deleted file mode 100644 index 5b526ea982..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/move_opxml.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -RELEASE_VER=0.3.0 - -case `uname -m` in - 'i386') \ - mv -f opxml ../../../../org.eclipse.linuxtools.oprofile.core.linux.x86_${RELEASE_VER}.*/os/linux/x86 - ;; - 'i586') - mv -f opxml ../../../../org.eclipse.linuxtools.oprofile.core.linux.x86_${RELEASE_VER}.*/os/linux/x86 - ;; - 'i686') - mv -f opxml ../../../../org.eclipse.linuxtools.oprofile.core.linux.x86_${RELEASE_VER}.*/os/linux/x86 - ;; - 'x86_64') - mv -f opxml ../../../../org.eclipse.linuxtools.oprofile.core.linux.x86_64_${RELEASE_VER}.*/os/linux/x86_64 - ;; - 'ppc') - mv -f opxml ../../../../org.eclipse.linuxtools.oprofile.core.linux.ppc_${RELEASE_VER}.*/os/linux/ppc - ;; - 'ppc64') - mv -f opxml ../../../../org.eclipse.linuxtools.oprofile.core.linux.ppc_${RELEASE_VER}.*/os/linux/ppc - ;; - *) - echo Could not detect system architecture -- please move the opxml binary into the appropriate org.eclipse.linuxtools.oprofile.core.linux.[x86,x86_64,ppc]/os/linux/[x86,x86_64,ppc] directory. - exit 1 - ;; - esac && echo Success!
\ No newline at end of file diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/opinfo.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/opinfo.cc deleted file mode 100644 index 6a6e8fe0df..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/opinfo.cc +++ /dev/null @@ -1,246 +0,0 @@ -/* Generic oprofile information class for opmxl. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2003, Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "opinfo.h" - -#include <sstream> -#include <string.h> - -#include "xmlfmt.h" - -using namespace std; - -// From liboputil.a. Sadly this won't work if we want to enable -// remote-system profiling. -extern "C" double op_cpu_frequency (void); - -// Forward declaration -static void __output_unit_mask_info (ostream& os, const opinfo::event_t* e); - -// Constructor -opinfo::opinfo (op_cpu cpu_type, string dir) - : _cpu_type (cpu_type), _dir (dir) -{ -} - -// Returns the number of counters for this cpu type -int -opinfo::get_nr_counters (void) const -{ - return op_get_nr_counters (_cpu_type); -} - -// Returns (in LIST) a list of valid events for the given counter -void -opinfo::get_events (eventlist_t& list, int ctr) const -{ - struct list_head* events, *p; - events = op_events (_cpu_type); - - list_for_each (p, events) - { - struct op_event* event = list_entry (p, struct op_event, event_next); - if (/*event->counter_mask == CTR_ALL || */ event->counter_mask & (1 << ctr)) - list.push_back (event); - } -} - -// Returns cpu frequency -double -opinfo::get_cpu_frequency (void) const -{ - return op_cpu_frequency (); -} - -// Checks whether the given CTR, EVENT, and MASK are valid -opinfo::eventcheck -opinfo::check (int ctr, int event, int mask) const -{ - eventcheck::result_t result = - static_cast<eventcheck::result_t> (op_check_events (ctr, event, mask, _cpu_type)); - return eventcheck (result); -} - -// Converts the given string into a corresponding op_cpu (CPU_NO_GOOD if invalid) -op_cpu -opinfo::str_to_op_cpu (const char* const cpu_str) -{ - int i; - for (i = 0; i < MAX_CPU_TYPE; ++i) - { - if (strcmp (op_get_cpu_type_str ((op_cpu) i), cpu_str) == 0) - return (op_cpu) i; - } - - return CPU_NO_GOOD; -} - -// This actually outputs a bunch of information -ostream& -operator<< (ostream& os, const opinfo& info) -{ - os << startt ("info"); - - // Output out number of counters and defaults - os << startt ("num-counters") << info.get_nr_counters () << endt - << startt ("cpu-frequency") << info.get_cpu_frequency () << endt - << startt ("defaults") - << startt ("sample-dir") << opinfo::get_default_samples_dir () << endt - << startt ("lock-file") << opinfo::get_default_lock_file () << endt - << startt ("log-file") << opinfo::get_default_log_file () << endt - << startt ("dump-status") << opinfo::get_default_dump_status () << endt - << endt; - - if (info.get_cpu_type() == CPU_TIMER_INT) - { - os << startt ("timer-mode") << "true" << endt; - - //create a fake timer event and output as normal - char UM_0_DESC[] = TIMER_EVENT_MASK_UM_0_DESCRIPTION; - char TIMER_NAME[] = TIMER_EVENT_NAME; - char TIMER_DESC[] = TIMER_EVENT_DESCRIPTION; - - struct op_unit_mask mask; - mask.unit_type_mask = utm_mandatory; - mask.default_mask = TIMER_EVENT_MASK_DEFAULT_VALUE; - mask.um[0].value = TIMER_EVENT_MASK_UM_0_VALUE; - mask.um[0].desc = UM_0_DESC; - mask.num = TIMER_EVENT_MASK_UM_NUM; - - opinfo::event_t timer_event; - timer_event.name = TIMER_NAME; - timer_event.desc = TIMER_DESC; - timer_event.val = TIMER_EVENT_NUMBER; - timer_event.min_count = TIMER_EVENT_MIN_COUNT; - timer_event.counter_mask = TIMER_EVENT_COUNTER_MASK; - timer_event.unit = &mask; - - os << startt ("event-list") << attrt ("counter", "0"); - - os << (&timer_event); - - os << endt; - } - else - { - os << startt ("timer-mode") << "false" << endt; - - // Output event list - for (int ctr = 0; ctr < info.get_nr_counters (); ++ctr) - { - opinfo::eventlist_t events; - - ostringstream ctr_s; - ctr_s << ctr; - os << startt ("event-list") << attrt ("counter", ctr_s.str ()); - info.get_events (events, ctr); - opinfo::eventlist_t::iterator i; - for (i = events.begin (); i != events.end (); ++i) - os << (*i); - os << endt; - } - } - - return os << endt; -} - -// Prints the given EVENT on the given stream -ostream& -operator<< (ostream& os, const opinfo::event_t* event) -{ - os << startt ("event") - << startt ("name") << event->name << endt - << startt ("description") << event->desc << endt - << startt ("value") << static_cast<int> (event->val) << endt - << startt ("minimum") << static_cast<int> (event->min_count) << endt; - - // ouput unit mask info - __output_unit_mask_info (os, event); - - return os << endt; -} - -// Prints the given eventcheck on the given stream -ostream& -operator<< (ostream& os, const opinfo::eventcheck& check) -{ - static const char* errors[3] = {"invalid-event", "invalid-um", "invalid-counter"}; - - os << startt ("check-events"); - - if (check.get_result () == OP_OK_EVENT) - os << startt ("result") << "ok" << endt; - else - { - for (unsigned int i = 0; i < sizeof (errors) / sizeof (errors[0]); ++i) - { - if ((check.get_result () & (1 << i)) > 0) - os << startt ("result") << errors[i] << endt; - } - } - - return os << endt; -} - -// Convenience function to output unit mask information -static void -__output_unit_mask_info (ostream& os, const opinfo::event_t* event) -{ - const struct op_unit_mask* umask = event->unit; - const char* type; - - switch (umask->unit_type_mask) - { - case utm_exclusive: - type = "exclusive"; break; - case utm_bitmask: - type = "bitmask"; break; - case utm_mandatory: - default: - type = "mandatory"; break; - } - - os << startt ("unit-mask") - << startt ("type") << type << endt - << startt ("default") << umask->default_mask << endt; - - for (u32 i = 0; i < umask->num; ++i) - { - os << startt ("mask") - << startt ("value") << umask->um[i].value << endt - << startt ("description") << umask->um[i].desc << endt - << endt; - } - - os << endt; -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/opinfo.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/opinfo.h deleted file mode 100644 index 706efed02a..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/opinfo.h +++ /dev/null @@ -1,139 +0,0 @@ -/* Generic oprofile information class for opmxl. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2003, Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _OPINFO_H -#define _OPINFO_H -#include <vector> -#include <ostream> - -#include <op_cpu_type.h> -#include <op_config.h> -#include <op_events.h> - -#define OP_SAMPLES_DIR "/var/lib/oprofile/samples/" -#define OP_LOCK_FILE "/var/lib/oprofile/lock" -#define OP_LOG_FILE "/var/lib/oprofile/samples/oprofiled.log" -#define OP_DUMP_STATUS "/var/lib/oprofile/complete_dump" -#define TIMER_EVENT_NAME "TIMER" -#define TIMER_EVENT_DESCRIPTION "Profiling through timer interrupt" -#define TIMER_EVENT_NUMBER 0 -#define TIMER_EVENT_MIN_COUNT 0 -#define TIMER_EVENT_COUNTER_MASK 0 -#define TIMER_EVENT_MASK_DEFAULT_VALUE 0 -#define TIMER_EVENT_MASK_UM_NUM 1 -#define TIMER_EVENT_MASK_UM_0_VALUE 0 -#define TIMER_EVENT_MASK_UM_0_DESCRIPTION "No unit mask" - -struct op_event; - -// A class which knows about static oprofile information, i.e., things -// which do not depend on sample files. -class opinfo -{ - public: - // The type of an oprofile event - typedef struct op_event event_t; - - // The type of a list of oprofile events - typedef std::vector<event_t*> eventlist_t; - - // A class used for reporting the validity of an event. - // Used by opinfo::check. - class eventcheck - { - public: - // The result type returned by get_result; - typedef enum op_event_check result_t; - - // Constructor - eventcheck (result_t ec) : _ec (ec) {}; - - // Returns the result of the check. Can be (bitmask): - // OP_OK_EVENT, OP_INVALID_EVENT, OP_INVALID_UM, OP_INVALID_COUNTER - inline result_t get_result (void) const { return _ec; }; - - private: - // The result from the check - result_t _ec; - }; - - // Get the default sample directory - inline static const char* get_default_samples_dir (void) { return OP_SAMPLES_DIR; }; - - // Get the default lock filename - inline static const char* get_default_lock_file (void) { return OP_LOCK_FILE; }; - - // Get the default log filename - inline static const char* get_default_log_file (void) { return OP_LOG_FILE; }; - - // Get the default dump status filename - inline static const char* get_default_dump_status (void) { return OP_DUMP_STATUS; }; - - // Converts the given string into an enum op_cpu - static op_cpu str_to_op_cpu (const char* const cpu_str); - - // Constructors - opinfo (op_cpu cpu_type = op_get_cpu_type (), std::string dir = get_default_samples_dir ()); - - // Returns the number of counters for this cpu type - int get_nr_counters (void) const; - - // Returns a list of valid events for the given counter on this cpu type - void get_events (eventlist_t& list, int ctr) const; - - // Returns the samples directory in use - inline const std::string& get_samples_directory (void) const { return _dir; }; - - // Returns the CPU frequency in MHz - double get_cpu_frequency (void) const; - - // Returns an eventcheck object representing whether the given - // CTR, EVENT, and MASK are valid for this cpu type - eventcheck check (int ctr, int event, int mask) const; - - // Returns the cpu type being used - op_cpu get_cpu_type (void) const { return _cpu_type; }; - - private: - // The cpu type - op_cpu _cpu_type; - - // The sample directory to use - std::string _dir; -}; - -// Insert operators for various classes defined in this file -std::ostream& operator<< (std::ostream& os, const opinfo::eventcheck& ec); -std::ostream& operator<< (std::ostream& os, const opinfo::event_t* event); -std::ostream& operator<< (std::ostream& os, const opinfo& info); -#endif // !_OPINFO_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/oprofiledb.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/oprofiledb.cc deleted file mode 100644 index 27e94be54b..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/oprofiledb.cc +++ /dev/null @@ -1,181 +0,0 @@ -/* oprofile_db - An Oprofile sample file database wrapper. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include <iostream> -#include <op_sample_file.h> -#include <string.h> - -#include "oprofiledb.h" -#include "stable.h" -#include "sample.h" - -oprofile_db::oprofile_db (std::string filename) - : _filename (filename), _tree (NULL), _symbol_table (NULL), _is_kernel (false) -{ -} - -oprofile_db::~oprofile_db () -{ - _close_db (); - samples_t::iterator i = _samples.begin (); - while (i != _samples.end ()) - { - delete SAMPLE (*i); - ++i; - } - _samples.clear (); -} - -void -oprofile_db::_open_db (void) -{ - if (_tree == NULL) - { - int rc; - - _tree = new odb_t; - rc = odb_open (_tree, _filename.c_str (), ODB_RDONLY, sizeof (opd_header)); - if (rc != 0) - { - // This shouldn't happen, but let's at least print something out. - std::cerr << "Error opening oprofile database: " << strerror (rc) - << std::endl; - return; - } - - // Get the is_kernel parameter: this is needed for sample gathering later - const opd_header* hdr = static_cast<opd_header*> (odb_get_data (_tree)); - _is_kernel = (hdr->is_kernel != 0); - } -} - -void -oprofile_db::_close_db (void) -{ - if (_tree != NULL) - { - odb_close (_tree); - delete _tree; - } - - _tree = NULL; -} - -static void -samples_odb_travel (odb_t* hash, int start, int end, oprofile_db::callback_t callback, void* data) -{ - odb_node_nr_t node_nr, pos; - odb_node_t* node = odb_get_iterator (hash, &node_nr); - for (pos = 0; pos < node_nr; ++pos) - { - if (node[pos].key) - callback (node[pos].key, node[pos].value, data); - } -} - -void -oprofile_db::walk_samples (callback_t callback, void* data) -{ - _open_db (); - samples_odb_travel (_tree, 0, ~0, callback, data); - _close_db (); -} - -const oprofile_db::samples_t& -oprofile_db::get_samples (symboltable* stable) -{ - _symbol_table = stable; - walk_samples (_get_samples_callback, this); - _symbol_table = NULL; - return _samples; -} - -bool -oprofile_db::has_samples (void) -{ - walk_samples (_has_samples_callback, this); - return _has_samples; -} - -long -oprofile_db::get_count (void) -{ - long count = 0; - walk_samples (_get_count_callback, &count); - return count; -} - -// This is a callback from oprofile when traveling the samples in the sample file. -void -oprofile_db::_get_samples_callback (odb_key_t key, odb_value_t info, void* data) -{ - oprofile_db* odb = static_cast<oprofile_db*> (data); - - symbol* symbol = NULL; - bfd_vma real_addr; - if (odb->_symbol_table != NULL) - symbol = odb->_symbol_table->lookup_vma ((bfd_vma) key, real_addr, odb->_is_kernel); - - // Oprofile can have multiple samples for the same VMA, so look in the - // our map/database and see if the given VMA exists. If it does not exist, - // add a new Sample. If it does exist, just increment the count of the Sample - // by INFO. - samples_t::iterator i = odb->_samples.find ((bfd_vma) key); - if (i == odb->_samples.end ()) - { - // new sample - sample* s = new sample (real_addr, symbol, info); - odb->_samples.insert (sample_t (key, s)); - } - else - { - // existing sample - SAMPLE (*i)->incr_count (info); - } -} - -void -oprofile_db::_has_samples_callback (odb_key_t key, odb_value_t info, void* data) -{ - oprofile_db* odb = static_cast<oprofile_db*> (data); - if (info > 0) - odb->has_samples (true); -} - -void -oprofile_db::_get_count_callback (odb_key_t key, odb_value_t info, void* data) -{ - long* count = static_cast<long*> (data); - *count += info; -} - diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/oprofiledb.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/oprofiledb.h deleted file mode 100644 index f858b8719e..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/oprofiledb.h +++ /dev/null @@ -1,113 +0,0 @@ -/* oprofile_db - An Oprofile sample file database wrapper. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _OPROFILEDB_H -#define _OPROFILEDB_H - -#include <map> -#include <string> -#include <bfd.h> -#include <odb.h> - -class sample; -class symboltable; - -// A class which represents an oprofile sample database. This is much -// lower-level stuff than class samplefile. -class oprofile_db -{ - public: - typedef void (*callback_t)(odb_key_t, odb_value_t, void*); - - // Creates an oprofile_db from the given sample file - oprofile_db (std::string sample_file); - ~oprofile_db (); - - // Function object used to compare VMA for sorting - struct ltvma - { - bool operator() (const bfd_vma a, const bfd_vma b) const - { return (a < b); } - }; - - // The type of the sample database returned be get_samples - typedef std::map<const bfd_vma, sample*, ltvma> samples_t; - - // The type of one sample in the database - typedef std::pair<const bfd_vma, sample*> sample_t; - - // Macro to fetch the sample from the sample_t. - static inline sample* SAMPLE (sample_t sample) { return sample.second; } - - // Retrieves the sample database using STABLE as a symbol table (may be NULL) - const samples_t& get_samples (symboltable* stable); - - // Set/query whether the db has any samples in it - bool has_samples (void); - void has_samples (bool yesno) { _has_samples = yesno; }; - - // Get the total number of samples in this samplefile - long get_count (void); - - // Walks the samples with the given callback - void walk_samples (callback_t callback, void* data); - - protected: - // Callbacks for walking oprofile sample database - static void _get_samples_callback (odb_key_t key, odb_value_t info, void* data); - static void _has_samples_callback (odb_key_t key, odb_value_t info, void* data); - static void _get_count_callback (odb_key_t key, odb_value_t info, void* data); - - // Makes sure the oprofile sample file is open - void _open_db (void); - - // Closes the oprofile sample file - void _close_db (void); - - // The sample file - std::string _filename; - - // The oprofile sample database for the file - odb_t* _tree; - - // A map of all the samples - samples_t _samples; - - // The symbol table used to resolve VMA into symbols - symboltable* _symbol_table; - - bool _has_samples; - callback_t _callback; - bool _is_kernel; -}; -#endif // !_OPROFILEDB_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/opxml.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/opxml.cc deleted file mode 100644 index fb4b846b87..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/opxml.cc +++ /dev/null @@ -1,516 +0,0 @@ -/* Opxml a simple program to output XML descriptions of oprofile sample - files (and a little more). This program exists as a bridge between - GPL'd software (oprofile and BFD) and EPL'd software (Eclipse). - Written by Keith Seitz <keiths@redhat.com> - Edited by Kent Sebastian <ksebasti@redhat.com> - - Copyright 2004, 2008, 2009 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include <stdlib.h> -#include <iostream> -#include <string.h> -#include <getopt.h> -#include <errno.h> -#include <iterator> -#include <vector> -#include <set> - -#include "opinfo.h" -#include "oxmlstream.h" -#include "session.h" -#include "sample.h" -#include "sevent.h" - -using namespace std; - -// Enum describing info options -enum options -{ - INFO, - CHECK_EVENT, - MODEL_DATA, - SESSIONS -}; - -// Strings of options -static const char* options[] = -{ - "info", - "check-events", - "model-data", - "sessions", - 0 -}; - -// Help for options -struct help -{ - const char* arg; - const char* desc; -}; - -static const struct help args_help[] = -{ - {"[CPU]\t\t\t", "information for given cpu (defualt: current cpu)" }, - {"CTR EVENT UMASK\t", "check counter/event validity"}, - {"EVENT SESSION\t", "get model data (image, symbols, samples..) for given SESSION and EVENT"}, - {"\t\t\t", "get session information"} -}; - -//hacky struct to ensure that the default session is -// always printed out first (and the rest alphabetical) -struct sevent_comp { - bool operator() (const sessionevent* lhs, const sessionevent* rhs) { return (lhs->get_session()->get_name() < rhs->get_session()->get_name()); } -}; - -typedef set<sessionevent*, struct sevent_comp > ordered_sessions_t; -struct session_list_t { - sessionevent* default_sevent; - ordered_sessions_t* sessions; -}; - - - -const string DEFAULT_SESSION_NAME = "current"; - -// Local functions -static void print_usage (const char* const argv0); -static int get_option_index (const char* options[], const char* arg); -static void wrong_num_arguments (int argc, char* argv[], const char* opts); -static int get_integer (const char* arg); - -// Info handlers -static int info (opinfo& info, int argc, char* argv[]); -static int check_events (opinfo& info, int argc, char* argv[]); -static int model_data (opinfo& info, int argc, char* argv[]); -static int sessions (opinfo& info, int argc, char* argv[]); - -//helper function -static bool object_in_list(const string obj, const vector<string>& objects); - - -static void -wrong_num_arguments (int argc, char* argv[], const char* opts) -{ - cerr << "wrong # args: should be \""; - for (int i = 0; i < argc; ++i) - cerr << argv[i] << " "; - - cerr << opts << "\"" << endl; - exit (EXIT_FAILURE); -} - -// Converts the argument into its corresponding option index -static int -get_option_index (const char* options[], const char* arg) -{ - const char* option; - - int i = 0; - for (option = options[0]; option != NULL; option = options[++i]) - { - if (strncmp (option, arg, strlen (arg)) == 0) - return i; - } - - return -1; -} - -// Prints a small help message -static void -print_help (const char* const argv0) -{ - cerr << "Use '" << argv0 << " --help' for a complete list of options." - << endl; -} - -// Prints the usage of this program -static void -print_usage (const char* const argv0) -{ - cerr << argv0 << ": usage: " << argv0 << " [OPTION] INFO [INFO_OPTIONS]" << endl; - cerr << "Supply information about Oprofile and its sample files." << endl << endl; - cerr << "Options:" << endl << endl; - cerr << "-c, --cpu CPU_TYPE\t\t cpu type (current: " - << op_get_cpu_type_str (op_get_cpu_type ()) << ")" << endl; - cerr << "-d, --dir SAMPLES_DIR\t\t set sample directory (default: " - << opinfo::get_default_samples_dir () << ")" << endl; - - cerr << endl << "Types of INFO:" << endl << endl; - - for (unsigned int i = 0; i < (sizeof (args_help) / sizeof (args_help[0])); ++i) - { - cerr << options[i] << " " << args_help[i].arg << " " - << args_help[i].desc << endl; - } -} - -int -main (int argc, char* argv[]) -{ - const char* argv0 = argv[0]; - - if (argc < 2) - { - print_help (argv0); - exit (EXIT_FAILURE); - } - - op_cpu cpu_type = op_get_cpu_type (); - string dir = opinfo::get_default_samples_dir (); - - static struct option long_options[] = - { - {"cpu-type", required_argument, 0, 'c'}, - {"dir", required_argument, 0, 'd'}, - {"help", no_argument, 0, 'h'}, - {0, 0, 0, 0} - }; - - int index; - while (true) - { - int c; - c = getopt_long_only (argc, argv, "+", long_options, &index); - if (c == -1) - break; - - if (c == 0 && long_options[index].flag == 0) - c = long_options[index].val; - - switch (c) - { - case 'c': - cpu_type = opinfo::str_to_op_cpu (optarg); - if (cpu_type == CPU_NO_GOOD) - { - cerr << argv0 << ": cpu \"" << optarg << "\" not recognized" - << endl; - exit (EXIT_FAILURE); - } - break; - - case 'd': - dir = optarg; - break; - - case 'h': - print_usage (argv0); - exit (EXIT_SUCCESS); - break; - - case '?': - print_help (argv0); - exit (EXIT_FAILURE); - } - } - - // Check that we have a valid cpu type. It can be invalid (here) because - // the Oprofile module not loaded/running. Oprofile library will output error. - if (cpu_type == CPU_NO_GOOD) - exit (EXIT_FAILURE); - - argc -= optind; - argv += optind; - - if (argc == 0) - { - print_help (argv0); - exit (EXIT_FAILURE); - } - - int rc; - opinfo oinfo (cpu_type, dir); - index = get_option_index (options, argv[0]); - { - switch ((enum options) index) - { - case INFO: - rc = info (oinfo, argc, argv); - break; - - case CHECK_EVENT: - rc = check_events (oinfo, argc, argv); - break; - - case MODEL_DATA: - rc = model_data(oinfo, argc, argv); - break; - - case SESSIONS: - rc = sessions (oinfo, argc, argv); - break; - - default: - cerr << argv0 << ": unknown option \"" << argv[0] << "\"" - << endl; - print_help (argv0); - rc = EXIT_FAILURE; - } - } - - return rc; -} - -/* Get an integer value from the argument. Only does ints > 0. - Returns the integer or -1. */ -static int -get_integer (const char* arg) -{ - errno = 0; - int integer = strtol (arg, NULL, 10); - if (errno != 0) - return -errno; - - return integer; -} - -/* Output static information about oprofile for this cpu type. */ -static int -info (opinfo& info, int argc, char* argv[]) -{ - oxmlstream oxml (cout); - oxml << info << endxml; - return EXIT_SUCCESS; -} - -/* Check whether the given counter/event/umask info is valid. - * - * Input: COUNTER EVENT UMASK (all integers) - * Note: output is a BITMASK of errors. Expect multiple "result" fields on error. - */ -static int -check_events (opinfo& info, int argc, char* argv[]) -{ - if (argc != 4) - wrong_num_arguments (1, argv, "counter event umask"); - - int counter = get_integer (argv[1]); - if (counter < 0) - { - cerr << "invalid counter \"" << argv[1] << "\"" << endl; - return EXIT_FAILURE; - } - - if (counter >= info.get_nr_counters ()) - { - cerr << "counter must not be greater than " - << (info.get_nr_counters () - 1) << endl; - return EXIT_FAILURE; - } - - int event = get_integer (argv[2]); - if (event < 0) - { - cerr << "invalid event \"" << argv[2] << "\"" << endl; - return EXIT_FAILURE; - } - - int umask = get_integer (argv[3]); - if (umask < 0) - { - cerr << "invalid unit mask \"" << argv[3] << "\"" << endl; - return EXIT_FAILURE; - } - - opinfo::eventcheck result = info.check (counter, event, umask); - - oxmlstream oxml (cout); - oxml << result << endxml; - return EXIT_SUCCESS; -} - -/* Print out the samples associated with the given session - * - * Input: - * event name - * session name (a default session is 'current') - */ -static int -model_data (opinfo& info, int argc, char* argv[]) -{ - //TODO: should this be xml so the parser can parse such an error? - if (argc < 3) - wrong_num_arguments (1, argv, "event session"); - - string event (argv[1]); - string session_name (argv[2]); - - vector<string> object_list; - if (argc >= 3) - { - //make a list of binary paths to filter out images - for (int j = 3; j < argc; j++) { - object_list.insert(object_list.begin(), argv[j]); - } - } - session session (session_name, &info); - - //passing the object list in here filters the images that - // are added to the sessionevent from an early stage - sessionevent* sevent = session.get_event (event); - - if (sevent == NULL) - { - oxmlstream oxml (cout); - oxml << startt ("error"); - - oxml << "no such session, event or matching images: " - << "session=" << session_name - << "; event=" << event - << endt << endxml; - - return EXIT_FAILURE; - } - - sessionevent::profileimages_t* images = sevent->get_images (); - - oxmlstream oxml (cout); - oxml << startt ("model-data"); - - sessionevent::profileimages_t::iterator i; - for (i = images->begin (); i != images->end (); ++i) - { - if (object_list.empty() || object_in_list((*i)->get_name(),object_list)) - oxml << (*i); - } - - oxml << endt << endxml; - - // delete sevent; -- don't do this: it takes too much time! - return EXIT_SUCCESS; -} - -static bool -object_in_list(const string obj, const vector<string>& objects) { - vector<string>::const_iterator it; - - for (it = objects.begin(); it != objects.end(); it++) { - if ((*it) == obj) { - return true; - } - } - - return false; -} - -//The special case handling for the default event is to enusure it is always -// the first event ouput. This is for usability of the UI on the java side -// so that the current session is always the first in the view. -static int -sessions (opinfo& info, int argc, char* argv[]) -{ - session::sessionlist_t sessions; - sessions = session::get_sessions (info); - - - /* This seems goofy, but this is best for the UI. - Arrange the sessions by the event that they collected. */ - - typedef map<string, struct session_list_t* > eventlist_t; - eventlist_t eventlist; - - session::sessionlist_t::iterator sit = sessions.begin (); - session::sessionlist_t::iterator const send = sessions.end (); - for (; sit != send; ++sit) - { - session* s = *sit; - session::seventlist_t events = s->get_events (); - - session::seventlist_t::iterator sit = events.begin (); - for (; sit != events.end (); ++sit) - { - sessionevent* sevent = *sit; - string event = sevent->get_name (); - - if (eventlist.find (event) == eventlist.end ()) - { - // New event -- new event, and new list of sessions - struct session_list_t* sl = (session_list_t*)malloc(sizeof(session_list_t*)); - sl->default_sevent = NULL; - sl->sessions = new ordered_sessions_t; - - //check if it's the default session - if (s->get_name() == DEFAULT_SESSION_NAME) { - sl->default_sevent = sevent; - } else { - sl->sessions->insert(sevent); - } - - eventlist.insert (pair<string, session_list_t*> (event, sl)); - } - else - { - // Known event -- add this session to the existing list for this event - - //check if it's the default session - if (s->get_name() == DEFAULT_SESSION_NAME) { - eventlist[event]->default_sevent = sevent; - } else { - eventlist[event]->sessions->insert(sevent); - } - } - } - } - - // Done compiling the list of events. Output information. - oxmlstream oxml (cout); - oxml << startt ("sessions"); - - if (!eventlist.empty ()) - { - eventlist_t::iterator elit; - for (elit = eventlist.begin (); elit != eventlist.end (); ++elit) - { - string event = elit->first; - - sessionevent* default_sevent = elit->second->default_sevent; - ordered_sessions_t* sessionlist = elit->second->sessions; - - oxml << startt ("event") << attrt ("name", event); - - if (default_sevent != NULL) - oxml << default_sevent; - - copy (sessionlist->begin (), sessionlist->end (), ostream_iterator<sessionevent*> (oxml, "")); - oxml << endt; - - if (default_sevent != NULL) - free(default_sevent); - delete sessionlist; - } - } - - oxml << endt << endxml; - - return EXIT_SUCCESS; -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/oxmlstream.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/oxmlstream.h deleted file mode 100644 index c9de2a64b6..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/oxmlstream.h +++ /dev/null @@ -1,48 +0,0 @@ -/* oxmlstream.h - A convenience class for outputting XML. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2003, Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _OXMLSTREAM_H -#define _OXMLSTREAM_H -#include <ostream> -#include "xmlbuf.h" -#include "xmlfmt.h" - -// An ostream which outputs in XML. See xmlfmt.h for XML operators. -class oxmlstream : public std::ostream -{ - public: - // Constructor - pass ostream onto which XML should be output. - oxmlstream (std::ostream& os) : std::ostream (new xmlbuf (os)) {} - ~oxmlstream () { delete rdbuf (); } -}; -#endif // ! _OXMLSTREAM_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/profileimage.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/profileimage.cc deleted file mode 100644 index b797a56ff5..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/profileimage.cc +++ /dev/null @@ -1,362 +0,0 @@ -/* profileimage - A class which represents a single image for - which oprofile has samples (or for which some child dependency - has samples). - Written by Keith Seitz <keiths@redhat.com> - Edited by Kent Sebastian <ksebasti@redhat.com> - Copyright 2004,2008 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "profileimage.h" - -#include <stdio.h> -#include <iostream> -#include <iterator> -#include <set> -#include <list> - -#include "sample.h" -#include "imageheader.h" -#include "xmlfmt.h" - -using namespace std; - -profileimage::profileimage (samplefile* sfile) - : _samplefile (sfile), _header (NULL) -{ - _dependencies = new list<profileimage*>; -} - -profileimage::~profileimage () -{ - delete _samplefile; - delete _dependencies; - if (_header != NULL) - delete _header; -} - -// returns parsed_filename.image if top-level image -// or parsed_filename.lib_image if dependency -string -profileimage::get_name (void) const -{ - if (!_samplefile->has_samplefile ()) - { - // We have no sample file for this object -- look for - // the image name in the first dependency - list<profileimage*>::iterator i = _dependencies->begin (); - if (i != _dependencies->end ()) - return (*i)->get_samplefile ()->get_image (); - else - { - // Can this happen? I don't think so, but... - cerr << "WARNING: empty profileimage at " << __FILE__ - << ":" << __LINE__ << endl; - return ""; - } - } - - return _samplefile->get_name (); -} - -long -profileimage::get_count (void) const -{ - return _samplefile->get_sample_count (); -} - -void -profileimage::add_dependency (profileimage* image) -{ - _dependencies->push_back (image); -} - -const imageheader* -profileimage::get_header (void) -{ - if (_header == NULL) - { - samplefile* sfile; - if (_samplefile->has_samplefile ()) - sfile =_samplefile; - else - { - // No samplefile -- use first dependency - list<profileimage*>::iterator i = _dependencies->begin (); - if (i != _dependencies->end ()) - sfile = (*i)->get_samplefile (); - else - { - // Can this happen? I don't think so, but... - cerr << "WARNING: empty profileimage at " << __FILE__ - << ":" << __LINE__ << endl; - return NULL; - } - } - - _header = new imageheader (sfile); - } - - return _header; -} - -/* - * This loops through the samples and symbols for the image - * and organizes them in a top down manner so that they can - * be output as below: - * - * - * IMAGE name="" - * SYMBOL1 name="" file="" - * SAMPLE1 --\ - * .. |-- this done by sample's operator<< - * SAMPLEN --/ - * .. - * SYMBOLN - * - * - * Note that this will only output info if there are symbols - * for the specified image. - * - */ -ostream& -operator<< (ostream& os, profileimage* image) -{ - samplefile* sfile; - - if (image->get_samplefile ()->has_samplefile ()) - { - sfile = image->get_samplefile(); - - //index the symbols by their bfd symbol - map<const asymbol*, symbol*> symbols; - - //a list of samples collapsed by file & line number - list<sample*> samples_aggregated; - - //get a list of samples from this image - samplefile::samples_t all_samples = sfile->get_samples(); - - //loop through samples, collapsing those with the same sample and line # - for (samplefile::samples_t::iterator i = all_samples.begin (); i != all_samples.end (); ++i) - { - const sample* smpl = samplefile::SAMPLE (*i); - - if (smpl->has_symbol()) - { - unsigned int line = 0; - const char* func = NULL; - const char* file = NULL; - sfile->get_debug_info (smpl->get_vma (), func, file, line); - - //these are deleted in add_sample or at the end of this method - sample* new_sample = new sample(smpl->get_vma(), smpl->get_symbol(), smpl->get_count(), line); - - add_sample(samples_aggregated, new_sample); - } - } - - //loop through the samples, find all unique symbols - //add the sample to the symbol's list of samples - for (list<sample*>::iterator i = samples_aggregated.begin (); i != samples_aggregated.end (); ++i) - { - if ((*i)->has_symbol()) - { - unsigned int line = 0; - const char* func = NULL; - const char* file = NULL; - sfile->get_debug_info ((*i)->get_vma (), func, file, line); - - //deleted when output later - symbol* new_symbol = new symbol((*i)->get_symbol()->get_asymbol(), (file == NULL ? "" : file) ); - - //duplicates aren't inserted because of the unique asymbol* - symbols.insert(pair<const asymbol*, symbol*>(new_symbol->get_asymbol(),new_symbol)); - - //this symbol must be in the map, either it was just added or it was already there - symbols[(*i)->get_symbol()->get_asymbol()]->add_sample((*i)); - - //add to total count of the symbol - symbols[(*i)->get_symbol()->get_asymbol()]->add_count((*i)->get_count()); - } - } - - char buf[11]; - long total_count = sfile->get_sample_count() + get_dependent_count(image->get_dependencies()); - sprintf(buf,"%ld", total_count); - - os << startt ("image") - << attrt ("name", get_name(image)) - << attrt ("count", buf); - - if (symbols.size() > 0) { - os << startt("symbols"); - - set<symbol*, symbol_comp>* sorted_symbols = sort_symbols(&symbols); - - //output the symbols, and free their memory - for (set<symbol*, symbol_comp>::iterator i = sorted_symbols->begin(); i != sorted_symbols->end(); ++i) - { - os << *i; - delete *i; - } - - os << endt; // </symbols> - sorted_symbols->clear(); - symbols.clear(); - } - - //free the memory from the allocated samples - for (list<sample*>::iterator i = samples_aggregated.begin(); i != samples_aggregated.end(); ++i) - { -// cerr << (*i)->get_demangled_name() << " " << (*i)->get_line() << " " << (*i)->get_count() << endl; - delete (*i); - } - samples_aggregated.clear(); - - - //output dependent images - list<profileimage*>* deps = image->get_dependencies (); - if (!deps->empty()) - { - char buf[21]; - sprintf(buf,"%ld", get_dependent_count(deps)); - - os << startt ("dependent") - << attrt ("count", buf); - - set<profileimage*, depimage_comp>* ordered_deps = sort_depimages(deps); - - copy (ordered_deps->begin (), ordered_deps->end (), ostream_iterator<profileimage*> (os, "")); - os << endt; - } - - os << endt; //</image> - } - - return os; -} - -//Adds the sample new_sample to the container samples. -// -//This method is required to collapse multiple samples that -// occur on the same line, since one line can correspond to -// more than one instructions and hence multiple samples -// occur for the same line of code. -void -add_sample(list<sample*> &samples, sample* new_sample) -{ - bool added = false; - - if (samples.size() == 0) - { - samples.push_back(new_sample); - } - else - { - for (list<sample*>::iterator i = samples.begin(); i != samples.end(); ++i) - { - //compare based on the symbols (bfd symbol ptr) and line number - if ((*i)->get_symbol()->get_asymbol() == new_sample->get_symbol()->get_asymbol() && - (*i)->get_line() == new_sample->get_line()) - { - //sample exists -- remove from vector, aggregate, reinsert - sample* s = new sample( (*i)->get_vma(), - (*i)->get_symbol(), - (*i)->get_count() + new_sample->get_count(), - (*i)->get_line()); - - delete (*i); - samples.erase(i); - samples.push_back(s); - added = true; - break; - } - } - - if (!added) - { - samples.push_back(new_sample); - } - } -} - -long -get_dependent_count(const list<profileimage*>* const deps) -{ - long dep_count = 0; - - //get total count for all the dependent images - for (list<profileimage*>::const_iterator i = deps->begin(); i != deps->end(); ++i) - { - dep_count += (*i)->get_samplefile()->get_sample_count(); - } - - return dep_count; -} - -//special case name for VDSO -string -get_name(const profileimage* p) -{ - string name = p->get_name(); - - if (name == "") - { - //FIXME: any better way to do this? - if ((p->get_samplefile()->get_sample_file_name()).find("{anon:[vdso]}",0) != string::npos) - { - name = VDSO_NAME_STRING; - } - } - - return name; -} - -set<profileimage*, depimage_comp>* -sort_depimages(const std::list<profileimage*>* const deps) { - set<profileimage*, depimage_comp>* sorted_deps = new set<profileimage*, depimage_comp>(); - for (list<profileimage*>::const_iterator i = deps->begin(); i != deps->end(); ++i) { - sorted_deps->insert((*i)); - } - - return sorted_deps; -} - -set<symbol*, symbol_comp>* -sort_symbols(const std::map<const asymbol*, symbol*>* const symbols) { - set<symbol*, symbol_comp>* sorted_syms = new set<symbol*, symbol_comp>(); - - for (map<const asymbol*, symbol*>::const_iterator i = symbols->begin(); i != symbols->end(); ++i) { - sorted_syms->insert(i->second); - } - - return sorted_syms; -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/profileimage.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/profileimage.h deleted file mode 100644 index 2064ac5325..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/profileimage.h +++ /dev/null @@ -1,127 +0,0 @@ -/* profileimage - A class which represents a single image for - which oprofile has samples (or for which some child dependency - has samples). - Written by Keith Seitz <keiths@redhat.com> - Edited by Kent Sebastian <ksebasti@redhat.com> - Copyright 2004,2008 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _PROFILEIMAGE_H -#define _PROFILEIMAGE_H - -#include <list> -#include <string> -#include <set> - -#include "samplefile.h" -#include "symbol.h" - -#define VDSO_NAME_STRING "[vdso]" - -class sample; -class imageheader; - -class profileimage -{ - public: - // Constructor - pass in the samplefile; CANNOT BE NULL. - profileimage (samplefile* sfile); - - // Destructor - ~profileimage (); - - // Returns the name of this image; it is the name of the actual binary - // in which samples were collected. - std::string get_name (void) const; - - // Returns the image header for this image - const imageheader* get_header (void); - - // Add the given profileimage as a dependency of this image - void add_dependency (profileimage* image); - - // Returns a list of all the dependencies of this image - std::list<profileimage*>* get_dependencies (void) const { return _dependencies; }; - - // Returns the Oprofile samplefile for this image - samplefile* get_samplefile (void) const { return _samplefile; }; - - // Returns the count of all the samples collected in this image, excluding dependencies - long get_count (void) const; - - private: - // The samplefile (non-NULL) - samplefile* _samplefile; - - // List of dependencies - std::list<profileimage*>* _dependencies; - - // Image header - imageheader* _header; -}; - -struct depimage_comp { - bool operator() (const profileimage* lhs, const profileimage* rhs) - { - if (lhs->get_count() == rhs->get_count()) - if (lhs->get_name() == rhs->get_name()) - return true; - else - return lhs->get_name() < rhs->get_name(); - else - return lhs->get_count() > rhs->get_count(); - } -}; - -struct symbol_comp { - bool operator() (const symbol* lhs, const symbol* rhs) - { - if (lhs->get_count() == rhs->get_count()) - { - std::string ln(lhs->name()), rn(rhs->name()); - if (ln == rn) - return true; - else - return ln < rn; - } - else - return lhs->get_count() > rhs->get_count(); - } -}; - - -std::ostream& operator<< (std::ostream& os, profileimage* image); -void add_sample(std::list<sample*> &samples, sample* new_sample); -long get_dependent_count(const std::list<profileimage*>* const deps); -std::set<profileimage*, depimage_comp>* sort_depimages(const std::list<profileimage*>* const deps); -std::set<symbol*, symbol_comp>* sort_symbols(const std::map<const asymbol*, symbol*>* const symbols); -std::string get_name(const profileimage* p); -#endif // !_PROFILEIMAGE_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sample.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sample.cc deleted file mode 100644 index 98fec82aa4..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sample.cc +++ /dev/null @@ -1,78 +0,0 @@ -/* sample - A class which represents an Oprofile sample - Written by Keith Seitz <keiths@redhat.com> - Edited by Kent Sebastian <ksebasti@redhat.com> - Copyright 2004,2008 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "sample.h" -#include "xmlfmt.h" -#include "symbol.h" - -using namespace std; - -// Constructor - pass in sample's address, any associated symbol, count, -sample::sample(bfd_vma addr, symbol* sym, unsigned int count) - : _addr (addr), _symbol (sym), _count (count) -{ -} - -sample::sample(bfd_vma addr, const symbol* sym, unsigned int count, unsigned int line) - : _addr (addr), _symbol (sym), _count (count), _line (line) -{ -} - -const char* -sample::get_name (void) const -{ - return (has_symbol () ? _symbol->name () : NULL); -} - -const char* -sample::get_demangled_name (void) const -{ - return (has_symbol () ? _symbol->demangled_name () : NULL); -} - -/* - * <sample> - * <count>4312</count> - * <line>41</line> - * </sample> - */ -ostream& -operator<< (ostream& os, const sample* s) -{ - os << startt ("sample") - << startt ("count") << s->get_count () << endt - << startt ("line") << s->get_line() << endt; - - return os << endt; -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sample.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sample.h deleted file mode 100644 index 2106cf034f..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sample.h +++ /dev/null @@ -1,99 +0,0 @@ -/* Sample - A class which represents an Oprofile sample - Written by Keith Seitz <keiths@redhat.com> - Edited by Kent Sebastian <ksebasti@redhat.com> - Copyright 2003,2008 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _SAMPLE_H -#define _SAMPLE_H -#include <stdlib.h> -#include <bfd.h> -#include <ostream> -#include <set> - - -class symbol; - - -class sample -{ - public: - sample (bfd_vma a, symbol* sym, unsigned int cnt); - sample (bfd_vma a, const symbol* sym, unsigned int cnt, unsigned int line); - - // Get the name of the symbol corresponding to this sample - // Returns NULL if no symbol. - const char* get_name (void) const; - - // Returns the demangled name for this sample - const char* get_demangled_name (void) const; - - // Returns the total sample count for this sample - inline unsigned int get_count(void) const { return _count; }; - - // Increments the total sample count for this sample - inline void incr_count (int n) { _count += n; }; - - // Does this sample have a symbol? - inline bool has_symbol (void) const { return _symbol != NULL; }; - - // Returns the symbol for this sample (could be NULL) - inline const symbol* get_symbol (void) const { return _symbol; }; - - // Gets the real vma for this sample - inline bfd_vma get_vma (void) const { return _addr; }; - - inline unsigned int get_line() const { return _line; }; - - private: - // (real) Address of sample - bfd_vma _addr; - - // Symbol for sample (according to minimal symbols) - const symbol* _symbol; - - // Number of times sample appears in output - unsigned int _count; - - //line number -- set in profileimage - unsigned int _line; - -}; - - -struct sample_comp { - bool operator() (const sample* lhs, const sample* rhs) { return (lhs->get_count() == rhs->get_count() ? lhs->get_line() < rhs->get_line() : lhs->get_count() > rhs->get_count() ); } -}; - - -// Operator to output samples -std::ostream& operator<< (std::ostream& os, const sample* s); -#endif // !_SAMPLE_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/samplefile.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/samplefile.cc deleted file mode 100644 index 2ab3de14fe..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/samplefile.cc +++ /dev/null @@ -1,269 +0,0 @@ -/* samplefile - A class which represents a samplefile. This class either - represents a real disk file or a "fake" one (needed in cases where - Oprofile only collected samples in a dependency, like a library). - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "samplefile.h" -#include "sample.h" -#include "stable.h" -#include "xmlfmt.h" - -#include <algorithm> - -using namespace std; - -// From libutil++ -extern bool create_file_list (list<string>& file_list, const string& base_dir, - const string& filter = "*", bool recursive = true); - -samplefile::samplefile (string filename) -{ - _st = NULL; - _db = new oprofile_db (filename); - _filename = filename; - _get_info_from_filename (); -} - -// This seems like a giant waste of time, but when it comes down to processing many -// hundreds of samplefiles, we really need to be able to do this quickly. -string -samplefile::event_for_filename (string filename) -{ - string event; - - string::size_type pos = filename.find_last_of ('/'); - if (pos != string::npos) - { - string basename = filename.substr (pos + 1, string::npos); - - // Tokenize the basename between the '.'. This seems like a contradiction - // to the speed mantra, but consider it a minimal sanity check. - vector<string> parts = _tokenize (basename, '.'); - if (parts.size () == 6) - event = parts[0]; - } - - return event; -} - -void -samplefile::_get_info_from_filename (void) -{ - // First the easy stuff: event specifications - // Filenames look like: EVENT.COUNT.UMASK.TGID.TID.CPU - string basename; - string dir_name; - string::size_type pos = _filename.find_last_of ('/'); - if (pos != string::npos) - { - dir_name = _filename.substr (0, pos); - basename = _filename.substr (pos + 1, string::npos); - - // Tokenize the basename between the '.' - vector<string> parts = _tokenize (basename, '.'); - if (parts.size () == 6) - { - // Right number of specifications! - int i = 0; - _event = parts[i++]; - _count = parts[i++]; - _unit_mask = parts[i++]; - _tgid = parts[i++]; - _tid = parts[i++]; - _cpu = parts[i++]; - } - else - return ; - - /* Now the hard part: the lib and image names */ - - // Like the event spec, the easiest way to do this is to tokenize the pathname - parts = _tokenize (dir_name, '/'); - - // Strip off everything up to either "{root}" or "{kern}" - vector<string>::size_type i = 0; - - /* Basically, we have - "/path/to/samples/<session>/{root} or {kern}" - + "/path/to/executable/{dep}" + "{root}" || "{kern}" - + "/path/to/library[/{cg}] - [+ "/path/to/callgraph"] */ - - // First "token" to look for is "{root}" or "{kern}" - for ( ; i < parts.size (); ++i) - { - if (parts[i] == "{root}" || parts[i] == "{kern}") - break; - } - - // Skip past "{root}" or "{kern}" - ++i; - - // Next "token" is "{dep}". Everything else is image name - for ( ; i < parts.size () && parts[i] != "{dep}"; ++i) - _image += "/" + parts[i]; - - // Skip past "{dep}" - ++i; - - // "{dep}" must be followed by "{kern}" or "{root}" - if (parts[i] != "{kern}" && parts[i] != "{root}") - { - // Error. Filename truncated. - return; - } - - // Skip past "{kern}" or "{root}" - ++i; - - // Next "token" will be "{cg}" or string::npos - for ( ; i < parts.size () && parts[i] != "{cg}"; ++i) - _lib_image += "/" + parts[i]; - - // Skip past "{cg}" (or end) - ++i; - - // Last bits will be callgraph - for ( ; i < parts.size (); ++i) - _callgraph += "/" + parts[i]; - } -} - -vector<string> -samplefile::_tokenize (const string& str, char delim) -{ - vector<string> tokens; - string::size_type start, end; - - start = end = 0; - while ((end = str.find (delim, start)) != string::npos) - { - if (start != end ) // ignore zero-length, i.e, str[0] == delim - tokens.push_back (str.substr (start, end - start)); - - // skip the delimiter character - start = end + 1; - } - - // add any trailing stuff - if (start != str.length ()) - tokens.push_back (str.substr (start, string::npos)); - - return tokens; -} - -samplefile::~samplefile (void) -{ - if (_db != NULL) - { - delete _db; - _db = NULL; - } - - if (_st != NULL) - { - delete _st; - _st = NULL; - } -} - -// DO NOT FREE THE RESULT. ~oprofile_db will do it. -const samplefile::samples_t -samplefile::get_samples (void) -{ - samplefile::samples_t samples; - - if (has_samplefile ()) - { - if (_st == NULL) - { - _st = new symboltable (get_name ().c_str ()); - _st->read_symbols (); - } - - samples = _db->get_samples (_st); - } - - return samples; -} - -bool -samplefile::get_debug_info (bfd_vma vma, const char*& func, const char*& file, unsigned int& line) -{ - return (_st == NULL ? false : _st->get_debug_info (vma, func, file, line)); -} - -void -samplefile::get_sample_file_list (list<string>& file_list, const string& base_dir) -{ - file_list.clear (); - - list<string> files; - if (create_file_list (files, base_dir)) - { - list<string>::iterator i; - for (i = files.begin (); i != files.end (); ++i) - { - // Only allow unique filenames into the final list. - // (This can happen because we can have multiple counters - // for any given sample file.) - if (find (file_list.begin (), file_list.end (), *i) - == file_list.end ()) - file_list.push_back (*i); - } - } -} - -// Output header & list of samples -/* - * <samplefile>/var/lib/oprofile/samples/current/blah/blah/blah</samplefile> - * SAMPLE (handled by class sample) - */ -ostream& -operator<< (ostream& os, samplefile* sf) -{ - // output the sfile's full pathname (used for fetching debug info) - os << startt ("samplefile") << sf->get_sample_file_name () << endt; - - // output list of samples - //TODO: grouped by symbol, then line number - samplefile::samples_t samples = sf->get_samples (); - samplefile::samples_t::iterator s; - for (s = samples.begin (); s != samples.end (); ++s) - { - const sample* smpl = samplefile::SAMPLE (*s); - os << smpl; - } - - return os; -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/samplefile.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/samplefile.h deleted file mode 100644 index 246fddc162..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/samplefile.h +++ /dev/null @@ -1,161 +0,0 @@ -/* samplefile - A class which represents a samplefile. This class either - represents a real disk file or a "fake" one (needed in cases where - Oprofile only collected samples in a dependency, like a library). - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _SAMPLEFILE_H -#define _SAMPLEFILE_H -#include <string> -#include <list> -#include <vector> - -#include "oprofiledb.h" - -class symboltable; - -class samplefile -{ - public: - // The type of a list of samples. STL container with iterators. - typedef oprofile_db::samples_t samples_t; - - // The type of a sample. Also an STL container. Use SAMPLE to get at - // actual sample. - typedef oprofile_db::sample_t sample_t; - - // The type of a list of samplefiles - typedef std::list<samplefile*> samplefilelist_t; - - // Convenience function to return the sample associated with - // a sample_t - static inline sample* SAMPLE (sample_t sample) - { return oprofile_db::SAMPLE (sample); }; - - // Constructor -- pass in the filename (may be "" when there - // were no samples collected for the profileimage, i.e., "fake"). - samplefile (std::string filename); - - // Destructor - ~samplefile (void); - - // Does this sample have a samplefile? This happens when Oprofile has - // collected samples for an image, but all those samples were collected - // in libraries and other dependencies. - bool has_samplefile (void) const - { return _filename != ""; }; - - // Is this samplefile a dependency? - bool is_dependency (void) const - { return (!has_samplefile () || (_image != _lib_image)); } - - // Get count of all samples in this file - long get_sample_count (void) - { return (has_samplefile () ? _db->get_count () : 0); }; - - // Returns the filename of this samplefile (or "" if it is "fake") - std::string get_sample_file_name (void) const - { return _filename; }; - - // Returns the image name - std::string get_image (void) const - { return _image; }; - - // Returns the library image name - std::string get_lib_image (void) const - {return _lib_image; }; - - // Returns the logical name of the image in this samplefile, i.e., - // the lib_image if this is a dependency or image_name if not - std::string get_name (void) const - { return (is_dependency () ? get_lib_image () : get_image ()); }; - - // Returns the event name that was collected in this samplefile - std::string get_event (void) const - { return _event; }; - - std::string get_count (void) const - { return _count; }; - - std::string get_unit_mask (void) const - { return _unit_mask; }; - - std::string get_tgid (void) const - { return _tgid; }; - - std::string get_tid (void) const - { return _tid; }; - - std::string get_cpu (void) const - { return _cpu; }; - - std::string get_callgraph (void) const - { return _callgraph; }; - - // Returns a list of all the samples in this samplefile. Do NOT free the result! - const samples_t get_samples (void); - - // Returns the debug info for the given VMA. - bool get_debug_info (bfd_vma vma, const char*& func, const char*& file, unsigned int& line); - - // Get list of files from base_dir - static void get_sample_file_list (std::list<std::string>& file_list, - const std::string& base_dir); - - // This may seem like a bad practice, but this is done for speed reasons - static std::string event_for_filename (std::string filename); - - private: - static std::vector<std::string> _tokenize (const std::string& str, char delim); - void _get_info_from_filename (void); - - // The oprofile_db associated with this samplefile - oprofile_db* _db; - - // The symbol table opened for the executable represented by this samplefile - symboltable* _st; - - // Information about the collection configuration - std::string _filename; // Disk filename of samplefile - std::string _image; // Name of the image recorded - std::string _lib_image; // Name of the library (== _image if not a sub-image) - std::string _event; - std::string _count; - std::string _unit_mask; - std::string _tgid; - std::string _tid; - std::string _cpu; - std::string _callgraph; -}; - -std::ostream& operator<< (std::ostream& os, samplefile* sf); -#endif // !_SAMPLEFILE_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/session.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/session.cc deleted file mode 100644 index e9390b8aa3..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/session.cc +++ /dev/null @@ -1,224 +0,0 @@ -/* session - a class which represents an oprofile session. - All sessions occur as directories of the samples directory. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2003, 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "session.h" -#include <iostream> -#include <string.h> - -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> -#include <dirent.h> - -#include "sevent.h" -#include "opinfo.h" -#include "xmlfmt.h" - -using namespace std; - -session::session(string name, const opinfo* info) - : _name (name), _info (info) -{ -} - -string -session::get_base_directory (void) const -{ - return _info->get_samples_directory () + _name; -} - -session::sessionlist_t -session::get_sessions (const opinfo& info) -{ - sessionlist_t sessions; - - struct stat sbuf; - int rc = stat (info.get_samples_directory ().c_str (), &sbuf); - if (rc < 0) - { - cerr << "cannot stat samples directory (" << info.get_samples_directory () << ")" - << endl; - return sessions; - } - else if (S_ISDIR (sbuf.st_mode) == 0) - { - cerr << "samples directory (" << info.get_samples_directory () - << ") is not a directory" << endl; - return sessions; - } - - DIR* dirp = opendir (info.get_samples_directory ().c_str ()); - if (dirp == NULL) - { - cerr << "cannot read samples directory (" << info.get_samples_directory () << ")" - << endl; - return sessions; - } - - struct dirent* dir; - while ((dir = readdir (dirp)) != NULL) - { - if (strcmp (dir->d_name, ".") != 0 && strcmp (dir->d_name, "..") != 0) - { - string name (dir->d_name); - sessions.push_back (new session (name, &info)); - } - } - - return sessions; -} - -// returns NULL if not found -sessionevent* -session::get_event (string event_name) -{ - list<string> filelist; - samplefile::get_sample_file_list (filelist, get_base_directory ()); - - // Loop through all sample files, create & populate sessionevents - // with sample file lists - sessionevent* the_sevent = NULL; - list<samplefile*> deps; - list<string>::iterator fit = filelist.begin (); - for (; fit != filelist.end (); ++fit) - { - if (samplefile::event_for_filename (*fit) == event_name) - { - samplefile* sfile = new samplefile (*fit); - - if (!sfile->is_dependency ()) - { - // main image - if (the_sevent == NULL) - { - // found the desired event -- create it - the_sevent = new sessionevent (this, event_name); - } - - // Add this sample file to the sessionevent - the_sevent->add_sample_file (sfile); - } - else - { - // dependency -- save it for later resolution - deps.push_back (sfile); - } - } - } - - // Now run through the list of dependencies - if (the_sevent != NULL) - { - list<samplefile*>::iterator sfit; - for (sfit = deps.begin (); sfit != deps.end (); ++sfit) - { - samplefile* sfile = *sfit; - the_sevent->add_sample_file (sfile); - } - } - - return the_sevent; -} - - - -session::seventlist_t -session::get_events () -{ - list<string> filelist; - samplefile::get_sample_file_list (filelist, get_base_directory ()); - - // Loop through all sample files, create & populate sessionevents - // with sample file lists - seventlist_t events; - map<string, sessionevent*> emap; - list<samplefile*> deps; - list<string>::iterator fit = filelist.begin (); - for (; fit != filelist.end (); ++fit) - { - if (samplefile::event_for_filename (*fit) != "") - { - samplefile* sfile = new samplefile (*fit); - if (!sfile->is_dependency ()) - { - // main image - map<string, sessionevent*>::iterator item; - item = emap.find (sfile->get_event ()); - if (item == emap.end ()) - { - // new event -- create sessionevent - sessionevent* se = new sessionevent (this, sfile->get_event ()); - - // Save this sessionevent in the event map - emap.insert (make_pair<string, sessionevent*> (sfile->get_event (), se)); - - // Add this sample file to the list - se->add_sample_file (sfile); - - // Finally, add this new sessionevent to result - events.push_back (se); - } - else - { - // Add this sample file to the sessionevent - sessionevent* se = (*item).second; - se->add_sample_file (sfile); - } - } - else - { - // dependency -- save it for later resolution - deps.push_back (sfile); - } - } - } - - // Now run through the list of dependencies - list<samplefile*>::iterator sfit; - for (sfit = deps.begin (); sfit != deps.end (); ++sfit) - { - samplefile* sfile = *sfit; - map<string, sessionevent*>::iterator item; - item = emap.find (sfile->get_event ()); - if (item != emap.end ()) - { - sessionevent* se = (*item).second; - se->add_sample_file (sfile); - } - else - cerr << "WARNING! dep file with no event!" << endl; - } - - return events; -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/session.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/session.h deleted file mode 100644 index c7edafebd1..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/session.h +++ /dev/null @@ -1,80 +0,0 @@ -/* session - a class which represents an oprofile session. - All sessions occur as directories of the samples directory. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2003, 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _SESSION_H -#define _SESSION_H -#include <string> -#include <list> - -#include "samplefile.h" - -class opinfo; -class sessionevent; - -class session -{ - public: - // Constructor - pass in the name of the session (or "" for the default) - // and cpu/config information - session (std::string name, const opinfo* info); - - // Returns a list of all sessions - typedef std::list<session*> sessionlist_t; - static sessionlist_t get_sessions (const opinfo& info); - - // Returns the name of this session - const std::string& get_name (void) const { return _name; }; - - // Returns a list of events collected in this session. - typedef std::list<sessionevent*> seventlist_t; - seventlist_t get_events (); - - // Searches for and returns the sessionevent which collected the - // given event_name. Returns NULL if not found. Return value must be - // freed by caller. - sessionevent* get_event (std::string event_name); - - // Returns the directory for this session, i.e., SAMPLES_DIR+session_name - std::string get_base_directory (void) const; - - private: - // The name of this session - std::string _name; - - // The cpu info - const opinfo* _info; -}; - - -#endif // !_SESSION_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sevent.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sevent.cc deleted file mode 100644 index 130813b838..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sevent.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* sevent (sessionevent) - a class which represents an event collected - within an oprofile session. There will be one sessionevent for every - event collected within a session. No two sessionevents with the same - session name may have the same event name. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "sevent.h" - -#include "session.h" -#include "xmlfmt.h" - -using namespace std; - -sessionevent::sessionevent (const session* session, string event) - : _session (session), _event_name (event) -{ - _files = new profileimages_t; -} - -sessionevent::~sessionevent () -{ - profileimages_t::iterator it; - for (it = _files->begin (); it != _files->end (); ++it) - delete (*it); - delete _files; -} - -void -sessionevent::add_sample_file (samplefile* sfile) -{ - if (!sfile->is_dependency ()) - { - // top-level image - _files->push_back (new profileimage (sfile)); - - } - else - { - // find file -- add dependent - bool found = false; - profileimages_t::iterator it; - for (it = _files->begin (); it != _files->end (); ++it) - { - if ((*it)->get_name () == sfile->get_image ()) - { - (*it)->add_dependency (new profileimage (sfile)); - found = true; - } - } - - if (!found) - { - // This does happen!! We got no samples in a profileimage, - // but we DID get samples in a dependency. Create a new - // "fake" profileimage and add this as a dependency. - profileimage* img = new profileimage (new samplefile ("")); - img->add_dependency (new profileimage (sfile)); - _files->push_back (img); - } - } -} - -long -sessionevent::get_count (void) const -{ - // Get list of images - profileimages_t::iterator it; - long count = 0; - for (it = _files->begin (); it != _files->end (); ++it) - { - // Get count of the main image - count += (*it)->get_count (); - - // Add count for dependencies - list<profileimage*>* deps = (*it)->get_dependencies (); - list<profileimage*>::iterator dit; - for (dit = deps->begin (); dit != deps->end (); ++dit) - count += (*dit)->get_count (); - } - - return count; -} - -/* - * <session name="foo"> - * <count>1234</count> - * </session> - * - */ -ostream& -operator<< (ostream& os, const sessionevent* se) -{ - return os << startt ("session") << attrt ("name", se->get_session ()->get_name ()) -// << startt ("count") << se->get_count () << endt - << endt; -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sevent.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sevent.h deleted file mode 100644 index bd92ed7d31..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/sevent.h +++ /dev/null @@ -1,84 +0,0 @@ -/* sevent (sessionevent) - a class which represents an event collected - within an oprofile session. There will be one sessionevent for every - event collected within a session. No two sessionevents with the same - session name may have the same event name. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _SEVENT_H -#define _SEVENT_H -#include <string> -#include <list> - -#include "profileimage.h" - -class samplefile; -class session; - -class sessionevent -{ - public: - // Constructor -- pass in session and event name - sessionevent (const session* session, std::string event); - - // Desctructor - ~sessionevent (); - - // Returns the event name - const std::string get_name (void) const { return _event_name; }; - - // Returns the session - const session* get_session (void) const { return _session; }; - - // Adds the samplefile to this sessionevent - void add_sample_file (samplefile* sfile); - - // Returns the count of all samples in this sessionevent - long get_count (void) const; - - // Returns a list of the images in the sessionevent - typedef std::list<profileimage*> profileimages_t; - profileimages_t* get_images (void) const { return _files; }; - - private: - // The session - const session* _session; - - // The name of the event - const std::string _event_name; - - // A list of images in this session - profileimages_t* _files; -}; - -std::ostream& operator<< (std::ostream& os, const sessionevent* se); -#endif // _SEVENT_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/stable.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/stable.cc deleted file mode 100644 index a868be1b72..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/stable.cc +++ /dev/null @@ -1,315 +0,0 @@ -/* symboltable - A symbol table class - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include <stdlib.h> -#include <string.h> -#include <iostream> -#include <fcntl.h> -#include <algorithm> - -#include "stable.h" -#include "symbol.h" - -static bool ltvma (const symbol* a, const symbol* b); - -// Stolen from oprofile -char const* symboltable::_boring_symbols[] = { - "gcc2_compiled.", - "_init" -}; - -// Helper function for sorting symbols by VMA -static bool -compare_symbol_with_vma (bfd_vma vma, const symbol* a) -{ - return (a->end () > vma); -} - -symboltable::symboltable(const char* file) - : _filename (strdup (file)), _abfd (NULL), _symbol_table (NULL), _cache_symbol (NULL) -{ -} - -symboltable::~symboltable () -{ - if (_symbol_table != NULL) - free (_symbol_table); - - std::vector<symbol*>::iterator i = _symbols.begin (); - while (i != _symbols.end ()) - { - delete (*i); - //_symbols.erase (i); - ++i; - } - - _symbols.clear (); - _close_bfd (); - free (_filename); -} - -// If this returns NULL, then the VMA is not in any range of -// msymbols. This is can apparently happen. op_time and friends -// ignore these samples. -symbol* -symboltable::lookup_vma (bfd_vma vma, bfd_vma& real_vma, bool is_kernel) -{ - if (is_kernel) - real_vma = vma; - else - real_vma = vma + _start_vma - _text_offset; - return (lookup_vma (real_vma)); -} - -symbol* -symboltable::lookup_vma (bfd_vma real_vma) -{ - if (_cache_symbol != NULL && _cache_symbol->contains (real_vma)) - return _cache_symbol; - - std::vector<symbol*>::iterator i; - i = upper_bound (_symbols.begin (), _symbols.end (), - real_vma, compare_symbol_with_vma); - if (i != _symbols.end () && (*i)->contains (real_vma)) - { - _cache_symbol = *i; - return *i; - } - - return NULL; -} - -bool -symboltable::read_symbols () -{ - if (_open_bfd ()) - { - long storage_needed = bfd_get_symtab_upper_bound (_abfd); - if (storage_needed > 0) - { - _symbol_table = (asymbol**) malloc (storage_needed); - long num_symbols = bfd_canonicalize_symtab (_abfd, _symbol_table); - for (int i = 0; i < num_symbols; ++i) - { - if (_interesting_symbol (_symbol_table[i])) - _symbols.push_back (new symbol (_symbol_table[i])); - } - - if (_symbols.size() > 0) - { - // Sort in order of increasing vma and eliminate duplicates - stable_sort (_symbols.begin (), _symbols.end (), ltvma); - - // Eliminate duplicates - for (size_t i = 0; i < _symbols.size () - 1; ++i) - { - if (_symbols[i]->start () == _symbols[i+1]->start ()) - { - int erase; - - // Opt to keep FUNCTIONs, first come, first kept - if (_symbols[i]->flags () & BSF_FUNCTION) - erase = i + 1; - else if (_symbols[i+1]->flags () & BSF_FUNCTION) - erase = i; - else // Don't know. Keep first. - erase = i + 1; - - delete *(_symbols.begin () + erase); - _symbols.erase (_symbols.begin () + erase); - --i; - } - } - - // Fill in end addresses - for (size_t i = 0; i <= _symbols.size () - 1; ++i) - { - asymbol* this_sym; - asymbol* next_sym = NULL; - asection* this_sect; - asection* next_sect; - - this_sym = _symbols[i]->get_asymbol (); - this_sect = bfd_get_section (this_sym); - if (i < _symbols.size () - 1) - { - next_sym = _symbols[i + 1]->get_asymbol (); - next_sect = bfd_get_section (next_sym); - } - else - next_sect = NULL; - - if (next_sect != NULL - && bfd_get_section (this_sym) == bfd_get_section (next_sym)) - _symbols[i]->end (_symbols[i + 1]->start ()); - else - { - asection* asect = bfd_get_section (this_sym); - bfd_vma end = bfd_get_section_vma (_abfd, asect); - end += bfd_section_size (_abfd, asect); - _symbols[i]->end (end); - } - } - - return true; - } - } - /* This may not seem correct, since we're pasing pointers of asymbols - and the like to other pieces of opxml (class symbol, in particular), - but remember that we've allocated memory for the symbol table earlier, - and class symbol references that. So as long as the object "class symboltable" - is not deleted, all symbols will be valid, and we can close the bfd. */ - _close_bfd (); - } - - return false; -} - -bool -symboltable::_interesting_symbol (asymbol* sym) -{ - if (!(bfd_get_section_flags (bfd_asymbol_bfd (sym), bfd_get_section (sym)) & SEC_CODE)) - return false; - - const char* name = bfd_asymbol_name (sym); - if (name == NULL || name[0] == '\0') - return false; - - // C++ exception stuff - if (name[0] == '.' && name[1] == 'L') - return false; - - for (size_t i = 0; i < sizeof (_boring_symbols) / sizeof (_boring_symbols[0]); i++) - { - if (strcmp (name, _boring_symbols[i]) == 0) - return false; - } - - return true; -} - -bool -symboltable::_open_bfd (void) -{ - if (_abfd == NULL) - { - bfd_init (); - int fd = open (_filename, O_RDONLY); // bfd_close will close fd - _abfd = bfd_fdopenr (_filename, NULL, fd); - if (_abfd != NULL) - { - char** matches; - if (bfd_check_format_matches (_abfd, bfd_object, &matches)) - { - asection const* sect; - - sect = bfd_get_section_by_name(_abfd, ".text"); - if (sect != NULL) { - _text_offset = sect->filepos; - } else { - return false; - } - -// //fail: this might not get the text section because -// // other sections may also have the SEC_CODE flag -// for (sect = _abfd->sections; sect != NULL; sect = sect->next) -// { -// if (sect->flags & SEC_CODE) -// { -// _text_offset = sect->filepos; -// break; -// } -// } - - } - - _start_vma = bfd_get_start_address (_abfd); - } - } - return (_abfd != NULL); -} - -void -symboltable::_close_bfd (void) -{ - if (_abfd != NULL) - bfd_close (_abfd); - - _abfd = NULL; -} - -bool -symboltable::get_debug_info (bfd_vma vma, const char*& function, - const char*& source_file, unsigned int& line) -{ - function = NULL; - source_file = NULL; - line = 0; - - symbol* symbol = lookup_vma (vma); - if (symbol != NULL) - { - asection* asection = symbol->section (); - - bfd_vma pc = vma - bfd_get_section_vma (_abfd, asection); - return bfd_find_nearest_line (_abfd, asection, _symbol_table, pc, - &source_file, &function, &line); - } - - - return false; -} - -#if 0 -void -symboltable::dump_table (void) -{ - printf ("%8s\t%8s\t%s\n", "start", "end", "name"); - - std::vector<symbol*>::iterator i; - for (i = _symbols.begin (); i != _symbols.end (); ++i) - { - symbol* sym = *i;; - printf("%8x\t%8x\t%s\n", (unsigned int)sym->start (), (unsigned int)sym->end (), - sym->name ()); - } -} -#endif - -// Helper function to sort two symbols based on VMA -static bool -ltvma (const symbol* a, const symbol* b) -{ - return (a->start () < b->start ()); -} - diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/stable.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/stable.h deleted file mode 100644 index 5f0bdbefc0..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/stable.h +++ /dev/null @@ -1,108 +0,0 @@ -/* symboltable - A symbol table class - Written by Keith Seitz <keiths@redhat.com> - Copyright 2004 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _STABLE_H -#define _STABLE_H -#include <bfd.h> -#include <vector> - -class symbol; - -class symboltable -{ - public: - symboltable (const char* file); - ~symboltable (void); - - // Lookup a Symbol for the given sample vma. Returns the symbol found (or NULL) - // and gives the real address of the sample. Sadly, kernel images are treated - // differently from userspace images. - symbol* lookup_vma (bfd_vma sample_vma, bfd_vma &real_address, bool is_kernel); - symbol* lookup_vma (bfd_vma real_vma); - - // Read in the samples - bool read_symbols (void); - - inline asymbol** get_bfd_symbol_table (void) const { return _symbol_table; }; - - /* Gets the debug info for a given address: - function name in debug info - source filename - line number - - Returns true if debug info found. False otherwise. - NOTE: could return true but still have source_file and line be - invalid!*/ - bool get_debug_info (bfd_vma vma, const char*& function, - const char*& source_file, unsigned int& line); - -#if 0 - // Debugging. Dump the symbol table - void dump_table (void); -#endif - - protected: - // Opens the BFD associated with the executable - bool _open_bfd (void); - - // Closes the BFD - void _close_bfd (void); - - // Helper function: is the given asymbol "interesting"? (i.e., should - // it go into the symbol table?) - static bool _interesting_symbol (asymbol* sym); - - // A list of known uninteresting symbols - static char const* _boring_symbols[]; - - // All of the executable's symbols - std::vector<symbol*> _symbols; - - // The executable's filename - char* _filename; - - // The BFD associated with this executable - bfd* _abfd; - - // The BFD symbol table - asymbol** _symbol_table; - - // The physical load address of this executable (NOT THE BFD SECTION - // START ADDRESS) - bfd_vma _start_vma; - bfd_vma _text_offset; - - // A performance cache - symbol* _cache_symbol; -}; -#endif // !_STABLE_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/symbol.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/symbol.cc deleted file mode 100644 index 034923aac9..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/symbol.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* symbol - A class which represents symbols in executables - Written by Keith Seitz <keiths@redhat.com> - Edited by Kent Sebastian <ksebasti@redhat.com> - Copyright 2003,2008 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include <stdlib.h> -#include <stdio.h> - -#include "symbol.h" -#include "xmlfmt.h" - -// From libiberty -#ifndef DMGL_PARAMS -#define DMGL_PARAMS (1 << 0) // Include function arguments -#endif - -#ifndef DMGL_ANSI -#define DMGL_ANSI (1 << 1) // Include const, volatile, etc -#endif - -using namespace std; - -extern "C" char* cplus_demangle (char const* mangled_name, int options); - -const bfd_vma symbol::UNSET = (bfd_vma) -1; - - -symbol::symbol (asymbol* sym) - : _end (UNSET), _asymbol (sym) -{ - _count = 0; -} - -symbol::symbol (asymbol* sym, string src_filename) - : _end (UNSET), _asymbol (sym), _src_filename(src_filename) -{ - _count = 0; -} - -bool -symbol::contains (bfd_vma addr) const -{ - if (addr >= start() && addr < _end) - return true; - return false; -} - -const char* -symbol::demangled_name (void) const -{ - char* demangled = cplus_demangle (name (), DMGL_PARAMS | DMGL_ANSI); - if (demangled == NULL) - return name (); - - return demangled; -} - -ostream& -operator<< (ostream& os, const symbol* s) -{ - //convert symbol's total count to a string for attrt - char buf[11]; - sprintf(buf,"%u",s->get_count()); - - //output this symbol's info - os << startt ("symbol") - << attrt ("name", s->demangled_name ()) - << attrt ("file", s->get_srcfilename()) - << attrt ("count", buf); - - //ouput all samples under this symbol - const std::set<sample*, sample_comp>* samples = s->get_sample_list(); - for (std::set<sample*, sample_comp>::iterator i = samples->begin(); i != samples->end(); ++i) - os << (*i); - - return os << endt; -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/symbol.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/symbol.h deleted file mode 100644 index 044aa02f3e..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/symbol.h +++ /dev/null @@ -1,118 +0,0 @@ -/* symbol - A class which represents symbols in executables - Written by Keith Seitz <keiths@redhat.com> - Edited by Kent Sebastian <ksebasti@redhat.com> - Copyright 2003,2008 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _SYMBOL_H -#define _SYMBOL_H - -#include <ostream> -#include <bfd.h> -#include <set> - -#include "sample.h" - -class symbol -{ - public: - symbol (asymbol* sym); - symbol (asymbol* sym, std::string src_filename); - - // Get the start address of this symbol - inline bfd_vma start (void) const { return bfd_asymbol_value (_asymbol); }; - - // Get the end address of this symbol - inline bfd_vma end (void) const { return _end; }; - - // Set the end address of this symbol - inline void end (bfd_vma addr) { _end = addr; }; - - // Get BFD's symbol info - inline asymbol* get_asymbol (void) const { return _asymbol; }; - - // Get BFD's section info - inline asection* section (void) const { return bfd_get_section (_asymbol); }; - - // Get the name of this symbol - inline const char* name (void) const { return bfd_asymbol_name (_asymbol); }; - - // Get the demangled name of this symbol (could be the same as name()) - const char* demangled_name (void) const; - - // Get the BFD flags for this symbol (i.e., BSF_FUNCTION, BSF_GLOBAL) - inline flagword flags (void) const { return _asymbol->flags; }; - - // Does this symbol contain the address ADDR? - bool contains (bfd_vma addr) const; - - // return filename this symbol is in (used in operator<<) - inline const char * get_srcfilename() const { return _src_filename.c_str(); }; - - // Constant that all unset address are set to - static const bfd_vma UNSET; - - //add the sample s to the list of samples under this symbol - inline void add_sample(sample* s) { _samples.insert(_samples.begin(), s); }; - - // return the samples (used in operator<< when outputting all the samples) - inline const std::set<sample*, sample_comp>* get_sample_list() const { return &_samples; }; - - // add the count of a sample to the total count (called after a sample is added with add_sample()) - inline void add_count(unsigned int c) { _count += c; }; - - // return total count of all samples under this symbol - inline const unsigned int get_count() const { return _count; }; - - protected: - // The end address of this symbol (can only be set once all symbols read) - bfd_vma _end; - - // The BFD symbol - asymbol* _asymbol; - - //filename the symbols is in (set later, from sample debuginfo) - std::string _src_filename; - - //list of samples under this symbol, sorted by count - // the samples a freed in profileimage.cc - //NOTE: because of the sample aggregation in profileimage.cc - // and since the comparer uses both count and line # to compare, - // all samples are guaranteed to be unique and ordered properly - std::set<sample*, sample_comp> _samples; - - //count for all samples below this symbol - unsigned int _count; -}; - -// ostream inserter for this class -std::ostream& operator<< (std::ostream& os, const symbol* s); -#endif // !_SYMBOL_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlbuf.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlbuf.cc deleted file mode 100644 index bb489848c3..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlbuf.cc +++ /dev/null @@ -1,122 +0,0 @@ -/* xmlbuf - A class for XML output on an ostream. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2003, Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include <stdio.h> - -#include "xmlbuf.h" -#include "xmltag.h" - -#define XML_ENCODING "UTF-8" -#define XML_VERSION "1.0" - -using namespace std; - -xmlbuf::xmlbuf (ostream& outstream) - : _os (outstream) -{ - _top = xmltag::dtd_header (XML_VERSION, XML_ENCODING); - _current = _top; - _tag_stack = new stack<xmltag*> (); -} - -xmlbuf::~xmlbuf () -{ - // delete tree - delete _top; - - // delete tag stack and any items left on it - while (!_tag_stack->empty ()) - { - xmltag* t = _tag_stack->top (); - _tag_stack->pop (); - delete t; - } - - delete _tag_stack; -} - -// Only tags get text -- escape reserved characters -int -xmlbuf::overflow (int ch) -{ - switch (ch) - { - case EOF: - /* nothing */ break; - case '&': - _current->add_text ("&"); break; - case '<': - _current->add_text ("<"); break; - case '>': - _current->add_text (">"); break; - case '\'': - _current->add_text ("'"); break; - case '\"': - _current->add_text ("""); break; - default: - _current->add_char (ch); break; - } - - return ch; -} - -void -xmlbuf::add_tag (const string& tag_name) -{ - xmltag* tag = _current->add_child (tag_name); - _tag_stack->push (_current); - _current = tag; -} - -void -xmlbuf::end_tag (void) -{ - _current = _tag_stack->top (); - _tag_stack->pop (); -} - -void -xmlbuf::add_attr (const string& name, const string& value) -{ - _current->add_attr (name, value); -} - -void -xmlbuf::dump (void) -{ - // dump output to stream - _top->output (_os); - - // reset top of tree - _top->delete_children (); -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlbuf.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlbuf.h deleted file mode 100644 index 7a6a891e23..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlbuf.h +++ /dev/null @@ -1,83 +0,0 @@ -/* xmlbuf - A class for XML output on an ostream. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2003, Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _XMLBUF_H -#define _XMLBUF_H -#include <streambuf> -#include <ostream> -#include <string> -#include <stack> - -class xmltag; - -class xmlbuf : public std::streambuf -{ - public: - // Constructor - pass in the ostream to which to dump the whole - // XML tree. - xmlbuf (std::ostream& outstream); - ~xmlbuf (); - - // Adds an XML tag of the given name - // Invoked via "addt" operator (defined in xmlfmt.h) - void add_tag (const std::string& tag_name); - - // Ends the current tag - // Invoked via "endt" operator (defined in xmlfmt.h) - void end_tag (void); - - // Adds the given attribute NAME with VALUE to the current tag - // Invoked via "attrt" operator (defined in xmlfmt.h) - void add_attr (const std::string& name, const std::string& value); - - // Dumps the whole tree to the (real) output stream - // Invoked via "endxml" operator (defined in xmlfmt.h) - void dump (void); - - protected: - int overflow (int ch); - - private: - // The ostream to dump the tree - std::ostream& _os; - - // The top of the XML document tree - xmltag* _top; - - // The current node in the tree being constructed - xmltag* _current; - - // A stack of tags being constructed - std::stack<xmltag*>* _tag_stack; -}; -#endif // !_XMLBUF_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlfmt.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlfmt.cc deleted file mode 100644 index 1e81a43987..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlfmt.cc +++ /dev/null @@ -1,100 +0,0 @@ -/* xmlfmt - defines several operators and classes for formatting - an XML stream (see oxmlstream.h) - Written by Keith Seitz <keiths@redhat.com> - Kent Sebastian <ksebasti@redhat.com> - Copyright 2003,2009 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "xmlfmt.h" -#include "xmlbuf.h" - -using namespace std; - -ostream& -operator<< (ostream& os, const startt& s) -{ - xmlbuf* xbuf = dynamic_cast<xmlbuf*> (os.rdbuf ()); - if (xbuf != NULL) - xbuf->add_tag (s._name); - return os; -} - -ostream& -operator<< (ostream& os, const attrt& a) -{ - xmlbuf* xbuf = dynamic_cast<xmlbuf*> (os.rdbuf ()); - if (xbuf != NULL) { - valid_string(const_cast<string&>(a._value)); - xbuf->add_attr (a._name, a._value); - } - return os; -} - -ostream& -endt (ostream& os) -{ - xmlbuf* xbuf = dynamic_cast<xmlbuf*> (os.rdbuf ()); - if (xbuf != NULL) - xbuf->end_tag (); - return os; -} - -ostream& -endxml (ostream& os) -{ - xmlbuf *xbuf = dynamic_cast<xmlbuf*> (os.rdbuf ()); - if (xbuf != NULL) - xbuf->dump (); - return os; -} - -//cant have characters "'&<> in an attribute, will cause xml parsing exceptions -void -valid_string (string &s) { - string chars = "&\"'<>"; - string char_replacements[] = {"&", """, "'", "<", ">"}; - char search_char; - - for (int char_index = 0; char_index < 5; char_index++) { - search_char = chars[char_index]; - - string::size_type search_index = 0; - while(1) { - search_index = s.find(search_char, search_index); - - if (search_index == string::npos) - break; - - s.replace(search_index, 1, char_replacements[char_index]); - search_index += char_replacements[char_index].length(); - } - } -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlfmt.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlfmt.h deleted file mode 100644 index 87ac6d8a41..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmlfmt.h +++ /dev/null @@ -1,73 +0,0 @@ -/* xmlfmt - defines several operators and classes for formatting - an XML stream (see oxmlstream.h) - Written by Keith Seitz <keiths@redhat.com> - Kent Sebastian <ksebasti@redhat.com> - Copyright 2003,2009 Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#ifndef _XMLFMT_H -#define _XMLFMT_H -#include <ostream> - -// Start a new tag with the given NAME -class startt -{ - public: - startt (const std::string &name) : _name (name) {}; - friend std::ostream& operator<< (std::ostream& os, const startt& s); - - private: - std::string _name; -}; - -// Add an attribute with the given NAME and VALUE to the current tag -class attrt -{ - public: - attrt (const std::string& name, const std::string& value) - : _name (name), _value (value) {}; - friend std::ostream& operator<< (std::ostream&, const attrt& a); - - private: - std::string _name; - std::string _value; - -}; - -// End the current tag -std::ostream& endt (std::ostream& os); - -// End the XML document and output it -std::ostream& endxml (std::ostream& os); - -//function to ensure strings dont have invalid characters -void valid_string(std::string &s); -#endif // ! _XMLFMT_H diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmltag.cc b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmltag.cc deleted file mode 100644 index aa85cc2841..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmltag.cc +++ /dev/null @@ -1,178 +0,0 @@ -/* xmltag/xmlattr - Classes which are nodes in the XML document tree - constructed by oxmlstream, xmlbuf, xmlfmt. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2003, Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include "xmltag.h" - -using namespace std; - -bool xmltag::_header_output = false; - -xmltag* -xmltag::dtd_header (string version, string encoding) -{ - string txt ("<?xml version=\"" + version + "\" encoding=\"" + encoding + "\"?>"); - xmltag* header = new xmltag (""); - header->add_text (txt); - return header; -} - -xmltag::xmltag (const string& name) - : _name (name), _level (-1) -{ - _children = new _childlist_t; -} - -xmltag::xmltag (const string& name, int level) - : _name (name), _level (level) -{ - _children = new _childlist_t; -} - -xmltag::~xmltag () -{ - // delete all children - delete_children (); - delete _children; -} - -void -xmltag::delete_children (void) -{ - _childlist_t::iterator i; - for (i = _children->begin (); i != _children->end (); ++i) - delete (*i); - - _children->clear (); -} - -xmltag* -xmltag::add_child (const string& name) -{ - xmltag* child = new xmltag (name, _level + 1); - _children->push_back (child); - return child; -} - -void -xmltag::add_text (const string& txt) -{ - _text += txt; -} - -void -xmltag::add_char (const char c) -{ - _text += c; -} - -void -xmltag::add_attr (const string& name, const string& value) -{ - _attributes.add (name, value); -} - -// Tags output a start tag with attributes, then children, then a closing tag. -void -xmltag::output (ostream& os) -{ - bool is_hdr = (_level == -1); - bool no_txt = (_text.length () == 0); - - if (is_hdr) - { - if (!xmltag::_header_output) - { - os << _text << endl; - xmltag::_header_output = true; - } - } - else - { - os << _indent () << "<" << _name; - _attributes.output (os); - os << ">" << _text; - if (no_txt) - os << endl; - } - - // output children - _output_children (os); - - if (!is_hdr) - { - if (no_txt) - os << _indent (); - os << "</" << _name << ">" << endl; - } -} - -// Walk through children, having them output themselves -void -xmltag::_output_children (ostream& os) -{ - _childlist_t::iterator i; - for (i = _children->begin (); i != _children->end (); ++i) - { - xmltag* child = (*i); - child->output (os); - } -} - -string -xmltag::_indent (void) -{ - return (_level > 0 ? std::string (_level, '\t') : ""); -} - -xmlattr::~xmlattr () -{ - list<attr_t*>::iterator i; - for (i = _attributes.begin (); i != _attributes.end (); ++i) - delete (*i); -} - -void -xmlattr::add (const string& name, const string& value) -{ - _attributes.push_back (new attr_t (name, value)); -} - -// Attributes output 'name="value"' for each attribute -void -xmlattr::output (ostream& os) -{ - list<attr_t*>::iterator i; - for (i = _attributes.begin (); i != _attributes.end (); ++i) - os << " " << attr_name (*i) << "=\"" << attr_value (*i) << "\""; -} diff --git a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmltag.h b/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmltag.h deleted file mode 100644 index 7d85620f7f..0000000000 --- a/oprofile/org.eclipse.linuxtools.oprofile.core/natives/linux/opxml/xmltag.h +++ /dev/null @@ -1,122 +0,0 @@ -/* xmltag/xmlattr - Classes which are nodes in the XML document tree - constructed by oxmlstream, xmlbuf, xmlfmt. - Written by Keith Seitz <keiths@redhat.com> - Copyright 2003, Red Hat, Inc. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Red Hat, Inc. nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - OF THE POSSIBILITY OF SUCH DAMAGE. */ - -#include <utility> -#include <string> -#include <list> -#include <ostream> - -// An XML tag attribute handler class -class xmlattr -{ - public: - ~xmlattr(); - - // The type of all attributes - typedef std::pair<std::string, std::string> attr_t; - - // Convenience accessors - static inline const std::string& attr_name (const attr_t* a) { return a->first; }; - static inline const std::string& attr_value (const attr_t* a) { return a->second; }; - - // Add an attribute of the given NAME and VALUE - void add (const std::string& name, const std::string& value); - - // Output all attributes to the given ostream. - void output (std::ostream& os); - - private: - // A list of all attributes - std::list<attr_t*> _attributes; -}; - -// An XML tag -class xmltag -{ - public: - // Convenience function to construct a "tag" which contains - // document type definition - static xmltag* dtd_header (std::string version, std::string encoding); - - // Constructors - give NAME of tag and (optionally) an indent level - xmltag (const std::string& name); - xmltag (const std::string& name, int level); - ~xmltag (); - - // Add a under this tag of the given NAME and return a pointer to it - xmltag* add_child (const std::string& name); - - // Delete all children - void delete_children (void); - - // Add an attribute of the given NAME and VALUE to this tag - void add_attr (const std::string& name, const std::string& value); - - // Add the character C to the text contained in this tag - void add_char (const char c); - - // Add the given TXT to the text contained in this tag - void add_text (const std::string& txt); - - // Output the tag and it's text to the given stream - void output (std::ostream& os); - - private: - // convenience type of the list of child tags - typedef std::list<xmltag*> _childlist_t; - - // A function to return indentation - std::string _indent (void); - - // Convenience function to output the children of this tag to the given stream - void _output_children (std::ostream& os); - - // Have we output the DTD? - static bool _header_output; - - // The name of this tag - std::string _name; - - // The text of this tag - std::string _text; - - // The attributes associated with this tag - xmlattr _attributes; - - // The "children" of this tag (i.e., tags this tag encloses) - _childlist_t* _children; - - // The indent level for this tag - int _level; -}; |