microsoft / microsoft-pdb

Information from Microsoft about the PDB format. We'll try to keep this up to date. Just trying to help the CLANG/LLVM community get onto Windows.
Other
1.86k stars 273 forks source link

Differentiating between fuction parameter and function variable #18

Open 8thMage opened 8 years ago

8thMage commented 8 years ago

hello, i'm trying to parse a pdb in order to write a debugger. i've got the following sample function: `static void clear(PictureBuffer buffer,unsigned int Color) { PictureBuffer a = buffer; for(int i=0;i<a.height;i++) { for(int j=0;j<buffer.width;j++) { buffer.picture[i*buffer.pitch+j]=Color;

    }
}

} ` and you can see in this function 2 instances of PictureBuffer, one of them is passed as a parameter and one is in the function. the function parameter as speced in x64 call convention is passed as a pointer, and the instance in the scope sits as values on the stack well i've got the hex for the places in the pdb here, and i don't see any difference between the two instances, can you point me to how i can know whether it's a pointer or not?

hex

also, is there a place to ask question about the pdb file format that is not in the github issues section? please point me to it if there is one. thanks, the_8th_mage.

AndrewPardoe commented 8 years ago

Hey 8thMage, send me mail--it's my firstname.lastname@microsoft.com--and I'll loop you in with the linker dev who can explain these things for you. We've never really documented this area as there are so few people who are interested :-/

8thMage commented 8 years ago

I sent it, but you have not responded, please tell if you didn't get it.

avakar commented 8 years ago

Wouldn't it be better to keep the discussion here? So that other people can benefit from it in the future?

AndrewPardoe commented 8 years ago

@8thMage, I was sleeping :) I sent mail a couple hours ago.

@avakar, email and Skype can be more expedient than GitHub issues. We will roll back anything we've learned or discovered from this conversation to a public forum.

Dazler commented 7 years ago

What i think is both the variables are acting as a pointer ..because in memory, u have created only one instance of your image, and first you have stored address of that instance into function parameter and then again into variable used in function, that's why you are not getting any difference in hex places for both variables, since both are pointing to the address of the picture simultaneously.

skochinsky commented 7 years ago

Yes, the compiler probably reused the incoming argument slot for the local variable (it can do that because you don't use the argument anywhere else) so both point to the same stack location. You can verify by checking the generated assembly.