<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">So you need to fix "<span style="font-family: Menlo-Regular;" class="">DW_OP_call_frame_cfa" so it creates the same kind of value on the expression stack as "</span>DW_OP_reg31" does. I am guessing that "DW_OP_reg31" will have a Value that whose value is "eValueTypeScalar". Verify this and change "<span style="font-family: Menlo-Regular;" class="">DW_OP_call_frame_cfa" to match. We want the Scalar gotten by:</span><div class=""><font face="Menlo-Regular" class=""><br class=""></font></div><div class=""><font face="Menlo-Regular" class=""> Scalar value;<br class=""> if (frame->GetFrameBaseValue(value, error_ptr)) {<br class=""><br class="">To be the same kind of value. Seems the expression parsing code that uses "</font><span style="font-family: Menlo-Regular;" class="">DW_OP_call_frame_cfa" is doing the wrong thing by setting the value to a load address type.</span></div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Sep 19, 2017, at 10:51 AM, Leonardo Bianconi <<a href="mailto:leonardo.bianconi@eldorado.org.br" class="">leonardo.bianconi@eldorado.org.br</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class=""><br class=""><blockquote type="cite" class="">-----Original Message-----<br class="">From: Greg Clayton [<a href="mailto:clayborg@gmail.com" class="">mailto:clayborg@gmail.com</a>]<br class="">Sent: terça-feira, 19 de setembro de 2017 12:33<br class="">To: Leonardo Bianconi <<a href="mailto:leonardo.bianconi@eldorado.org.br" class="">leonardo.bianconi@eldorado.org.br</a>><br class="">Cc: <a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a><br class="">Subject: Re: [lldb-dev] Reading eValueTypeLoadAddress with missing compiler<br class="">type<br class=""><br class=""><br class=""><blockquote type="cite" class="">On Sep 19, 2017, at 4:10 AM, Leonardo Bianconi<br class=""></blockquote><<a href="mailto:leonardo.bianconi@eldorado.org.br" class="">leonardo.bianconi@eldorado.org.br</a>> wrote:<br class=""><blockquote type="cite" class=""><br class="">Some more details:<br class=""><br class="">I'm part of the team that is working in LLDB to enable PPC64le architecture, so<br class=""></blockquote>I'm running my test in a Power8 machine.<br class=""><blockquote type="cite" class="">When compiling the code with clang, it works, the issue happen when compiling<br class=""></blockquote>with gcc, which generates a different debug information content.<br class=""><blockquote type="cite" class=""><br class="">Talking a bit about the power stack frame, it is organized this way:<br class=""><br class="">Suppose that you have two functions a() and b() and a calls b, then the frames<br class=""></blockquote>will be like this:<br class=""><blockquote type="cite" class=""><br class="">high address<br class="">+-----------------+<br class="">| ... | // frame of a<br class="">| ... |<br class="">| ... |<br class="">| ... |<br class="">| ... |<br class="">| back chain | // r31 and r1 points here when running function a<br class="">+-----------------+<br class="">| ... | // frame of b<br class="">|variable address |<br class="">| ... |<br class="">| ... |<br class="">| ... |<br class="">| back chain | // r31 and r1 points here when running function b<br class="">+-----------------+<br class="">low address<br class=""><br class="">The debug information related to find the variable with clang is:<br class=""><2><6ce>: Abbrev Number: 27 (DW_TAG_variable)<br class=""> <6cf> DW_AT_location : 3 byte block: 91 f0 0 (DW_OP_fbreg: 112)<br class=""> <6d3> DW_AT_name : (indirect string, offset: 0x1cf): a<br class=""> <6d7> DW_AT_decl_file : 5<br class=""> <6d8> DW_AT_decl_line : 6<br class=""> <6d9> DW_AT_type : <0x1bf><br class=""><2><6dd>: Abbrev Number: 0<br class=""><1><6de>: Abbrev Number: 0<br class=""><1><6b5>: Abbrev Number: 26 (DW_TAG_subprogram)<br class=""> <6b6> DW_AT_low_pc : 0x10000630<br class=""> <6be> DW_AT_high_pc : 0x88<br class=""> <6c2> DW_AT_frame_base : 1 byte block: 6f (DW_OP_reg31 (r31))<br class=""> <6c4> DW_AT_name : (indirect string, offset: 0x1ca): main<br class=""> <6c8> DW_AT_decl_file : 5<br class=""> <6c9> DW_AT_decl_line : 5<br class=""> <6ca> DW_AT_type : <0x1bf><br class=""> <6ce> DW_AT_external : 1<br class=""><br class="">Which uses the r31 (DW_OP_reg31) and a positive offset (112) to find it, which<br class=""></blockquote>is ok, as it does not need to read the memory using the address in the r31<br class="">register.<br class=""><blockquote type="cite" class=""><br class="">The issue happen when using the debug information generated by gcc, which<br class=""></blockquote>is:<br class=""><blockquote type="cite" class=""> <2><9e>: Abbrev Number: 5 (DW_TAG_variable)<br class=""> <9f> DW_AT_name : a<br class=""> <a1> DW_AT_decl_file : 1<br class=""> <a2> DW_AT_decl_line : 6<br class=""> <a3> DW_AT_type : <0x3b><br class=""> <a7> DW_AT_location : 2 byte block: 91 5c (DW_OP_fbreg: -36)<br class=""><1><81>: Abbrev Number: 4 (DW_TAG_subprogram)<br class=""> <82> DW_AT_external : 1<br class=""> <82> DW_AT_name : (indirect string, offset: 0xe): main<br class=""> <86> DW_AT_decl_file : 1<br class=""> <87> DW_AT_decl_line : 5<br class=""> <88> DW_AT_type : <0x3b><br class=""> <8c> DW_AT_low_pc : 0x840<br class=""> <94> DW_AT_high_pc : 0xf8<br class=""> <9c> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)<br class=""> <9e> DW_AT_GNU_all_tail_call_sites: 1<br class=""><br class="">Here, it says to use the "DW_OP_call_frame_cfa", that is correctly executed in<br class=""></blockquote>the LLDB, obtaining the content of r31 and setting it as "<br class="">lldb_private::Value::eValueTypeLoadAddress", which means the data it is looking<br class="">for is located in the address obtained in the r31, and it need to be read from<br class="">memory. If the address was correctly read, it would point to the back chain of the<br class="">previous frame, and the variable would be found, as the offset is negative (-36),<br class="">so ("previous back chain address" - 36) is the correct variable address.<br class=""><blockquote type="cite" class=""><br class="">My code is very simple:<br class="">=====================================<br class="">#include <stdlib.h><br class="">#include <stdio.h><br class=""><br class="">int main(void) {<br class=""> int a = 2;<br class=""> printf("a address: %p \n", (void*)&a);<br class=""> printf("a = %d \n", a);<br class=""> return 0;<br class="">}<br class="">=====================================<br class=""><br class="">And I'm using the commands:<br class="">gcc -O0 -ggdb stest.cpp (gcc version 5.4.1 20170304)<br class="">clang -O0 -ggdb stest.cpp<br class=""><br class=""><br class="">I think it is not related with the variable type, right?<br class=""></blockquote><br class="">It might be, can you show the DWARF for the 0x3b type? This was in your GCC<br class="">variable's DWARF:<br class=""><br class=""><blockquote type="cite" class=""> <a3> DW_AT_type : <0x3b><br class=""></blockquote></blockquote><br class="">It is a 4 byte signed integer:<br class=""><br class=""><1><3b>: Abbrev Number: 3 (DW_TAG_base_type)<br class=""> <3c> DW_AT_byte_size : 4<br class=""> <3d> DW_AT_encoding : 5 (signed)<br class=""> <3e> DW_AT_name : int<br class=""><br class=""><blockquote type="cite" class=""><br class="">There should be nothing wrong with that as long as LLDB is correctly setting r31<br class="">into the expression stack in response to the DW_OP_call_frame_cfa opcode. It<br class="">should grab r31 - 36 and push the result onto the expression stack with<br class="">eValueTypeLoadAddress as the type. Then we just need to read the type from<br class="">memory. Since the type is so simple (int), I don't see the type failing here. I am<br class="">guessing the DW_OP_call_frame_cfa is messing up the expression somehow.<br class="">Can you step through and make sure that "r31 - 36" is correctly being pushed<br class="">onto the expression stack?<br class=""></blockquote><br class="">I think I was not clear when I referenced the " DW_OP_call_frame_cfa", sorry for that. I mean it is trying to resolve the frame base value, not the variable yet, the issue is before trying to get the variable address.<br class=""><br class="">I will do some steps to clarify it:<br class=""><br class="">* Using gcc binary<br class="">- On the prompt I type the command "p a" to print the variable value.<br class="">- LLDB needs the base frame, which must be found using the debug info " DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)".<br class="">- The value of r31 is read, and it is set to " lldb_private::Value::eValueTypeLoadAddress", which means that beyond read the r31 value, this value is an address that must be read as well, in order to point to the previous frame:<br class=""><br class="">+-----------+<br class="">| | // frame of a<br class="">|back chain | //previous r31' and r1'<br class="">+-----------+<br class="">| | // frame of b<br class="">|back chain | //current r31 and r1<br class="">+-----------+<br class=""><br class="">Issue: It should get the r31' as address of frame base to apply the offset, and read the variable value that is inside the "frame of b", as the offset is negative. Instead of that, as the compiler type is invalid, the address obtained from r31 value is not being read, no error is shown, and the frame base value keeps as r31, which is incorrect. When using this value, the variable address is located in the red zone "r31 - 28 (offset)" (DW_AT_location : 2 byte block: 91 64 (DW_OP_fbreg: -28)).<br class=""><br class=""><br class="">* Using Clang binary:<br class="">- On the prompt I type the command "p a" to print the variable value.<br class="">- LLDB needs the base frame, which must be found using the debug info "DW_AT_frame_base : 1 byte block: 6f (DW_OP_reg31 (r31))".<br class="">- The value of r31 is read, and the memory of the address found in r31 is not read from memory, when running the case " DW_OP_reg31".<br class=""><br class="">+-----------+<br class="">| | // frame of a<br class="">|back chain | //previous r31' and r1'<br class="">+-----------+<br class="">| | // frame of b<br class="">|back chain | //current r31 and r1<br class="">+-----------+<br class=""><br class="">Result: It gets the r31 value, which points to the back chain of the "frame b", as expected, because the offset is positive, so "r31 + 112" (<6cf> DW_AT_location : 3 byte block: 91 f0 0 (DW_OP_fbreg: 112)).<br class=""><br class=""><br class=""><br class="">It is visible that gcc and lldb generates different debug info, gcc calculates the variable offset from the beginning of the frame, while lldb from the end of the frame. I saw in the code that LLDB is getting the correct information about the frame, but as the compiler type is invalid, the memory is not read, if it was valid, it would work correctly, that is why I'm trying to set the correct compiler type. I need to know what compiler type to use when reading the previous frame.<br class=""><br class="">I placed the full output from the binaries in the pastbin:<br class="">Clang debug info: <a href="https://pastebin.com/tyXp5C9g" class="">https://pastebin.com/tyXp5C9g</a><br class="">Gcc debug info: <a href="https://pastebin.com/00b0SiKm" class="">https://pastebin.com/00b0SiKm</a><br class="">Disassembly of gcc binary: <a href="https://pastebin.com/06UakF24" class="">https://pastebin.com/06UakF24</a> <br class=""><br class=""><br class=""><blockquote type="cite" class=""><br class=""><blockquote type="cite" class=""><br class="">Thanks!<br class=""><br class=""><br class=""><br class=""><blockquote type="cite" class="">-----Original Message-----<br class="">From: Greg Clayton [<a href="mailto:clayborg@gmail.com" class="">mailto:clayborg@gmail.com</a>]<br class="">Sent: segunda-feira, 18 de setembro de 2017 17:24<br class="">To: Leonardo Bianconi <<a href="mailto:leonardo.bianconi@eldorado.org.br" class="">leonardo.bianconi@eldorado.org.br</a>><br class="">Cc: <a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a><br class="">Subject: Re: [lldb-dev] Reading eValueTypeLoadAddress with missing compiler<br class="">type<br class=""><br class="">If you have the binary and the function that this is happening in and can share<br class=""></blockquote></blockquote>the<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">binary that contains debug info and also share which file and function and<br class="">variable is causing the issue, I might be able to tell you why this is happening.<br class=""><br class="">Greg<br class=""><br class=""><blockquote type="cite" class="">On Sep 18, 2017, at 1:23 PM, Greg Clayton <<a href="mailto:clayborg@gmail.com" class="">clayborg@gmail.com</a>> wrote:<br class=""><br class="">A DW_TAG_subprogram's usually has a DW_AT_frame_base DWARF<br class=""></blockquote>expression that describes where the frame is. That evaluates to something<br class=""></blockquote></blockquote>and<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">doesn't require any type. I am guessing you now have a variable that is<br class=""></blockquote></blockquote>relative to<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">that frame base and that variable's type is not valid. This can be due to many<br class="">reasons, most likely is the compiler may have redacted your type when trying<br class=""></blockquote></blockquote>to<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">save space. Can you confirm this is what is happening?<br class=""><blockquote type="cite" class=""><br class=""><br class=""><blockquote type="cite" class="">On Sep 18, 2017, at 12:25 PM, Leonardo Bianconi via lldb-dev <lldb-<br class=""></blockquote></blockquote><a href="mailto:dev@lists.llvm.org" class="">dev@lists.llvm.org</a>> wrote:<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class="">Hi all!<br class=""><br class="">I'm facing an issue with a value of<br class=""></blockquote></blockquote>lldb_private::Value::eValueTypeLoadAddress type, which cannot be loaded<br class=""></blockquote></blockquote>from<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">memory because the compiler type was not filled.<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">That happens obtaining the fame base, which is based on<br class=""></blockquote></blockquote>"DW_OP_call_frame_cfa" case (DWARFExpression.cpp:2825).<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">After obtain the base frame, when resolving the value (Value.cpp:612), as<br class=""></blockquote></blockquote></blockquote></blockquote>the<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">compiler type is invalid, the value is not read from memory, and the frame<br class=""></blockquote></blockquote>base<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">keep as its address.<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class="">How can I solve this issue?<br class="">I looked in many files, and couldn't find how to fill the compiler type in the<br class=""></blockquote></blockquote>"DWARFExpression::Evaluate" method.<br class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class=""><br class="">Thanks,<br class="">Leonardo Bianconi.<br class="">_______________________________________________<br class="">lldb-dev mailing list<br class=""><a href="mailto:lldb-dev@lists.llvm.org" class="">lldb-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev<br class=""></blockquote><br class=""></blockquote></blockquote><br class=""></blockquote></blockquote><br class=""></div></div></blockquote></div><br class=""></div></body></html>