473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Dump Memory Pointer?

Is there anyway that when a function is passed a memory pointer that the
contents of that pointer can be dereferenced or the bytes dumped to a
file or console?

The problem is i have no idea what the pointer really is to and nor do I
have any idea what the total size of the pointer is. I'm trying to
debug something for a friend and this has me stumped and I don't know if
it's even possible.

TIA,
cc
Jul 22 '05 #1
5 3436
On Wed, 14 Apr 2004 15:03:59 -0400 in comp.lang.c++,
ch************@tkdsoftware.com (Chris Cranford) wrote,
Is there anyway that when a function is passed a memory pointer that the
contents of that pointer can be dereferenced or the bytes dumped to a
file or console?

The problem is i have no idea what the pointer really is to and nor do I
have any idea what the total size of the pointer is. I'm trying to
debug something for a friend and this has me stumped and I don't know if
it's even possible.


I suppose you have to guess as to the size of memory area you want to
look at.

Cast the pointer to (unsigned char *). Then hit it with something like
an adaptation of
http://groups.google.com/gr*********....earthlink.net

Jul 22 '05 #2
"Chris Cranford" <ch************@tkdsoftware.com> wrote in message
news:10**************@distinctinnovations.com...
Is there anyway that when a function is passed a memory pointer that the
contents of that pointer can be dereferenced or the bytes dumped to a
file or console?

The problem is i have no idea what the pointer really is to and nor do I
have any idea what the total size of the pointer is. I'm trying to
debug something for a friend and this has me stumped and I don't know if
it's even possible.

Every object in C++ can be considered as an array of unsigned chars which
you can safely *read*. But you have to know the size. Example:
#include <iostream>
#include <vector>
int main()
{
using namespace std;

vector<int>something(10);

unsigned char *p=reinterpret_cast<unsigned char *>(&something);
// std::cout<<static_cast<unsigned>(something[i]); if you want to see
numbers
for(unsigned i=0; i<sizeof(something); ++i)
cout<<p[i];

cout<<endl;

}
All bytes including those with padding bits are printed.


Ioannis Vranos

Jul 22 '05 #3
"Ioannis Vranos" <iv*@guesswh.at.emails.ru> wrote in message
news:c5***********@ulysses.noc.ntua.gr...

// std::cout<<static_cast<unsigned>(something[i]); if you want to see
numbers

// std::cout<<static_cast<unsigned>(p[i]); if you want to see numbers


Ioannis Vranos
Jul 22 '05 #4
Chris Cranford <ch************@tkdsoftware.com> spoke thus:
The problem is i have no idea what the pointer really is to and nor do I
have any idea what the total size of the pointer is. I'm trying to
debug something for a friend and this has me stumped and I don't know if
it's even possible.


How can you have no idea what the pointer is? If it isn't a pointer
to a type you know about, then it's a void pointer. If it's a void
pointer, you 1) can't dereference it directly, and 2) can't
dereference it at all unless you figure out (preferably by reading the
code, although I guess you could static_cast randomly...) what it was
pointing to. And you can't "dump" what a pointer is pointing to
without dereferencing the pointer.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #5
Christopher Benson-Manica <at***@nospam.cyberspace.org> spoke thus:
...
pointing to. And you can't "dump" what a pointer is pointing to
without dereferencing the pointer.

^
Or, of course, by knowing the size of what it's pointing to.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Pacher R. Dragos | last post by:
Can someone please tell me how do I dump memory in C. I tryed to define a void pointer to an offset but It doesn't work as I expected. A tiny example would be very nice.
9
by: Microsoft News Server | last post by:
Hi, I am currently having a problem with random, intermittent lock ups in my ASP.net application on our production server (99% CPU usage by 3 threads, indefinately). I currently use IIS Debug...
8
by: nkrisraj | last post by:
Hi, I have a following structure: typedef struct { RateData rdr; int RateID; char RateBalance; } RateInfo;
4
by: news.fe.internet.bosch.com | last post by:
Hi, I have c++ application which dumps core only static mode and not in debug mode , I used gdb debugger to know which function is reason for core dump , is there other ways to find it out. ...
6
by: wenmang | last post by:
Here is the code which causes core dump when is built differently, 1 for regular dev built, the other for packaging build. class my_class{ public: my_class(){}; ~my_class(){}; private:...
8
by: Rakesh | last post by:
Hi - What is wrong this implementation? I get a core dump at the free() statement? Thanks Rakesh #include <ext/hash_map> #include <iostream.h> #include <ext/hash_set>
14
by: Sheldon | last post by:
Hi, I have a python script that uses a C extention. I keep getting a recurring problem that causes a core dump a few lines after the C extention return data back tp python. I tried using pbd and...
4
by: loudking | last post by:
Hi, all Here is part of my code. ======================================== void *record; /* treat record */ if (record) {
2
by: erfan | last post by:
Hi,comp.c: I try to learn malloc,facing a problem like this: -------- #include<unistd.h> #include<stdlib.h> #include<stdio.h> int main(void) {
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.