Skip to content

Commit

Permalink
remove native compiler support and unused functions
Browse files Browse the repository at this point in the history
* remove broken native compiler (pgcc) support

* remove unused demangling functions
  • Loading branch information
kupsch committed Oct 13, 2020
1 parent cb7fe4b commit e4817fe
Show file tree
Hide file tree
Showing 20 changed files with 14 additions and 373 deletions.
10 changes: 1 addition & 9 deletions common/src/freebsdHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,15 +239,7 @@ inline int P_rexec(char **ahost, u_short inport, char *user,
}
#endif

/* The following values are taken from demangle.h in binutils */
#define DMGL_PARAMS (1 << 0) /* Include function args */
#define DMGL_ANSI (1 << 1) /* Include const, volatile, etc */

#define DMGL_ARM (1 << 11) /* Use C++ ARM name mangling */

extern "C" char *cplus_demangle(char *, int);
extern void dedemangle( char * demangled, char * dedemangled );
extern char * COMMON_EXPORT P_cplus_demangle( const char * symbol, bool nativeCompiler,
extern char * COMMON_EXPORT P_cplus_demangle( const char * symbol,
bool includeTypes = false );

inline int P_mkdir(const char *pathname, mode_t mode) {
Expand Down
3 changes: 1 addition & 2 deletions common/src/freebsdKludges.C
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ using std::map;

#include "symbolDemangleWithCache.h"

char * P_cplus_demangle( const char * symbol, bool /*nativeCompiler*/,
bool includeTypes )
char * P_cplus_demangle( const char * symbol, bool includeTypes )
{
char *demangled = symbol_demangle_with_cache(symbol, includeTypes);
return demangled;
Expand Down
4 changes: 1 addition & 3 deletions common/src/linuxHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ inline int P_rexec(char **ahost, u_short inport, char *user,

#define DMGL_ARM (1 << 11) /* Use C++ ARM name mangling */

extern "C" char *cplus_demangle(char *, int);
extern void dedemangle( char * demangled, char * dedemangled );
extern COMMON_EXPORT char * P_cplus_demangle( const char * symbol, bool nativeCompiler,
extern COMMON_EXPORT char * P_cplus_demangle( const char * symbol,
bool includeTypes = false );

inline int P_mkdir(const char *pathname, mode_t mode) {
Expand Down
3 changes: 1 addition & 2 deletions common/src/linuxKludges.C
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ unsigned long long PDYN_mulMillion(unsigned long long in) {

#include "symbolDemangleWithCache.h"

char * P_cplus_demangle( const char * symbol, bool /*nativeCompiler*/,
bool includeTypes )
char * P_cplus_demangle( const char * symbol, bool includeTypes )
{
char *demangled = symbol_demangle_with_cache(symbol, includeTypes);
return demangled;
Expand Down
2 changes: 1 addition & 1 deletion common/src/ntHeaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ inline int P_unlink(const char *pathname) {
}
extern char *cplus_demangle(char *, int, bool );
/* We can't export this, it's inline. */
inline char * P_cplus_demangle( const char * symbol, bool /* nativeCompiler */, bool includeTypes = false ) {
inline char * P_cplus_demangle( const char * symbol, bool includeTypes = false ) {
return cplus_demangle( (char *)symbol, 0, includeTypes );
}

Expand Down
140 changes: 0 additions & 140 deletions common/src/string-regex.C
Original file line number Diff line number Diff line change
Expand Up @@ -39,146 +39,6 @@
#endif


/* This doesn't actually belong here. */
void dedemangle( char * demangled, char * result )
{
/* Lifted from Jeffrey Odom. Code reformatted so
I could figure out how to eliminate compiler warnings.
Adjusted to handle spaces inside templates intelligently.
We cut off everything after the first l-paren, so we don't
need to worry about the space after the parameters but
before the 'const'. */
char * resultBegins = NULL;
char * resultEnds = NULL;
// starts with open paren, is a member function
if ( demangled[0] == '(' &&
strstr( demangled, "::" ) != NULL)
{
int depth = 0, i = 0;
for (;;)
{
if (demangled[i] == '\0')
break;
if (demangled[i] == '(')
depth++;
if (demangled[i] == ')') {
depth--;
if (!depth)
break;
}
i++;
}
if (demangled[i] != '\0') {
resultBegins = demangled+i+1;
if (resultBegins[0] == ':' && resultBegins[1] == ':')
resultBegins += 2;
resultEnds = strrchr(resultBegins, ' ');
if (resultEnds)
*resultEnds = '\0';
}
demangled = resultBegins;
}
if ( strrchr( demangled, '(' ) != NULL )
{
/* Strip off return types, if any. Be careful not to
pull off [template?/]class/namespace information.
The only space that matters is the one that's _not_
inside a template, so skip the templates and cut at the
first space. We can ignore 'operator[<[<]|>[>]]' because
we'll stop before we reach it.
Caveat: conversion operators (e.g., "operator bool") have
spaces in the function name. Right now we deal with this
specifically (is the function "operator *"?). Could be
altered to after the last template but before the last
left parenthesis. (Instead of next, for "operator ()".)
*/

resultBegins = demangled;
int stack = 0; bool inTemplate = false;
unsigned int offset;
int lastColon = 0;
for ( offset = 0; offset < strlen( resultBegins ); offset++ )
{
if ( resultBegins[offset] == '<' )
{
stack++;
inTemplate = true;
}
else if ( resultBegins[offset] == '>' )
{
stack--;
if ( stack == 0 )
{
inTemplate = false;
}
}
else if ( !inTemplate && resultBegins[offset] == '(' )
{
/* We've stumbled on something without a return value. */

offset = 0;
resultBegins = demangled;
break;
}
else if ( !inTemplate && resultBegins[offset] == ' ' )
{
/* FIXME: verify that the space isn't in the function name,
e.g., 'operator bool'. If the first space we meet _is_
a function name, it doesn't have a(n explicit) return type. */
if ( strstr( &(resultBegins[ lastColon + 1 ]), "operator " ) == resultBegins + lastColon + 1 )
{
resultBegins = demangled;
offset = 0;
}
else
{
resultBegins = &(resultBegins[offset + 1]);
offset++;
}

break;
}
else if ( !inTemplate && resultBegins[offset] == ':' )
{
lastColon = offset;
}
} /* end template elimination loop */

/* Scan past the function name; the first left parenthesis
not in in a template declaration starts the function arguments. */
stack = 0; inTemplate = false;
for ( ; offset < strlen( resultBegins ); offset++ )
{
if ( resultBegins[offset] == '<' )
{
stack++;
inTemplate = true;
}
if ( resultBegins[offset] == '>' )
{
stack--;
if ( stack == 0 ) { inTemplate = false; }
}
if ( !inTemplate && resultBegins[offset] == '(' )
{
resultEnds = const_cast<char *>(&(resultBegins[offset]));
* resultEnds = '\0';
break;
}
} /* end template elimination loop */
} /* end if a function prototype */
else
{
/* Assume demangle OK. */
resultBegins = demangled;
}

strcpy( result, resultBegins );
} /* end dedemangle */


// Use POSIX regular expression pattern matching to check if string s matches
// the pattern in this string
bool regexEquiv(const char *str_, const char *s, bool checkCase )
Expand Down
6 changes: 0 additions & 6 deletions dyninstAPI/h/BPatch_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,6 @@ class BPATCH_DLL_EXPORT BPatch_module: public BPatch_sourceObj{

bool isSharedLib();

// BPatch_module::isNativeCompiler
// Returns true if this module was compiled with a native compiler for
// the particular platform

bool isNativeCompiler();


// BPatch_module::getAddressRanges
//
Expand Down
6 changes: 0 additions & 6 deletions dyninstAPI/src/BPatch_module.C
Original file line number Diff line number Diff line change
Expand Up @@ -792,12 +792,6 @@ Dyninst::SymtabAPI::Module *Dyninst::SymtabAPI::convert(const BPatch_module *m)
return m->mod->pmod()->mod();
}

bool BPatch_module::isNativeCompiler()
{
if (!mod) return false;
return mod->obj()->parse_img()->isNativeCompiler();
}

size_t BPatch_module::getAddressWidth()
{
if (!mod) return 0;
Expand Down
1 change: 0 additions & 1 deletion dyninstAPI/src/image.C
Original file line number Diff line number Diff line change
Expand Up @@ -1428,7 +1428,6 @@ image::image(fileDescriptor &desc,
is_libdyninstRT(false),
is_a_out(false),
main_call_addr_(0),
nativeCompiler(false),
linkedFile(NULL),
#if defined(os_linux) || defined(os_freebsd)
archive(NULL),
Expand Down
4 changes: 0 additions & 4 deletions dyninstAPI/src/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,6 @@ class image : public codeRange {

bool getExecCodeRanges(std::vector<std::pair<Address, Address> > &ranges);

bool isNativeCompiler() const { return nativeCompiler; }

// Return symbol table information
SymtabAPI::Symbol *symbol_info(const std::string& symbol_name);
// And used for finding inferior heaps.... hacky, but effective.
Expand Down Expand Up @@ -489,8 +487,6 @@ class image : public codeRange {
bool is_a_out;
Address main_call_addr_; // address of call to main()

bool nativeCompiler;

// data from the symbol table
SymtabAPI::Symtab *linkedFile;
#if defined(os_linux) || defined(os_freebsd)
Expand Down
7 changes: 0 additions & 7 deletions dyninstAPI/src/mapped_module.C
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,6 @@ mapped_object *mapped_module::obj() const
return obj_;
}

bool mapped_module::isNativeCompiler() const
{
// This should probably be per-module info at some point; some
// .o's might be compiled native, and others not.
return pmod()->mod()->exec()->isNativeCompiler();
}

SymtabAPI::supportedLanguages mapped_module::language() const
{
return pmod()->language();
Expand Down
2 changes: 0 additions & 2 deletions dyninstAPI/src/mapped_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ class mapped_module {
AddressSpace *proc() const;

// A lot of stuff shared with the internal module
// Were we compiled with the native compiler?
bool isNativeCompiler() const;

SymtabAPI::supportedLanguages language() const;

Expand Down
6 changes: 1 addition & 5 deletions symlite/src/SymLite-elf.C
Original file line number Diff line number Diff line change
Expand Up @@ -366,11 +366,7 @@ std::string SymElf::getDemangledName(const Symbol_t &sym)

if (cache[cache_index].demangled_name)
return std::string(cache[cache_index].demangled_name);
char *res = P_cplus_demangle(name, false, true);
if (!res) {
//Try native demangler
res = P_cplus_demangle(name, true, true);
}
char *res = P_cplus_demangle(name, true);

cache[cache_index].demangled_name = res ? res : name;
return cache[cache_index].demangled_name;
Expand Down
9 changes: 0 additions & 9 deletions symtabAPI/h/Symtab.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ class SYMTAB_EXPORT Symtab : public LookupInterface,
bool isData(const Offset where) const;
bool isValidOffset(const Offset where) const;

bool isNativeCompiler() const;
bool getMappedRegions(std::vector<Region *> &mappedRegs) const;

/***** Line Number Information *****/
Expand Down Expand Up @@ -435,12 +434,6 @@ class SYMTAB_EXPORT Symtab : public LookupInterface,

void setModuleLanguages(dyn_hash_map<std::string, supportedLanguages> *mod_langs);

bool buildDemangledName( const std::string &mangled,
std::string &pretty,
std::string &typed,
bool nativeCompiler,
supportedLanguages lang );

// Change the type of a symbol after the fact
bool changeType(Symbol *sym, Symbol::SymbolType oldType);

Expand Down Expand Up @@ -513,8 +506,6 @@ class SYMTAB_EXPORT Symtab : public LookupInterface,
bool is_a_out;
Offset main_call_addr_; // address of call to main()

bool nativeCompiler;

unsigned address_width_;
char *code_ptr_;
char *data_ptr_;
Expand Down
48 changes: 1 addition & 47 deletions symtabAPI/src/Object-elf.C
Original file line number Diff line number Diff line change
Expand Up @@ -3054,49 +3054,6 @@ void Object::get_valid_memory_areas(Elf_X &elf) {
}
}

//
// parseCompilerType - parse for compiler that was used to generate object
//
//
//
#if defined(os_linux)

// Differentiating between g++ and pgCC by stabs info
// will not work; the gcc-compiled object files that
// get included at link time will fill in the N_OPT stabs line. Instead,
// look for "pgCC_compiled." symbols.
bool parseCompilerType(Object *objPtr) {
dyn_c_hash_map<string, std::vector<Symbol *> > *syms = objPtr->getAllSymbols();
return syms->contains("pgCC_compiled.");
}

#else
bool parseCompilerType(Object *objPtr)
{
stab_entry *stabptr = objPtr->get_stab_info();
const char *next_stabstr = stabptr->getStringBase();

for (unsigned int i=0; i < stabptr->count(); ++i) {
// if (stabstrs) bperr("parsing #%d, %s\n", stabptr->type(i), stabptr->name(i));
switch (stabptr->type(i)) {

case N_UNDF: /* start of object file */
/* value contains offset of the next string table for next module */
// assert(stabptr.nameIdx(i) == 1);
stabptr->setStringBase(next_stabstr);
next_stabstr = stabptr->getStringBase() + stabptr->val(i);
break;

case N_OPT: /* Compiler options */
delete stabptr;
return false;
}
}
delete stabptr;
return false; // Shouldn't happen - maybe N_OPT stripped
}
#endif


#if (defined(os_linux) || defined(os_freebsd))

Expand Down Expand Up @@ -4826,10 +4783,7 @@ void Object::parseStabTypes() {
// bperr("stab #%d = %s\n", i, ptr);
// may be nothing to parse - XXX jdd 5/13/99

if (parseCompilerType(this))
temp = parseStabString(mod, mostRecentLinenum, (char *) ptr, stabptr->val(i), &commonBlock->asCommonType());
else
temp = parseStabString(mod, stabptr->desc(i), (char *) ptr, stabptr->val(i), &commonBlock->asCommonType());
temp = parseStabString(mod, stabptr->desc(i), (char *) ptr, stabptr->val(i), &commonBlock->asCommonType());
if (temp.length()) {
//Error parsing the stabstr, return should be \0
// //bperr( "Stab string parsing ERROR!! More to parse: %s\n",
Expand Down

0 comments on commit e4817fe

Please sign in to comment.