File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -177,6 +177,9 @@ def _graph(args: argparse.Namespace) -> None:
177177 elif args .filter not in obj .typename :
178178 continue
179179 queue .append ((0 , obj ))
180+ censor_list : list [str ] | None = None
181+ if args .censor :
182+ censor_list = args .censor .split ("," )
180183 while queue :
181184 depth , obj = queue .pop (0 )
182185 if obj .addr in seen :
@@ -197,9 +200,19 @@ def _graph(args: argparse.Namespace) -> None:
197200 payload = f"\\ n{ obj .payload } "
198201 else :
199202 payload = f"\\ n{ obj .payload [:31 ]} …"
200- print (
201- f' x{ obj .addr :x} [label="0x{ obj .addr :x} \\ n{ obj .typename } \\ n{ obj .size } { payload } "{ style } ];'
202- )
203+ if censor_list :
204+ if any (obj .typename .startswith (censored ) for censored in censor_list ):
205+ print (
206+ f' x{ obj .addr :x} [label="0x{ obj .addr :x} \\ n[omitted]\\ n{ obj .size } "{ style } ];'
207+ )
208+ else :
209+ print (
210+ f' x{ obj .addr :x} [label="0x{ obj .addr :x} \\ n{ obj .typename } \\ n{ obj .size } "{ style } ];'
211+ )
212+ else :
213+ print (
214+ f' x{ obj .addr :x} [label="0x{ obj .addr :x} \\ n{ obj .typename } \\ n{ obj .size } { payload } "{ style } ];'
215+ )
203216 if excluded_addresses is not None and obj .addr in excluded_addresses :
204217 continue
205218
@@ -271,6 +284,11 @@ def _graph(args: argparse.Namespace) -> None:
271284 type = str ,
272285 help = "Highlight entries by typename." ,
273286 )
287+ parser_graph .add_argument (
288+ "--censor" ,
289+ type = str ,
290+ help = "Censor nodes that match a comma-separated list of prefixes of a typename" ,
291+ )
274292 parser_graph .set_defaults (func = _graph )
275293 args = parser .parse_args ()
276294
You can’t perform that action at this time.
0 commit comments