@@ -266,6 +266,8 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
266
266
Status error;
267
267
const int short_option =
268
268
g_breakpoint_set_options[option_idx].short_option ;
269
+ const char *long_option =
270
+ g_breakpoint_set_options[option_idx].long_option ;
269
271
270
272
switch (short_option) {
271
273
case ' a' : {
@@ -284,13 +286,15 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
284
286
285
287
case ' u' :
286
288
if (option_arg.getAsInteger (0 , m_column))
287
- error.SetErrorStringWithFormat (" invalid column number: %s" ,
288
- option_arg.str ().c_str ());
289
+ error =
290
+ CreateOptionParsingError (option_arg, short_option, long_option,
291
+ g_int_parsing_error_message);
289
292
break ;
290
293
291
294
case ' E' : {
292
295
LanguageType language = Language::GetLanguageTypeFromString (option_arg);
293
296
297
+ llvm::StringRef error_context;
294
298
switch (language) {
295
299
case eLanguageTypeC89:
296
300
case eLanguageTypeC:
@@ -308,19 +312,18 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
308
312
m_exception_language = eLanguageTypeObjC;
309
313
break ;
310
314
case eLanguageTypeObjC_plus_plus:
311
- error. SetErrorStringWithFormat (
312
- " Set exception breakpoints separately for c++ and objective-c" ) ;
315
+ error_context =
316
+ " Set exception breakpoints separately for c++ and objective-c" ;
313
317
break ;
314
318
case eLanguageTypeUnknown:
315
- error.SetErrorStringWithFormat (
316
- " Unknown language type: '%s' for exception breakpoint" ,
317
- option_arg.str ().c_str ());
319
+ error_context = " Unknown language type for exception breakpoint" ;
318
320
break ;
319
321
default :
320
- error.SetErrorStringWithFormat (
321
- " Unsupported language type: '%s' for exception breakpoint" ,
322
- option_arg.str ().c_str ());
322
+ error_context = " Unsupported language type for exception breakpoint" ;
323
323
}
324
+ if (!error_context.empty ())
325
+ error = CreateOptionParsingError (option_arg, short_option,
326
+ long_option, error_context);
324
327
} break ;
325
328
326
329
case ' f' :
@@ -336,9 +339,9 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
336
339
bool success;
337
340
m_catch_bp = OptionArgParser::ToBoolean (option_arg, true , &success);
338
341
if (!success)
339
- error. SetErrorStringWithFormat (
340
- " Invalid boolean value for on-catch option: '%s' " ,
341
- option_arg. str (). c_str () );
342
+ error =
343
+ CreateOptionParsingError (option_arg, short_option, long_option ,
344
+ g_bool_parsing_error_message );
342
345
} break ;
343
346
344
347
case ' H' :
@@ -355,23 +358,24 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
355
358
m_skip_prologue = eLazyBoolNo;
356
359
357
360
if (!success)
358
- error. SetErrorStringWithFormat (
359
- " Invalid boolean value for skip prologue option: '%s' " ,
360
- option_arg. str (). c_str () );
361
+ error =
362
+ CreateOptionParsingError (option_arg, short_option, long_option ,
363
+ g_bool_parsing_error_message );
361
364
} break ;
362
365
363
366
case ' l' :
364
367
if (option_arg.getAsInteger (0 , m_line_num))
365
- error.SetErrorStringWithFormat (" invalid line number: %s." ,
366
- option_arg.str ().c_str ());
368
+ error =
369
+ CreateOptionParsingError (option_arg, short_option, long_option,
370
+ g_int_parsing_error_message);
367
371
break ;
368
372
369
373
case ' L' :
370
374
m_language = Language::GetLanguageTypeFromString (option_arg);
371
375
if (m_language == eLanguageTypeUnknown)
372
- error. SetErrorStringWithFormat (
373
- " Unknown language type: '%s' for breakpoint " ,
374
- option_arg. str (). c_str () );
376
+ error =
377
+ CreateOptionParsingError (option_arg, short_option, long_option ,
378
+ g_language_parsing_error_message );
375
379
break ;
376
380
377
381
case ' m' : {
@@ -384,9 +388,9 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
384
388
m_move_to_nearest_code = eLazyBoolNo;
385
389
386
390
if (!success)
387
- error. SetErrorStringWithFormat (
388
- " Invalid boolean value for move-to-nearest-code option: '%s' " ,
389
- option_arg. str (). c_str () );
391
+ error =
392
+ CreateOptionParsingError (option_arg, short_option, long_option ,
393
+ g_bool_parsing_error_message );
390
394
break ;
391
395
}
392
396
@@ -404,8 +408,8 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
404
408
if (BreakpointID::StringIsBreakpointName (option_arg, error))
405
409
m_breakpoint_names.push_back (std::string (option_arg));
406
410
else
407
- error. SetErrorStringWithFormat ( " Invalid breakpoint name: %s " ,
408
- option_arg. str (). c_str () );
411
+ error = CreateOptionParsingError (
412
+ option_arg, short_option, long_option, " Invalid breakpoint name " );
409
413
break ;
410
414
}
411
415
@@ -443,9 +447,9 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
443
447
bool success;
444
448
m_throw_bp = OptionArgParser::ToBoolean (option_arg, true , &success);
445
449
if (!success)
446
- error. SetErrorStringWithFormat (
447
- " Invalid boolean value for on-throw option: '%s' " ,
448
- option_arg. str (). c_str () );
450
+ error =
451
+ CreateOptionParsingError (option_arg, short_option, long_option ,
452
+ g_bool_parsing_error_message );
449
453
} break ;
450
454
451
455
case ' X' :
@@ -457,9 +461,8 @@ class CommandObjectBreakpointSet : public CommandObjectParsed {
457
461
OptionValueFileColonLine value;
458
462
Status fcl_err = value.SetValueFromString (option_arg);
459
463
if (!fcl_err.Success ()) {
460
- error.SetErrorStringWithFormat (
461
- " Invalid value for file:line specifier: %s" ,
462
- fcl_err.AsCString ());
464
+ error = CreateOptionParsingError (option_arg, short_option,
465
+ long_option, fcl_err.AsCString ());
463
466
} else {
464
467
m_filenames.AppendIfUnique (value.GetFileSpec ());
465
468
m_line_num = value.GetLineNumber ();
@@ -1557,6 +1560,7 @@ class BreakpointNameOptionGroup : public OptionGroup {
1557
1560
ExecutionContext *execution_context) override {
1558
1561
Status error;
1559
1562
const int short_option = g_breakpoint_name_options[option_idx].short_option ;
1563
+ const char *long_option = g_breakpoint_name_options[option_idx].long_option ;
1560
1564
1561
1565
switch (short_option) {
1562
1566
case ' N' :
@@ -1566,15 +1570,13 @@ class BreakpointNameOptionGroup : public OptionGroup {
1566
1570
break ;
1567
1571
case ' B' :
1568
1572
if (m_breakpoint.SetValueFromString (option_arg).Fail ())
1569
- error.SetErrorStringWithFormat (
1570
- " unrecognized value \" %s\" for breakpoint" ,
1571
- option_arg.str ().c_str ());
1573
+ error = CreateOptionParsingError (option_arg, short_option, long_option,
1574
+ g_int_parsing_error_message);
1572
1575
break ;
1573
1576
case ' D' :
1574
1577
if (m_use_dummy.SetValueFromString (option_arg).Fail ())
1575
- error.SetErrorStringWithFormat (
1576
- " unrecognized value \" %s\" for use-dummy" ,
1577
- option_arg.str ().c_str ());
1578
+ error = CreateOptionParsingError (option_arg, short_option, long_option,
1579
+ g_bool_parsing_error_message);
1578
1580
break ;
1579
1581
case ' H' :
1580
1582
m_help_string.SetValueFromString (option_arg);
@@ -1617,6 +1619,8 @@ class BreakpointAccessOptionGroup : public OptionGroup {
1617
1619
Status error;
1618
1620
const int short_option =
1619
1621
g_breakpoint_access_options[option_idx].short_option ;
1622
+ const char *long_option =
1623
+ g_breakpoint_access_options[option_idx].long_option ;
1620
1624
1621
1625
switch (short_option) {
1622
1626
case ' L' : {
@@ -1625,29 +1629,26 @@ class BreakpointAccessOptionGroup : public OptionGroup {
1625
1629
if (success) {
1626
1630
m_permissions.SetAllowList (value);
1627
1631
} else
1628
- error.SetErrorStringWithFormat (
1629
- " invalid boolean value '%s' passed for -L option" ,
1630
- option_arg.str ().c_str ());
1632
+ error = CreateOptionParsingError (option_arg, short_option, long_option,
1633
+ g_bool_parsing_error_message);
1631
1634
} break ;
1632
1635
case ' A' : {
1633
1636
bool value, success;
1634
1637
value = OptionArgParser::ToBoolean (option_arg, false , &success);
1635
1638
if (success) {
1636
1639
m_permissions.SetAllowDisable (value);
1637
1640
} else
1638
- error.SetErrorStringWithFormat (
1639
- " invalid boolean value '%s' passed for -L option" ,
1640
- option_arg.str ().c_str ());
1641
+ error = CreateOptionParsingError (option_arg, short_option, long_option,
1642
+ g_bool_parsing_error_message);
1641
1643
} break ;
1642
1644
case ' D' : {
1643
1645
bool value, success;
1644
1646
value = OptionArgParser::ToBoolean (option_arg, false , &success);
1645
1647
if (success) {
1646
1648
m_permissions.SetAllowDelete (value);
1647
1649
} else
1648
- error.SetErrorStringWithFormat (
1649
- " invalid boolean value '%s' passed for -L option" ,
1650
- option_arg.str ().c_str ());
1650
+ error = CreateOptionParsingError (option_arg, short_option, long_option,
1651
+ g_bool_parsing_error_message);
1651
1652
} break ;
1652
1653
default :
1653
1654
llvm_unreachable (" Unimplemented option" );
@@ -2141,6 +2142,8 @@ class CommandObjectBreakpointRead : public CommandObjectParsed {
2141
2142
ExecutionContext *execution_context) override {
2142
2143
Status error;
2143
2144
const int short_option = m_getopt_table[option_idx].val ;
2145
+ const char *long_option =
2146
+ m_getopt_table[option_idx].definition ->long_option ;
2144
2147
2145
2148
switch (short_option) {
2146
2149
case ' f' :
@@ -2150,8 +2153,8 @@ class CommandObjectBreakpointRead : public CommandObjectParsed {
2150
2153
Status name_error;
2151
2154
if (!BreakpointID::StringIsBreakpointName (llvm::StringRef (option_arg),
2152
2155
name_error)) {
2153
- error. SetErrorStringWithFormat ( " Invalid breakpoint name: %s " ,
2154
- name_error.AsCString ());
2156
+ error = CreateOptionParsingError (option_arg, short_option ,
2157
+ long_option, name_error.AsCString ());
2155
2158
}
2156
2159
m_names.push_back (std::string (option_arg));
2157
2160
break ;
0 commit comments