Added a --force option to "memory read,"

disallowing reads over 1KiB in total size
unless the user explicitly allows them.

llvm-svn: 155750
This commit is contained in:
Sean Callanan 2012-04-28 01:27:38 +00:00
parent 833f04962a
commit 1276c33345
1 changed files with 14 additions and 1 deletions

View File

@ -37,7 +37,8 @@ g_option_table[] =
{
{ LLDB_OPT_SET_1, false, "num-per-line" ,'l', required_argument, NULL, 0, eArgTypeNumberPerLine ,"The number of items per line to display."},
{ LLDB_OPT_SET_2, false, "binary" ,'b', no_argument , NULL, 0, eArgTypeNone ,"If true, memory will be saved as binary. If false, the memory is saved save as an ASCII dump that uses the format, size, count and number per line settings."},
{ LLDB_OPT_SET_3, true , "view-as" ,'t', required_argument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."},
{ LLDB_OPT_SET_3, true , "view-as" ,'t', required_argument, NULL, 0, eArgTypeNone ,"The name of a type to view memory as."},
{ LLDB_OPT_SET_4, false, "force" ,'r', no_argument, NULL, 0, eArgTypeNone ,"Necessary if reading over 1024 bytes of memory."},
};
@ -94,6 +95,10 @@ public:
case 't':
error = m_view_as_type.SetValueFromCString (option_arg);
break;
case 'r':
m_force = true;
break;
default:
error.SetErrorStringWithFormat("unrecognized short option '%c'", short_option);
@ -270,6 +275,7 @@ public:
OptionValueUInt64 m_num_per_line;
bool m_output_as_binary;
OptionValueString m_view_as_type;
bool m_force;
};
@ -591,6 +597,13 @@ public:
item_count = total_byte_size / item_byte_size;
}
if (total_byte_size > 1024 && !m_memory_options.m_force)
{
result.AppendErrorWithFormat("Normally, \'memory read\' will not read over 1Kbyte of data.\n");
result.AppendErrorWithFormat("Please use --force to override this restriction.\n");
return false;
}
DataBufferSP data_sp;
size_t bytes_read = 0;
if (!clang_ast_type.GetOpaqueQualType())