1
0
forked from 0ad/0ad

Made a few changes on udbg to make it work with two different libbfd versions as well as made a few mmgr assertions more verbose

This was SVN commit r1928.
This commit is contained in:
Simon Brenner 2005-02-21 17:08:51 +00:00
parent 3776f91aeb
commit 642e107242
2 changed files with 16 additions and 6 deletions

View File

@ -798,6 +798,9 @@ void mmgr_write_leak_report(void)
bool mmgr_is_valid_ptr(const void* p)
{
// null pointer - won't even try ;-)
if (p == NULL)
return false;
lock();
bool found = allocs_find(p) != 0;
unlock();
@ -812,7 +815,7 @@ static bool alloc_is_valid(const Alloc* a)
// this allocation has been over/underrun, i.e. modified outside the
// allocation's memory range.
assert2(0);
assert2(0 && "Memory over/underrun detected by mmgr");
log("[!] Memory over/underrun:\n");
log_this_alloc(a);
return false;
@ -1077,7 +1080,7 @@ void free_dbg(const void* user_p, AllocType type, const char* file, int line, co
if(!a)
{
// you tried to free a pointer mmgr didn't allocate
assert2(0);
assert2(0 && "mmgr tried to free a pointer mmgr didn't allocate");
log("[!] mmgr_free: not allocated by this memory manager\n");
goto fail;
}
@ -1230,7 +1233,7 @@ void mmgr_free_dbg(void* p, const char* file, int line, const char* func)
char* mmgr_strdup_dbg(const char* s, const char* file, int line, const char* func)
{
const size_t size = strlen(s);
const size_t size = strlen(s)+1;
char* copy = (char*)mmgr_malloc_dbg(size, file,line,func);
if(!copy)
return 0;
@ -1240,7 +1243,7 @@ char* mmgr_strdup_dbg(const char* s, const char* file, int line, const char* fun
wchar_t* mmgr_wcsdup_dbg(const wchar_t* s, const char* file, int line, const char* func)
{
const size_t size = wcslen(s) * sizeof(wchar_t);
const size_t size = (wcslen(s) + 1) * sizeof(wchar_t);
wchar_t* copy = (wchar_t*)mmgr_malloc_dbg(size, file,line,func);
if(!copy)
return 0;

View File

@ -31,6 +31,12 @@
#include "bfd.h"
#include <cxxabi.h>
#ifndef bfd_get_section_size
#define bfd_get_section_size bfd_get_section_size_before_reloc
#endif
#define PROFILE_RESOLVE_SYMBOL 0
// Hard-coded - yuck :P
#ifdef TESTING
#define EXE_NAME "ps_test"
@ -224,7 +230,7 @@ void udbg_init(void)
if (read_symbols(EXE_NAME, &ps_dbg_context)==0)
udbg_initialized=true;
#ifdef PROFILE_RESOLVE_SYMBOL
#if PROFILE_RESOLVE_SYMBOL
{
TIMER(udbg_init_benchmark)
char symbol[DBG_SYMBOL_LEN];
@ -258,7 +264,7 @@ static void find_address_in_section (bfd *abfd, asection *section, void *data)
if (pc < vma)
return;
size = bfd_get_section_size_before_reloc (section);
size = bfd_get_section_size (section);
if (pc >= vma + size)
return;
@ -309,6 +315,7 @@ int debug_resolve_symbol_dladdr(void *ptr, char* sym_name, char* file, int* line
file[DBG_FILE_LEN-1]=0;
*line=0;
return 0;
}
int debug_resolve_symbol(void* ptr_of_interest, char* sym_name, char* file, int* line)