# mtrace()

This topic is 4333 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi I am trying to use mtrace and its not working. following a tutorial at: http://www.cis.gvsu.edu/~wolffe/courses/cs656/projects/tutorial_UNIX.html I find my code compiles fine, but when it comes to it, no log file is created! I cannot also run mtrace from the command line. But I can run mtrace(), any ideas? This is what i am running: gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4) Thanks

##### Share on other sites
Hey!

I have never used mtrace before, but I gave it a try, and here is what i did

The test driver:
#include <stdio.h>#include <string.h>#include <mcheck.h>int main(){	mtrace();		int *dval = (int*)malloc(sizeof(int));	*dval = 1;	printf("%d\n", *dval);	free(dval);		muntrace();	return 0;}

Setting up the logfile, compiling and running:

$export MALLOC_TRACE=mtrace.log$ gcc -g -o mtrace_test mtrace_test.c
$ls mtrace_test mtrace_test.c$ ./mtrace_test
1
$ls mtrace.log mtrace_test mtrace_test.c$ mtrace ./mtrace_test mtrace.log
No memory leaks.

Hmm, you say you cant run mtrace from the command line...
Maybe its location is not in the PATH variable

// where is mtrace installed?
$which mtrace /usr/bin/mtrace // is /usr/bin in the PATH variable?$ echo $PATH /home/drobole/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games // turns out it is on my system, but if it is not on yours, you can run it by typing the full path name:$ /usr/bin/mtrace ./mtrace_test mtrace.log

//or you can add it to the PATH variable if you know how to do that

My guess is that the wich utility uses the PATH variable to locate the ntrace program, so if which cant find ntrace, you can try to find it with the locate utility instead.
$locate ntrace | grep bin If you want to make sure locate's database is updated, you can run the command$ updatedb as root, before running locate.
If you still cant find it, my guess is that ntrace is not installed correctly.

Hope it helps ^^

[Edited by - pulpfist on January 26, 2006 2:07:14 PM]

##### Share on other sites
Hmm Just seem unable to find mtrace anyhwere.

Tried the example, but mtrace is nowehere to be found.

$which mtrace /usr/bin/which: no mtrace in (/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/brett/bin)$ locate mtrace
/usr/share/man/fr/man3/mtrace.3.gz
/usr/share/man/ja/man3/mtrace.3.gz
/usr/share/man/man3/mtrace.3.gz

$echo$PATH
/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/brett/bin

$locate ntrace | grep bin Returns nothing at all. This is a dual processor machine with 64 bit supported. What package do I need to re-install? Best Thanks again. #### Share this post ##### Link to post ##### Share on other sites It looks like mtrace is only partially installed. Did you install it with the rpm utility? Im not familiar with 64 bit systems, and I have not used RedHat for a few years.If you dont have the rpm package for this utility, I would try to download it from here, and install it like this: # tar -xvzf mtrace-5.2.tar.gz# cd mtrace-5.2# ./configure# make# make install You can safely do the steps including # make If all went well up to that point, you can use # make install to actually install it system wide. Thats my best tip Im afraid. Good luck ^^ EDIT: Ehm.. I tried to download and compile the program, but it didnt work very well. After some searching, it looks like mtrace is part of the glibc-devel package... [Edited by - pulpfist on January 28, 2006 7:19:43 AM] #### Share this post ##### Link to post ##### Share on other sites Tried downloading but that would not compile. According to the man page, all we need is a perl script that does the conversion. However I cannot find this script anywhere and have tried downloading and find absolutely nothing. Its driving me crazy as I need to memory profile. Are there any other free tools that would help locate memory leaks? #### Share this post ##### Link to post ##### Share on other sites Did you realy try the glibc-devel rpm package? It should work if you download the right version for your system. There is one called YAMD wich looks pretty simple to use, but I have not tried it myself. The README file explains the installation. I was looking at these, but most of them seem kinda cumbersome to use/install. Anyone else know any good memory debuggers? #### Share this post ##### Link to post ##### Share on other sites It seems very bizzare and the only that seems missing is the mtrace perl script. I have everything else, I have re-installed the packages to my knowledege and still does not work. locate mtrace /usr/share/man/fr/man3/mtrace.3.gz /usr/share/man/ja/man3/mtrace.3.gz /usr/share/man/man3/mtrace.3.gz mtrace() > q bash: syntax error near unexpected token `q' locate glibc-devel [brett@phy-pc3016 man3]$

---returns nothing...I guess you're right and its not installed. Trouble is I cannot seem to install this development package, I am sure I tried one of the versions. I keep going round and round in circles as when I try and install this I get dependency problems, which take me round in ever decreasing circles, asking for a new pakage and when I obtain this asking for another. I am downloading from the redhat site: https://rhn.redhat.com/network/software/search.pxt

How could I re-install the whole package.

I am not that familiar with Linux so any assistance would be great.

##### Share on other sites
just tried this...devel is installed.

rpm -qa | grep glibc
glibc-devel-2.3.4-2
glibc-2.3.4-2
glibc-2.3.4-2
glibc-common-2.3.4-2

##### Share on other sites
Bizarre indeed.
Read this to understand why rpm s***s.

One drawback with rpm (as explained in the link above) is that it cant automatically download and install all dependent packages for you =(
(most other package managers do)

I can see 3 possible solutions to this problem:

1. Install all the packages glibc-devel depends on. (This can potentially be a huge task, and end up nowhere)

2. Install and use URPMI. (I have not tried this) (Mandrake is based on RedHat so the description should be working more or less "out of the box" for RedHat aswell)
Another similar utility is apt-rpm. I think I would go with that rather than URPMI.

3. Install the newest version of Debian, and use the apt-get utility to install everything. (What most amateurs (should) do)
Other posts here talk about what distributions are better, some says ubuntu, others say gentoo or debian. I say debian.

Ofcourse, reinstalling the OS is the ultimate defeat, and sometimes not an option. If you reinstall RedHat there is no guarantee that the current problem disappears either.

Sorry I cant help you with any quick solutions. It sounds like your system has some flaws already, like partially installed packages :/
In this case, installing debian or ubuntu may very well be the fastest and least hair-loosing experience. If that is an option at all...

EDIT:
If the command:
$locate glibc-devel returns nothing, while$ rpm -qa | grep glibc
does, I would defenitly run the command
# updatedb as root to make sure locate's database is updated.
And then try \$ locate mtrace again...

If you still dont find either mtrace or glibc-devel using the locate utility, I would seriously suspect that someone has deleted files on your system using the rm command. (Something that would confuse rpm big time)

The actual perl script can be found here.
You can download it and place it in /usr/local/bin, and make it executable with the command:

# chmod u=rwx,go=u-w /usr/local/bin/mtrace.pl

Thats a quick solution I guess.
With some luck it will work, but dont expect it to.

[Edited by - pulpfist on January 31, 2006 11:12:11 PM]

• ### Forum Statistics

• Total Topics
628674
• Total Posts
2984160

• 13
• 12
• 10
• 9
• 9