function trace back and address to line number conversion


 
Thread Tools Search this Thread
Operating Systems AIX function trace back and address to line number conversion
# 1  
Old 10-16-2009
function trace back and address to line number conversion

Hi,
I am new to AIX and I am developing a small tool for our product which helps debug memory leaks etc.

Q1)Is there a way in which i can get a function trace back as to the call (lets say malloc() )has been made in which file--> in which function.

I tried using the

#pragma options ( i might be making a mistake in the sub options for tbtable would need guidance here too)
and

-qtbtable=full

which says that a full stack trace would be appended as a text file at the end of the object file that we create if we create the obj file using the -g option.

But I dont seem to see any stack trace at the end of the obj file.
Can someone tell me what possibly could be my mistake? or suggest a better way of getting a stack trace


now using __builtin_return_address() i can get the code address from where the fucntion call ( malloc() ) has been made.

Q2)Is there any function which will help me find the line number of the function call ( malloc() ).

On HP UX we have addr2line() function which does this thing... on AIX i dont have an idea which function does it.

Thank you very much in advance.
Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find encapsulating function name from line number?

I am looking at a log file which just tells me the filename and the line number inside that file that has the Error. What I am interested is knowing the encapsulating function. For example, here are the contents of the log file Error: foo.file on line wxy Error: foo.file... (3 Replies)
Discussion started by: kaaliakahn
3 Replies

2. Shell Programming and Scripting

Line count of trace files for 24 period

Hi, Using solaris 10 5.10 o/s I am learning awk as I work here on the job. What I need to do is isolate the trace file for the last 24 hours. After that I need to open those trace files and search for 'TNS-|ORA-' message from each one. These trace files MAY HAVE an occurance of them. I... (5 Replies)
Discussion started by: bdby
5 Replies

3. IP Networking

IP address to host name conversion

hi, i want to get the hostname for the specified IP address. # host www.google.com www.google.com has address 173.194.69.104 www.google.com has address 173.194.69.105 www.google.com has address 173.194.69.106 www.google.com has address 173.194.69.147 www.google.com has address... (3 Replies)
Discussion started by: kavitha rao
3 Replies

4. Shell Programming and Scripting

IP address to decimal format conversion

I have a file which consist of some class 4 IP address as 172.16.112.50 172.16.112.50 172.16.112.50 172.16.112.100 192.168.1.30 172.16.112.100 172.16.112.50 172.16.112.50 172.16.112.50 i want to store them in pure decimal notations instead of the given dotted decimal formats e.g.... (2 Replies)
Discussion started by: vaibhavkorde
2 Replies

5. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

Hello Everyone. I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below: if ; then if ; then tail +$1 $3 | head -n $2 else ... (5 Replies)
Discussion started by: grc
5 Replies

6. Programming

Binary conversion function

Is/are there any function(s) in C that convert(s) character/ASCII/Decimal to binary and vice versa? what about bcopy and strcpy? (1 Reply)
Discussion started by: Peevish
1 Replies

7. Shell Programming and Scripting

Adding a columnfrom a specifit line number to a specific line number

Hi, I have a huge file & I want to add a specific text in column. But I want to add this text from a specific line number to a specific line number & another text in to another range of line numbers. To be more specific: lets say my file has 1000 lines & 4 Columns. I want to add text "Hello"... (2 Replies)
Discussion started by: Ezy
2 Replies

8. Shell Programming and Scripting

Function Trace

Does anyone know if there is a util out there to run through a shell script and be able to trace the function call tree. I have inherited some code and the original author was ****mad**** keen on functions - even ones called only once! If anyone knows of anything I would appreciate it - web... (3 Replies)
Discussion started by: ajcannon
3 Replies

9. UNIX for Dummies Questions & Answers

Date format conversion function

Hello, does somebody knows about a function that would convert a date like: YYMMDD into a date like YYYY-MM-DD ? Thank you for your ideas :) (9 Replies)
Discussion started by: Cecile
9 Replies

10. UNIX for Advanced & Expert Users

conversion of a input function to i18n

m using unix c with curses im trying out the conversion of an existing code in c to i18n for the japanese language. the problem is that, the input which is given as the japanese characters is not taken correctly. and what it outputs is question marks(i.e. ???), equivalent to the number o f... (4 Replies)
Discussion started by: nirnay_s
4 Replies
Login or Register to Ask a Question
leaks(1)						    BSD General Commands Manual 						  leaks(1)

NAME
leaks -- Search a process's memory for unreferenced malloc buffers SYNOPSIS
leaks pid | partial-executable-name | memory-graph-file [-list] [-groupByType] [-nocontext] [-nostacks] [-nosources] [-quiet] [-exclude symbol] [-trace address] [-outputGraph path] [-fullContent] [-atExit] DESCRIPTION
leaks identifies leaked memory -- memory that the application has allocated, but has been lost and cannot be freed. Specifically, leaks examines a specified process's memory for values that may be pointers to malloc-allocated buffers. Any buffer reachable from a pointer in writable global memory (e.g., __DATA segments), a register, or on the stack is assumed to be memory in use. Any buffer reachable from a pointer in a reachable malloc-allocated buffer is also assumed to be in use. The buffers which are not reachable are leaks; the buffers could never be freed because no pointer exists in memory to the buffer, and thus free() could never be called for these buffers. Such buf- fers waste memory; removing them can reduce swapping and memory usage. Leaks are particularly dangerous for long-running programs, for even- tually the leaks could fill memory and cause the application to crash. leaks requires one argument -- either the process ID or the full or partial executable name of the process to examine, or the pathname of a memory graph file generated by leaks or the Xcode Memory Graph Debugger. Once the leaked buffers have been identified, leaks analyzes them to find "root leaks" (those which are not referenced by any other buffer) and "root cycles" (cycles of objects which reference or retain each other, but which are not referenced by any other buffer outside the cycle). Then, it identifies the tree of buffers which are referenced by those root leaks and root cycles, if any. leaks then prints each such "leak tree". If the MallocStackLogging environment variable was set when the application was launched, leaks also prints a stack trace describing where the buffer was allocated. MEMORY GRAPH FILES
A memory graph file archives the memory state of a process for further analysis at a later time, on a different machine, or by other people. It includes information about all VM and malloc nodes in the process, and the references between them. Memory graph files can be generated by leaks using the -outputGraph option (and the -fullContent option if desired), or by examining a live process with the Xcode Memory Graph Debugger then using the Export Memory Graph menu item from the File menu. The standard filename suffix for memory graph files is ".mem- graph". These files can be used as input to various commands including leaks, heap, stringdups, vmmap, malloc_history, footprint, and the Xcode Memory Graph Debugger. OPTIONS
-list Print the leaks as a list ("classic"-style) rather than as a tree. Warning: this option may be removed in the future. -groupByType When printing a tree of leaked objects, group the children of a node in the tree by type, rather than showing individual instances. -nocontext Do not print the string or hex representation of leaked memory. Although that information can be useful for recognizing the contents of the buffer and understanding why it might be leaked, it can also provide overwhelming detail, and could expose con- fidential information from your process if you, for example, file bug reports with that output included. -nostacks Do not print backtraces of leaked blocks even if the target process has the MallocStackLogging environment variable set. -nosources Do not print sourceFile:lineNumber in backtraces. This can improve performance when examining a process with a huge number of debug symbols. -quiet Do not print process description header or binary image list. -exclude symbol Exclude leaked blocks whose backtraces include the specified symbol. This option can be repeated for multiple symbols. This allows ignoring leaks that, for example, are allocated in libraries for which you do not have source code. -trace address Print chains of references from process 'roots' (e.g., global data, registers, or locations on stacks) to the given block. This is useful for determining what is holding onto a buffer such that it has not been freed. -outputGraph path Generate a memory graph file containing information about all VM and malloc nodes, and the references between them. path can be a path to a file, or just a directory name; in the latter case a filename with the ".memgraph" suffix will be generated. -fullContent When generating a memory graph file, include descriptions of the content of various objects, as would be shown by "heap <pid> -addresses all", and as needed by "stringdups <pid>". -atExit Launches the specified process and runs leaks when the process exits. The process to launch must be the end of the command, and proceeded by '--': leaks -atExit -- /MyPath/MyProgram -MyArg ENVIRONMENT
The leaks command may detect more leaks if the target process is run with the MallocScribble environment variable. If this variable is set then when malloc blocks are deallocated they are filled with 0x55 bytes, thus overwriting any "stale" data such as pointers remaining in those blocks. This reduces the number of false pointers remaining in the process memory. EXIT STATUS
The leaks command exits with one of the following values: 0 No leaks were detected. 1 One or more leaks were detected. >1 An error occurred. SEE ALSO
malloc(3), heap(1), malloc_history(1), stringdups(1), vmmap(1), footprint(1), DevToolsSecurity(1) The Xcode Memory Graph Debuggger graphically shows malloc blocks and VM regions (both leaked and non-leaked), and the references between them. The Xcode developer tools also include Instruments, a graphical application that can give information similar to that provided by leaks. The Allocations instrument graphically displays dynamic, real-time information about the object and memory use in an application, including back- traces of where the allocations occurred. The Leaks instrument performs memory leak analysis. BSD
May 6, 2018 BSD