OS prevents GDB from giving us the physical address, and instead we have virtual addresses. Is there a way to actually get that physical address?
Doing debugging on Windows Visual Studio looks more promising: the addresses look more like real addresses. However, are they really the physical addresses???
I have been investigating GDB and Visual Studio with the following source code for a few days already (and you can tell this from my profile)
int main()
{
int a = 10;
int b = 13;
int c;
c = a + b;
return 0;
}
PS: I know I have been asking many similar questions. This is a super broad topic, and I thank you all the great helps. JFYI, it is 3:36AM :( and I do a lot of research + testing before I come here to ask. Thanks.
Physical Address: Refers to the physical address of the Ethernet connection to your computer or server. This may also be referred to as your MAC (Media Access Control) Address, Host ID or Server ID. It is twelve characters long and is a combination of numbers (0–9) and letters (A–F, a–f).
This logical address (generated by CPU) combines with the base address generated by the MMU to form the physical address. The hardware device called Memory-Management Unit is used for mapping logical addresses to their corresponding physical address.
Whenever workloads access data in memory, the system needs to look up the physical memory address that matches the virtual address. This is what we refer to as memory translations or mappings. To map virtual memory addresses to physical memory addresses, page tables are used.
If you mean the actual address on the physical memory hardware, then there isn't really such a thing (consider that the OS may decide to swap your page to disk, etc.)
See here: How to translate a virtual memory address to a physical address?
You can't, the program and gdb simply don't know about it, which is the point of virtualizing the memory. The operating system takes care of distributing large enough chunks to programs on demand.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With