udbg fixes and a fix for the underscore problem in the assembler symbols

This was SVN commit r2765.
This commit is contained in:
Simon Brenner 2005-09-26 05:38:40 +00:00
parent 1c71c72e74
commit ee35659dc7
6 changed files with 77 additions and 26 deletions

View File

@ -36,6 +36,8 @@
extern int win_get_gfx_info();
extern int win_get_cpu_info();
extern int win_get_snd_info();
#elif OS_UNIX
extern int unix_get_cpu_info();
#endif
extern "C" int ogl_get_gfx_info();
@ -130,6 +132,8 @@ void get_cpu_info()
{
#if OS_WIN
win_get_cpu_info();
#elif OS_UNIX
unix_get_cpu_info();
#endif
#if CPU_IA32

View File

@ -3,6 +3,16 @@ section .data use32
section .bss use32
section .text use32
; Usage:
; use sym(ia32_cap) instead of _ia32_cap - on relevant platforms, sym() will add
; the underlines automagically, on others it won't
%ifdef DONT_USE_UNDERLINE
%define sym(a) a
%else
%define sym(a) _ %+ a
%endif
;-------------------------------------------------------------------------------
; fast general memcpy
;-------------------------------------------------------------------------------
@ -225,8 +235,8 @@ sse_mask resd 1
__SECT__
; void __declspec(naked) ia32_memcpy(void* dst, const void* src, size_t nbytes)
global _ia32_memcpy
_ia32_memcpy:
global sym(ia32_memcpy)
sym(ia32_memcpy):
push edi
push esi
@ -288,8 +298,8 @@ __SECT__
; extern "C" bool __cdecl ia32_cpuid(u32 func, u32* regs)
global _ia32_cpuid
_ia32_cpuid:
global sym(ia32_cpuid)
sym(ia32_cpuid):
push ebx
push edi
@ -331,8 +341,8 @@ _ia32_cpuid:
;-------------------------------------------------------------------------------
; extern "C" uint __cdecl ia32_control87(uint new_cw, uint mask)
global _ia32_control87
_ia32_control87:
global sym(ia32_control87)
sym(ia32_control87):
push eax
fnstcw [esp]
pop eax ; old_cw
@ -353,8 +363,8 @@ _ia32_control87:
;-------------------------------------------------------------------------------
; extern "C" bool __cdecl ia32_init()
global _ia32_init
_ia32_init:
global sym(ia32_init)
sym(ia32_init):
push ebx
; check if CPUID is supported
@ -379,12 +389,12 @@ _ia32_init:
.no_cpuid:
; check if SSE is supported (used by memcpy code)
extern _ia32_cap
extern sym(ia32_cap)
push byte 32+25 ; ia32.h's SSE cap (won't change)
call _ia32_cap
call sym(ia32_cap)
pop edx ; remove stack param
neg eax ; SSE? ~0 : 0
mov [sse_mask], eax
pop ebx
ret
ret

View File

@ -112,8 +112,7 @@ void* debug_get_nth_caller(uint n, void *context)
int bt_size;
bt_size=backtrace(bt, n+2);
// oops - out of stack frames
debug_assert((bt_size >= n+2) && "Hrmm.. Not enough stack frames to backtrace!");
assert(bt_size >= n+2 && "Need at least n+2 frames in get_nth_caller");
return bt[n+1]; // n==1 => bt[2], and so forth
}
@ -130,13 +129,13 @@ const wchar_t* debug_dump_stack(wchar_t* buf, size_t max_chars, uint skip, void*
wchar_t *bufend = buf + max_chars;
bt_size=backtrace(bt, ARRAY_SIZE(bt));
// oops - out of stack frames
debug_assert((bt_size >= ARRAY_SIZE(bt)) && "Hrmm.. Not enough stack frames to backtrace!");
// did we get enough backtraced frames?
assert((bt_size >= skip) && "Need at least <skip> frames in the backtrace");
// Assumed max length of a single print-out
static const uint MAX_OUT_CHARS=1024;
for (uint i=skip;i<(skip+N_FRAMES) && bufpos+MAX_OUT_CHARS < bufend;i++)
for (uint i=skip;i<bt_size && bufpos+MAX_OUT_CHARS < bufend;i++)
{
char file[DBG_FILE_LEN];
char symbol[DBG_SYMBOL_LEN];
@ -144,9 +143,9 @@ const wchar_t* debug_dump_stack(wchar_t* buf, size_t max_chars, uint skip, void*
uint len;
if (debug_resolve_symbol(bt[i], symbol, file, &line) == 0)
len = swprintf(bufpos, MAX_OUT_CHARS, L"(%p) %hs:%d %hs\n", bt[i], file, line, symbol);
len = swprintf(bufpos, MAX_OUT_CHARS, L"(0x%08x) %hs:%d %hs\n", bt[i], file, line, symbol);
else
len = swprintf(bufpos, MAX_OUT_CHARS, L"(%p)\n", bt[i]);
len = swprintf(bufpos, MAX_OUT_CHARS, L"(0x%08x)\n", bt[i]);
if (len < 0)
{
@ -176,7 +175,19 @@ static int slurp_symtab(symbol_file_context *ctx)
return -1;
}
symcount = bfd_read_minisymbols (abfd, FALSE, (void **)syms, &size);
size = bfd_get_symtab_upper_bound(abfd);
if (size < 0)
{
bfd_perror("symtab_upper_bound");
return -1;
}
*syms = (asymbol **)malloc(size);
if (!syms)
return -1;
symcount = bfd_canonicalize_symtab(abfd, *syms);
if (symcount == 0)
symcount = bfd_read_minisymbols (abfd, FALSE, (void **)syms, &size);
if (symcount == 0)
symcount = bfd_read_minisymbols (abfd, TRUE /* dynamic */, (void **)syms, &size);

View File

@ -1,5 +1,6 @@
#include "precompiled.h"
#include <unistd.h>
#include <stdio.h>
#include <wchar.h>
@ -7,6 +8,9 @@
#include "sysdep/sysdep.h"
#include "udbg.h"
#define GNU_SOURCE
#include <dlfcn.h>
// these are basic POSIX-compatible backends for the sysdep.h functions.
// Win32 has better versions which override these.
@ -23,14 +27,33 @@ void wdisplay_msg(const wchar_t* caption, const wchar_t* msg)
int get_executable_name(char* n_path, size_t buf_size)
{
UNUSED(n_path);
UNUSED(buf_size);
return -ENOSYS;
Dl_info dl_info;
memset(&dl_info, 0, sizeof(dl_info));
if (!dladdr((void *)get_executable_name, &dl_info) ||
!dl_info.dli_fname )
{
return -ENOSYS;
}
strncpy(n_path, dl_info.dli_fname, buf_size);
return 0;
}
extern int cpus;
int unix_get_cpu_info()
{
long res = sysconf(_SC_NPROCESSORS_CONF);
if (res == -1)
cpus = 1;
else
cpus = (int)res;
return 0;
}
ErrorReaction display_error_impl(const wchar_t* text, int flags)
{
wprintf(L"%s\n", text);
printf("%ls\n\n", text);
const bool manual_break = flags & DE_MANUAL_BREAK;
const bool allow_suppress = flags & DE_ALLOW_SUPPRESS;

View File

@ -51,7 +51,7 @@ void CNetLog::Open(const char *filename)
fprintf(m_pFile, "\n\n***************************************************\n");
fprintf(m_pFile, "LOG STARTED: %04d-%02d-%02d at %02d:%02d:%02d\n",
1900+now->tm_year, now->tm_mon, now->tm_mday, now->tm_hour,
1900+now->tm_year, now->tm_mon+1, now->tm_mday, now->tm_hour,
now->tm_min, now->tm_sec);
fprintf(m_pFile, "Timestamps are in seconds since engine startup\n\n");
}

View File

@ -39,9 +39,12 @@ public:
// Perform all CSimulation updates for the specified elapsed time.
void Update(double frameTime);
static uint GetMessageMask(CNetMessage *, uint, void *);
// Calculate the message mask of a message to be queued
static uint GetMessageMask(CNetMessage *, uint oldMask, void *userdata);
// Translate the command message into an entity order and queue it
static uint TranslateMessage(CNetMessage *, uint, void *);
// Returns oldMask
static uint TranslateMessage(CNetMessage *, uint oldMask, void *userdata);
void QueueLocalCommand(CNetMessage *pMsg);
};