Skip to content

Commit

Permalink
rust-lldb: fix crash when printing empty string
Browse files Browse the repository at this point in the history
  • Loading branch information
euclio committed Mar 6, 2019
1 parent 7f19f16 commit 9e5def9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/etc/lldb_rust_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ def render_element(i):


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)
Expand Down
35 changes: 35 additions & 0 deletions src/test/debuginfo/empty-string.rs
Original file line number Diff line number Diff line change
@@ -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() {}

0 comments on commit 9e5def9

Please sign in to comment.