예제 #1
0
void SymbolMap::SaveSymbolMap(const char *filename) const {
	lock_guard guard(lock_);

	// Don't bother writing a blank file.
	if (!File::Exists(filename) && functions.empty() && data.empty()) {
		return;
	}

#if defined(_WIN32) && defined(UNICODE)
	gzFile f = gzopen_w(ConvertUTF8ToWString(filename).c_str(), "w9");
#else
	gzFile f = gzopen(filename, "w9");
#endif

	if (f == Z_NULL)
		return;

	gzprintf(f, ".text\n");

	for (auto it = modules.begin(), end = modules.end(); it != end; ++it) {
		const ModuleEntry &mod = *it;
		gzprintf(f, ".module %x %08x %08x %s\n", mod.index, mod.start, mod.size, mod.name);
	}

	for (auto it = functions.begin(), end = functions.end(); it != end; ++it) {
		const FunctionEntry& e = it->second;
		gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_FUNCTION, GetLabelNameRel(e.start, e.module));
	}

	for (auto it = data.begin(), end = data.end(); it != end; ++it) {
		const DataEntry& e = it->second;
		gzprintf(f, "%08x %08x %x %i %s\n", e.start, e.size, e.module, ST_DATA, GetLabelNameRel(e.start, e.module));
	}
	gzclose(f);
}
예제 #2
0
void SymbolMap::SaveNocashSym(const char *filename) const {
	lock_guard guard(lock_);

	// Don't bother writing a blank file.
	if (!File::Exists(filename) && functions.empty() && data.empty()) {
		return;
	}

	FILE* f = fopen(filename, "w");
	if (f == NULL)
		return;

	// only write functions, the rest isn't really interesting
	for (auto it = functions.begin(), end = functions.end(); it != end; ++it) {
		const FunctionEntry& e = it->second;
		fprintf(f, "%08X %s,%04X\n", GetModuleAbsoluteAddr(e.start,e.module),GetLabelNameRel(e.start, e.module), e.size);
	}
	
	fclose(f);
}