Path: utzoo!utgpu!cs.utexas.edu!uunet!olivea!mintaka!bloom-picayune.mit.edu!athena.mit.edu!jtkohl From: jtkohl@MIT.EDU (John T Kohl) Newsgroups: alt.hackers Subject: MIPS vs. mprof Message-ID: Date: 22 Feb 91 01:15:42 GMT Sender: news@athena.mit.edu (News system) Organization: MIT Project Athena Lines: 40 Approved: jtkohl@MIT.EDU I recently started using the mprof package to ferret out memory leaks in a fairly large library/program package for which I'm project leader. However, on the DS3100 it had some problems dealing with call chains which went through static functions from a particular library which had removed the symbols pointing to the static function names (by using ld -x -r). So I hacked up the code to find the entry points which had previously been named. Here's the comment I left in the code: /* jtkohl@mit.edu: this [the missing function address] (apparently) happens when the symbol name for the referenced function has been stripped out, such as when it's a static function and the .o file had ld -x -r run over it. What we really ought to do is determine where the procedure really starts. we attempt to do so, by starting with the previous function's address, looking for the SECOND addiu sp,sp,{neg_size}. since the MIPS and GCC compilers only generate one such instruction per C function, the second one should be in the prologue of the desired function. HOWEVER, if we have a static function which is a LEAF (no locals, no function calls) we will actually miss the function and find the next one. Luckily, such a function can never appear on the call graph leading to a malloc, so if we assign it an address just before the address of the next function, then we should never mistakenly "find" it when doing a binary search for a return address. If we have two or more functions with no args before the next known function, it gets hairier... ADDIU sp,sp, {size} is: 0x27bd.... (16-bit offset size) */ -- John Kohl or Digital Equipment Corporation/Project Athena (The above opinions are MINE. Don't put my words in somebody else's mouth!) Brought to you by Super Global Mega Corp .com