Hi Tim,<div><br><div>Thanks. I just went through the function and yah as you said i looked into the standard and it seems to be as per C++11. Was confused by the documentation at <a href="http://msdn.microsoft.com/en-us/library/ytk2ae82.aspx">http://msdn.microsoft.com/en-us/library/ytk2ae82.aspx</a> which mentioned this should be always const which may not be right as mentioned at <a href="http://stackoverflow.com/questions/6067244/type-of-this-pointer">http://stackoverflow.com/questions/6067244/type-of-this-pointer</a> .</div>
<div><br></div><div>Thanks for the input.<br><br><div class="gmail_quote">On Tue, Oct 2, 2012 at 12:34 PM, Tim Northover <span dir="ltr"><<a href="mailto:t.p.northover@gmail.com" target="_blank">t.p.northover@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Karthik,<br>
<div class="im"><br>
> Expected result when we run -<br>
><br>
> print Simple::fun in GDB is<br>
> void fun(Simple* const this)<br>
><br>
> as this should be a const pointer but in case of arm compiled binary we get<br>
> void fun(Simple* this).<br>
<br>
</div>I believe the actual type is coming from CXXMethodDecl::getThisType,<br>
which quotes the standard as saying:<br>
<br>
// C++ 9.3.2p1: The type of this in a member function of a class X is X*.<br>
// If the member function is declared const, the type of this is const X*,<br>
// if the member function is declared volatile, the type of this is<br>
// volatile X*, and if the member function is declared const volatile,<br>
// the type of this is const volatile X*.<br>
<br>
I.e. no const where you're expecting it.<br>
<br>
I've checked the standards, and we're not making it up either: both<br>
C++11 and C++03 say the same.<br>
<div class="im"><br>
> Seems to be problem with qualifier type but was wondering how is this<br>
> target dependent?<br>
<br>
</div>I think it's the gdb programs that are printing different things for<br>
the same DWARF debug information. Dumping the information from the x86<br>
binary gives:<br>
<br>
<1><6b>: Abbrev Number: 6 (DW_TAG_class_type)<br>
<6c> DW_AT_name : (indirect string, offset: 0x3e): Simple<br>
<70> DW_AT_byte_size : 1<br>
<71> DW_AT_decl_file : 1<br>
<72> DW_AT_decl_line : 1<br>
[...]<br>
<3><7f>: Abbrev Number: 8 (DW_TAG_formal_parameter)<br>
<80> DW_AT_type : <0x86><br>
<84> DW_AT_artificial : 1<br>
<84> DW_AT_object_pointer: 1<br>
<1><86>: Abbrev Number: 9 (DW_TAG_pointer_type)<br>
<87> DW_AT_type : <0x6b><br>
<br>
The "this" parameter has type "Simple *" as expected, but also has the<br>
attribute DW_AT_object_pointer. My guess is that the x86 gdb decides<br>
to print it as "const" because of this, but the ARM one doesn't.<br>
<br>
Hope this helps.<br>
<span class="HOEnZb"><font color="#888888"><br>
Tim.<br>
</font></span></blockquote></div><br></div></div>