Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: How to access the contents of a specific memory address?

by bulk88 (Priest)
on Jul 29, 2012 at 21:38 UTC ( [id://984313]=note: print w/replies, xml ) Need Help??


in reply to Re^2: How to access the contents of a specific memory address?
in thread How to access the contents of a specific memory address?

What do you want know on perl's memory allocation?

If you want a 1 second glimpse, run
use Devel::Peek; $num = 5; Dump($num); print $num."\n"; Dump($num);
Output
SV = IV(0xbf4958) at 0xbf495c REFCNT = 1 FLAGS = (IOK,pIOK) IV = 5 5 SV = PVIV(0x39df74) at 0xbf495c REFCNT = 1 FLAGS = (IOK,POK,pIOK,pPOK) IV = 5 PV = 0x84cb0c "5"\0 CUR = 1 LEN = 4
If you want to know more, read illguts. Someone on perlmonks is bound to know whatever you ask about Perl's C side.

Replies are listed 'Best First'.
Re^4: How to access the contents of a specific memory address?
by pat_mc (Pilgrim) on Jul 30, 2012 at 19:54 UTC
    Yes, this is taking me half the way I wanted to go. I can use Devel::Peek to inspect variables and their location in memory. What I really wanted to do, however, was to go the other way: to find out which value is currently stored in a specific memory location.

    Is there a way Devel::Peek will provide this information, too?
      Yes, this is taking me half the way I wanted to go. I can use Devel::Peek to inspect variables and their location in memory. What I really wanted to do, however, was to go the other way: to find out which value is currently stored in a specific memory location.

      Is there a way Devel::Peek will provide this information, too?


      I am confused. Are you saying "I have a PV */char * from an unknown SV, I want to find out what SV * does this PV */char * belong to, how can I do this?"? This might be possible to do BTW.

      Or are you asking, I have a PV */char *, I want to find out how long is the allocation according to the malloc system?

      If I understand "to find out which value is currently stored in a specific memory location." in isolation, you want to read a memory block into the Perl language. That involves unpack(), and was shown to you before in this thread.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://984313]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-03-19 07:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found