[prev in list] [next in list] [prev in thread] [next in thread]
List: oprofile-list
Subject: [patch 4/7] Oprofile AMD IBS support
From: "Jason Yeh" <jason.yeh () amd ! com>
Date: 2008-01-29 21:49:20
Message-ID: 479F9F60.9050200 () amd ! com
[Download RAW message or body]
This patch includes more changes to back end data structure to support IBS events.
---
libdb/db_insert.c | 8 ++++----
libdb/odb.h | 2 +-
libpp/profile_container.cpp | 7 +++++++
libpp/profile_container.h | 2 ++
libpp/sample_container.cpp | 10 ++++++++++
libpp/sample_container.h | 3 +++
libutil++/op_bfd.cpp | 5 +++++
libutil++/op_bfd.h | 3 +++
libutil/op_fileio.c | 20 ++++++++++++++++++++
libutil/op_fileio.h | 13 +++++++++++++
10 files changed, 68 insertions(+), 5 deletions(-)
diff -uprN -X dontdiff oprofile-cvs-original/libdb/db_insert.c \
oprofile-cvs-ibs/libdb/db_insert.c
--- oprofile-cvs-original/libdb/db_insert.c 2008-01-28 16:05:26.000000000 -0600
+++ oprofile-cvs-ibs/libdb/db_insert.c 2008-01-29 09:39:46.000000000 -0600
@@ -49,7 +49,7 @@ static inline int add_node(odb_data_t *
return 0;
}
-int odb_update_node(odb_t * odb, odb_key_t key)
+int odb_update_node(odb_t * odb, odb_key_t key, odb_value_t value)
{
odb_index_t index;
odb_node_t * node;
@@ -60,8 +60,8 @@ int odb_update_node(odb_t * odb, odb_key
while (index) {
node = &data->node_base[index];
if (node->key == key) {
- if (node->value + 1 != 0) {
- node->value += 1;
+ if (node->value + value != 0) {
+ node->value += value;
} else {
/* post profile tools must handle overflow */
/* FIXME: the tricky way will be just to add
@@ -92,7 +92,7 @@ int odb_update_node(odb_t * odb, odb_key
index = node->next;
}
- return add_node(data, key, 1);
+ return add_node(data, key, value);
}
diff -uprN -X dontdiff oprofile-cvs-original/libdb/odb.h oprofile-cvs-ibs/libdb/odb.h
--- oprofile-cvs-original/libdb/odb.h 2008-01-28 16:05:26.000000000 -0600
+++ oprofile-cvs-ibs/libdb/odb.h 2008-01-29 09:39:46.000000000 -0600
@@ -178,7 +178,7 @@ void odb_hash_free_stat(odb_hash_stat_t
*
* returns EXIT_SUCCESS on success, EXIT_FAILURE on failure
*/
-int odb_update_node(odb_t * odb, odb_key_t key);
+int odb_update_node(odb_t * odb, odb_key_t key, odb_value_t value);
/** Add a new node w/o regarding if a node with the same key already exists
*
diff -uprN -X dontdiff oprofile-cvs-original/libpp/profile_container.cpp \
oprofile-cvs-ibs/libpp/profile_container.cpp
--- oprofile-cvs-original/libpp/profile_container.cpp 2008-01-28 16:05:26.000000000 \
-0600
+++ oprofile-cvs-ibs/libpp/profile_container.cpp 2008-01-29 09:39:46.000000000 -0600
@@ -162,6 +162,12 @@ profile_container::add_samples(op_bfd co
}
+void profile_container::delete_samples(symbol_entry const * symbol, bfd_vma vma)
+{
+ samples->erase(symbol, vma);
+}
+
+
symbol_collection const
profile_container::select_symbols(symbol_choice & choice) const
{
@@ -332,3 +338,4 @@ symbol_container::symbols_t::iterator pr
{
return symbols->end();
}
+
diff -uprN -X dontdiff oprofile-cvs-original/libpp/profile_container.h \
oprofile-cvs-ibs/libpp/profile_container.h
--- oprofile-cvs-original/libpp/profile_container.h 2008-01-28 16:05:26.000000000 \
-0600
+++ oprofile-cvs-ibs/libpp/profile_container.h 2008-01-29 09:39:46.000000000 -0600
@@ -66,6 +66,8 @@ public:
void add(profile_t const & profile, op_bfd const & abfd,
std::string const & app_name, size_t pclass);
+ void delete_samples(symbol_entry const * symbol, bfd_vma vma);
+
/// Find a symbol from its image_name, vma, return zero if no symbol
/// for this image at this vma
symbol_entry const * find_symbol(std::string const & image_name,
diff -uprN -X dontdiff oprofile-cvs-original/libpp/sample_container.cpp \
oprofile-cvs-ibs/libpp/sample_container.cpp
--- oprofile-cvs-original/libpp/sample_container.cpp 2008-01-28 16:05:26.000000000 \
-0600
+++ oprofile-cvs-ibs/libpp/sample_container.cpp 2008-01-29 09:39:46.000000000 -0600
@@ -108,6 +108,16 @@ sample_container::find_by_vma(symbol_ent
}
+void
+sample_container::erase(symbol_entry const * symbol, bfd_vma vma)
+{
+ sample_index_t key(symbol, vma);
+ samples_iterator it = samples.find(key);
+ if (it != samples.end())
+ samples.erase(key);
+}
+
+
count_array_t
sample_container::accumulate_samples(debug_name_id filename,
size_t linenr) const
diff -uprN -X dontdiff oprofile-cvs-original/libpp/sample_container.h \
oprofile-cvs-ibs/libpp/sample_container.h
--- oprofile-cvs-original/libpp/sample_container.h 2008-01-28 16:05:26.000000000 \
-0600
+++ oprofile-cvs-ibs/libpp/sample_container.h 2008-01-29 09:39:46.000000000 -0600
@@ -44,6 +44,9 @@ public:
/// samples into an existing one. Can only be done before any lookups
void insert(symbol_entry const * symbol, sample_entry const &);
+ /// erase the sample entry for the given image_name and vma if any
+ void erase(symbol_entry const * symbol, bfd_vma vma);
+
/// return nr of samples in the given filename
count_array_t accumulate_samples(debug_name_id filename_id) const;
diff -uprN -X dontdiff oprofile-cvs-original/libutil/op_fileio.c \
oprofile-cvs-ibs/libutil/op_fileio.c
--- oprofile-cvs-original/libutil/op_fileio.c 2008-01-28 16:05:29.000000000 -0600
+++ oprofile-cvs-ibs/libutil/op_fileio.c 2008-01-29 09:39:46.000000000 -0600
@@ -56,6 +56,26 @@ void op_close_file(FILE * fp)
}
+void op_read_file(FILE * fp, void * buf, size_t size)
+{
+ size_t count;
+
+ count = fread(buf, size, 1, fp);
+
+ if (count != 1) {
+ if (feof(fp)) {
+ fprintf(stderr,
+ "oprofiled:op_read_file: read less than expected %lu bytes\n",
+ (unsigned long)size);
+ } else {
+ fprintf(stderr,
+ "oprofiled:op_read_file: error reading\n");
+ }
+ exit(EXIT_FAILURE);
+ }
+}
+
+
void op_write_file(FILE * fp, void const * buf, size_t size)
{
size_t written;
diff -uprN -X dontdiff oprofile-cvs-original/libutil/op_fileio.h \
oprofile-cvs-ibs/libutil/op_fileio.h
--- oprofile-cvs-original/libutil/op_fileio.h 2008-01-28 16:05:29.000000000 -0600
+++ oprofile-cvs-ibs/libutil/op_fileio.h 2008-01-29 09:39:46.000000000 -0600
@@ -41,6 +41,19 @@ FILE * op_try_open_file(char const * nam
FILE * op_open_file(char const * name, char const * mode);
/**
+ * op_read_file - read a file
+ * @param fp file pointer
+ * @param buf buffer
+ * @param size size in bytes to read
+ *
+ * Read from a file. It is considered an error
+ * if anything less than size bytes is read.
+ * Failure is fatal.
+ */
+void op_read_file(FILE * fp, void * buf, size_t size);
+
+
+/**
* op_read_int_from_file - parse an ASCII value from a file into an integer
* @param filename name of file to parse integer value from
* @param fatal non-zero if any error must be fatal
diff -uprN -X dontdiff oprofile-cvs-original/libutil++/op_bfd.cpp \
oprofile-cvs-ibs/libutil++/op_bfd.cpp
--- oprofile-cvs-original/libutil++/op_bfd.cpp 2008-01-28 16:05:30.000000000 -0600
+++ oprofile-cvs-ibs/libutil++/op_bfd.cpp 2008-01-29 09:39:46.000000000 -0600
@@ -275,6 +275,11 @@ void op_bfd::add_symbols(op_bfd::symbols
<< dec << syms.size() << hex << endl;
}
+unsigned long op_bfd::filepos(symbol_index_t sym_index) const
+{
+ return syms[sym_index].filepos();
+}
+
bfd_vma op_bfd::offset_to_pc(bfd_vma offset) const
{
diff -uprN -X dontdiff oprofile-cvs-original/libutil++/op_bfd.h \
oprofile-cvs-ibs/libutil++/op_bfd.h
--- oprofile-cvs-original/libutil++/op_bfd.h 2008-01-28 16:05:30.000000000 -0600
+++ oprofile-cvs-ibs/libutil++/op_bfd.h 2008-01-29 09:39:46.000000000 -0600
@@ -158,6 +158,9 @@ public:
/** return the relocated PC value for the given file offset */
bfd_vma offset_to_pc(bfd_vma offset) const;
+
+ unsigned long filepos(symbol_index_t sym_index) const;
+
/**
* If passed 0, return the file position of the .text section.
* Otherwise, return the filepos of a section with a matching
["op_cvs_IBS_PATCH_4" (text/plain)]
diff -uprN -X dontdiff oprofile-cvs-original/libdb/db_insert.c \
oprofile-cvs-ibs/libdb/db_insert.c
--- oprofile-cvs-original/libdb/db_insert.c 2008-01-28 16:05:26.000000000 -0600
+++ oprofile-cvs-ibs/libdb/db_insert.c 2008-01-29 09:39:46.000000000 -0600
@@ -49,7 +49,7 @@ static inline int add_node(odb_data_t *
return 0;
}
-int odb_update_node(odb_t * odb, odb_key_t key)
+int odb_update_node(odb_t * odb, odb_key_t key, odb_value_t value)
{
odb_index_t index;
odb_node_t * node;
@@ -60,8 +60,8 @@ int odb_update_node(odb_t * odb, odb_key
while (index) {
node = &data->node_base[index];
if (node->key == key) {
- if (node->value + 1 != 0) {
- node->value += 1;
+ if (node->value + value != 0) {
+ node->value += value;
} else {
/* post profile tools must handle overflow */
/* FIXME: the tricky way will be just to add
@@ -92,7 +92,7 @@ int odb_update_node(odb_t * odb, odb_key
index = node->next;
}
- return add_node(data, key, 1);
+ return add_node(data, key, value);
}
diff -uprN -X dontdiff oprofile-cvs-original/libdb/odb.h oprofile-cvs-ibs/libdb/odb.h
--- oprofile-cvs-original/libdb/odb.h 2008-01-28 16:05:26.000000000 -0600
+++ oprofile-cvs-ibs/libdb/odb.h 2008-01-29 09:39:46.000000000 -0600
@@ -178,7 +178,7 @@ void odb_hash_free_stat(odb_hash_stat_t
*
* returns EXIT_SUCCESS on success, EXIT_FAILURE on failure
*/
-int odb_update_node(odb_t * odb, odb_key_t key);
+int odb_update_node(odb_t * odb, odb_key_t key, odb_value_t value);
/** Add a new node w/o regarding if a node with the same key already exists
*
diff -uprN -X dontdiff oprofile-cvs-original/libpp/profile_container.cpp \
oprofile-cvs-ibs/libpp/profile_container.cpp
--- oprofile-cvs-original/libpp/profile_container.cpp 2008-01-28 16:05:26.000000000 \
-0600
+++ oprofile-cvs-ibs/libpp/profile_container.cpp 2008-01-29 09:39:46.000000000 -0600
@@ -162,6 +162,12 @@ profile_container::add_samples(op_bfd co
}
+void profile_container::delete_samples(symbol_entry const * symbol, bfd_vma vma)
+{
+ samples->erase(symbol, vma);
+}
+
+
symbol_collection const
profile_container::select_symbols(symbol_choice & choice) const
{
@@ -332,3 +338,4 @@ symbol_container::symbols_t::iterator pr
{
return symbols->end();
}
+
diff -uprN -X dontdiff oprofile-cvs-original/libpp/profile_container.h \
oprofile-cvs-ibs/libpp/profile_container.h
--- oprofile-cvs-original/libpp/profile_container.h 2008-01-28 16:05:26.000000000 \
-0600
+++ oprofile-cvs-ibs/libpp/profile_container.h 2008-01-29 09:39:46.000000000 -0600
@@ -66,6 +66,8 @@ public:
void add(profile_t const & profile, op_bfd const & abfd,
std::string const & app_name, size_t pclass);
+ void delete_samples(symbol_entry const * symbol, bfd_vma vma);
+
/// Find a symbol from its image_name, vma, return zero if no symbol
/// for this image at this vma
symbol_entry const * find_symbol(std::string const & image_name,
diff -uprN -X dontdiff oprofile-cvs-original/libpp/sample_container.cpp \
oprofile-cvs-ibs/libpp/sample_container.cpp
--- oprofile-cvs-original/libpp/sample_container.cpp 2008-01-28 16:05:26.000000000 \
-0600
+++ oprofile-cvs-ibs/libpp/sample_container.cpp 2008-01-29 09:39:46.000000000 -0600
@@ -108,6 +108,16 @@ sample_container::find_by_vma(symbol_ent
}
+void
+sample_container::erase(symbol_entry const * symbol, bfd_vma vma)
+{
+ sample_index_t key(symbol, vma);
+ samples_iterator it = samples.find(key);
+ if (it != samples.end())
+ samples.erase(key);
+}
+
+
count_array_t
sample_container::accumulate_samples(debug_name_id filename,
size_t linenr) const
diff -uprN -X dontdiff oprofile-cvs-original/libpp/sample_container.h \
oprofile-cvs-ibs/libpp/sample_container.h
--- oprofile-cvs-original/libpp/sample_container.h 2008-01-28 16:05:26.000000000 \
-0600
+++ oprofile-cvs-ibs/libpp/sample_container.h 2008-01-29 09:39:46.000000000 -0600
@@ -44,6 +44,9 @@ public:
/// samples into an existing one. Can only be done before any lookups
void insert(symbol_entry const * symbol, sample_entry const &);
+ /// erase the sample entry for the given image_name and vma if any
+ void erase(symbol_entry const * symbol, bfd_vma vma);
+
/// return nr of samples in the given filename
count_array_t accumulate_samples(debug_name_id filename_id) const;
diff -uprN -X dontdiff oprofile-cvs-original/libutil/op_fileio.c \
oprofile-cvs-ibs/libutil/op_fileio.c
--- oprofile-cvs-original/libutil/op_fileio.c 2008-01-28 16:05:29.000000000 -0600
+++ oprofile-cvs-ibs/libutil/op_fileio.c 2008-01-29 09:39:46.000000000 -0600
@@ -56,6 +56,26 @@ void op_close_file(FILE * fp)
}
+void op_read_file(FILE * fp, void * buf, size_t size)
+{
+ size_t count;
+
+ count = fread(buf, size, 1, fp);
+
+ if (count != 1) {
+ if (feof(fp)) {
+ fprintf(stderr,
+ "oprofiled:op_read_file: read less than expected %lu bytes\n",
+ (unsigned long)size);
+ } else {
+ fprintf(stderr,
+ "oprofiled:op_read_file: error reading\n");
+ }
+ exit(EXIT_FAILURE);
+ }
+}
+
+
void op_write_file(FILE * fp, void const * buf, size_t size)
{
size_t written;
diff -uprN -X dontdiff oprofile-cvs-original/libutil/op_fileio.h \
oprofile-cvs-ibs/libutil/op_fileio.h
--- oprofile-cvs-original/libutil/op_fileio.h 2008-01-28 16:05:29.000000000 -0600
+++ oprofile-cvs-ibs/libutil/op_fileio.h 2008-01-29 09:39:46.000000000 -0600
@@ -41,6 +41,19 @@ FILE * op_try_open_file(char const * nam
FILE * op_open_file(char const * name, char const * mode);
/**
+ * op_read_file - read a file
+ * @param fp file pointer
+ * @param buf buffer
+ * @param size size in bytes to read
+ *
+ * Read from a file. It is considered an error
+ * if anything less than size bytes is read.
+ * Failure is fatal.
+ */
+void op_read_file(FILE * fp, void * buf, size_t size);
+
+
+/**
* op_read_int_from_file - parse an ASCII value from a file into an integer
* @param filename name of file to parse integer value from
* @param fatal non-zero if any error must be fatal
diff -uprN -X dontdiff oprofile-cvs-original/libutil++/op_bfd.cpp \
oprofile-cvs-ibs/libutil++/op_bfd.cpp
--- oprofile-cvs-original/libutil++/op_bfd.cpp 2008-01-28 16:05:30.000000000 -0600
+++ oprofile-cvs-ibs/libutil++/op_bfd.cpp 2008-01-29 09:39:46.000000000 -0600
@@ -275,6 +275,11 @@ void op_bfd::add_symbols(op_bfd::symbols
<< dec << syms.size() << hex << endl;
}
+unsigned long op_bfd::filepos(symbol_index_t sym_index) const
+{
+ return syms[sym_index].filepos();
+}
+
bfd_vma op_bfd::offset_to_pc(bfd_vma offset) const
{
diff -uprN -X dontdiff oprofile-cvs-original/libutil++/op_bfd.h \
oprofile-cvs-ibs/libutil++/op_bfd.h
--- oprofile-cvs-original/libutil++/op_bfd.h 2008-01-28 16:05:30.000000000 -0600
+++ oprofile-cvs-ibs/libutil++/op_bfd.h 2008-01-29 09:39:46.000000000 -0600
@@ -158,6 +158,9 @@ public:
/** return the relocated PC value for the given file offset */
bfd_vma offset_to_pc(bfd_vma offset) const;
+
+ unsigned long filepos(symbol_index_t sym_index) const;
+
/**
* If passed 0, return the file position of the .text section.
* Otherwise, return the filepos of a section with a matching
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
oprofile-list mailing list
oprofile-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oprofile-list
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic