diff options
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 766a9e6272..c2729527d6 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 | |||
