<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - line number info causes erratic stepping in gdb"
   href="https://llvm.org/bugs/show_bug.cgi?id=23076">23076</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>line number info causes erratic stepping in gdb
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>LLVM Codegen
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>Wolfgang_Pieb@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>int a = 1, b;

int main(void)
{
    if (a
        &&
        b)
        return 1;

    return 0;
}
//*****************

When compiled with -g, the branch instructions that are generated at the end of
the basic blocks that evaluate the conditions get line number entries that
differ from those of the conditions, causing the debugger to skip back to the
if statement's line during single stepping. Some partial IR:

define i32 @main() #0 {
entry:
  %retval = alloca i32, align 4
  store i32 0, i32* %retval
  %0 = load i32, i32* @a, align 4, !dbg !14
  %tobool = icmp ne i32 %0, 0, !dbg !14
  br i1 %tobool, label %land.lhs.true, label %if.end, !dbg !16

land.lhs.true:                                    ; preds = %entry
  %1 = load i32, i32* @b, align 4, !dbg !17
  %tobool1 = icmp ne i32 %1, 0, !dbg !17
  br i1 %tobool1, label %if.then, label %if.end, !dbg !18  <====

...

!4 = !MDSubprogram(name: "main", scope: !1, file: !1, line: 3, type: !5,
isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped,
isOptimized: false, function: i32 ()* @main, variables: !2)

...

!14 = !MDLocation(line: 5, column: 9, scope: !15)
!15 = distinct !MDLexicalBlock(scope: !4, file: !1, line: 5, column: 9)
!16 = !MDLocation(line: 6, column: 9, scope: !15)
!17 = !MDLocation(line: 7, column: 9, scope: !15)
!18 = !MDLocation(line: 5, column: 9, scope: !4) <====


This started happening with r225956.

It seems that the branch instruction should be associated with the same line
and scope as the instructions that evaluate the condition. This is especially
visible with the second branch, as it currently makes the debugger bounce back
to the if when stepping through the condition.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>