summaryrefslogtreecommitdiffstats
path: root/meta/packages/oprofile/oprofile/fix_debug_search.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/oprofile/oprofile/fix_debug_search.patch')
-rw-r--r--meta/packages/oprofile/oprofile/fix_debug_search.patch222
1 files changed, 222 insertions, 0 deletions
diff --git a/meta/packages/oprofile/oprofile/fix_debug_search.patch b/meta/packages/oprofile/oprofile/fix_debug_search.patch
new file mode 100644
index 0000000000..b894908144
--- /dev/null
+++ b/meta/packages/oprofile/oprofile/fix_debug_search.patch
@@ -0,0 +1,222 @@
1Index: libutil++/bfd_support.cpp
2===================================================================
3RCS file: /cvsroot/oprofile/oprofile/libutil++/bfd_support.cpp,v
4retrieving revision 1.9
5diff -u -r1.9 bfd_support.cpp
6--- libutil++/bfd_support.cpp 29 Apr 2008 12:07:46 -0000 1.9
7+++ libutil++/bfd_support.cpp 2 Jul 2008 20:55:09 -0000
8@@ -12,8 +12,11 @@
9
10 #include "op_bfd.h"
11 #include "op_fileio.h"
12+#include "op_config.h"
13 #include "string_manip.h"
14+#include "file_manip.h"
15 #include "cverb.h"
16+#include "locate_images.h"
17
18 #include <cstdlib>
19 #include <cstring>
20@@ -42,13 +45,22 @@
21 }
22
23
24-bool separate_debug_file_exists(string const & name, unsigned long const crc)
25+bool separate_debug_file_exists(string & name, unsigned long const crc,
26+ extra_images const & extra)
27 {
28 unsigned long file_crc = 0;
29 // The size of 2 * 1024 elements for the buffer is arbitrary.
30 char buffer[2 * 1024];
31-
32- ifstream file(name.c_str());
33+
34+ image_error img_ok;
35+ string const image_path = extra.find_image_path(name, img_ok, true);
36+
37+ if (img_ok != image_ok)
38+ return false;
39+
40+ name = image_path;
41+
42+ ifstream file(image_path.c_str());
43 if (!file)
44 return false;
45
46@@ -281,40 +293,35 @@
47 }
48
49
50-bool find_separate_debug_file(bfd * ibfd, string const & dir_in,
51- string const & global_in, string & filename)
52+bool find_separate_debug_file(bfd * ibfd, string const & filepath_in,
53+ string & debug_filename, extra_images const & extra)
54 {
55- string dir(dir_in);
56- string global(global_in);
57+ string filepath(filepath_in);
58 string basename;
59 unsigned long crc32;
60
61 if (!get_debug_link_info(ibfd, basename, crc32))
62 return false;
63-
64- if (dir.size() > 0 && dir.at(dir.size() - 1) != '/')
65- dir += '/';
66-
67- if (global.size() > 0 && global.at(global.size() - 1) != '/')
68- global += '/';
69+
70+ // Work out the image file's directory prefix
71+ string filedir = op_dirname(filepath);
72+ // Make sure it starts with /
73+ if (filedir.size() > 0 && filedir.at(filedir.size() - 1) != '/')
74+ filedir += '/';
75+
76+ string first_try(filedir + ".debug/" + basename);
77+ string second_try(DEBUGDIR + filedir + basename);
78+ string third_try(filedir + basename);
79
80 cverb << vbfd << "looking for debugging file " << basename
81 << " with crc32 = " << hex << crc32 << endl;
82-
83- string first_try(dir + basename);
84- string second_try(dir + ".debug/" + basename);
85-
86- if (dir.size() > 0 && dir[0] == '/')
87- dir = dir.substr(1);
88
89- string third_try(global + dir + basename);
90-
91- if (separate_debug_file_exists(first_try, crc32))
92- filename = first_try;
93- else if (separate_debug_file_exists(second_try, crc32))
94- filename = second_try;
95- else if (separate_debug_file_exists(third_try, crc32))
96- filename = third_try;
97+ if (separate_debug_file_exists(first_try, crc32, extra))
98+ debug_filename = first_try;
99+ else if (separate_debug_file_exists(second_try, crc32, extra))
100+ debug_filename = second_try;
101+ else if (separate_debug_file_exists(third_try, crc32, extra))
102+ debug_filename = third_try;
103 else
104 return false;
105
106Index: libutil++/bfd_support.h
107===================================================================
108RCS file: /cvsroot/oprofile/oprofile/libutil++/bfd_support.h,v
109retrieving revision 1.5
110diff -u -r1.5 bfd_support.h
111--- libutil++/bfd_support.h 28 Apr 2008 21:23:25 -0000 1.5
112+++ libutil++/bfd_support.h 2 Jul 2008 20:55:09 -0000
113@@ -13,6 +13,7 @@
114
115 #include "utility.h"
116 #include "op_types.h"
117+#include "locate_images.h"
118
119 #include <bfd.h>
120 #include <stdint.h>
121@@ -84,9 +85,9 @@
122 */
123 extern bool
124 find_separate_debug_file(bfd * ibfd,
125- std::string const & dir_in,
126- std::string const & global_in,
127- std::string & filename);
128+ std::string const & filepath_in,
129+ std::string & debug_filename,
130+ extra_images const & extra);
131
132 /// open the given BFD
133 bfd * open_bfd(std::string const & file);
134Index: libutil++/op_bfd.cpp
135===================================================================
136RCS file: /cvsroot/oprofile/oprofile/libutil++/op_bfd.cpp,v
137retrieving revision 1.83
138diff -u -r1.83 op_bfd.cpp
139--- libutil++/op_bfd.cpp 19 May 2008 23:15:04 -0000 1.83
140+++ libutil++/op_bfd.cpp 2 Jul 2008 20:55:09 -0000
141@@ -97,6 +97,7 @@
142 :
143 filename(fname),
144 archive_path(extra_images.get_archive_path()),
145+ extra_found_images(extra_images),
146 file_size(-1),
147 anon_obj(false)
148 {
149@@ -341,11 +342,8 @@
150 return debug_info.reset(true);
151
152 // check to see if there is an .debug file
153- string const global(archive_path + DEBUGDIR);
154- string const image_path = archive_path + filename;
155- string const dirname(image_path.substr(0, image_path.rfind('/')));
156
157- if (find_separate_debug_file(ibfd.abfd, dirname, global, debug_filename)) {
158+ if (find_separate_debug_file(ibfd.abfd, filename, debug_filename, extra_found_images)) {
159 cverb << vbfd << "now loading: " << debug_filename << endl;
160 dbfd.abfd = open_bfd(debug_filename);
161 if (dbfd.has_debug_info())
162Index: libutil++/op_bfd.h
163===================================================================
164RCS file: /cvsroot/oprofile/oprofile/libutil++/op_bfd.h,v
165retrieving revision 1.51
166diff -u -r1.51 op_bfd.h
167--- libutil++/op_bfd.h 19 May 2008 23:15:04 -0000 1.51
168+++ libutil++/op_bfd.h 2 Jul 2008 20:55:09 -0000
169@@ -21,6 +21,7 @@
170 #include <set>
171
172 #include "bfd_support.h"
173+#include "locate_images.h"
174 #include "utility.h"
175 #include "cached_value.h"
176 #include "op_types.h"
177@@ -261,6 +262,9 @@
178 /// path to archive
179 std::string archive_path;
180
181+ /// reference to extra_images
182+ extra_images const & extra_found_images;
183+
184 /// file size in bytes
185 off_t file_size;
186
187Index: libutil++/op_spu_bfd.cpp
188===================================================================
189RCS file: /cvsroot/oprofile/oprofile/libutil++/op_spu_bfd.cpp,v
190retrieving revision 1.6
191diff -u -r1.6 op_spu_bfd.cpp
192--- libutil++/op_spu_bfd.cpp 29 Apr 2008 12:07:46 -0000 1.6
193+++ libutil++/op_spu_bfd.cpp 2 Jul 2008 20:55:09 -0000
194@@ -43,6 +43,7 @@
195 extra_images const & extra_images, bool & ok)
196 :
197 archive_path(extra_images.get_archive_path()),
198+ extra_found_images(extra_images),
199 file_size(-1),
200 embedding_filename(fname)
201 {
202Index: pp/oparchive.cpp
203===================================================================
204RCS file: /cvsroot/oprofile/oprofile/pp/oparchive.cpp,v
205retrieving revision 1.17
206diff -u -r1.17 oparchive.cpp
207--- pp/oparchive.cpp 29 Apr 2008 12:07:46 -0000 1.17
208+++ pp/oparchive.cpp 2 Jul 2008 20:55:09 -0000
209@@ -116,11 +116,10 @@
210 */
211 bfd * ibfd = open_bfd(real_exe_name);
212 if (ibfd) {
213- string global(archive_path + DEBUGDIR);
214 string dirname = op_dirname(real_exe_name);
215 string debug_filename;
216- if (find_separate_debug_file(ibfd, dirname, global,
217- debug_filename)) {
218+ if (find_separate_debug_file(ibfd, real_exe_name,
219+ debug_filename, classes.extra_found_images)) {
220 /* found something copy it over */
221 string dest_debug_dir = options::outdirectory +
222 dirname + "/.debug/";