BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / debugger / demangle / demangle.cpp
blob60c3626176a48c855fac38ce4cb3f6e0437d90c9
1 /*
2 * Copyright 2009-2011, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
6 #include "demangle.h"
8 #include <string.h>
10 #ifdef _KERNEL_MODE
11 # include <debug.h>
12 #endif
15 static inline bool
16 looks_like_gcc3_symbol(const char* symbol)
18 return strncmp(symbol, "_Z", 2) == 0;
22 const char*
23 demangle_symbol(const char* mangledName, char* buffer, size_t bufferSize,
24 bool* _isObjectMethod)
26 // try the gcc3 demangler, if it looks like a gcc3 symbol
27 const char* demangled = NULL;
28 if (looks_like_gcc3_symbol(mangledName)) {
29 demangled = demangle_symbol_gcc3(mangledName, buffer, bufferSize,
30 _isObjectMethod);
31 if (demangled != NULL)
32 return demangled;
35 // fallback is gcc2
36 return demangle_symbol_gcc2(mangledName, buffer, bufferSize,
37 _isObjectMethod);
41 status_t
42 get_next_argument(uint32* _cookie, const char* mangledName, char* name,
43 size_t nameSize, int32* _type, size_t* _argumentLength)
45 // try the gcc3 demangler, if it looks like a gcc3 symbol
46 if (looks_like_gcc3_symbol(mangledName)) {
47 status_t error = get_next_argument_gcc3(_cookie, mangledName, name,
48 nameSize, _type, _argumentLength);
49 if (error == B_OK)
50 return B_OK;
53 // fallback is gcc2
54 return get_next_argument_gcc2(_cookie, mangledName, name, nameSize, _type,
55 _argumentLength);
59 #ifdef _KERNEL_MODE
61 static status_t
62 std_ops(int32 op, ...)
64 switch (op) {
65 case B_MODULE_INIT:
66 case B_MODULE_UNINIT:
67 return B_OK;
70 return B_BAD_VALUE;
74 static struct debugger_demangle_module_info sModuleInfo = {
76 "debugger/demangle/v1",
78 std_ops
81 demangle_symbol,
82 get_next_argument,
85 module_info* modules[] = {
86 (module_info*)&sModuleInfo,
87 NULL
90 #endif // _KERNEL_MODE