Hi all, I'm working on lldb to make it available to ppc64le, but the "step over" is not working for some cases. When debugging, I can see that the disassembler analyze some instructions forward, looking for a branch instruction (llvm/tools/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp:87 - "const bool can_branch = mc_disasm_ptr->CanBranch(inst);"), while trying to set the next breakpoint. On this case, the instruction is the "bne cr7,0x2000092c", which is a branch, but at llvm/lib/MC/MCInstrDesc.cpp:35 - "if (isBranch() || isCall() || isReturn() || isIndirectBranch())" it returns false, making lldb do not set the correct breakpoint, so the execution does not stop at next line, which should be the "step over" behavior. The variable "Flags" for the disassembled instruction does not have the branch flag. I have tried to change the file "/lib/Target/PowerPC/PPCInstrInfo.td", adding "isBranch = 1" for the instruction "bc 4, $bi, $dst", but had not effect. Comparing with x86_64, building the same cpp file, the instruction "jne 0x4005eb" has the branch flag, which identifies it as a branch instruction. Where is the definition that an instruction is a branch? Is it a bug? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <lists.llvm.org/pipermail/llvm-dev/attachments/20171129/2b787f79/attachment.html>
Hello Leonardo, What is the opcode of the MCInstrDesc? Sean On Wed, Nov 29, 2017 at 1:48 PM, Leonardo Bianconi via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Hi all, > > > > I’m working on lldb to make it available to ppc64le, but the “step over” > > is not working for some cases. > > > > When debugging, I can see that the disassembler analyze some instructions > > forward, looking for a branch instruction > > (llvm/tools/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp:87 > > – “const bool can_branch = mc_disasm_ptr->CanBranch(inst);”), while > > trying to set the next breakpoint. > > > > On this case, the instruction is the “bne cr7,0x2000092c”, which is a > branch, > > but at llvm/lib/MC/MCInstrDesc.cpp:35 – > > “if (isBranch() || isCall() || isReturn() || isIndirectBranch())” it returns > false, > > making lldb do not set the correct breakpoint, so the execution does not > stop > > at next line, which should be the “step over” behavior. > > > > The variable “Flags” for the disassembled instruction does not have the > branch > > flag. > > > > I have tried to change the file “/lib/Target/PowerPC/PPCInstrInfo.td”, > adding > > “isBranch = 1” for the instruction "bc 4, $bi, $dst", but had not effect. > > > > Comparing with x86_64, building the same cpp file, the instruction > > “jne 0x4005eb” has the branch flag, which identifies it as a branch > instruction. > > > > Where is the definition that an instruction is a branch? Is it a bug? > > > > Thanks! > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >
Hi Sean, Yes, it is. It has the method "isBranch()", which checks the "Flags" variable if the branch bit is set. Leonardo Bianconi. -----Original Message----- From: Sean Fertile [mailto:sd.fertile at gmail.com] Sent: quarta-feira, 29 de novembro de 2017 23:31 To: Leonardo Bianconi <leonardo.bianconi at eldorado.org.br> Cc: llvm-dev at lists.llvm.org Subject: Re: [llvm-dev] PPC64 Disassembler Hello Leonardo, What is the opcode of the MCInstrDesc? Sean On Wed, Nov 29, 2017 at 1:48 PM, Leonardo Bianconi via llvm-dev <llvm-dev at lists.llvm.org> wrote:> Hi all, > > > > I’m working on lldb to make it available to ppc64le, but the “step over” > > is not working for some cases. > > > > When debugging, I can see that the disassembler analyze some > instructions > > forward, looking for a branch instruction > > (llvm/tools/lldb/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cp > p:87 > > – “const bool can_branch = mc_disasm_ptr->CanBranch(inst);”), while > > trying to set the next breakpoint. > > > > On this case, the instruction is the “bne cr7,0x2000092c”, which is a > branch, > > but at llvm/lib/MC/MCInstrDesc.cpp:35 – > > “if (isBranch() || isCall() || isReturn() || isIndirectBranch())” it > returns false, > > making lldb do not set the correct breakpoint, so the execution does > not stop > > at next line, which should be the “step over” behavior. > > > > The variable “Flags” for the disassembled instruction does not have > the branch > > flag. > > > > I have tried to change the file “/lib/Target/PowerPC/PPCInstrInfo.td”, > adding > > “isBranch = 1” for the instruction "bc 4, $bi, $dst", but had not effect. > > > > Comparing with x86_64, building the same cpp file, the instruction > > “jne 0x4005eb” has the branch flag, which identifies it as a branch > instruction. > > > > Where is the definition that an instruction is a branch? Is it a bug? > > > > Thanks! > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >
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? Would you be able to provide a test case that reproduces the issue? On Thu, Nov 30, 2017 at 2:30 AM, Sean Fertile via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hello Leonardo, > > What is the opcode of the MCInstrDesc? > > Sean > > On Wed, Nov 29, 2017 at 1:48 PM, Leonardo Bianconi via llvm-dev > <llvm-dev at lists.llvm.org> wrote: > > Hi all, > > > > > > > > I’m working on lldb to make it available to ppc64le, but the “step over” > > > > is not working for some cases. > > > > > > > > When debugging, I can see that the disassembler analyze some instructions > > > > forward, looking for a branch instruction > > > > (llvm/tools/lldb/source/Plugins/Disassembler/llvm/ > DisassemblerLLVMC.cpp:87 > > > > – “const bool can_branch = mc_disasm_ptr->CanBranch(inst);”), while > > > > trying to set the next breakpoint. > > > > > > > > On this case, the instruction is the “bne cr7,0x2000092c”, which is a > > branch, > > > > but at llvm/lib/MC/MCInstrDesc.cpp:35 – > > > > “if (isBranch() || isCall() || isReturn() || isIndirectBranch())” it > returns > > false, > > > > making lldb do not set the correct breakpoint, so the execution does not > > stop > > > > at next line, which should be the “step over” behavior. > > > > > > > > The variable “Flags” for the disassembled instruction does not have the > > branch > > > > flag. > > > > > > > > I have tried to change the file “/lib/Target/PowerPC/PPCInstrInfo.td”, > > adding > > > > “isBranch = 1” for the instruction "bc 4, $bi, $dst", but had not effect. > > > > > > > > Comparing with x86_64, building the same cpp file, the instruction > > > > “jne 0x4005eb” has the branch flag, which identifies it as a branch > > instruction. > > > > > > > > Where is the definition that an instruction is a branch? Is it a bug? > > > > > > > > Thanks! > > > > > > _______________________________________________ > > LLVM Developers mailing list > > llvm-dev at lists.llvm.org > > lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <lists.llvm.org/pipermail/llvm-dev/attachments/20171130/f9d9467e/attachment.html>