зеркало из https://github.com/mozilla/pjs.git
bug #15906: added symbol_name parameter to GC_address_to_source, instead of relying on traceback table.
This commit is contained in:
Родитель
0de8f74961
Коммит
1d48510a31
|
@ -13,6 +13,7 @@ struct CodeLocation {
|
|||
CodeLocation* mNext;
|
||||
char* mCodeAddr;
|
||||
UInt32 mFileOffset;
|
||||
char mSymbolName[256];
|
||||
char mFileName[256];
|
||||
|
||||
CodeLocation() : mNext(NULL), mCodeAddr(NULL), mFileOffset(0)
|
||||
|
@ -31,7 +32,7 @@ struct CodeLocationCache {
|
|||
CodeLocationCache();
|
||||
|
||||
CodeLocation* findLocation(char* codeAddr);
|
||||
void saveLocation(char* codeAddr, char fileName[256], UInt32 fileOffset);
|
||||
void saveLocation(char* codeAddr, char symbolName[256], char fileName[256], UInt32 fileOffset);
|
||||
};
|
||||
|
||||
CodeLocationCache::CodeLocationCache()
|
||||
|
@ -69,7 +70,7 @@ CodeLocation* CodeLocationCache::findLocation(char* codeAddr)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void CodeLocationCache::saveLocation(char* codeAddr, char fileName[256], UInt32 fileOffset)
|
||||
void CodeLocationCache::saveLocation(char* codeAddr, char symbolName[256], char fileName[256], UInt32 fileOffset)
|
||||
{
|
||||
CodeLocation** link = mLastLink;
|
||||
CodeLocation* location = *link;
|
||||
|
@ -85,6 +86,7 @@ void CodeLocationCache::saveLocation(char* codeAddr, char fileName[256], UInt32
|
|||
// save the specified location.
|
||||
location->mCodeAddr = codeAddr;
|
||||
location->mFileOffset = fileOffset;
|
||||
::strcpy(location->mSymbolName, symbolName);
|
||||
::strcpy(location->mFileName, fileName);
|
||||
}
|
||||
|
||||
|
@ -182,7 +184,7 @@ void GC_unregister_fragment(char* dataStart, char* dataEnd,
|
|||
GC_remove_roots(dataStart, dataEnd);
|
||||
}
|
||||
|
||||
int GC_address_to_source(char* codeAddr, char fileName[256], UInt32* fileOffset)
|
||||
int GC_address_to_source(char* codeAddr, char symbolName[256], char fileName[256], UInt32* fileOffset)
|
||||
{
|
||||
CodeFragment** link = find_fragment(codeAddr);
|
||||
if (link != NULL) {
|
||||
|
@ -196,15 +198,16 @@ int GC_address_to_source(char* codeAddr, char fileName[256], UInt32* fileOffset)
|
|||
// see if this is a cached location.
|
||||
CodeLocation* location = fragment->mLocations.findLocation(codeAddr);
|
||||
if (location != NULL) {
|
||||
::strcpy(symbolName, location->mSymbolName);
|
||||
::strcpy(fileName, location->mFileName);
|
||||
*fileOffset = location->mFileOffset;
|
||||
return 1;
|
||||
}
|
||||
sym_file* symbols = fragment->mSymbols;
|
||||
if (symbols != NULL) {
|
||||
if (get_source(symbols, UInt32(codeAddr - fragment->mCodeStart), fileName, fileOffset)) {
|
||||
if (get_source(symbols, UInt32(codeAddr - fragment->mCodeStart), symbolName, fileName, fileOffset)) {
|
||||
// save this location in the per-fragment cache.
|
||||
fragment->mLocations.saveLocation(codeAddr, fileName, *fileOffset);
|
||||
fragment->mLocations.saveLocation(codeAddr, symbolName, fileName, *fileOffset);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
gc_fragments.h
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __FILES__
|
||||
#include <Files.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void GC_register_fragment(char* dataStart, char* dataEnd,
|
||||
char* codeStart, char* codeEnd,
|
||||
const FSSpec* fragmentSpec);
|
||||
|
||||
void GC_unregister_fragment(char* dataStart, char* dataEnd,
|
||||
char* codeStart, char* codeEnd);
|
||||
|
||||
int GC_address_to_source(char* codeAddr, char fileName[256], UInt32* fileOffset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
|
@ -807,23 +807,25 @@ static char* pc2name(word pc, char name[], long size)
|
|||
}
|
||||
|
||||
extern void MWUnmangle(const char *mangled_name, char *unmangled_name, size_t buffersize);
|
||||
extern int GC_address_to_source(char* codeAddr, char fileName[256], UInt32* fileOffset);
|
||||
extern int GC_address_to_source(char* codeAddr, char symbolName[256], char fileName[256], UInt32* fileOffset);
|
||||
|
||||
void GC_print_callers(struct callinfo info[NFRAMES])
|
||||
{
|
||||
register int i;
|
||||
UInt32 file_offset;
|
||||
static char name[1024], unmangled_name[1024], file_name[256];
|
||||
static char symbol_name[1024], unmangled_name[1024], file_name[256];
|
||||
|
||||
GC_err_printf0("Callers at location:\n");
|
||||
for (i = 0; i < NFRAMES; i++) {
|
||||
if (info[i].ci_pc == 0) break;
|
||||
pc2name(info[i].ci_pc, name, sizeof(name));
|
||||
MWUnmangle(name, unmangled_name, sizeof(unmangled_name));
|
||||
if (GC_address_to_source((char*)info[i].ci_pc, file_name, &file_offset))
|
||||
if (GC_address_to_source((char*)info[i].ci_pc, symbol_name, file_name, &file_offset)) {
|
||||
MWUnmangle(symbol_name, unmangled_name, sizeof(unmangled_name));
|
||||
GC_err_printf3("%s[%s,%ld]\n", unmangled_name, file_name, file_offset);
|
||||
else
|
||||
} else {
|
||||
pc2name(info[i].ci_pc, symbol_name, sizeof(symbol_name));
|
||||
MWUnmangle(symbol_name, unmangled_name, sizeof(unmangled_name));
|
||||
GC_err_printf2("%s(%08X)\n", unmangled_name, info[i].ci_pc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -249,7 +249,7 @@ inline UInt32 delta(UInt32 x, UInt32 y)
|
|||
return (y - x);
|
||||
}
|
||||
|
||||
int get_source(sym_file* symbols, UInt32 codeOffset, char fileName[256], UInt32* fileOffset)
|
||||
int get_source(sym_file* symbols, UInt32 codeOffset, char symbolName[256], char fileName[256], UInt32* fileOffset)
|
||||
{
|
||||
const DiskSymbolHeaderBlock& header = symbols->mHeader;
|
||||
const ResourceTableEntry& codeEntry = symbols->mCodeEntry;
|
||||
|
@ -265,14 +265,20 @@ int get_source(sym_file* symbols, UInt32 codeOffset, char fileName[256], UInt32*
|
|||
UInt32 moduleIndex = (i % modulesPerPage);
|
||||
symbols->seek((header.dshb_mte.dti_first_page + modulePage) * header.dshb_page_size + moduleIndex * sizeof(ModulesTableEntry));
|
||||
if (symbols->read(&moduleEntry, sizeof(moduleEntry)) == sizeof(moduleEntry)) {
|
||||
const UInt8* moduleName = symbols->getName(moduleEntry.mte_nte_index);
|
||||
// printf("module name = %#s\n", moduleName);
|
||||
if (isMeatyModule(moduleEntry) && (codeOffset >= moduleEntry.mte_res_offset) && (codeOffset - moduleEntry.mte_res_offset) < moduleEntry.mte_size) {
|
||||
FileReferenceTableEntry frte;
|
||||
if (getFileReferenceTableEntry(symbols, moduleEntry.mte_imp_fref, &frte)) {
|
||||
UInt32 length;
|
||||
// get the name of the symbol.
|
||||
const UInt8* moduleName = symbols->getName(moduleEntry.mte_nte_index);
|
||||
// printf("module name = %#s\n", moduleName);
|
||||
// trim off the leading "."
|
||||
length = moduleName[0] - 1;
|
||||
BlockMoveData(moduleName + 2, symbolName, length);
|
||||
symbolName[length] = '\0';
|
||||
// get the name of the file.
|
||||
const UInt8* name = symbols->getName(frte.frte_fn.nte_index);
|
||||
UInt32 length = name[0];
|
||||
length = name[0];
|
||||
BlockMoveData(name + 1, fileName, length);
|
||||
fileName[length] = '\0';
|
||||
// printf("file name = %s\n", fileName);
|
||||
|
|
|
@ -49,7 +49,7 @@ typedef struct sym_file sym_file;
|
|||
sym_file* open_sym_file(const FSSpec* symSpec);
|
||||
void close_sym_file(sym_file* symbols);
|
||||
|
||||
int get_source(sym_file* symbols, UInt32 codeOffset, char fileName[256], UInt32* fileOffset);
|
||||
int get_source(sym_file* symbols, UInt32 codeOffset, char symbolName[256], char fileName[256], UInt32* fileOffset);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
|
|
Загрузка…
Ссылка в новой задаче