[Lldb-commits] [PATCH] D44998: ObjectFileELF: Add support for arbitrarily named code sections

Konstantin Baladurin via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 3 01:28:38 PDT 2018


kbaladurin added inline comments.
Herald added a reviewer: espindola.


================
Comment at: packages/Python/lldbsuite/test/arm/breakpoint-thumb-codesection/TestBreakpointThumbCodesection.py:29
+
+        self.runCmd("run")
+
----------------
labath wrote:
> Do you think there's any added value in making sure that the breakpoint is *hit* (instead of just making sure that it's resolved to the right file address). If it's the latter we could make this a non-execution test and have it run everywhere (e.g., via lldb-test breakpoint) instead of just on arm hardware.
I think we need to make sure that breakpoint is *hit* and program can successfully continue execution after it, because it is resolved to right address in both cases:

lldb without this patch:
```
$ llvm-arm/bin/lldb thumb-bp 
(lldb) target create "thumb-bp"
Current executable set to 'thumb-bp' (arm).
(lldb) b bp.c:3
Breakpoint 1: where = thumb-bp`f + 6 at bp.c:3, address = 0x000103f6
(lldb) r
Process 22192 launched: '/home/kbaladurin/thumb-bp' (arm)
Process 22192 stopped
* thread #1: tid = 22192, 0x000103d0 thumb-bp`__libc_csu_init + 32, name = 'thumb-bp', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
    frame #0: 0x000103d0 thumb-bp`__libc_csu_init + 32
thumb-bp`__libc_csu_init:
->  0x103d0 <+32>: ldr    r3, [r5], #4
    0x103d4 <+36>: mov    r2, r9
    0x103d6 <+38>: mov    r1, r8
    0x103d8 <+40>: mov    r0, r7
(lldb) disas -n f
thumb-bp`f:
    0x103f0 <+0>:  strmi  r11, [r1], -r2, lsl #1
    0x103f4 <+4>:  stmdals r1, {r0, r12, pc}
    0x103f8 <+8>:  .long  0x91003001                ; unknown opcode
    0x103fc <+12>: ldrbmi r11, [r0, -r2]!

```

lldb with this patch:
```
$ llvm-arm-patch/bin/lldb thumb-bp 
(lldb) target create "thumb-bp"
Current executable set to 'thumb-bp' (arm).
(lldb) b bp.c:3
Breakpoint 1: where = thumb-bp`f + 6 at bp.c:3, address = 0x000103f6
(lldb) r
Process 22282 launched: '/home/kbaladurin/thumb-bp' (arm)
Process 22282 stopped
* thread #1: tid = 22282, 0x000103f6 thumb-bp`f(a=10) + 6 at bp.c:3, name = 'thumb-bp', stop reason = breakpoint 1.1
    frame #0: 0x000103f6 thumb-bp`f(a=10) + 6 at bp.c:3
   1   	__attribute__((section("__codesection")))
   2   	int f(int a) {
-> 3   	  return a + 1; // Set break point at this line.
   4   	}
   5   	
   6   	int main() {
   7   	  return f(10);
(lldb) disas
thumb-bp`f:
    0x103f0 <+0>:  sub    sp, #0x8
    0x103f2 <+2>:  mov    r1, r0
    0x103f4 <+4>:  str    r0, [sp, #0x4]
->  0x103f6 <+6>:  ldr    r0, [sp, #0x4]
    0x103f8 <+8>:  adds   r0, #0x1
    0x103fa <+10>: str    r1, [sp]
    0x103fc <+12>: add    sp, #0x8
    0x103fe <+14>: bx     lr

```

In both cases resolved address is 0x103f6 that is right according to the debug information:
```
 Line Number Statements:
  [0x00000025]  Extended opcode 2: set Address to 0x103f0
  [0x0000002c]  Special opcode 6: advance Address by 0 to 0x103f0 and Line by 1 to 2
  [0x0000002d]  Set column to 10
  [0x0000002f]  Set prologue_end to true
  [0x00000030]  Special opcode 90: advance Address by 6 to 0x103f6 and Line by 1 to 3
```

But lldb uses arm breakpoint in the first case and thumb one in the second. 


https://reviews.llvm.org/D44998





More information about the lldb-commits mailing list