Rollup merge of #58629 - euclio:debug-empty-str, r=alexcrichton

rust-lldb: fix crash when printing empty string

Fixes #52185.

~Re-enables the pretty-std debuginfo test and tweaks the test as necessary to get it to pass again. This reveals that lldb's formatting of enums is broken (#58492). I also removed the emoji from the test because I couldn't get the docker image's gdb to print the emoji, just octal escapes (https://github.com/rust-lang/rust/pull/53154/files#r208263904).~
This commit is contained in:
Mazdak Farrokhzad 2019-03-09 17:18:14 +01:00 committed by GitHub
commit 6371622662
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 0 deletions

View file

@ -290,6 +290,8 @@ def print_array_of_values(array_name, data_ptr_val, length, internal_dict):
def read_utf8_string(ptr_val, byte_count):
if byte_count == 0:
return '""'
error = lldb.SBError()
process = ptr_val.get_wrapped_value().GetProcess()
data = process.ReadMemory(ptr_val.as_integer(), byte_count, error)

View file

@ -0,0 +1,35 @@
// ignore-windows failing on win32 bot
// ignore-android: FIXME(#10381)
// compile-flags:-g
// min-gdb-version: 7.7
// min-lldb-version: 310
// === GDB TESTS ===================================================================================
// gdb-command: run
// gdb-command: print empty_string
// gdb-check:$1 = ""
// gdb-command: print empty_str
// gdb-check:$2 = ""
// === LLDB TESTS ==================================================================================
// lldb-command: run
// lldb-command: fr v empty_string
// lldb-check:[...]empty_string = ""
// lldb-command: fr v empty_str
// lldb-check:[...]empty_str = ""
fn main() {
let empty_string = String::new();
let empty_str = "";
zzz(); // #break
}
fn zzz() {}