diff options
author | Daniel Markus <daniel.markus@leica-geosystems.com> | 2015-03-12 14:34:49 +0100 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2015-03-21 16:42:23 +0100 |
commit | ba72b88a4147ae2d050aa0a8d452a07e09330e33 (patch) | |
tree | 0832814d4d58628d4c17100ad205976e2789ad69 /meta-oe/classes | |
parent | 01bd032f2f55bcfaed5f4ff66a68fba97e30243f (diff) | |
download | meta-openembedded-ba72b88a4147ae2d050aa0a8d452a07e09330e33.tar.gz |
socorro-syms: Add directory arrangement needed by minidump_stackwalk
http://code.google.com/p/google-breakpad/wiki/LinuxStarterGuide
When extracting a stack trace out of a Breakpad minidump, the application
minidump_stackwalk is used. This application needs all symbol files to be
arranged in a particular directory structure in order to match the correct
symbol file with the version of the crashed program in question.
A directory structure is created in accordance with minidump_stackwalk. The
structure contains the name of the application binary and a hash value where the
hash corresponds to the binary the symbol file was produced from. The symbol
file is moved to the hash directory allowing multiple versions of the same
symbol file.
Signed-off-by: Daniel Markus <daniel.markus@leica-geosystems.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-oe/classes')
-rw-r--r-- | meta-oe/classes/socorro-syms.bbclass | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/meta-oe/classes/socorro-syms.bbclass b/meta-oe/classes/socorro-syms.bbclass index 766a9e627..c2729527d 100644 --- a/meta-oe/classes/socorro-syms.bbclass +++ b/meta-oe/classes/socorro-syms.bbclass | |||
@@ -42,6 +42,16 @@ python symbol_file_preprocess() { | |||
42 | breakpad_sym_file_path = os.path.join(breakpad_syms_dir, sym_file_name) | 42 | breakpad_sym_file_path = os.path.join(breakpad_syms_dir, sym_file_name) |
43 | socorro_sym_file_path = os.path.join(socorro_syms_dir, sym_file_name) | 43 | socorro_sym_file_path = os.path.join(socorro_syms_dir, sym_file_name) |
44 | 44 | ||
45 | create_socorro_sym_file(breakpad_sym_file_path, socorro_sym_file_path) | ||
46 | |||
47 | arrange_socorro_sym_file(socorro_sym_file_path, socorro_syms_dir) | ||
48 | |||
49 | return | ||
50 | } | ||
51 | |||
52 | |||
53 | def create_socorro_sym_file(breakpad_sym_file_path, socorro_sym_file_path): | ||
54 | |||
45 | # In the symbol file, all source files are referenced like the following. | 55 | # In the symbol file, all source files are referenced like the following. |
46 | # FILE 123 /path/to/some/File.cpp | 56 | # FILE 123 /path/to/some/File.cpp |
47 | # Go through all references and replace the file paths with repository | 57 | # Go through all references and replace the file paths with repository |
@@ -56,7 +66,6 @@ python symbol_file_preprocess() { | |||
56 | socorro_sym_file.write(line) | 66 | socorro_sym_file.write(line) |
57 | 67 | ||
58 | return | 68 | return |
59 | } | ||
60 | 69 | ||
61 | 70 | ||
62 | def socorro_file_reference(line): | 71 | def socorro_file_reference(line): |
@@ -162,3 +171,42 @@ def git_repository_path(source_file_path): | |||
162 | 171 | ||
163 | return socorro_reference | 172 | return socorro_reference |
164 | 173 | ||
174 | |||
175 | def arrange_socorro_sym_file(socorro_sym_file_path, socorro_syms_dir): | ||
176 | |||
177 | import re | ||
178 | |||
179 | # Breakpad's minidump_stackwalk needs a certain directory structure in order | ||
180 | # to find correct symbols when extracting a stack trace out of a minidump. | ||
181 | # The directory structure must look like the following. | ||
182 | # YourBinary/<hash>/YourBinary.sym | ||
183 | # YourLibrary.so/<hash>/YourLibrary.so.sym | ||
184 | # To be able to create such structure we need to extract the hash value that | ||
185 | # is found in each symbol file. The header of the symbol file looks | ||
186 | # something like this: | ||
187 | # MODULE Linux x86 A079E473106CE51C74C1C25AF536CCD30 YourBinary | ||
188 | # See | ||
189 | # http://code.google.com/p/google-breakpad/wiki/LinuxStarterGuide | ||
190 | |||
191 | # Create the directory with the same name as the binary. | ||
192 | binary_dir = re.sub("\.sym$", "", socorro_sym_file_path) | ||
193 | if not os.path.exists(binary_dir): | ||
194 | os.makedirs(binary_dir) | ||
195 | |||
196 | # Get the hash from the header of the symbol file. | ||
197 | with open(socorro_sym_file_path, 'r') as socorro_sym_file: | ||
198 | |||
199 | # The hash is the 4th argument of the first line. | ||
200 | sym_file_hash = socorro_sym_file.readline().split()[3] | ||
201 | |||
202 | # Create the hash directory. | ||
203 | hash_dir = os.path.join(binary_dir, sym_file_hash) | ||
204 | if not os.path.exists(hash_dir): | ||
205 | os.makedirs(hash_dir) | ||
206 | |||
207 | # Move the symbol file to the hash directory. | ||
208 | sym_file_name = os.path.basename(socorro_sym_file_path) | ||
209 | os.rename(socorro_sym_file_path, os.path.join(hash_dir, sym_file_name)) | ||
210 | |||
211 | return | ||
212 | |||