generic-poky/meta/packages/oprofile/oprofile/fix_debug_search.patch

223 lines
7.0 KiB
Diff

Index: libutil++/bfd_support.cpp
===================================================================
RCS file: /cvsroot/oprofile/oprofile/libutil++/bfd_support.cpp,v
retrieving revision 1.9
diff -u -r1.9 bfd_support.cpp
--- libutil++/bfd_support.cpp 29 Apr 2008 12:07:46 -0000 1.9
+++ libutil++/bfd_support.cpp 2 Jul 2008 20:55:09 -0000
@@ -12,8 +12,11 @@
#include "op_bfd.h"
#include "op_fileio.h"
+#include "op_config.h"
#include "string_manip.h"
+#include "file_manip.h"
#include "cverb.h"
+#include "locate_images.h"
#include <cstdlib>
#include <cstring>
@@ -42,13 +45,22 @@
}
-bool separate_debug_file_exists(string const & name, unsigned long const crc)
+bool separate_debug_file_exists(string & name, unsigned long const crc,
+ extra_images const & extra)
{
unsigned long file_crc = 0;
// The size of 2 * 1024 elements for the buffer is arbitrary.
char buffer[2 * 1024];
-
- ifstream file(name.c_str());
+
+ image_error img_ok;
+ string const image_path = extra.find_image_path(name, img_ok, true);
+
+ if (img_ok != image_ok)
+ return false;
+
+ name = image_path;
+
+ ifstream file(image_path.c_str());
if (!file)
return false;
@@ -281,40 +293,35 @@
}
-bool find_separate_debug_file(bfd * ibfd, string const & dir_in,
- string const & global_in, string & filename)
+bool find_separate_debug_file(bfd * ibfd, string const & filepath_in,
+ string & debug_filename, extra_images const & extra)
{
- string dir(dir_in);
- string global(global_in);
+ string filepath(filepath_in);
string basename;
unsigned long crc32;
if (!get_debug_link_info(ibfd, basename, crc32))
return false;
-
- if (dir.size() > 0 && dir.at(dir.size() - 1) != '/')
- dir += '/';
-
- if (global.size() > 0 && global.at(global.size() - 1) != '/')
- global += '/';
+
+ // Work out the image file's directory prefix
+ string filedir = op_dirname(filepath);
+ // Make sure it starts with /
+ if (filedir.size() > 0 && filedir.at(filedir.size() - 1) != '/')
+ filedir += '/';
+
+ string first_try(filedir + ".debug/" + basename);
+ string second_try(DEBUGDIR + filedir + basename);
+ string third_try(filedir + basename);
cverb << vbfd << "looking for debugging file " << basename
<< " with crc32 = " << hex << crc32 << endl;
-
- string first_try(dir + basename);
- string second_try(dir + ".debug/" + basename);
-
- if (dir.size() > 0 && dir[0] == '/')
- dir = dir.substr(1);
- string third_try(global + dir + basename);
-
- if (separate_debug_file_exists(first_try, crc32))
- filename = first_try;
- else if (separate_debug_file_exists(second_try, crc32))
- filename = second_try;
- else if (separate_debug_file_exists(third_try, crc32))
- filename = third_try;
+ if (separate_debug_file_exists(first_try, crc32, extra))
+ debug_filename = first_try;
+ else if (separate_debug_file_exists(second_try, crc32, extra))
+ debug_filename = second_try;
+ else if (separate_debug_file_exists(third_try, crc32, extra))
+ debug_filename = third_try;
else
return false;
Index: libutil++/bfd_support.h
===================================================================
RCS file: /cvsroot/oprofile/oprofile/libutil++/bfd_support.h,v
retrieving revision 1.5
diff -u -r1.5 bfd_support.h
--- libutil++/bfd_support.h 28 Apr 2008 21:23:25 -0000 1.5
+++ libutil++/bfd_support.h 2 Jul 2008 20:55:09 -0000
@@ -13,6 +13,7 @@
#include "utility.h"
#include "op_types.h"
+#include "locate_images.h"
#include <bfd.h>
#include <stdint.h>
@@ -84,9 +85,9 @@
*/
extern bool
find_separate_debug_file(bfd * ibfd,
- std::string const & dir_in,
- std::string const & global_in,
- std::string & filename);
+ std::string const & filepath_in,
+ std::string & debug_filename,
+ extra_images const & extra);
/// open the given BFD
bfd * open_bfd(std::string const & file);
Index: libutil++/op_bfd.cpp
===================================================================
RCS file: /cvsroot/oprofile/oprofile/libutil++/op_bfd.cpp,v
retrieving revision 1.83
diff -u -r1.83 op_bfd.cpp
--- libutil++/op_bfd.cpp 19 May 2008 23:15:04 -0000 1.83
+++ libutil++/op_bfd.cpp 2 Jul 2008 20:55:09 -0000
@@ -97,6 +97,7 @@
:
filename(fname),
archive_path(extra_images.get_archive_path()),
+ extra_found_images(extra_images),
file_size(-1),
anon_obj(false)
{
@@ -341,11 +342,8 @@
return debug_info.reset(true);
// check to see if there is an .debug file
- string const global(archive_path + DEBUGDIR);
- string const image_path = archive_path + filename;
- string const dirname(image_path.substr(0, image_path.rfind('/')));
- if (find_separate_debug_file(ibfd.abfd, dirname, global, debug_filename)) {
+ if (find_separate_debug_file(ibfd.abfd, filename, debug_filename, extra_found_images)) {
cverb << vbfd << "now loading: " << debug_filename << endl;
dbfd.abfd = open_bfd(debug_filename);
if (dbfd.has_debug_info())
Index: libutil++/op_bfd.h
===================================================================
RCS file: /cvsroot/oprofile/oprofile/libutil++/op_bfd.h,v
retrieving revision 1.51
diff -u -r1.51 op_bfd.h
--- libutil++/op_bfd.h 19 May 2008 23:15:04 -0000 1.51
+++ libutil++/op_bfd.h 2 Jul 2008 20:55:09 -0000
@@ -21,6 +21,7 @@
#include <set>
#include "bfd_support.h"
+#include "locate_images.h"
#include "utility.h"
#include "cached_value.h"
#include "op_types.h"
@@ -261,6 +262,9 @@
/// path to archive
std::string archive_path;
+ /// reference to extra_images
+ extra_images const & extra_found_images;
+
/// file size in bytes
off_t file_size;
Index: libutil++/op_spu_bfd.cpp
===================================================================
RCS file: /cvsroot/oprofile/oprofile/libutil++/op_spu_bfd.cpp,v
retrieving revision 1.6
diff -u -r1.6 op_spu_bfd.cpp
--- libutil++/op_spu_bfd.cpp 29 Apr 2008 12:07:46 -0000 1.6
+++ libutil++/op_spu_bfd.cpp 2 Jul 2008 20:55:09 -0000
@@ -43,6 +43,7 @@
extra_images const & extra_images, bool & ok)
:
archive_path(extra_images.get_archive_path()),
+ extra_found_images(extra_images),
file_size(-1),
embedding_filename(fname)
{
Index: pp/oparchive.cpp
===================================================================
RCS file: /cvsroot/oprofile/oprofile/pp/oparchive.cpp,v
retrieving revision 1.17
diff -u -r1.17 oparchive.cpp
--- pp/oparchive.cpp 29 Apr 2008 12:07:46 -0000 1.17
+++ pp/oparchive.cpp 2 Jul 2008 20:55:09 -0000
@@ -116,11 +116,10 @@
*/
bfd * ibfd = open_bfd(real_exe_name);
if (ibfd) {
- string global(archive_path + DEBUGDIR);
string dirname = op_dirname(real_exe_name);
string debug_filename;
- if (find_separate_debug_file(ibfd, dirname, global,
- debug_filename)) {
+ if (find_separate_debug_file(ibfd, real_exe_name,
+ debug_filename, classes.extra_found_images)) {
/* found something copy it over */
string dest_debug_dir = options::outdirectory +
dirname + "/.debug/";