OLD | NEW |
1 // Copyright (c) 2006, Google Inc. | 1 // Copyright (c) 2006, Google Inc. |
2 // All rights reserved. | 2 // All rights reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // * Redistributions of source code must retain the above copyright | 8 // * Redistributions of source code must retain the above copyright |
9 // notice, this list of conditions and the following disclaimer. | 9 // notice, this list of conditions and the following disclaimer. |
10 // * Redistributions in binary form must reproduce the above | 10 // * Redistributions in binary form must reproduce the above |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 return; | 126 return; |
127 | 127 |
128 // This code extracts the version and build information from the OS | 128 // This code extracts the version and build information from the OS |
129 CFStringRef vers_path = | 129 CFStringRef vers_path = |
130 CFSTR("/System/Library/CoreServices/SystemVersion.plist"); | 130 CFSTR("/System/Library/CoreServices/SystemVersion.plist"); |
131 CFURLRef sys_vers = | 131 CFURLRef sys_vers = |
132 CFURLCreateWithFileSystemPath(NULL, | 132 CFURLCreateWithFileSystemPath(NULL, |
133 vers_path, | 133 vers_path, |
134 kCFURLPOSIXPathStyle, | 134 kCFURLPOSIXPathStyle, |
135 false); | 135 false); |
136 CFDataRef data; | 136 CFReadStreamRef read_stream = CFReadStreamCreateWithFile(NULL, sys_vers); |
137 SInt32 error; | 137 CFRelease(sys_vers); |
138 CFURLCreateDataAndPropertiesFromResource(NULL, sys_vers, &data, NULL, NULL, | 138 if (!read_stream) { |
139 &error); | |
140 | |
141 if (!data) { | |
142 CFRelease(sys_vers); | |
143 return; | 139 return; |
144 } | 140 } |
145 | 141 if (!CFReadStreamOpen(read_stream)) { |
| 142 CFRelease(read_stream); |
| 143 return; |
| 144 } |
| 145 CFDataRef data = NULL; |
| 146 CFIndex num_bytes_read = 0; |
| 147 const UInt8 *data_bytes = |
| 148 CFReadStreamGetBuffer(read_stream, 0, &num_bytes_read); |
| 149 if (data_bytes) { |
| 150 data = CFDataCreate(NULL, data_bytes, num_bytes_read); |
| 151 } |
| 152 CFReadStreamClose(read_stream); |
| 153 CFRelease(read_stream); |
| 154 if (!data) { |
| 155 return; |
| 156 } |
146 CFDictionaryRef list = static_cast<CFDictionaryRef> | 157 CFDictionaryRef list = static_cast<CFDictionaryRef> |
147 (CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, | 158 (CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, |
148 NULL)); | 159 NULL)); |
| 160 CFRelease(data); |
149 if (!list) { | 161 if (!list) { |
150 CFRelease(sys_vers); | |
151 CFRelease(data); | |
152 return; | 162 return; |
153 } | 163 } |
154 | |
155 CFStringRef build_version = static_cast<CFStringRef> | 164 CFStringRef build_version = static_cast<CFStringRef> |
156 (CFDictionaryGetValue(list, CFSTR("ProductBuildVersion"))); | 165 (CFDictionaryGetValue(list, CFSTR("ProductBuildVersion"))); |
157 CFStringRef product_version = static_cast<CFStringRef> | 166 CFStringRef product_version = static_cast<CFStringRef> |
158 (CFDictionaryGetValue(list, CFSTR("ProductVersion"))); | 167 (CFDictionaryGetValue(list, CFSTR("ProductVersion"))); |
159 string build_str = ConvertToString(build_version); | 168 string build_str = ConvertToString(build_version); |
160 string product_str = ConvertToString(product_version); | 169 string product_str = ConvertToString(product_version); |
161 | 170 |
162 CFRelease(list); | 171 CFRelease(list); |
163 CFRelease(sys_vers); | |
164 CFRelease(data); | |
165 | 172 |
166 strlcpy(build_string_, build_str.c_str(), sizeof(build_string_)); | 173 strlcpy(build_string_, build_str.c_str(), sizeof(build_string_)); |
167 | 174 |
168 // Parse the string that looks like "10.4.8" | 175 // Parse the string that looks like "10.4.8" |
169 os_major_version_ = IntegerValueAtIndex(product_str, 0); | 176 os_major_version_ = IntegerValueAtIndex(product_str, 0); |
170 os_minor_version_ = IntegerValueAtIndex(product_str, 1); | 177 os_minor_version_ = IntegerValueAtIndex(product_str, 1); |
171 os_build_number_ = IntegerValueAtIndex(product_str, 2); | 178 os_build_number_ = IntegerValueAtIndex(product_str, 2); |
172 } | 179 } |
173 | 180 |
174 void MinidumpGenerator::SetTaskContext(breakpad_ucontext_t *task_context) { | 181 void MinidumpGenerator::SetTaskContext(breakpad_ucontext_t *task_context) { |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1575 } else { | 1582 } else { |
1576 info_ptr->validity = MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID; | 1583 info_ptr->validity = MD_BREAKPAD_INFO_VALID_DUMP_THREAD_ID; |
1577 info_ptr->dump_thread_id = handler_thread_; | 1584 info_ptr->dump_thread_id = handler_thread_; |
1578 info_ptr->requesting_thread_id = 0; | 1585 info_ptr->requesting_thread_id = 0; |
1579 } | 1586 } |
1580 | 1587 |
1581 return true; | 1588 return true; |
1582 } | 1589 } |
1583 | 1590 |
1584 } // namespace google_breakpad | 1591 } // namespace google_breakpad |
OLD | NEW |