[Lldb-commits] [PATCH] D147816: Clarify how watchpoint description in stop packets work, fix AArch64 unintended behavior

Jason Molenda via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Apr 12 17:30:11 PDT 2023

jasonmolenda added a comment.

FWIW to show the motivation for this patch (which, again comes down to removing `core >= ArchSpec::eCore_arm_generic && core <= ArchSpec::eCore_arm_aarch64` when creating the StopInfo from the watchpoint description), the test case I wrote in https://reviews.llvm.org/D147820 shows the problem where I adopt the lldb-server mechanism of watchpoint reporting on Darwin systems and I hit this problem:

  #include <stdint.h>
  #include <stdio.h>
  int main() {
    union {
  	  uint8_t buf[8];
  	  uint64_t val;
    } a;
    a.val = 0;  // break here
    for (int i = 0; i < 5; i++) {
      a.val = i;
      printf ("a.val is %lu\n", a.val);
  (lldb) br s -p break
  (lldb) r
  Process 2182 stopped
  -> 8   	  a.val = 0;  // break here
  (lldb) w s v a.buf[2]
  Watchpoint created: Watchpoint 1: addr = 0xfffffffff3a2 size = 1 state = enabled type = w
      declare @ '/home/jason/a.c:7'
      watchpoint spec = 'a.buf[2]'
      new value: '\xff'
  (lldb) c
  Process 2182 resuming
  a.val is 0
  a.val is 1
  a.val is 2
  a.val is 3
  a.val is 4
  Process 2182 exited with status = 0 (0x00000000) 

These watchpoint hits are silently skipped over on AArch64.  If you turn on the packet log, you'll see the watchpoint hits reported by debugserver, but lldb silently skips them.  This is correct behavior on MIPS; ARM targets using lldb-server should not have opted into this behavior.  When we set aside the comments and variable renaming, that's what we're fixing with this patch.

  rG LLVM Github Monorepo



More information about the lldb-commits mailing list