473,406 Members | 2,745 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,406 software developers and data experts.

Stack access

15
Hey
i needed to know how to access the stack and all the local variables of the functions in the stack for VC++.
We're implementing a Garbage Collector and need to find rootsets. Looking for the contents of stack would help us find these rootset.
For now we've found that we may be able to access the stack using the ESP register but still haven't found a way to use it.
Can anyone help us?
Thanks in advance.
Mar 23 '09 #1
6 2562
weaknessforcats
9,208 Expert Mod 8TB
gcnew won't work for you?
Mar 23 '09 #2
vsachar
15
I looked into gcnew and it doesn't look like what we need. Could you please explain a little about it?
Thanks.

We're looking to access the addresses in the stack, of local dynamic variables that are being used, and compare with the addresses of all dynamically allocated memory. This is how we're collecting the garbage.

Is there a way to access the stack and copy the addresses in it? We're trying _asm but cannot make sense of how exactly to use the esp and ebp registers.

If anyone has any information, please let us know.
Thanks in advance.
Mar 24 '09 #3
vsachar
15
I forgot to mention that we're trying to write a garbage collector for C++. We're using VC++.
Thanks
Mar 24 '09 #4
newb16
687 512MB
What will you do if some pointer is allocated in register (e.g. EAX) and never appears on stack? How do you know is it a pointer or integer without access to debug information?
Mar 24 '09 #5
Banfa
9,065 Expert Mod 8TB
Can't you solve this problem by just using http://bytes.com/topic/c/insights/65...-smart-pointer?
Mar 24 '09 #6
weaknessforcats
9,208 Expert Mod 8TB
gcnew is the garbage-collected C++ new operator used in Managed C++. You need CLI support in your C++ program.

Since this is the same garbage collector that's used in C#, I don't see why you would go to the trouble to write your own.

Alternatively, if this a Windows program you can create a private heap using HeapCreate. Allocate from there and then just delete the heap when you are done. That will take care of your garbage. This is actually recommended by Richter in Windows via C/C++ 2007.
Mar 24 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Andrew | last post by:
Last night I was reading about implementing my own stack. The example given pushes items on and off the stack at the start and end of each procedure (ie. in a std module). What's not so clear is...
0
by: CoderGuy | last post by:
Hello I am reading up a bit on how memmory is used in the .NET Framework and have a few question about the stack-based approach * I understand that the stack is used to provide a layer of...
19
by: Jim | last post by:
I have spent the past few weeks designing a database for my company. The problem is I have started running into what I believe are stack overflow problems. There are two tab controls on the form...
4
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's...
12
by: Benny | last post by:
DataSet ds = new DataSet() Is the variable (pointer) 'ds' in the stack and the dataset object being pointed allocated in the heap Thanks Benny
0
by: CoderGuy | last post by:
Hello I am reading up a bit on how memmory is used in the .NET Framework and have a few question about the stack-based approach * I understand that the stack is used to provide a layer of...
16
by: sarathy | last post by:
Hi all, I need a few clarifications regarding memory allocaion in C++. I apologize for the lengthy explanation. 1. In C++, Objects are allocated in heap. What does heap refer to? Is it an area...
24
by: John | last post by:
I know this is a very fundamental question. I am still quite confused if the program call stack stack should always grows upwards from the bottom, or the opposite, or doesn't matter?? That means...
8
by: t | last post by:
The stack container adaptor uses deque as its default underlying sequential container. I don't understand why since we only add elements and remove elements from one side of a stack. Why isn't...
62
by: jt | last post by:
hello everyone.. int fun() { /* anything */ } int main(void) { fun(); }
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.