Rust-lldb: conditional breakpoint on string value?

⚓ Rust    📅 2025-09-15    👤 surdeus    👁️ 2      

surdeus

I was hoping to set a breakpoint in rust-lldb based on the value of a string. However, I'm not having any luck. I'm trying to debug using expr to see what certain conditionals would return:

(lldb) expr self.description == "Interest Paid"
error: warning: <user expression 89>:1:18: result of comparison against a string literal is unspecified (use an explicit string comparison function instead)
    1 | self.description == "Interest Paid"
      |                  ^  ~~~~~~~~~~~~~~~
error: <user expression 89>:1:18: invalid operands to binary expression ('alloc::string::String' and 'const char[14]')
    1 | self.description == "Interest Paid"
      | ~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
(lldb) expr (int) strcmp(self.description, "Interest Paid")
(int) $15 = -60
(lldb) p self.description
(alloc::string::String) "Interest Paid" {
  [0] = 'I'
  [1] = 'n'
  [2] = 't'
  [3] = 'e'
  [4] = 'r'
  [5] = 'e'
  [6] = 's'
  [7] = 't'
  [8] = ' '
  [9] = 'P'
  [10] = 'a'
  [11] = 'i'
  [12] = 'd'
}

Does anyone know how (or if) this should work?

1 post - 1 participant

Read full topic

🏷️ Rust_feed