- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- What are valid heap addresses for 64 bit applicati...
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
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
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
07-29-2013 07:57 AM - last edited on 07-29-2013 07:35 PM by JinJing1
07-29-2013 07:57 AM - last edited on 07-29-2013 07:35 PM by JinJing1
If I do this C++ code in a 64-bit program on HP-UX 11.31 and new is successful:
char *p = new char;
p points to somewhere in the heap. But what is possible min and max values for p?
I understand that p is always bigger than 0x6000000000000000. But what are actual min and max values on HP-UX 11.31 for a valid pointer?
P.S. This thread has been moved from HP-UX >General > to HP-UX > languages.-Hp forum moderator
Solved! Go to Solution.
- Tags:
- gdb
- heap usage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2013 09:51 AM - edited 07-29-2013 07:43 PM
07-29-2013 09:51 AM - edited 07-29-2013 07:43 PM
Re: What are valid heap addresses for 64 bit application on HP-UX 11.31?
Take a look at end(3C).
The heap range is from _end to the current brk value.
(gdb) p /x &_end
$8 = 0x6000000000000038
(gdb) p /x sbrk(0)
$9 = 0x38
Unfortunately since there is no debug info for sbrk, it only prints at the low order 32 bits. :-(
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2013 10:24 PM - edited 07-29-2013 10:49 PM
07-29-2013 10:24 PM - edited 07-29-2013 10:49 PM
Re: What are valid heap addresses for 64 bit application on HP-UX 11.31?
Dennis, thank for a reply.
Unfortunatelly I still don't quite understand how to get min and max values.
Take this program as an example (I build it: aCC +DD64 -g main2.cpp -o main2)
#include <stdio.h>
int main()
{
char *p = new char;
printf("%p\n", p);
delete p;
return 0;
}
So my question in what range can be p after "new char"? MIN_VALUE < p < MAX_VALUE ?
I run gdb and did what you suggested:
(gdb) r Starting program: /import/home/sergey.kurenkov/src/ia64.11-31/tests/test.analyze_core/./main2 Breakpoint 1, main () at main2.cpp:4 4 char *p = new char; (gdb) n 5 printf("%p\n", p); (gdb) p/x p $1 = 0x6000000000004790 (gdb) p/x &_end $2 = 0x6000000000000070 (gdb) p/x &_edata $3 = 0x6000000000000050 (gdb)
Looking at this I can guess that I can use &_end as MIN_VALUE, but how to get MAX_VALUE?
Is it p/x &_end + sbrk(0)? If it is so it is useless in case one analyzes a core file. I mean one can't execute p/x sbrk(0) while analyzing a core file:
(gdb) p/x sbrk(0)
You can't do that without a process to debug.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-29-2013 11:43 PM - edited 07-29-2013 11:44 PM
07-29-2013 11:43 PM - edited 07-29-2013 11:44 PM
Solution>how to get MAX_VALUE?
>Is it p/x &_end + sbrk(0)?
No, it's at least: p /x ((long long)&_end >> 32 << 32) + sbrk(0)
>If it is so it is useless in case one analyzes a core file.
You'll need to compute this outside of gdb:
$ elfdump -o -S core.10472
core.10472:
*** Program Header ***
Type Offset Vaddr FSize Memsz
CoreVer 00000000000004d8 0000000000000000 0000000000000004 0000000000000004
...
CoreLoad 000000000000caf8 6000000000000000 0000000000001000 0000000000001000
It's CoreLoad.Vaddr + CoreLoad.Memsz: 0x6000000000000000 + 0x0000000000001000
Or use gdb's "info file":
(gdb) info file
Operating System Information:
sysname : B.11.31
...
Symbols from "./a.out".
Local core dump file:
`./core.10472', file type elf64-big.
0x6000000000000000 - 0x6000000000001000 is segment5 (PT_HP_CORE_LOADABLE)