File tree Expand file tree Collapse file tree 5 files changed +72
-0
lines changed Expand file tree Collapse file tree 5 files changed +72
-0
lines changed Original file line number Diff line number Diff line change @@ -16,4 +16,7 @@ type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)R
1616type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)RefMut<.+>$" --category Rust
1717type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)RefCell<.+>$" --category Rust
1818type summary add -F lldb_lookup.summary_lookup -e -x -h "^(core::([a-z_]+::)+)NonZero<.+>$" --category Rust
19+ type summary add -F lldb_lookup.summary_lookup -e -x -h "^core::num::([a-z_]+::)*NonZero.+$" --category Rust
20+ type summary add -F lldb_lookup.summary_lookup -e -x -h "^(std::([a-z_]+::)+)PathBuf$" --category Rust
21+ type summary add -F lldb_lookup.summary_lookup -e -x -h "^&(mut )?(std::([a-z_]+::)+)Path$" --category Rust
1922type category enable Rust
Original file line number Diff line number Diff line change @@ -58,6 +58,11 @@ def summary_lookup(valobj, dict):
5858 if rust_type == RustType .STD_NONZERO_NUMBER :
5959 return StdNonZeroNumberSummaryProvider (valobj , dict )
6060
61+ if rust_type == RustType .STD_PATHBUF :
62+ return StdPathBufSummaryProvider (valobj , dict )
63+ if rust_type == RustType .STD_PATH :
64+ return StdPathSummaryProvider (valobj , dict )
65+
6166 return ""
6267
6368
Original file line number Diff line number Diff line change @@ -173,6 +173,35 @@ def StdStrSummaryProvider(valobj, dict):
173173 return '"%s"' % data
174174
175175
176+ def StdPathBufSummaryProvider (valobj , dict ):
177+ # type: (SBValue, dict) -> str
178+ # logger = Logger.Logger()
179+ # logger >> "[StdPathBufSummaryProvider] for " + str(valobj.GetName())
180+ return StdOsStringSummaryProvider (valobj .GetChildMemberWithName ("inner" ), dict )
181+
182+
183+ def StdPathSummaryProvider (valobj , dict ):
184+ # type: (SBValue, dict) -> str
185+ # logger = Logger.Logger()
186+ # logger >> "[StdPathSummaryProvider] for " + str(valobj.GetName())
187+ length = valobj .GetChildMemberWithName ("length" ).GetValueAsUnsigned ()
188+ if length == 0 :
189+ return '""'
190+
191+ data_ptr = valobj .GetChildMemberWithName ("data_ptr" )
192+
193+ start = data_ptr .GetValueAsUnsigned ()
194+ error = SBError ()
195+ process = data_ptr .GetProcess ()
196+ data = process .ReadMemory (start , length , error )
197+ if PY3 :
198+ try :
199+ data = data .decode (encoding = 'UTF-8' )
200+ except UnicodeDecodeError :
201+ return '%r' % data
202+ return '"%s"' % data
203+
204+
176205class StructSyntheticProvider :
177206 """Pretty-printer for structs and struct enum variants"""
178207
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ class RustType(object):
3232 STD_REF_MUT = "StdRefMut"
3333 STD_REF_CELL = "StdRefCell"
3434 STD_NONZERO_NUMBER = "StdNonZeroNumber"
35+ STD_PATH = "StdPath"
36+ STD_PATHBUF = "StdPathBuf"
3537
3638
3739STD_STRING_REGEX = re .compile (r"^(alloc::([a-z_]+::)+)String$" )
@@ -51,6 +53,8 @@ class RustType(object):
5153STD_REF_MUT_REGEX = re .compile (r"^(core::([a-z_]+::)+)RefMut<.+>$" )
5254STD_REF_CELL_REGEX = re .compile (r"^(core::([a-z_]+::)+)RefCell<.+>$" )
5355STD_NONZERO_NUMBER_REGEX = re .compile (r"^(core::([a-z_]+::)+)NonZero<.+>$" )
56+ STD_PATHBUF_REGEX = re .compile (r"^(std::([a-z_]+::)+)PathBuf$" )
57+ STD_PATH_REGEX = re .compile (r"^&(mut )?(std::([a-z_]+::)+)Path$" )
5458
5559TUPLE_ITEM_REGEX = re .compile (r"__\d+$" )
5660
@@ -75,6 +79,8 @@ class RustType(object):
7579 RustType .STD_REF_CELL : STD_REF_CELL_REGEX ,
7680 RustType .STD_CELL : STD_CELL_REGEX ,
7781 RustType .STD_NONZERO_NUMBER : STD_NONZERO_NUMBER_REGEX ,
82+ RustType .STD_PATHBUF : STD_PATHBUF_REGEX ,
83+ RustType .STD_PATH : STD_PATH_REGEX ,
7884}
7985
8086def is_tuple_fields (fields ):
Original file line number Diff line number Diff line change 1+ //@ ignore-gdb
2+
3+ //@ compile-flags:-g
4+
5+ // === LLDB TESTS =================================================================================
6+
7+ // lldb-command:run
8+
9+ // lldb-command:print pathbuf
10+ // lldb-check:[...] "/some/path" { inner = "/some/path" { inner = { inner = size=10 { [0] = '/' [1] = 's' [2] = 'o' [3] = 'm' [4] = 'e' [5] = '/' [6] = 'p' [7] = 'a' [8] = 't' [9] = 'h' } } } }
11+ // lldb-command:po pathbuf
12+ // lldb-check:"/some/path"
13+ // lldb-command:print path
14+ // lldb-check:[...] "/some/path" { data_ptr = [...] length = 10 }
15+ // lldb-command:po path
16+ // lldb-check:"/some/path"
17+
18+ use std:: path:: Path ;
19+
20+ fn main ( ) {
21+ let path = Path :: new ( "/some/path" ) ;
22+ let pathbuf = path. to_path_buf ( ) ;
23+
24+ zzz ( ) ; // #break
25+ }
26+
27+ fn zzz ( ) {
28+ ( )
29+ }
You can’t perform that action at this time.
0 commit comments