@@ -51,12 +51,13 @@ class ScriptAddOptions {
5151 FormatterMatchType m_match_type;
5252 ConstString m_name;
5353 std::string m_category;
54+ uint32_t m_ptr_match_depth;
5455
5556 ScriptAddOptions (const TypeSummaryImpl::Flags &flags,
5657 FormatterMatchType match_type, ConstString name,
57- std::string catg)
58+ std::string catg, uint32_t m_ptr_match_depth )
5859 : m_flags(flags), m_match_type(match_type), m_name(name),
59- m_category (catg) {}
60+ m_category (catg), m_ptr_match_depth(m_ptr_match_depth) {}
6061
6162 typedef std::shared_ptr<ScriptAddOptions> SharedPointer;
6263};
@@ -146,6 +147,7 @@ class CommandObjectTypeSummaryAdd : public CommandObjectParsed,
146147 std::string m_python_function;
147148 bool m_is_add_script = false ;
148149 std::string m_category;
150+ uint32_t m_ptr_match_depth = 1 ;
149151 };
150152
151153 CommandOptions m_options;
@@ -211,7 +213,7 @@ class CommandObjectTypeSummaryAdd : public CommandObjectParsed,
211213 TypeSummaryImplSP script_format;
212214 script_format = std::make_shared<ScriptSummaryFormat>(
213215 options->m_flags , funct_name_str.c_str (),
214- lines.CopyList (" " ).c_str ());
216+ lines.CopyList (" " ).c_str (), options-> m_ptr_match_depth );
215217
216218 Status error;
217219
@@ -1178,6 +1180,13 @@ Status CommandObjectTypeSummaryAdd::CommandOptions::SetOptionValue(
11781180 case ' p' :
11791181 m_flags.SetSkipPointers (true );
11801182 break ;
1183+ case ' d' :
1184+ if (option_arg.getAsInteger (0 , m_ptr_match_depth)) {
1185+ error = Status::FromErrorStringWithFormat (
1186+ " invalid integer value for option '%c': %s" , short_option,
1187+ option_arg.data ());
1188+ }
1189+ break ;
11811190 case ' r' :
11821191 m_flags.SetSkipReferences (true );
11831192 break ;
@@ -1266,7 +1275,8 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
12661275 (" " + m_options.m_python_function + " (valobj,internal_dict)" );
12671276
12681277 script_format = std::make_shared<ScriptSummaryFormat>(
1269- m_options.m_flags , funct_name, code.c_str ());
1278+ m_options.m_flags , funct_name, code.c_str (),
1279+ m_options.m_ptr_match_depth );
12701280
12711281 ScriptInterpreter *interpreter = GetDebugger ().GetScriptInterpreter ();
12721282
@@ -1300,12 +1310,13 @@ bool CommandObjectTypeSummaryAdd::Execute_ScriptSummary(
13001310 std::string code = " " + m_options.m_python_script ;
13011311
13021312 script_format = std::make_shared<ScriptSummaryFormat>(
1303- m_options.m_flags , funct_name_str.c_str (), code.c_str ());
1313+ m_options.m_flags , funct_name_str.c_str (), code.c_str (),
1314+ m_options.m_ptr_match_depth );
13041315 } else {
13051316 // Use an IOHandler to grab Python code from the user
13061317 auto options = std::make_unique<ScriptAddOptions>(
13071318 m_options.m_flags , m_options.m_match_type , m_options.m_name ,
1308- m_options.m_category );
1319+ m_options.m_category , m_options. m_ptr_match_depth );
13091320
13101321 for (auto &entry : command.entries ()) {
13111322 if (entry.ref ().empty ()) {
@@ -1380,8 +1391,8 @@ bool CommandObjectTypeSummaryAdd::Execute_StringSummary(
13801391 return false ;
13811392 }
13821393
1383- std::unique_ptr<StringSummaryFormat> string_format (
1384- new StringSummaryFormat ( m_options.m_flags , format_cstr));
1394+ std::unique_ptr<StringSummaryFormat> string_format (new StringSummaryFormat (
1395+ m_options.m_flags , format_cstr, m_options. m_ptr_match_depth ));
13851396 if (!string_format) {
13861397 result.AppendError (" summary creation failed" );
13871398 return false ;
0 commit comments