2010-02-08 08:23:39 -08:00
|
|
|
/* Copyright (c) 2010 Wildfire Games
|
2009-04-18 10:00:33 -07:00
|
|
|
*
|
2010-02-08 08:23:39 -08:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
|
* the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included
|
|
|
|
|
* in all copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
|
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
|
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
|
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2009-04-18 10:00:33 -07:00
|
|
|
*/
|
|
|
|
|
|
2007-09-23 01:05:38 -07:00
|
|
|
// note: the BFD stuff *could* be used on other platforms, if we saw the
|
|
|
|
|
// need for it.
|
2007-05-16 20:37:49 -07:00
|
|
|
|
2007-09-23 01:05:38 -07:00
|
|
|
#include "precompiled.h"
|
2007-05-16 20:37:49 -07:00
|
|
|
|
|
|
|
|
#include "lib/timer.h"
|
2010-03-03 06:14:26 -08:00
|
|
|
#include "lib/utf8.h"
|
2007-05-16 20:37:49 -07:00
|
|
|
#include "lib/sysdep/sysdep.h"
|
|
|
|
|
#include "lib/debug.h"
|
|
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <cassert>
|
|
|
|
|
|
|
|
|
|
#include <bfd.h>
|
|
|
|
|
#include <cxxabi.h>
|
|
|
|
|
|
|
|
|
|
#ifndef bfd_get_section_size
|
|
|
|
|
#define bfd_get_section_size bfd_get_section_size_before_reloc
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define GNU_SOURCE
|
|
|
|
|
#include <dlfcn.h>
|
|
|
|
|
#include <execinfo.h>
|
|
|
|
|
|
|
|
|
|
// Hard-coded - yuck :P
|
|
|
|
|
// These should only be used as fallbacks
|
|
|
|
|
#if defined(TESTING)
|
|
|
|
|
#define EXE_NAME "pyrogenesis_test"
|
|
|
|
|
#elif defined(NDEBUG)
|
|
|
|
|
#define EXE_NAME "pyrogenesis"
|
|
|
|
|
#else
|
|
|
|
|
#define EXE_NAME "pyrogenesis_dbg"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define PROFILE_RESOLVE_SYMBOL 0
|
|
|
|
|
|
|
|
|
|
struct symbol_file_context
|
|
|
|
|
{
|
|
|
|
|
asymbol **syms;
|
|
|
|
|
bfd *abfd;
|
|
|
|
|
};
|
|
|
|
|
symbol_file_context ps_dbg_context;
|
|
|
|
|
bool udbg_initialized=false;
|
|
|
|
|
|
|
|
|
|
struct symbol_lookup_context
|
|
|
|
|
{
|
|
|
|
|
symbol_file_context *file_ctx;
|
|
|
|
|
|
|
|
|
|
bfd_vma address;
|
|
|
|
|
const char* symbol;
|
|
|
|
|
const char* filename;
|
2008-06-28 10:31:14 -07:00
|
|
|
uint line;
|
2007-05-16 20:37:49 -07:00
|
|
|
|
|
|
|
|
bool found;
|
|
|
|
|
};
|
|
|
|
|
|
2009-11-06 08:15:09 -08:00
|
|
|
void* debug_GetCaller(void* UNUSED(context), const wchar_t* UNUSED(lastFuncToSkip))
|
2007-05-16 20:37:49 -07:00
|
|
|
{
|
2008-09-27 03:05:11 -07:00
|
|
|
// bt[0] == this function
|
|
|
|
|
// bt[1] == our caller
|
|
|
|
|
// bt[2] == the first caller they are interested in
|
|
|
|
|
// HACK: we currently don't support lastFuncToSkip (would require debug information),
|
|
|
|
|
// instead just returning the caller of the function calling us
|
|
|
|
|
void *bt[3];
|
|
|
|
|
int bt_size = backtrace(bt, 3);
|
2009-07-25 13:35:48 -07:00
|
|
|
if (bt_size < 3)
|
|
|
|
|
return NULL;
|
2008-09-27 03:05:11 -07:00
|
|
|
return bt[2];
|
2007-05-16 20:37:49 -07:00
|
|
|
}
|
|
|
|
|
|
2009-11-06 08:15:09 -08:00
|
|
|
LibError debug_DumpStack(wchar_t* buf, size_t max_chars, void* UNUSED(context), const wchar_t* UNUSED(lastFuncToSkip))
|
2007-05-16 20:37:49 -07:00
|
|
|
{
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 11:48:32 -07:00
|
|
|
static const size_t N_FRAMES = 16;
|
2008-10-18 11:42:23 -07:00
|
|
|
void *bt[N_FRAMES];
|
2007-05-16 20:37:49 -07:00
|
|
|
int bt_size=0;
|
|
|
|
|
wchar_t *bufpos = buf;
|
|
|
|
|
wchar_t *bufend = buf + max_chars;
|
|
|
|
|
|
|
|
|
|
bt_size=backtrace(bt, ARRAY_SIZE(bt));
|
|
|
|
|
|
|
|
|
|
// Assumed max length of a single print-out
|
had to remove uint and ulong from lib/types.h due to conflict with other library.
this snowballed into a massive search+destroy of the hodgepodge of
mostly equivalent types we had in use (int, uint, unsigned, unsigned
int, i32, u32, ulong, uintN).
it is more efficient to use 64-bit types in 64-bit mode, so the
preferred default is size_t (for anything remotely resembling a size or
index). tile coordinates are ssize_t to allow more efficient conversion
to/from floating point. flags are int because we almost never need more
than 15 distinct bits, bit test/set is not slower and int is fastest to
type. finally, some data that is pretty much directly passed to OpenGL
is now typed accordingly.
after several hours, the code now requires fewer casts and less
guesswork.
other changes:
- unit and player IDs now have an "invalid id" constant in the
respective class to avoid casting and -1
- fix some endian/64-bit bugs in the map (un)packing. added a
convenience function to write/read a size_t.
- ia32: change CPUID interface to allow passing in ecx (required for
cache topology detection, which I need at work). remove some unneeded
functions from asm, replace with intrinsics where possible.
This was SVN commit r5942.
2008-05-11 11:48:32 -07:00
|
|
|
static const size_t MAX_OUT_CHARS=1024;
|
2007-05-16 20:37:49 -07:00
|
|
|
|
2008-09-27 03:05:11 -07:00
|
|
|
for (size_t i=0;(int)i<bt_size && bufpos+MAX_OUT_CHARS < bufend;i++)
|
2007-05-16 20:37:49 -07:00
|
|
|
{
|
2009-11-06 08:15:09 -08:00
|
|
|
wchar_t file[DBG_FILE_LEN];
|
|
|
|
|
wchar_t symbol[DBG_SYMBOL_LEN];
|
2007-05-16 20:37:49 -07:00
|
|
|
int line;
|
|
|
|
|
int len;
|
|
|
|
|
|
2008-09-27 03:05:11 -07:00
|
|
|
if (debug_ResolveSymbol(bt[i], symbol, file, &line) == 0)
|
2009-11-07 01:32:19 -08:00
|
|
|
len = swprintf(bufpos, MAX_OUT_CHARS, L"(%p) %ls:%d %ls\n", bt[i], file, line, symbol);
|
2007-05-16 20:37:49 -07:00
|
|
|
else
|
2009-11-07 01:32:19 -08:00
|
|
|
len = swprintf(bufpos, MAX_OUT_CHARS, L"(%p)\n", bt[i]);
|
2007-05-16 20:37:49 -07:00
|
|
|
|
|
|
|
|
if (len < 0)
|
|
|
|
|
{
|
|
|
|
|
// MAX_OUT_CHARS exceeded, realistically this was caused by some
|
|
|
|
|
// mindbogglingly long symbol name... replace the end with an
|
|
|
|
|
// ellipsis and a newline
|
|
|
|
|
memcpy(&bufpos[MAX_OUT_CHARS-6], L"...\n", 5*sizeof(wchar_t));
|
|
|
|
|
len = MAX_OUT_CHARS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bufpos += len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return INFO::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int slurp_symtab(symbol_file_context *ctx)
|
|
|
|
|
{
|
|
|
|
|
bfd *abfd=ctx->abfd;
|
|
|
|
|
asymbol ***syms=&ctx->syms;
|
|
|
|
|
long symcount;
|
|
|
|
|
int size=0;
|
|
|
|
|
|
|
|
|
|
if ((bfd_get_file_flags (abfd) & HAS_SYMS) == 0)
|
|
|
|
|
{
|
|
|
|
|
printf("slurp_symtab(): Huh? Has no symbols...\n");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)
|
2008-06-28 10:31:14 -07:00
|
|
|
symcount = bfd_read_minisymbols (abfd, FALSE, (void **)syms, (unsigned*)&size);
|
2007-05-16 20:37:49 -07:00
|
|
|
if (symcount == 0)
|
2008-06-28 10:31:14 -07:00
|
|
|
symcount = bfd_read_minisymbols (abfd, TRUE /* dynamic */, (void **)syms, (unsigned*)&size);
|
2007-05-16 20:37:49 -07:00
|
|
|
|
|
|
|
|
if (symcount < 0)
|
|
|
|
|
{
|
|
|
|
|
bfd_perror("slurp_symtab");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int read_symbols(const char *file_name, symbol_file_context *ctx)
|
|
|
|
|
{
|
|
|
|
|
char **matching=NULL;
|
|
|
|
|
|
|
|
|
|
ONCE(bfd_init());
|
|
|
|
|
|
|
|
|
|
ctx->abfd = bfd_openr (file_name, NULL);
|
|
|
|
|
if (ctx->abfd == NULL)
|
|
|
|
|
{
|
|
|
|
|
bfd_perror("udbg.cpp: bfd_openr");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (! bfd_check_format_matches (ctx->abfd, bfd_object, &matching))
|
|
|
|
|
{
|
|
|
|
|
if (bfd_get_error () == bfd_error_file_ambiguously_recognized)
|
|
|
|
|
{
|
|
|
|
|
printf("Error reading symbols from %s: ambiguous format\n", file_name);
|
|
|
|
|
while (*matching)
|
|
|
|
|
printf("\tPotential matching format: %s\n", *matching++);
|
|
|
|
|
free(matching);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bfd_perror("bfd_check_format_matches");
|
|
|
|
|
}
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int res=slurp_symtab(ctx);
|
|
|
|
|
if (res == 0)
|
|
|
|
|
return res;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bfd_perror("udbg.cpp: slurp_symtab");
|
|
|
|
|
bfd_close(ctx->abfd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void udbg_bfd_init(void)
|
|
|
|
|
{
|
2009-11-06 10:35:32 -08:00
|
|
|
fs::wpath path;
|
|
|
|
|
std::string exename;
|
|
|
|
|
if (sys_get_executable_name(path) == INFO::OK)
|
2007-05-16 20:37:49 -07:00
|
|
|
{
|
2009-11-09 13:40:24 -08:00
|
|
|
exename = utf8_from_wstring(path.string());
|
2009-11-06 10:35:32 -08:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
debug_printf(L"sys_get_executable_name didn't work, using hard-coded guess %hs.\n", EXE_NAME);
|
|
|
|
|
exename = EXE_NAME;
|
2007-05-16 20:37:49 -07:00
|
|
|
}
|
|
|
|
|
|
2009-11-06 10:35:32 -08:00
|
|
|
debug_printf(L"udbg_bfd_init: loading symbols from %hs.\n", exename.c_str());
|
2007-05-16 20:37:49 -07:00
|
|
|
|
2009-11-06 10:35:32 -08:00
|
|
|
if (read_symbols(exename.c_str(), &ps_dbg_context)==0)
|
2007-05-16 20:37:49 -07:00
|
|
|
udbg_initialized=true;
|
|
|
|
|
|
|
|
|
|
#if PROFILE_RESOLVE_SYMBOL
|
|
|
|
|
{
|
|
|
|
|
TIMER(udbg_init_benchmark)
|
|
|
|
|
char symbol[DBG_SYMBOL_LEN];
|
|
|
|
|
char file[DBG_FILE_LEN];
|
|
|
|
|
int line;
|
2008-09-27 03:05:11 -07:00
|
|
|
debug_ResolveSymbol(debug_get_nth_caller(3), symbol, file, &line);
|
2007-05-16 20:37:49 -07:00
|
|
|
printf("%s (%s:%d)\n", symbol, file, line);
|
|
|
|
|
for (int i=0;i<1000000;i++)
|
|
|
|
|
{
|
2008-09-27 03:05:11 -07:00
|
|
|
debug_ResolveSymbol(debug_get_nth_caller(1), symbol, file, &line);
|
2007-05-16 20:37:49 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void find_address_in_section (bfd *abfd, asection *section, void *data)
|
|
|
|
|
{
|
|
|
|
|
symbol_lookup_context *ctx=(symbol_lookup_context *)data;
|
|
|
|
|
asymbol **syms=ctx->file_ctx->syms;
|
|
|
|
|
|
|
|
|
|
bfd_vma pc=ctx->address;
|
|
|
|
|
bfd_vma vma;
|
|
|
|
|
bfd_size_type size;
|
|
|
|
|
|
|
|
|
|
if (ctx->found) return;
|
|
|
|
|
|
|
|
|
|
if ((bfd_get_section_flags (abfd, section) & SEC_ALLOC) == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
vma = bfd_get_section_vma (abfd, section);
|
|
|
|
|
if (pc < vma)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
size = bfd_get_section_size (section);
|
|
|
|
|
if (pc >= vma + size)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ctx->found = bfd_find_nearest_line (abfd, section, syms,
|
|
|
|
|
pc - vma, &ctx->filename, &ctx->symbol, &ctx->line);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// BFD functions perform allocs with real malloc - we need to free that data
|
|
|
|
|
void demangle_buf(char *buf, const char *symbol, size_t n)
|
|
|
|
|
{
|
|
|
|
|
int status=0;
|
|
|
|
|
char *alloc=NULL;
|
|
|
|
|
if (symbol == NULL || *symbol == '\0')
|
|
|
|
|
{
|
|
|
|
|
symbol = "??";
|
|
|
|
|
status = -1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
alloc=abi::__cxa_demangle(symbol, NULL, NULL, &status);
|
|
|
|
|
}
|
|
|
|
|
// status is 0 on success and a negative value on failure
|
|
|
|
|
if (status == 0)
|
|
|
|
|
symbol=alloc;
|
|
|
|
|
strncpy(buf, symbol, n);
|
|
|
|
|
buf[n-1]=0;
|
|
|
|
|
if (alloc)
|
|
|
|
|
free(alloc);
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 08:15:09 -08:00
|
|
|
static LibError debug_resolve_symbol_dladdr(void *ptr, wchar_t* sym_name, wchar_t* file, int* line)
|
2007-05-16 20:37:49 -07:00
|
|
|
{
|
|
|
|
|
Dl_info syminfo;
|
|
|
|
|
|
|
|
|
|
int res=dladdr(ptr, &syminfo);
|
|
|
|
|
if (res == 0)
|
|
|
|
|
WARN_RETURN(ERR::FAIL);
|
|
|
|
|
|
|
|
|
|
if (sym_name)
|
|
|
|
|
{
|
|
|
|
|
if (syminfo.dli_sname)
|
|
|
|
|
{
|
2009-11-06 08:15:09 -08:00
|
|
|
char sym_name_buf[DBG_SYMBOL_LEN];
|
|
|
|
|
demangle_buf(sym_name_buf, syminfo.dli_sname, DBG_SYMBOL_LEN);
|
2009-11-09 13:40:24 -08:00
|
|
|
wcscpy_s(sym_name, DBG_SYMBOL_LEN, wstring_from_utf8(sym_name_buf).c_str());
|
2007-05-16 20:37:49 -07:00
|
|
|
}
|
2009-11-06 08:15:09 -08:00
|
|
|
else
|
|
|
|
|
swprintf_s(sym_name, DBG_SYMBOL_LEN, L"%p", ptr);
|
2007-05-16 20:37:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
|
{
|
2009-11-09 13:40:24 -08:00
|
|
|
wcscpy_s(file, DBG_FILE_LEN, wstring_from_utf8(syminfo.dli_fname).c_str());
|
2007-05-16 20:37:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (line)
|
|
|
|
|
{
|
|
|
|
|
*line=0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return INFO::OK;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-06 08:15:09 -08:00
|
|
|
LibError debug_ResolveSymbol(void* ptr_of_interest, wchar_t* sym_name, wchar_t* file, int* line)
|
2007-05-16 20:37:49 -07:00
|
|
|
{
|
2007-05-26 10:10:28 -07:00
|
|
|
ONCE(udbg_bfd_init());
|
2007-05-16 20:37:49 -07:00
|
|
|
|
|
|
|
|
// We use our default context - in the future we could do something like
|
|
|
|
|
// mapping library -> file context to support more detailed reporting on
|
|
|
|
|
// external libraries
|
|
|
|
|
symbol_file_context *file_ctx=&ps_dbg_context;
|
|
|
|
|
bfd *abfd=file_ctx->abfd;
|
|
|
|
|
|
|
|
|
|
// Reset here if we fail later on
|
|
|
|
|
if (sym_name)
|
|
|
|
|
*sym_name=0;
|
|
|
|
|
if (file)
|
|
|
|
|
*file=0;
|
|
|
|
|
if (line)
|
|
|
|
|
*line=0;
|
|
|
|
|
|
|
|
|
|
if (!udbg_initialized)
|
|
|
|
|
return debug_resolve_symbol_dladdr(ptr_of_interest, sym_name, file, line);
|
|
|
|
|
|
|
|
|
|
symbol_lookup_context ctx;
|
|
|
|
|
memset(&ctx, 0, sizeof(ctx));
|
|
|
|
|
ctx.address=reinterpret_cast<bfd_vma>(ptr_of_interest);
|
|
|
|
|
ctx.file_ctx=file_ctx;
|
|
|
|
|
|
|
|
|
|
bfd_map_over_sections (abfd, find_address_in_section, &ctx);
|
|
|
|
|
|
|
|
|
|
// This will happen for addresses in external files. What one *could* do
|
|
|
|
|
// here is to figure out the originating library file and load that through
|
|
|
|
|
// BFD... but how often will external libraries have debugging info? really?
|
|
|
|
|
// At least attempt to find out the symbol name through dladdr.
|
|
|
|
|
if (!ctx.found)
|
|
|
|
|
return debug_resolve_symbol_dladdr(ptr_of_interest, sym_name, file, line);
|
|
|
|
|
|
|
|
|
|
if (sym_name)
|
|
|
|
|
{
|
2009-11-06 08:15:09 -08:00
|
|
|
char sym_name_buf[DBG_SYMBOL_LEN];
|
|
|
|
|
demangle_buf(sym_name_buf, ctx.symbol, DBG_SYMBOL_LEN);
|
2009-11-09 13:40:24 -08:00
|
|
|
wcscpy_s(sym_name, DBG_SYMBOL_LEN, wstring_from_utf8(sym_name_buf).c_str());
|
2007-05-16 20:37:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file)
|
|
|
|
|
{
|
|
|
|
|
if (ctx.filename != NULL)
|
|
|
|
|
{
|
|
|
|
|
const char *h;
|
|
|
|
|
h = strrchr (ctx.filename, '/');
|
|
|
|
|
if (h != NULL)
|
|
|
|
|
ctx.filename = h + 1;
|
|
|
|
|
|
2009-11-09 13:40:24 -08:00
|
|
|
wcscpy_s(file, DBG_FILE_LEN, wstring_from_utf8(ctx.filename).c_str());
|
2007-05-16 20:37:49 -07:00
|
|
|
}
|
|
|
|
|
else
|
2009-11-06 08:15:09 -08:00
|
|
|
wcscpy_s(file, DBG_FILE_LEN, L"none");
|
2007-05-16 20:37:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (line)
|
|
|
|
|
{
|
|
|
|
|
*line = ctx.line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return INFO::OK;
|
|
|
|
|
}
|
2008-01-25 20:43:02 -08:00
|
|
|
|
2008-09-27 03:05:11 -07:00
|
|
|
void debug_SetThreadName(char const* UNUSED(name))
|
2008-01-25 20:43:02 -08:00
|
|
|
{
|
|
|
|
|
// Currently unimplemented
|
|
|
|
|
}
|