- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Line and File number of a Calling function! how to...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 01:05 AM
тАО09-08-2009 01:05 AM
I am writting a wrapper function for Malloc and I need to get the line number and file number of Malloc function where ever it is called , to keep track of where Malloc is being called and where free is being called.
This is being done in order to check for memory leaks.
IS there a way i can find out the File number and line number where every it is called. (I will be modifying malloc in the way mentioned).
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 03:07 AM
тАО09-08-2009 03:07 AM
Re: Line and File number of a Calling function! how to get it?
I would suggest you use gdb's leak detection tools and not invent your own.
>Is there a way I can find out the file number and line number
(I assume you mean filename.)
If you are using PA, you can only find this if you have debug info, -g. And then you would have to use gdb to extract it from the hex addresses.
For IPF, you can get this info from unwind(5).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 07:49 PM
тАО09-08-2009 07:49 PM
Re: Line and File number of a Calling function! how to get it?
For example,
#include
#include
main ()
{
printf ("This is sample output from %s:%d\n", __FILE__, __LINE__);
}
would give following output
This is sample output from test_line.c:6
Regards
-Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 08:32 PM
тАО09-08-2009 08:32 PM
Re: Line and File number of a Calling function! how to get it?
The gdb is not working on our shell for some reason.Hence we are beign forced to try and create our own wrapper function. I guess one of the libraries is missing .
Currently I was trying to use dladdr to get info about the adresses of object and function from which the call might have been made.
Is there any way to use the 4 parameters specified by dladdr to pinpoint the line number from where the call is made? (we get the function address from dladdr)
@Rajesh
__LINE__ gives the line number where the macro __LINE__ is hard coded, it would not give the line number of the function calls made.
example:
int main()
{
hello();
....
}
int hello()
{
printf("line number is:%d",__LINE__);
...
}
This would give the line number of where in hello the __LINE__ is hardcoded.
What i want is the line number where hello(); is called.
Thanks for your reply guys Really appreciate it :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 08:55 PM
тАО09-08-2009 08:55 PM
Re: Line and File number of a Calling function! how to get it?
#define malloc( size ) \
memtrc_malloc( (size_t)(size), __FILE__, __LINE__ )
You get the idea.
(The whole thing is available at http://vms.pdv-systeme.de/users/martinv/memtrc.zip )
HTH,
Martin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 09:34 PM
тАО09-08-2009 09:34 PM
Re: Line and File number of a Calling function! how to get it?
Regards
-Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-10-2009 12:39 AM
тАО09-10-2009 12:39 AM
SolutionHave you downloaded wdb 6.0?
It would be much easier to get gdb working than to try to implement something that took years to develop and may not even be documented.
Are you using PA or IPF?
>Is there any way to use the 4 parameters specified by dladdr to pinpoint the line number from where the call is made?
No directly. Not unless you used the unwind(5) functions.
Note: There is no real need to get the function, file and line number in your instrumentation. You can simply play back the hex address and ask gdb for the position.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-01-2009 11:57 PM
тАО11-01-2009 11:57 PM
Re: Line and File number of a Calling function! how to get it?
http://forums.itrc.hp.com/service/forums/helptips.do?#33