OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/mac/foundation_util.h" | 5 #include "base/mac/foundation_util.h" |
6 | 6 |
| 7 #include <dlfcn.h> |
7 #include <stdlib.h> | 8 #include <stdlib.h> |
8 #include <string.h> | 9 #include <string.h> |
9 | 10 |
10 #include "base/file_path.h" | 11 #include "base/file_path.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "base/mac/scoped_cftyperef.h" | 13 #include "base/mac/scoped_cftyperef.h" |
13 #include "base/sys_string_conversions.h" | 14 #include "base/sys_string_conversions.h" |
14 | 15 |
15 namespace base { | 16 namespace base { |
16 namespace mac { | 17 namespace mac { |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 !it->compare(it->length() - kExtLength, kExtLength, kExt, kExtLength)) | 194 !it->compare(it->length() - kExtLength, kExtLength, kExt, kExtLength)) |
194 return FilePath(bundle_name); | 195 return FilePath(bundle_name); |
195 | 196 |
196 // Separate this component from the next one. | 197 // Separate this component from the next one. |
197 bundle_name += '/'; | 198 bundle_name += '/'; |
198 } | 199 } |
199 | 200 |
200 return FilePath(); | 201 return FilePath(); |
201 } | 202 } |
202 | 203 |
| 204 bool GetModulePathForSymbol(FilePath* path, const void* symbol) { |
| 205 Dl_info info; |
| 206 if (dladdr(symbol, &info) == 0) |
| 207 return false; |
| 208 *path = FilePath(info.dli_fname); |
| 209 return true; |
| 210 } |
| 211 |
203 CFTypeRef GetValueFromDictionary(CFDictionaryRef dict, | 212 CFTypeRef GetValueFromDictionary(CFDictionaryRef dict, |
204 CFStringRef key, | 213 CFStringRef key, |
205 CFTypeID expected_type) { | 214 CFTypeID expected_type) { |
206 CFTypeRef value = CFDictionaryGetValue(dict, key); | 215 CFTypeRef value = CFDictionaryGetValue(dict, key); |
207 if (!value) | 216 if (!value) |
208 return value; | 217 return value; |
209 | 218 |
210 if (CFGetTypeID(value) != expected_type) { | 219 if (CFGetTypeID(value) != expected_type) { |
211 ScopedCFTypeRef<CFStringRef> expected_type_ref( | 220 ScopedCFTypeRef<CFStringRef> expected_type_ref( |
212 CFCopyTypeIDDescription(expected_type)); | 221 CFCopyTypeIDDescription(expected_type)); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey)); | 344 CFDictionaryGetValue(user_info.get(), kCFErrorDescriptionKey)); |
336 } | 345 } |
337 o << "Code: " << CFErrorGetCode(err) | 346 o << "Code: " << CFErrorGetCode(err) |
338 << " Domain: " << CFErrorGetDomain(err) | 347 << " Domain: " << CFErrorGetDomain(err) |
339 << " Desc: " << desc.get(); | 348 << " Desc: " << desc.get(); |
340 if(errorDesc) { | 349 if(errorDesc) { |
341 o << "(" << errorDesc << ")"; | 350 o << "(" << errorDesc << ")"; |
342 } | 351 } |
343 return o; | 352 return o; |
344 } | 353 } |
OLD | NEW |