Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Dec 2002 15:20:17 +0300
From:      Lev Serebryakov <lev@serebryakov.spb.ru>
To:        Ferruccio Vitale <freebsd@cs.tin.it>, hackers@freebsd.org
Subject:   Re[2]: dlinfo() from sunOS, _DYNAMIC from Linux: did we have something like this?
Message-ID:  <165246107764.20021219152017@serebryakov.spb.ru>
In-Reply-To: <20021219120240.48ac3416.freebsd@cs.tin.it>
References:  <45792625.20021218000337@serebryakov.spb.ru> <20021219120240.48ac3416.freebsd@cs.tin.it>

next in thread | previous in thread | raw e-mail | index | archive | help
Hello Ferruccio,

Thursday, December 19, 2002, 2:02:40 PM, you wrote:

>>   Here is very good profiler (IMHO, better than `gcc -g' + `gprof'):
>>   FunctionCheck. But it need information about each module in program.
>>   It uses dlinfo() function on SunOS and _DYNAMIC variable on Linux to
>>   access all ELF symbol tables in loaded program. Did FreeBSD (4.x)
>>   have something like this?

FV> try 'dladdr'.
  Unfortunately, it is not solution. Here is code, which uses
  dlinfo()/_DYNAMIC, and I could not understand, how could dladdr() be
  used here:

  /* try to find out about dynamically loaded objects */
#if HAVE_DECL__DYNAMIC == 1                                                                                             
  dyn = _DYNAMIC;                                                                                                       
#else                                                                                                                   
  dlinfo(RTLD_SELF, RTLD_DI_LINKMAP, &lm);                                                                              
#if HAVE_ELF32_DYN_ == 1                                                                                                
  dyn = (Elf32_Dyn*)lm->l_ld;                                                                                           
#elif HAVE_ELF64_DYN_ == 1                                                                                              
  dyn = (Elf64_Dyn*)lm->l_ld;                                                                                           
#else                                                                                                                   
  dyn = NULL;                                                                                                           
#endif                                                                                                                  
#endif                                                                                                                  
  if (dyn != NULL)                                                                                                      
    {                                                                                                                   
    for (; dyn->d_tag != DT_NULL; dyn++)                                                                                
      {                                                                                                                 
      if (dyn->d_tag == DT_DEBUG)                                                                                       
        {                                                                                                               
          rdb = (struct r_debug *)dyn->d_un.d_ptr;                                                                      
          break;                                                                                                        
        }                                                                                                               
      }                                                                                                                 
    }                                                                                                                   

-- 
Best regards,
 Lev                            mailto:lev@serebryakov.spb.ru


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?165246107764.20021219152017>