* Implemented demangling support for the current gcc ABI. Looks good so far

save for the additional '&'/'*' print_demangled_call() is printing for
  reference/pointer arguments.
* Moved the new demangler and the gcc 2 demangler into the same module
  always supporting both (the right one is chosen). In mixed gcc 2/gcc 4
  environments we obviously need both of them.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30954 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-06-04 01:47:05 +00:00
parent cf2a26ea96
commit 15394881a8
6 changed files with 3966 additions and 221 deletions
+2 -7
View File
@@ -183,8 +183,8 @@ AddFilesToHaikuImage system add-ons kernel busses usb
: <usb>uhci <usb>ohci <usb>ehci ;
AddFilesToHaikuImage system add-ons kernel console : vga_text ;
AddFilesToHaikuImage system add-ons kernel debugger
: $(X86_ONLY)<kdebug>disasm <kdebug>hangman <kdebug>invalidate_on_exit
<kdebug>usb_keyboard <kdebug>run_on_exit ;
: <kdebug>demangle $(X86_ONLY)<kdebug>disasm <kdebug>hangman
<kdebug>invalidate_on_exit <kdebug>usb_keyboard <kdebug>run_on_exit ;
AddFilesToHaikuImage system add-ons kernel file_systems
: $(SYSTEM_ADD_ONS_FILE_SYSTEMS) ;
AddFilesToHaikuImage system add-ons kernel generic
@@ -197,11 +197,6 @@ AddFilesToHaikuImage system add-ons kernel interrupt_controllers
if $(TARGET_ARCH) = x86 {
AddFilesToHaikuImage system add-ons kernel cpu : generic_x86 ;
if $(HAIKU_GCC_VERSION[1]) = 2 {
AddFilesToHaikuImage system add-ons kernel debugger demangle :
<kdebug>gcc2 ;
}
}
# drivers
+3 -29
View File
@@ -2,34 +2,8 @@ SubDir HAIKU_TOP src add-ons kernel debugger demangle ;
UsePrivateHeaders kernel ;
# GCC3/4 only solution (using parts of libsubc++)
if $(HAIKU_GCC_VERSION[1]) >= 3 {
rule ExtractObject
{
SetupKernel $(2) ;
Depends $(1) : $(2) ;
Objects $(1) ;
MakeLocateDebug $(1) ;
}
actions ExtractObject
{
#$(TARGET_AR) $(LINKFLAGS) -o "$(1)" "$(2)" $(LINKLIBS) ;
pwd
echo $(TARGET_AR) -x "$(2)" "$(1)"
}
ExtractObject cp-demangle.o : $(TARGET_STATIC_LIBSUPC++) foo ;
KernelAddon <kdebug>gcc3+ :
gcc3+.cpp
cp-demangle.o
;
}
# GCC2 solution
KernelAddon <kdebug>gcc2 :
KernelAddon <kdebug>demangle :
demangle.cpp
gcc2.cpp
gcc3+.cpp
;
@@ -0,0 +1,84 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "demangle.h"
#include <string.h>
#include <debug.h>
static inline bool
looks_like_gcc3_symbol(const char* symbol)
{
return strncmp(symbol, "_Z", 2) == 0;
}
static const char*
demangle_symbol(const char* mangledName, char* buffer, size_t bufferSize,
bool* _isObjectMethod)
{
// try the gcc3 demangler, if it looks like a gcc3 symbol
const char* demangled = NULL;
if (looks_like_gcc3_symbol(mangledName)) {
demangled = demangle_symbol_gcc3(mangledName, buffer, bufferSize,
_isObjectMethod);
if (demangled != NULL)
return demangled;
}
// fallback is gcc2
return demangle_symbol_gcc2(mangledName, buffer, bufferSize,
_isObjectMethod);
}
static status_t
get_next_argument(uint32* _cookie, const char* mangledName, char* name,
size_t nameSize, int32* _type, size_t* _argumentLength)
{
// try the gcc3 demangler, if it looks like a gcc3 symbol
if (looks_like_gcc3_symbol(mangledName)) {
status_t error = get_next_argument_gcc3(_cookie, mangledName, name,
nameSize, _type, _argumentLength);
if (error == B_OK)
return B_OK;
}
// fallback is gcc2
return get_next_argument_gcc2(_cookie, mangledName, name, nameSize, _type,
_argumentLength);
}
static status_t
std_ops(int32 op, ...)
{
switch (op) {
case B_MODULE_INIT:
case B_MODULE_UNINIT:
return B_OK;
}
return B_BAD_VALUE;
}
static struct debugger_demangle_module_info sModuleInfo = {
{
"debugger/demangle/v1",
0,
std_ops
},
demangle_symbol,
get_next_argument,
};
module_info* modules[] = {
(module_info*)&sModuleInfo,
NULL
};
@@ -0,0 +1,27 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef DEMANGLE_H
#define DEMANGLE_H
#include <SupportDefs.h>
// gcc 2
const char* demangle_symbol_gcc2(const char* name, char* buffer,
size_t bufferSize, bool* _isObjectMethod);
status_t get_next_argument_gcc2(uint32* _cookie, const char* symbol,
char* name, size_t nameSize, int32* _type,
size_t* _argumentLength);
// gcc 3+
const char* demangle_symbol_gcc3(const char* name, char* buffer,
size_t bufferSize, bool* _isObjectMethod);
status_t get_next_argument_gcc3(uint32* _cookie, const char* symbol,
char* name, size_t nameSize, int32* _type,
size_t* _argumentLength);
#endif // DEMANGLE_H
+4 -37
View File
@@ -12,6 +12,8 @@
#include <debug.h>
#include "demangle.h"
//#define TRACE_GCC2_DEMANGLER
#ifdef TRACE_GCC2_DEMANGLER
@@ -420,7 +422,7 @@ get_next_argument_internal(uint32* _cookie, const char* symbol, char* name,
const char*
demangle_symbol(const char* name, char* buffer, size_t bufferSize,
demangle_symbol_gcc2(const char* name, char* buffer, size_t bufferSize,
bool* _isObjectMethod)
{
size_t nameLength;
@@ -467,44 +469,9 @@ demangle_symbol(const char* name, char* buffer, size_t bufferSize,
status_t
get_next_argument(uint32* _cookie, const char* symbol, char* name,
get_next_argument_gcc2(uint32* _cookie, const char* symbol, char* name,
size_t nameSize, int32* _type, size_t* _argumentLength)
{
return get_next_argument_internal(_cookie, symbol, name, nameSize, _type,
_argumentLength, false);
}
static status_t
std_ops(int32 op, ...)
{
#if __GNUC__ != 2
return B_NOT_SUPPORTED;
#else
switch (op) {
case B_MODULE_INIT:
case B_MODULE_UNINIT:
return B_OK;
}
return B_BAD_VALUE;
#endif
}
static struct debugger_demangle_module_info sModuleInfo = {
{
"debugger/demangle/gcc2/v1",
0,
std_ops
},
demangle_symbol,
get_next_argument,
};
module_info *modules[] = {
(module_info *)&sModuleInfo,
NULL
};
File diff suppressed because it is too large Load Diff