delorie.com/djgpp/doc/libc/libc_797.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

syms_val2name

Syntax

 
#include <debug/syms.h>

char *syms_val2name (unsigned long addr, unsigned long *offset);

Description

This function takes an address addr and returns the name of the closest symbol whose address is less that addr. If offset is not a NULL pointer, the offset of addr from the symbol's address is stored in the variable pointed to by offset.

You must call syms_init (see section syms_init) before calling any of the other syms_* functions for the first time.

This function is meant to be used to convert numerical addresses into function names and offsets into their code, like what symify does with the call frame traceback.

The function ignores several dummy symbols, like `_end' and `_etext'.

Return Value

The name of the found symbol, or the printed hexadecimal representation of addr, if no symbol was found near addr. The return value is a pointer to a static buffer, so don't overwrite it and don't pass it to free!

Portability

ANSI/ISO C No
POSIX No

Example

 
  unsigned long offs;
  char *symbol_name;
  syms_init ("foo.exe");
  symbol_name = syms_val2name (0x1c12, &offs);
  printf ("The address %x is at %s%+ld\n", 0x1c12, symbol_name, offs);


  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004