[Bug 44155] New: LLDB doesn't preserve values of strings

Bug ID 44155
Summary LLDB doesn’t preserve values of strings
Product lldb
Version unspecified
Hardware PC
OS All
Status NEW
Severity enhancement
Priority P
Component All Bugs
Assignee lldb-dev@lists.llvm.org
Reporter teemperor@gmail.com
CC jdevlieghere@apple.com, llvm-bugs@lists.llvm.org

(lldb) expr "foo"
(const char [4]) $0 = "foo"
(lldb) expr "bar"
(const char [4]) $1 = "bar"
(lldb) expr $0
(const char [4]) $0 = “bar”
^ Should have printed "foo"

This however works just fine:

(lldb) expr char c[] = "foo"; c
(char [4]) $0 = "foo"
(lldb) expr char c[] = "bar"; c
(char [4]) $1 = "bar"
(lldb) expr $0
(char [4]) $0 = “foo”

We either need to keep the sections for the strings around or support copying
the related memory to our storage for persistent variable values.

Raphael Isemann changed bug 44155