Skip to content

Commit

Permalink
gcc 3.x fixes and code cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
seppel committed Aug 5, 2002
1 parent 13f8338 commit 881c88d
Show file tree
Hide file tree
Showing 32 changed files with 568 additions and 530 deletions.
34 changes: 17 additions & 17 deletions analyser/analy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -497,9 +497,9 @@ void Analyser::init()
locations = NULL;
symbols = NULL;
symbol_count = location_count = 0;
cur_addr_ops = cur_label_ops = 1;
setLocationTreeOptimizeThreshold(1000);
setSymbolTreeOptimizeThreshold(1000);
cur_addr_ops = cur_label_ops = 1;
cur_func = NULL;
ops_parsed = 0;
next_explored = new InvalidAddress();
Expand Down Expand Up @@ -1151,13 +1151,13 @@ bool Analyser::deleteXRef(Address *from, Address *to)
if ((!validAddress(from, scvalid)) || (!validAddress(to, scvalid))) return false;

Location *a = getLocationByAddress(from);
if (!a) return false;
if (!a) return false;
ht_tree *x = a->xrefs;
if (!x) return false;
if (!x) return false;

DPRINTF("deleted xref %y->%y\n", from, to);
return x->del(to);
return x->del(to);
}

/*
Expand Down Expand Up @@ -1542,7 +1542,7 @@ void Analyser::finish()
{
DPRINTF("the analyser finished (for now).\n");
cur_func = NULL;
delete addr;
delete addr;
addr = new InvalidAddress();
setActive(false);
}
Expand Down Expand Up @@ -1682,8 +1682,8 @@ bool Analyser::gotoAddress(Address *Addr, Address *func)
delete first_explored;
delete last_explored;
delete next_explored;
func = (Address *)func->duplicate();
func = (Address *)func->duplicate();
if (!validCodeAddress(Addr) || explored->contains(Addr)) {
DPRINTF("Address: %y Valid: %d Explored: %d\n", addr, validCodeAddress(addr), explored->contains(addr));
do {
Expand All @@ -1706,10 +1706,10 @@ bool Analyser::gotoAddress(Address *Addr, Address *func)
}
}

if (func->isValid()) {
cur_func = newLocation(func);
setLocationFunction(cur_func, cur_func);
}
if (func->isValid()) {
cur_func = newLocation(func);
setLocationFunction(cur_func, cur_func);
}
delete func;
next_explored = (Address *)explored->findNext(addr);
if (!next_explored) {
Expand Down Expand Up @@ -1865,11 +1865,11 @@ bool Analyser::popAddress(Address **Addr, Address **func)
void Analyser::pushAddress(Address *Addr, Address *func)
{
if (validCodeAddress(Addr)) {
if (!func->isValid()) {
if (cur_func) {
func = cur_func->addr;
}
}
if (!func->isValid()) {
if (cur_func) {
func = cur_func->addr;
}
}
DPRINTF("addr %y (from func %y) pushed\n", Addr, func);
AddressQueueItem *aqi = new AddressQueueItem(Addr, func);
addr_queue->enqueue(aqi);
Expand Down
4 changes: 2 additions & 2 deletions analyser/analy_java.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ branch_enum_t AnalyJavaDisassembler::isBranch(OPCODE *opcode)
|| (strcmp("lookupswitch", opcode_str)==0)) {
return br_jXX;
} else if (strncmp("ret", opcode_str, 3)==0
|| strncmp("ret", opcode_str+1, 3)==0
|| strncmp("athrow", opcode_str, 6)==0) {
|| strncmp("ret", opcode_str+1, 3)==0
|| strncmp("athrow", opcode_str, 6)==0) {
return br_return;
} else if (strncmp("goto", opcode_str, 4)==0) {
return br_jump;
Expand Down
88 changes: 44 additions & 44 deletions analyser/class_analy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@
void ClassAnalyser::init(ht_class_shared_data *Class_shared, ht_streamfile *File)
{
class_shared = Class_shared;
file = File;
file = File;

Analyser::init();

initialized->done();
delete initialized;
initialized = class_shared->initialized;
initialized->done();
delete initialized;
initialized = class_shared->initialized;
/////////////

setLocationTreeOptimizeThreshold(100);
Expand Down Expand Up @@ -80,46 +80,46 @@ void ClassAnalyser::done()
void ClassAnalyser::beginAnalysis()
{
char buffer[1024];
char *b = buffer;
*(b++) = ';'; *(b++) = ' ';
b = java_demangle_flags(b, class_shared->flags);
b += ht_snprintf(b, 1024, "%s %s", (class_shared->flags & jACC_INTERFACE)?"interface":"class", class_shared->classinfo.thisclass);
if (class_shared->classinfo.superclass) {
b += ht_snprintf(b, 1024, " extends %s", class_shared->classinfo.superclass);
}
if (class_shared->classinfo.interfaces) {
b += ht_snprintf(b, 1024, " implements");
int count = class_shared->classinfo.interfaces->count();
for (int i=0; i<count; i++) {
b += ht_snprintf(b, 1024, " %y%c", class_shared->classinfo.interfaces->get(i), (i+1<count)?',':' ');
}
}
b += ht_snprintf(b, 1024, " {");
char *b = buffer;
*(b++) = ';'; *(b++) = ' ';
b = java_demangle_flags(b, class_shared->flags);
b += ht_snprintf(b, 1024, "%s %s", (class_shared->flags & jACC_INTERFACE)?"interface":"class", class_shared->classinfo.thisclass);
if (class_shared->classinfo.superclass) {
b += ht_snprintf(b, 1024, " extends %s", class_shared->classinfo.superclass);
}
if (class_shared->classinfo.interfaces) {
b += ht_snprintf(b, 1024, " implements");
int count = class_shared->classinfo.interfaces->count();
for (int i=0; i<count; i++) {
b += ht_snprintf(b, 1024, " %y%c", class_shared->classinfo.interfaces->get(i), (i+1<count)?',':' ');
}
}
b += ht_snprintf(b, 1024, " {");

Address *a = createAddress32(0);
addComment(a, 0, "");
addComment(a, 0, "");
addComment(a, 0, ";********************************************************");
addComment(a, 0, buffer);
addComment(a, 0, ";********************************************************");
delete a;
if (class_shared->methods) {
ClassMethod *cm = NULL;
ht_data *value;
while ((cm = (ClassMethod*)class_shared->methods->enum_next(&value, cm))) {
Address *a = createAddress32(cm->start);
char buffer2[1024];
java_demangle(buffer2, class_shared->classinfo.thisclass, cm->name, cm->type, cm->flags);
ht_snprintf(buffer, 1024, "; %s", buffer2);
addComment(a, 0, "");
delete a;
if (class_shared->methods) {
ClassMethod *cm = NULL;
ht_data *value;
while ((cm = (ClassMethod*)class_shared->methods->enum_next(&value, cm))) {
Address *a = createAddress32(cm->start);
char buffer2[1024];
java_demangle(buffer2, class_shared->classinfo.thisclass, cm->name, cm->type, cm->flags);
ht_snprintf(buffer, 1024, "; %s", buffer2);
addComment(a, 0, "");
addComment(a, 0, ";----------------------------------------------");
addComment(a, 0, buffer);
addComment(a, 0, buffer);
addComment(a, 0, ";----------------------------------------------");
addAddressSymbol(a, cm->name, label_func);
pushAddress(a, a);
pushAddress(a, a);
delete a;
}
}
}
}
setLocationTreeOptimizeThreshold(1000);
setSymbolTreeOptimizeThreshold(1000);

Expand Down Expand Up @@ -281,12 +281,12 @@ int ClassAnalyser::queryConfig(int mode)
Address *ClassAnalyser::fileofsToAddress(FILEOFS fileaddr)
{
Address *a = createAddress32(fileaddr);
if (validAddress(a, scvalid)) {
return a;
} else {
delete a;
return NULL;
}
if (validAddress(a, scvalid)) {
return a;
} else {
delete a;
return NULL;
}
}

/*
Expand All @@ -299,10 +299,10 @@ bool ClassAnalyser::validAddress(Address *Addr, tsectype action)
case scinitialized:
case sccode:
return class_shared->initialized->contains(Addr);
default:
default:

return true;
}
return true;
}
}


2 changes: 1 addition & 1 deletion analyser/class_analy.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
class ClassAnalyser: public Analyser {
public:
ht_class_shared_data *class_shared;
ht_streamfile *file;
ht_streamfile *file;

void init(ht_class_shared_data *Class_shared, ht_streamfile *File);
int load(ht_object_stream *f);
Expand Down
2 changes: 1 addition & 1 deletion analyser/pe_analy.cc
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ bool PEAnalyser::convertAddressToRVA(Address *addr, RVA *r)
} else if (oid == ATOM_ADDRESS_ALPHA_FLAT_32) {
*r = ((AddressAlphaFlat32*)addr)->addr - pe_shared->pe32.header_nt.image_base;
return true;
}
}
return false;
}

Expand Down
8 changes: 4 additions & 4 deletions analyser/stddata.cc
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ static void areafindprev(area_s *p, Object *from, Object **res)
{
//FIXME ??:
if (p) {
if (!from || from->compareTo(p->end) >= 0) {
if (!from || from->compareTo(p->end) >= 0) {
*res = p->end;
areafindprev(p->right, from, res);
} else if (from->compareTo(p->start) < 0) {
} else if (from->compareTo(p->start) < 0) {
areafindprev(p->left, from, res);
} else *res = from;
};
Expand Down Expand Up @@ -235,9 +235,9 @@ static void areadump(int sp, area_s *A)
{
if (A) {
for (int i=0; i<sp; i++) printf(" ");
char buf[1024];
char buf[1024];
ht_snprintf(buf, sizeof buf, "%y %y\n", A->start, A->end);
printf(buf);
printf(buf);
++sp;++sp;
areadump(sp, A->left);
areadump(sp, A->right);
Expand Down
30 changes: 15 additions & 15 deletions class.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ typedef struct _attrib_info {
u2 name;
u4 len;
union {
struct {
struct {
u2 max_stack;
u2 max_locals;
u4 len;
u4 start;
} code;
u4 len;
u4 start;
} code;
};
} attrib_info;

Expand Down Expand Up @@ -133,14 +133,14 @@ typedef struct _classfile {
struct ht_class_shared_data {
ht_stree *methods;
classfile *file;
Area *valid;
Area *initialized;
int flags;
struct {
char *thisclass;
char *superclass;
ht_list *interfaces;
} classinfo;
Area *valid;
Area *initialized;
int flags;
struct {
char *thisclass;
char *superclass;
ht_list *interfaces;
} classinfo;
};

extern ht_class_shared_data *class_read(ht_streamfile *);
Expand All @@ -164,9 +164,9 @@ class ClassMethod: public ht_data {
public:
char *name;
char *type;
ClassAddress start;
UINT length;
int flags;
ClassAddress start;
UINT length;
int flags;
ClassMethod(char *name, char *type, ClassAddress start, UINT length, int flags);
virtual ~ClassMethod();
virtual int compareTo(Object *o);
Expand Down
14 changes: 7 additions & 7 deletions classimg.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ ht_view *htclassimage_init(bounds *b, ht_streamfile *file, ht_format_group *grou
ht_analy_sub *analy=new ht_analy_sub();
Address *low = a->createAddress32(0);

Address *high = (Address*)class_shared->valid->findPrev(NULL);
if (!high) {
high = a->createAddress32(0);
} else {
high = (Address *)high->duplicate();
high->add(-1);
}
Address *high = (Address*)class_shared->valid->findPrev(NULL);
if (!high) {
high = a->createAddress32(0);
} else {
high = (Address *)high->duplicate();
high->add(-1);
}
analy->init(file, v, a, low, high);
delete low;
delete high;
Expand Down
Loading

0 comments on commit 881c88d

Please sign in to comment.