<div dir="ltr"><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">But where is the flat set? Maybe I can debug and check what is going on.</span></blockquote><div> The MCInstrDesc are in a table in lib/Target/PowerPC<span class="sew7ef5jopsljav"></span><span class="sew7ef5jopsljav"></span>/PPCGenInstrInfo.inc of your build directory.<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p class="gmail-MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Some additional information:</span></p>
<p class="gmail-MsoNormal" style="text-indent:35.4pt"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">MCInst opcode: 0x7cb</span></p><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Decode Index: 0x1e</span></blockquote><div>I had assumed this would have dissembled to '// Inst #234 = BC' which does have the branch flag set, but I think that opcode is for XXLNOR instruction.<br></div><div>Could it be disassembling to `// Inst #2014 = gBC` instead which does not have the branch flag set? Adding Hal and Ulrich in case they have some extra insight here.<br><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><p class="gmail-MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Test case:</span></p>
<p class="gmail-MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US"> </span></p>
<p class="gmail-m_1959917323803839692MsoListParagraph"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US"><span>-<span style="font:7pt "Times New Roman"">         
</span></span></span><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Build the file “lldb/packages/Python/<wbr>lldbsuite/test/<wbr>functionalities/stop-hook/<wbr>main.cpp”</span></p>
<p class="gmail-m_1959917323803839692MsoListParagraph"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US"><span>-<span style="font:7pt "Times New Roman"">         
</span></span></span><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Run LLDB with the binary just generated</span></p>
<p class="gmail-m_1959917323803839692MsoListParagraph"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US"><span>-<span style="font:7pt "Times New Roman"">         
</span></span></span><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Add the breakpoint “b main.cpp:30”</span></p>
<p class="gmail-m_1959917323803839692MsoListParagraph"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US"><span>-<span style="font:7pt "Times New Roman"">         
</span></span></span><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Send the command “n”, stepping over to next line.</span></p>
<p class="gmail-MsoNormal" style="text-indent:18pt"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Result: The debugger will not stop and will execute the entire binary.</span></p>
<p class="gmail-MsoNormal"><span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US"> </span></p>
<span style="font-size:11pt;font-family:"Calibri",sans-serif;color:rgb(31,73,125)" lang="EN-US">Remembering I’m using a little endian Power8 machine.</span></blockquote><div><br></div><div>Are there any outstanding patches or workarounds I need to build lldb on Power8?<br><br></div><div>Thanks<br></div><div>Sean<br> <br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 30, 2017 at 10:09 AM, Leonardo Bianconi <span dir="ltr"><<a href="mailto:leonardo.bianconi@eldorado.org.br" target="_blank">leonardo.bianconi@eldorado.org.br</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="blue" vlink="purple" lang="PT-BR">
<div class="m_1959917323803839692WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">But where is the flat set? Maybe I can debug and check what is going on.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">There is the possibility to be lldb usage, but it’s obtaining the disassembler as it is.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">When lldb tries to instantiate the disassembler, it checks many information in<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">llvm/tools/lldb/source/<wbr>Plugins/Disassembler/llvm/<wbr>DisassemblerLLVMC.cpp:1014 =<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">“DisassemblerLLVMC::<wbr>DisassemblerLLVMC(const ArchSpec &arch,</span><span lang="EN-US">
</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">const char *flavor_string)”,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">which I couldn’t find if it’s doing correct. Is there a place that explains the “flavor” and<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">“features_str” variables used at DisassemblerLLVMC.cpp:1163<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">(“newLLVMCDisassembler(triple_<wbr>str, cpu, features_str.c_str(), flavor, *this)”)?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Another question that I have is, how can I compare the data it gets with the real instructions?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">I found the file “PPCGenDisassemblerTables.inc”<wbr>, where the table is declared, and where the it<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">is decoded, so the current instruction bne cr7,0x2000092c (0x409e000c) is being processed by<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">the case 30 in the PPCGenDisassemblerTables.inc file:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">      case 30:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">        tmp = fieldFromInstruction(insn, 21, 5);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">        if (decodeUImmOperand<5>(MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail; }<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">        tmp = fieldFromInstruction(insn, 16, 5);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">        if (DecodeCRBITRCRegisterClass(<wbr>MI, tmp, Address, Decoder) == MCDisassembler::Fail) { return MCDisassembler::Fail;
 }<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">        tmp = fieldFromInstruction(insn, 2, 14);<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">        MI.addOperand(MCOperand::<wbr>createImm(tmp));<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">        return S;         
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Which is the correct reading for the BC instruction. What am I missing?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Some additional information:<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">MCInst opcode: 0x7cb<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:35.4pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Decode Index: 0x1e<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">=================             <wbr>                      
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Test case:<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="m_1959917323803839692MsoListParagraph"><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><span>-<span style="font:7.0pt "Times New Roman"">         
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Build the file “lldb/packages/Python/<wbr>lldbsuite/test/<wbr>functionalities/stop-hook/<wbr>main.cpp”<u></u><u></u></span></p>
<p class="m_1959917323803839692MsoListParagraph"><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><span>-<span style="font:7.0pt "Times New Roman"">         
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Run LLDB with the binary just generated<u></u><u></u></span></p>
<p class="m_1959917323803839692MsoListParagraph"><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><span>-<span style="font:7.0pt "Times New Roman"">         
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Add the breakpoint “b main.cpp:30”<u></u><u></u></span></p>
<p class="m_1959917323803839692MsoListParagraph"><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><span>-<span style="font:7.0pt "Times New Roman"">         
</span></span></span><u></u><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Send the command “n”, stepping over to next line.<u></u><u></u></span></p>
<p class="MsoNormal" style="text-indent:18.0pt"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Result: The debugger will not stop and will execute the entire binary.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Remembering I’m using a little endian Power8 machine.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US">Thanks!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1f497d" lang="EN-US"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Nemanja Ivanovic [mailto:<a href="mailto:nemanja.i.ibm@gmail.com" target="_blank">nemanja.i.ibm@gmail.<wbr>com</a>]
<br>
<b>Sent:</b> quinta-feira, 30 de novembro de 2017 07:54<br>
<b>To:</b> Sean Fertile <<a href="mailto:sd.fertile@gmail.com" target="_blank">sd.fertile@gmail.com</a>><br>
<b>Cc:</b> Leonardo Bianconi <<a href="mailto:leonardo.bianconi@eldorado.org.br" target="_blank">leonardo.bianconi@eldorado.<wbr>org.br</a>>; <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><span class=""><br>
<b>Subject:</b> Re: [llvm-dev] PPC64 Disassembler<u></u><u></u></span></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">The `isBranch` flag is already set on the branch instructions. Furthermore, we do use the `isBranch()` query in a few places in the PPC back end, so this does work. Perhaps there's something specific about the lldb usage?
 Is it somehow possible that the `isBranch()` query is called on the wrong instruction?<u></u><u></u></span></p>
</div><div><div class="h5">
<p class="MsoNormal"><span lang="EN-US">Would you be able to provide a test case that reproduces the issue?<u></u><u></u></span></p>
</div></div></div><div><div class="h5">
<div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span lang="EN-US">On Thu, Nov 30, 2017 at 2:30 AM, Sean Fertile via llvm-dev <</span><a href="mailto:llvm-dev@lists.llvm.org" target="_blank"><span lang="EN-US">llvm-dev@lists.llvm.org</span></a><span lang="EN-US">> wrote:<u></u><u></u></span></p>
<blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt">
<p class="MsoNormal"><span lang="EN-US">Hello Leonardo,<br>
<br>
What is the opcode of the MCInstrDesc?<br>
<br>
Sean<u></u><u></u></span></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US"><br>
On Wed, Nov 29, 2017 at 1:48 PM, Leonardo Bianconi via llvm-dev<br>
<</span><a href="mailto:llvm-dev@lists.llvm.org" target="_blank"><span lang="EN-US">llvm-dev@lists.llvm.org</span></a><span lang="EN-US">> wrote:<br>
> Hi all,<br>
><br>
><br>
><br>
> I’m working on lldb to make it available to ppc64le, but the “step over”<br>
><br>
> is not working for some cases.<br>
><br>
><br>
><br>
> When debugging, I can see that the disassembler analyze some instructions<br>
><br>
> forward, looking for a branch instruction<br>
><br>
> (llvm/tools/lldb/source/<wbr>Plugins/Disassembler/llvm/<wbr>DisassemblerLLVMC.cpp:87<br>
><br>
> – “const bool can_branch = mc_disasm_ptr->CanBranch(inst)<wbr>;”), while<br>
><br>
> trying to set the next breakpoint.<br>
><br>
><br>
><br>
> On this case, the instruction is the “bne     cr7,0x2000092c”, which is a<br>
> branch,<br>
><br>
> but at llvm/lib/MC/MCInstrDesc.cpp:35 –<br>
><br>
> “if (isBranch() || isCall() || isReturn() || isIndirectBranch())” it returns<br>
> false,<br>
><br>
> making lldb do not set the correct breakpoint, so the execution does not<br>
> stop<br>
><br>
> at next line, which should be the “step over” behavior.<br>
><br>
><br>
><br>
> The variable “Flags” for the disassembled instruction does not have the<br>
> branch<br>
><br>
> flag.<br>
><br>
><br>
><br>
> I have tried to change the file “/lib/Target/PowerPC/<wbr>PPCInstrInfo.td”,<br>
> adding<br>
><br>
> “isBranch = 1” for the instruction "bc 4, $bi, $dst", but had not effect.<br>
><br>
><br>
><br>
> Comparing with x86_64, building the same cpp file, the instruction<br>
><br>
> “jne    0x4005eb” has the branch flag, which identifies it as a branch<br>
> instruction.<br>
><br>
><br>
><br>
> Where is the definition that an instruction is a branch? Is it a bug?<br>
><br>
><br>
><br>
> Thanks!<br>
><br>
><u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US">> ______________________________<wbr>_________________<br>
> LLVM Developers mailing list<br>
> </span><a href="mailto:llvm-dev@lists.llvm.org" target="_blank"><span lang="EN-US">llvm-dev@lists.llvm.org</span></a><span lang="EN-US"><br>
> </span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank"><span lang="EN-US">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</span></a><span lang="EN-US"><br>
><br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
</span><a href="mailto:llvm-dev@lists.llvm.org" target="_blank"><span lang="EN-US">llvm-dev@lists.llvm.org</span></a><span lang="EN-US"><br>
</span><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank"><span lang="EN-US">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</span></a><span lang="EN-US"><u></u><u></u></span></p>
</blockquote>
</div>
<p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p>
</div>
</div></div></div>
</div>

</blockquote></div><br></div>