<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57840>57840</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Wrong line information during debug at Og
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ycwan9
      </td>
    </tr>
</table>

<pre>
    When compiled with `-Og`, after function `e` finishes, LLDB remains at line 9 in the next step, while displayes function `main` as the current top frame. This behavior is not present in GDB.

Source program:
```
$ cat a.c
#include <stdint.h>
volatile uint32_t a,  c;
uint16_t b[][1] = {1, 1, 1, 1, 1, 1};
int8_t d[1][5][9]
 ;
uint8_t e(void) {
  uint8_t f = b[5][0];
  int g =  c;
  d[0][4][7] =
      g >= 8 ? f : f >> g;
  return 0
; }
int main(void) {
  int i;
  e();
  for (i = 0; i < 8; i++)
    a = i;
}
```

```
$ clang --version
clang version 16.0.0 (https://github.com/llvm/llvm-project.git c63e05dc0776b4a0a75685ba8a8d7667e0dbaee3)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /scratch/software/clang-trunk/bin

$ lldb --version
lldb version 16.0.0git (https://github.com/llvm/llvm-project.git revision c63e05dc0776b4a0a75685ba8a8d7667e0dbaee3)
  clang revision c63e05dc0776b4a0a75685ba8a8d7667e0dbaee3
  llvm revision c63e05dc0776b4a0a75685ba8a8d7667e0dbaee3

$ gdb -v
GNU gdb (GDB) 13.0.50.20220831-git
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
```

Compile flags:
```
$ clang -Og -g -o a.elf a.c
```

LLDB trace:
```
$ lldb a.elf
(lldb) target create "a.elf"
Current executable set to '/scratch/ycwang/vio-work/a.elf' (x86_64).
(lldb) b main
Breakpoint 1: where = a.elf`main [inlined] e at a.c:10:7, address = 0x0000000000001150
(lldb) r
Process 3376730 launched: '/scratch/ycwang/vio-work/a.elf' (x86_64)
Process 3376730 stopped
* thread #1, name = 'a.elf', stop reason = breakpoint 1.1
    frame #0: 0x0000555555555150 a.elf`main [inlined] e at a.c:10:7
   7      uint8_t f = b[5][0];
   8      int g =  c;
   9      d[0][4][7] =
-> 10              g >= 8 ? f : f >> g;
   11     return 0
   12   ; }
   13   int main(void) {
(lldb) s
Process 3376730 stopped
* thread #1, name = 'a.elf', stop reason = step in
    frame #0: 0x0000555555555157 a.elf`main [inlined] e at a.c:8:12
   5     ;
   6    uint8_t e(void) {
   7      uint8_t f = b[5][0];
-> 8           int g =  c;
   9      d[0][4][7] =
   10         g >= 8 ? f : f >> g;
   11     return 0
(lldb) s
Process 3376730 stopped
* thread #1, name = 'a.elf', stop reason = step in
    frame #0: 0x000055555555515f a.elf`main [inlined] e at a.c:10:9
   7      uint8_t f = b[5][0];
   8      int g =  c;
   9      d[0][4][7] =
-> 10              g >= 8 ? f : f >> g;
   11     return 0
   12   ; }
   13   int main(void) {
(lldb) s
Process 3376730 stopped
* thread #1, name = 'a.elf', stop reason = step in
    frame #0: 0x0000555555555167 a.elf`main [inlined] e at a.c:9:14
   6    uint8_t e(void) {
   7      uint8_t f = b[5][0];
   8      int g =  c;
-> 9           d[0][4][7] =
   10         g >= 8 ? f : f >> g;
   11     return 0
   12   ; }
(lldb) s
Process 3376730 stopped
* thread #1, name = 'a.elf', stop reason = step in
    frame #0: 0x000055555555516d a.elf`main at a.c:9:14
   6    uint8_t e(void) {
   7      uint8_t f = b[5][0];
   8      int g =  c;
-> 9           d[0][4][7] =
   10         g >= 8 ? f : f >> g;
   11     return 0
   12   ; }
(lldb) bt
* thread #1, name = 'a.elf', stop reason = step in
  * frame #0: 0x000055555555516d a.elf`main at a.c:9:14
    frame #1: 0x00007ffff7de80b3 libc.so.6`__libc_start_main + 243
    frame #2: 0x000055555555506e a.elf`_start + 46
(lldb) frame var
(int) i = 0
```

GDB trace:
```
$ gdb a.elf
GNU gdb (GDB) 13.0.50.20220831-git
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-pc-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from a.elf...
(gdb) start
Temporary breakpoint 1 at 0x1150: file a.c, line 10.
Starting program: /scratch/ycwang/vio-work/a.elf 

Temporary breakpoint 1, main () at a.c:15
15        e();
(gdb) s
e () at a.c:10
10            g >= 8 ? f : f >> g;
(gdb) s
8         int g =  c;
(gdb) s
10            g >= 8 ? f : f >> g;
(gdb) s
9         d[0][4][7] =
(gdb) bt
#0  e () at a.c:9
#1  main () at a.c:15
(gdb) info locals
f = <optimized out>
g = <optimized out>
(gdb) s
main () at a.c:17
17          a = i;
(gdb) bt
#0  main () at a.c:17
(gdb) info locals
i = 0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJztWVtv4jgU_jXwYhHlAkl44KG002qkarqamdVonyonMYl3QhzZDpT99XuO7XAplJZRRzsrDYJc7OPP535sk4liM_tWsYbkYtnymhVkzXVFBrE_eijhOgivCV1oJsmia3LNRYN9DH5kwRuuKqaQ5P7-Zk4kW1LeKEI1qXnDyJTwhuiKkYY9aaI0a5F0XcE0pOCqremGqQNcHI_QVJlxeSclazTRoiULSZfMI18rrkjGKrriQhJ4boQmrWQK6WC6u5u5N_BvBv6VvX4RncwZUIgSAAaRa0bJ7Ne-hmOSA9vUy_uGiDd53RWMDKJrpQveaK8aRB9s90rUVKMYHbRH4SOMRNFIPojml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