Fix some memory leaks.
Add call to lldb.SBDebugger.Initialize() to lldb.py, so it automatically gets called when the lldb Python module gets loaded. llvm-svn: 116345
This commit is contained in:
parent
48daa1fddb
commit
4ab31c98e6
|
@ -21,6 +21,7 @@ except IOError:
|
|||
print "Error: Unable to open file for appending: " + output_name
|
||||
else:
|
||||
f_out.write ("debugger_unique_id = 0\n");
|
||||
f_out.write ("lldb.SBDebugger.Initialize()\n");
|
||||
try:
|
||||
f_out.close()
|
||||
except IOError:
|
||||
|
|
|
@ -181,7 +181,6 @@ BreakpointIDList::FindAndReplaceIDRanges (Args &old_args, Target *target, Comman
|
|||
if (BreakpointIDList::StringContainsIDRangeExpression (current_arg, &range_start_len, &range_end_pos))
|
||||
{
|
||||
is_range = true;
|
||||
range_start = (char *) malloc (range_start_len + 1);
|
||||
range_start.assign (current_arg, range_start_len);
|
||||
range_end = current_arg + range_end_pos;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <getopt.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -947,13 +948,10 @@ CommandInterpreter::HasAliasOptions ()
|
|||
}
|
||||
|
||||
void
|
||||
CommandInterpreter::BuildAliasCommandArgs
|
||||
(
|
||||
CommandObject *alias_cmd_obj,
|
||||
CommandInterpreter::BuildAliasCommandArgs (CommandObject *alias_cmd_obj,
|
||||
const char *alias_name,
|
||||
Args &cmd_args,
|
||||
CommandReturnObject &result
|
||||
)
|
||||
CommandReturnObject &result)
|
||||
{
|
||||
OptionArgVectorSP option_arg_vector_sp = GetAliasOptions (alias_name);
|
||||
|
||||
|
@ -970,10 +968,9 @@ CommandInterpreter::BuildAliasCommandArgs
|
|||
|
||||
OptionArgVector *option_arg_vector = option_arg_vector_sp.get();
|
||||
int old_size = cmd_args.GetArgumentCount();
|
||||
int *used = (int *) malloc ((old_size + 1) * sizeof (int));
|
||||
std::vector<bool> used (old_size + 1, false);
|
||||
|
||||
memset (used, 0, (old_size + 1) * sizeof (int));
|
||||
used[0] = 1;
|
||||
used[0] = true;
|
||||
|
||||
for (int i = 0; i < option_arg_vector->size(); ++i)
|
||||
{
|
||||
|
@ -1002,7 +999,7 @@ CommandInterpreter::BuildAliasCommandArgs
|
|||
else
|
||||
{
|
||||
new_args.AppendArgument (cmd_args.GetArgumentAtIndex (index));
|
||||
used[index] = 1;
|
||||
used[index] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -332,7 +332,8 @@ ShowUsage (FILE *out, lldb::OptionDefinition *option_table, Driver::OptionData d
|
|||
}
|
||||
|
||||
void
|
||||
BuildGetOptTable (lldb::OptionDefinition *expanded_option_table, struct option **getopt_table, uint32_t num_options)
|
||||
BuildGetOptTable (lldb::OptionDefinition *expanded_option_table, std::vector<struct option> &getopt_table,
|
||||
uint32_t num_options)
|
||||
{
|
||||
if (num_options == 0)
|
||||
return;
|
||||
|
@ -341,25 +342,27 @@ BuildGetOptTable (lldb::OptionDefinition *expanded_option_table, struct option *
|
|||
uint32_t j;
|
||||
std::bitset<256> option_seen;
|
||||
|
||||
getopt_table.resize (num_options + 1);
|
||||
|
||||
for (i = 0, j = 0; i < num_options; ++i)
|
||||
{
|
||||
char short_opt = expanded_option_table[i].short_option;
|
||||
|
||||
if (option_seen.test(short_opt) == false)
|
||||
{
|
||||
(*getopt_table)[j].name = expanded_option_table[i].long_option;
|
||||
(*getopt_table)[j].has_arg = expanded_option_table[i].option_has_arg;
|
||||
(*getopt_table)[j].flag = NULL;
|
||||
(*getopt_table)[j].val = expanded_option_table[i].short_option;
|
||||
getopt_table[j].name = expanded_option_table[i].long_option;
|
||||
getopt_table[j].has_arg = expanded_option_table[i].option_has_arg;
|
||||
getopt_table[j].flag = NULL;
|
||||
getopt_table[j].val = expanded_option_table[i].short_option;
|
||||
option_seen.set(short_opt);
|
||||
++j;
|
||||
}
|
||||
}
|
||||
|
||||
(*getopt_table)[j].name = NULL;
|
||||
(*getopt_table)[j].has_arg = 0;
|
||||
(*getopt_table)[j].flag = NULL;
|
||||
(*getopt_table)[j].val = 0;
|
||||
getopt_table[j].name = NULL;
|
||||
getopt_table[j].has_arg = 0;
|
||||
getopt_table[j].flag = NULL;
|
||||
getopt_table[j].val = 0;
|
||||
|
||||
}
|
||||
|
||||
|
@ -456,6 +459,7 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit)
|
|||
SBError error;
|
||||
std::string option_string;
|
||||
struct option *long_options = NULL;
|
||||
std::vector<struct option> long_options_vector;
|
||||
uint32_t num_options;
|
||||
|
||||
for (num_options = 0; g_options[num_options].long_option != NULL; ++num_options)
|
||||
|
@ -468,9 +472,12 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit)
|
|||
return error;
|
||||
}
|
||||
|
||||
long_options = (struct option *) malloc ((num_options + 1) * sizeof (struct option));
|
||||
BuildGetOptTable (g_options, long_options_vector, num_options);
|
||||
|
||||
BuildGetOptTable (g_options, &long_options, num_options);
|
||||
if (long_options_vector.empty())
|
||||
long_options = NULL;
|
||||
else
|
||||
long_options = &long_options_vector.front();
|
||||
|
||||
if (long_options == NULL)
|
||||
{
|
||||
|
@ -625,9 +632,11 @@ Driver::ParseArgs (int argc, const char *argv[], FILE *out_fh, bool &exit)
|
|||
error.SetErrorStringWithFormat ("invalid option with value %i", val);
|
||||
}
|
||||
if (error.Fail())
|
||||
{
|
||||
return error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If there is a trailing argument, it is the filename.
|
||||
if (optind == argc - 1)
|
||||
|
|
Loading…
Reference in New Issue