1
0
forked from 0ad/0ad
0ad/source/lib/debug_stl.h
janwas ee4c7965dd # merge all local changes; moving over to new SVN server
* app_hooks: add display_error; can be used by atlas to override our
dialog box
* lots of small fixes (mostly pertaining to headers)
* debug: clean up display_error, protect from reentrancy, fix a few edge
cases (e.g. error message from dtor -> exit pressed -> suppress all
subsequent errors)
* delay_load: add warning: NLSO ctors are unreliable since we're
compiling into static lib

This was SVN commit r4009.
2006-06-22 18:26:08 +00:00

73 lines
2.6 KiB
C++

/**
* =========================================================================
* File : debug_stl.h
* Project : 0 A.D.
* Description : portable debugging helper functions specific to the STL.
*
* @author Jan.Wassenberg@stud.uni-karlsruhe.de
* =========================================================================
*/
/*
* Copyright (c) 2004-2005 Jan Wassenberg
*
* Redistribution and/or modification are also permitted under the
* terms of the GNU General Public License as published by the
* Free Software Foundation (version 2 or later, at your option).
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#ifndef DEBUG_STL_H_INCLUDED
#define DEBUG_STL_H_INCLUDED
/**
* reduce complicated STL symbol names to human-readable form.
*
* algorithm: remove/replace undesired substrings in one pass (fast).
* example: "std::basic_string<char, char_traits<char>,
* std::allocator<char> >" => "string".
*
* @param buffer holding input symbol name; modified in-place.
* there is no length limit; must be large enough to hold typical STL
* strings. DBG_SYMBOL_LEN chars is a good measure.
* @return name for convenience.
**/
extern char* debug_stl_simplify_name(char* name);
/**
* abstraction of all STL iterators used by debug_stl.
**/
typedef const u8* (*DebugIterator)(void* internal, size_t el_size);
/**
* no STL iterator is larger than this; see below.
**/
const size_t DEBUG_STL_MAX_ITERATOR_SIZE = 64;
/**
* prepare to enumerate the elements of arbitrarily typed STL containers.
*
* works by retrieving element count&size via debug information and hiding
* the container's iterator implementation behind a common interface.
* a basic sanity check is performed to see if the container memory is
* valid and appears to be initialized.
*
* @param type_name exact type of STL container (see example above)
* @param p raw memory holding the container
* @param size sizeof(container)
* @param el_size sizeof(value_type)
* @param el_count out; number of valid elements in container
* @param el_iterator out; callback function that acts as an iterator
* @param it_mem out; buffer holding the iterator state. must be
* at least DEBUG_STL_MAX_ITERATOR_SIZE bytes.
* @return LibError (ERR_STL_*)
**/
extern LibError debug_stl_get_container_info(const char* type_name, const u8* p, size_t size,
size_t el_size, size_t* el_count, DebugIterator* el_iterator, void* it_mem);
#endif // #ifndef DEBUG_STL_H_INCLUDED