From d7f9d729727b2b85ae3228785762f4d2e6a8742f Mon Sep 17 00:00:00 2001 From: Michael Snyder Date: Fri, 14 May 2010 18:35:11 +0000 Subject: [PATCH] 2010-05-14 Michael Snyder * elfread.c: White space. * environ.c: White space. * eval.c: White space. * event-loop.c: White space. * event-top.c: White space. * exceptions.c: White space. * exec.c: White space. * expprint.c: White space. --- gdb/ChangeLog | 9 +++++++++ gdb/elfread.c | 2 ++ gdb/environ.c | 1 + gdb/eval.c | 44 +++++++++++++++++++++++++++++++++++++++----- gdb/event-loop.c | 2 +- gdb/event-top.c | 3 ++- gdb/exceptions.c | 9 +++++++++ gdb/exec.c | 3 ++- gdb/expprint.c | 10 ++++++++++ 9 files changed, 75 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 0c134eac3c..2b0de0957d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,14 @@ 2010-05-14 Michael Snyder + * elfread.c: White space. + * environ.c: White space. + * eval.c: White space. + * event-loop.c: White space. + * event-top.c: White space. + * exceptions.c: White space. + * exec.c: White space. + * expprint.c: White space. + * dbxread.c: White space. * dcache.c: White space. * disasm.c: White space. diff --git a/gdb/elfread.c b/gdb/elfread.c index 68bbf1266e..8c00938777 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -425,6 +425,7 @@ elf_symtab_read (struct objfile *objfile, int type, /* Named Local variable in a Data section. Check its name for stabs-in-elf. */ int special_local_sect; + if (strcmp ("Bbss.bss", sym->name) == 0) special_local_sect = SECT_OFF_BSS (objfile); else if (strcmp ("Ddata.data", sym->name) == 0) @@ -889,6 +890,7 @@ elf_symfile_read (struct objfile *objfile, int symfile_flags) if (debugfile) { bfd *abfd = symfile_bfd_open (debugfile); + symbol_file_add_separate (abfd, symfile_flags, objfile); xfree (debugfile); } diff --git a/gdb/environ.c b/gdb/environ.c index 84d8ccf019..ebd6431801 100644 --- a/gdb/environ.c +++ b/gdb/environ.c @@ -81,6 +81,7 @@ init_environ (struct gdb_environ *e) { int len = strlen (e->vector[i]); char *new = (char *) xmalloc (len + 1); + memcpy (new, e->vector[i], len + 1); e->vector[i] = new; } diff --git a/gdb/eval.c b/gdb/eval.c index 273cd0e145..1dbf6fa508 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -162,6 +162,7 @@ struct value * evaluate_expression (struct expression *exp) { int pc = 0; + return evaluate_subexp (NULL_TYPE, exp, &pc, EVAL_NORMAL); } @@ -172,6 +173,7 @@ struct value * evaluate_type (struct expression *exp) { int pc = 0; + return evaluate_subexp (NULL_TYPE, exp, &pc, EVAL_AVOID_SIDE_EFFECTS); } @@ -196,6 +198,7 @@ extract_field_op (struct expression *exp, int *subexp) { int tem; char *result; + if (exp->elts[*subexp].opcode != STRUCTOP_STRUCT && exp->elts[*subexp].opcode != STRUCTOP_PTR) return NULL; @@ -216,6 +219,7 @@ get_label (struct expression *exp, int *pos) int pc = (*pos)++; char *name = &exp->elts[pc + 2].string; int tem = longest_to_int (exp->elts[pc + 1].longconst); + (*pos) += 3 + BYTES_TO_EXP_ELEM (tem + 1); return name; } @@ -237,6 +241,7 @@ evaluate_struct_tuple (struct value *struct_val, int fieldno = -1; int variantno = -1; int subfieldno = -1; + while (--nargs >= 0) { int pc = *pos; @@ -252,12 +257,14 @@ evaluate_struct_tuple (struct value *struct_val, do { char *label = get_label (exp, &pc); + if (label) { for (fieldno = 0; fieldno < TYPE_NFIELDS (struct_type); fieldno++) { char *field_name = TYPE_FIELD_NAME (struct_type, fieldno); + if (field_name != NULL && strcmp (field_name, label) == 0) { variantno = -1; @@ -270,6 +277,7 @@ evaluate_struct_tuple (struct value *struct_val, fieldno++) { char *field_name = TYPE_FIELD_NAME (struct_type, fieldno); + field_type = TYPE_FIELD_TYPE (struct_type, fieldno); if ((field_name == 0 || *field_name == '\0') && TYPE_CODE (field_type) == TYPE_CODE_UNION) @@ -381,6 +389,7 @@ init_array_element (struct value *array, struct value *element, { LONGEST index; int element_size = TYPE_LENGTH (value_type (element)); + if (exp->elts[*pos].opcode == BINOP_COMMA) { (*pos)++; @@ -392,6 +401,7 @@ init_array_element (struct value *array, struct value *element, else if (exp->elts[*pos].opcode == BINOP_RANGE) { LONGEST low, high; + (*pos)++; low = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); high = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); @@ -464,6 +474,7 @@ unop_promote (const struct language_defn *language, struct gdbarch *gdbarch, it needs to modify this function. */ { struct type *builtin_int = builtin_type (gdbarch)->builtin_int; + if (TYPE_LENGTH (type1) < TYPE_LENGTH (builtin_int)) *arg1 = value_cast (builtin_int, *arg1); } @@ -848,6 +859,7 @@ evaluate_subexp_standard (struct type *expect_type, && TYPE_CODE (type) == TYPE_CODE_STRUCT) { struct value *rec = allocate_value (expect_type); + memset (value_contents_raw (rec), '\0', TYPE_LENGTH (type)); return evaluate_struct_tuple (rec, exp, pos, noside, nargs); } @@ -860,6 +872,7 @@ evaluate_subexp_standard (struct type *expect_type, struct value *array = allocate_value (expect_type); int element_size = TYPE_LENGTH (check_typedef (element_type)); LONGEST low_bound, high_bound, index; + if (get_discrete_bounds (range_type, &low_bound, &high_bound) < 0) { low_bound = 0; @@ -871,6 +884,7 @@ evaluate_subexp_standard (struct type *expect_type, { struct value *element; int index_pc = 0; + if (exp->elts[*pos].opcode == BINOP_RANGE) { index_pc = ++(*pos); @@ -882,6 +896,7 @@ evaluate_subexp_standard (struct type *expect_type, if (index_pc) { int continue_pc = *pos; + *pos = index_pc; index = init_array_element (array, element, exp, pos, noside, low_bound, high_bound); @@ -924,6 +939,7 @@ evaluate_subexp_standard (struct type *expect_type, LONGEST range_low, range_high; struct type *range_low_type, *range_high_type; struct value *elem_val; + if (exp->elts[*pos].opcode == BINOP_RANGE) { (*pos)++; @@ -968,6 +984,7 @@ evaluate_subexp_standard (struct type *expect_type, for (; range_low <= range_high; range_low++) { int bit_index = (unsigned) range_low % TARGET_CHAR_BIT; + if (gdbarch_bits_big_endian (exp->gdbarch)) bit_index = TARGET_CHAR_BIT - 1 - bit_index; valaddr[(unsigned) range_low / TARGET_CHAR_BIT] @@ -991,9 +1008,10 @@ evaluate_subexp_standard (struct type *expect_type, { struct value *array = evaluate_subexp (NULL_TYPE, exp, pos, noside); int lowbound - = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); + = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); int upper - = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); + = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); + if (noside == EVAL_SKIP) goto nosideret; return value_slice (array, lowbound, upper - lowbound + 1); @@ -1003,9 +1021,10 @@ evaluate_subexp_standard (struct type *expect_type, { struct value *array = evaluate_subexp (NULL_TYPE, exp, pos, noside); int lowbound - = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); + = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); int length - = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); + = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside)); + return value_slice (array, lowbound, length); } @@ -1101,6 +1120,7 @@ evaluate_subexp_standard (struct type *expect_type, if (gnu_runtime) { struct type *type = selector_type; + type = lookup_function_type (type); type = lookup_pointer_type (type); type = lookup_function_type (type); @@ -1286,6 +1306,7 @@ evaluate_subexp_standard (struct type *expect_type, it. */ struct type *type = value_type (called_method); + if (type && TYPE_CODE (type) == TYPE_CODE_PTR) type = TYPE_TARGET_TYPE (type); type = TYPE_TARGET_TYPE (type); @@ -1367,6 +1388,7 @@ evaluate_subexp_standard (struct type *expect_type, if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *method_type = check_typedef (value_type (arg1)); + arg1 = value_zero (method_type, not_lval); } else @@ -1458,6 +1480,7 @@ evaluate_subexp_standard (struct type *expect_type, /* Save the function position and move pos so that the arguments can be evaluated. */ int func_name_len; + save_pos1 = *pos; tem = 1; @@ -1567,6 +1590,7 @@ evaluate_subexp_standard (struct type *expect_type, /* Non-C++ case -- or no overload resolution */ { struct value *temp = arg2; + argvec[0] = value_struct_elt (&temp, argvec + 1, tstr, &static_memfuncp, op == STRUCTOP_STRUCT @@ -1773,6 +1797,7 @@ evaluate_subexp_standard (struct type *expect_type, else { struct value *temp = arg1; + return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string, NULL, "structure"); } @@ -1818,6 +1843,7 @@ evaluate_subexp_standard (struct type *expect_type, else { struct value *temp = arg1; + return value_struct_elt (&temp, NULL, &exp->elts[pc + 2].string, NULL, "structure pointer"); } @@ -2501,6 +2527,7 @@ evaluate_subexp_standard (struct type *expect_type, else { struct value *retvalp = evaluate_subexp_for_address (exp, pos, noside); + return retvalp; } @@ -2559,6 +2586,7 @@ evaluate_subexp_standard (struct type *expect_type, else { CORE_ADDR tls_addr; + tls_addr = target_translate_tls_address (exp->elts[pc + 1].objfile, value_as_address (arg1)); return value_at_lazy (exp->elts[pc + 2].type, tls_addr); @@ -2579,6 +2607,7 @@ evaluate_subexp_standard (struct type *expect_type, else { struct value *tmp = arg1; + arg2 = value_one (value_type (arg1), not_lval); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_ADD); @@ -2602,6 +2631,7 @@ evaluate_subexp_standard (struct type *expect_type, else { struct value *tmp = arg1; + arg2 = value_one (value_type (arg1), not_lval); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_SUB); @@ -2625,6 +2655,7 @@ evaluate_subexp_standard (struct type *expect_type, else { struct value *tmp = arg1; + arg2 = value_one (value_type (arg1), not_lval); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_ADD); @@ -2649,6 +2680,7 @@ evaluate_subexp_standard (struct type *expect_type, else { struct value *tmp = arg1; + arg2 = value_one (value_type (arg1), not_lval); binop_promote (exp->language_defn, exp->gdbarch, &tmp, &arg2); arg2 = value_binop (tmp, arg2, BINOP_SUB); @@ -2675,6 +2707,7 @@ evaluate_subexp_standard (struct type *expect_type, else if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *type = exp->elts[pc + 1].type; + /* If this is a typedef, then find its immediate target. We use check_typedef to resolve stubs, but we ignore its result because we do not want to dig past all @@ -2757,7 +2790,7 @@ evaluate_subexp_for_address (struct expression *exp, int *pos, if (noside == EVAL_AVOID_SIDE_EFFECTS) { struct type *type = - lookup_pointer_type (SYMBOL_TYPE (var)); + lookup_pointer_type (SYMBOL_TYPE (var)); enum address_class sym_class = SYMBOL_CLASS (var); if (sym_class == LOC_CONST @@ -2907,6 +2940,7 @@ parse_and_eval_type (char *p, int length) { char *tmp = (char *) alloca (length + 4); struct expression *expr; + tmp[0] = '('; memcpy (tmp + 1, p, length); tmp[length + 1] = ')'; diff --git a/gdb/event-loop.c b/gdb/event-loop.c index 735d0f6f9a..f1eba52fa0 100644 --- a/gdb/event-loop.c +++ b/gdb/event-loop.c @@ -858,8 +858,8 @@ gdb_wait_for_event (int block) else { struct timeval select_timeout; - struct timeval *timeout_p; + if (block) timeout_p = gdb_notifier.timeout_valid ? &gdb_notifier.select_timeout : NULL; diff --git a/gdb/event-top.c b/gdb/event-top.c index c7c206b357..718e245014 100644 --- a/gdb/event-top.c +++ b/gdb/event-top.c @@ -504,6 +504,7 @@ command_handler (char *command) { #ifdef HAVE_SBRK char *lim = (char *) sbrk (0); + space_at_cmd_start = lim - lim_at_start; #endif } @@ -556,7 +557,6 @@ command_line_handler (char *rl) char *nline; char got_eof = 0; - int repeat = (instream == stdin); if (annotation_level > 1 && instream == stdin) @@ -990,6 +990,7 @@ static void async_stop_sig (gdb_client_data arg) { char *prompt = get_prompt (); + #if STOP_SIGNAL == SIGTSTP signal (SIGTSTP, SIG_DFL); #if HAVE_SIGPROCMASK diff --git a/gdb/exceptions.c b/gdb/exceptions.c index 444db504b1..ec9b9be62e 100644 --- a/gdb/exceptions.c +++ b/gdb/exceptions.c @@ -104,6 +104,7 @@ static void catcher_pop (void) { struct catcher *old_catcher = current_catcher; + current_catcher = old_catcher->prev; /* Restore the cleanup chain, the error/quit messages, and the uiout @@ -174,6 +175,7 @@ exceptions_state_mc (enum catcher_action action) case CATCH_ITER: { struct gdb_exception exception = *current_catcher->exception; + if (current_catcher->mask & RETURN_MASK (exception.reason)) { /* Exit normally if this catcher can handle this @@ -243,6 +245,7 @@ void deprecated_throw_reason (enum return_reason reason) { struct gdb_exception exception; + memset (&exception, 0, sizeof exception); exception.reason = reason; @@ -299,6 +302,7 @@ print_exception (struct ui_file *file, struct gdb_exception e) as that way the MI's behavior is preserved. */ const char *start; const char *end; + for (start = e.message; start != NULL; start = end) { end = strchr (start, '\n'); @@ -412,6 +416,7 @@ void throw_error (enum errors error, const char *fmt, ...) { va_list args; + va_start (args, fmt); throw_it (RETURN_ERROR, error, fmt, args); va_end (args); @@ -457,6 +462,7 @@ catch_exception (struct ui_out *uiout, return_mask mask) { volatile struct gdb_exception exception; + TRY_CATCH (exception, mask) { (*func) (uiout, func_args); @@ -473,6 +479,7 @@ catch_exceptions_with_msg (struct ui_out *uiout, { volatile struct gdb_exception exception; volatile int val = 0; + TRY_CATCH (exception, mask) { val = (*func) (uiout, func_args); @@ -505,6 +512,7 @@ catch_errors (catch_errors_ftype *func, void *func_args, char *errstring, { volatile int val = 0; volatile struct gdb_exception exception; + TRY_CATCH (exception, mask) { val = func (func_args); @@ -520,6 +528,7 @@ catch_command_errors (catch_command_errors_ftype * command, char *arg, int from_tty, return_mask mask) { volatile struct gdb_exception e; + TRY_CATCH (e, mask) { command (arg, from_tty); diff --git a/gdb/exec.c b/gdb/exec.c index 5757a917f2..f9977a8ed6 100644 --- a/gdb/exec.c +++ b/gdb/exec.c @@ -224,6 +224,7 @@ exec_file_attach (char *filename, int from_tty) if (scratch_chan < 0) { char *exename = alloca (strlen (filename) + 5); + strcat (strcpy (exename, filename), ".exe"); scratch_chan = openp (getenv ("PATH"), OPF_TRY_CWD_FIRST, exename, write_files ? O_RDWR | O_BINARY : O_RDONLY | O_BINARY, @@ -458,6 +459,7 @@ add_target_sections (struct target_section *sections, if (count > 0) { int space = resize_section_table (table, count); + memcpy (table->sections + space, sections, count * sizeof (sections[0])); @@ -477,7 +479,6 @@ void remove_target_sections (bfd *abfd) { struct target_section *src, *dest; - struct target_section_table *table = current_target_sections; dest = table->sections; diff --git a/gdb/expprint.c b/gdb/expprint.c index 45deffe4ab..7299d646bb 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -42,6 +42,7 @@ void print_expression (struct expression *exp, struct ui_file *stream) { int pc = 0; + print_subexp (exp, &pc, stream, PREC_NULL); } @@ -96,6 +97,7 @@ print_subexp_standard (struct expression *exp, int *pos, case OP_LONG: { struct value_print_options opts; + get_raw_print_options (&opts); (*pos) += 3; value_print (value_from_longest (exp->elts[pc + 1].type, @@ -107,6 +109,7 @@ print_subexp_standard (struct expression *exp, int *pos, case OP_DOUBLE: { struct value_print_options opts; + get_raw_print_options (&opts); (*pos) += 3; value_print (value_from_double (exp->elts[pc + 1].type, @@ -118,6 +121,7 @@ print_subexp_standard (struct expression *exp, int *pos, case OP_VAR_VALUE: { struct block *b; + (*pos) += 3; b = exp->elts[pc + 1].block; if (b != NULL @@ -140,6 +144,7 @@ print_subexp_standard (struct expression *exp, int *pos, case OP_REGISTER: { const char *name = &exp->elts[pc + 2].string; + (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1); fprintf_filtered (stream, "$%s", name); return; @@ -181,6 +186,7 @@ print_subexp_standard (struct expression *exp, int *pos, case OP_STRING: { struct value_print_options opts; + nargs = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); /* LA_PRINT_STRING will print using the current repeat count threshold. @@ -202,6 +208,7 @@ print_subexp_standard (struct expression *exp, int *pos, case OP_OBJC_NSSTRING: /* Objective-C Foundation Class NSString constant. */ { struct value_print_options opts; + nargs = longest_to_int (exp->elts[pc + 1].longconst); (*pos) += 3 + BYTES_TO_EXP_ELEM (nargs + 1); fputs_filtered ("@\"", stream); @@ -215,6 +222,7 @@ print_subexp_standard (struct expression *exp, int *pos, case OP_OBJC_MSGCALL: { /* Objective C message (method) call. */ char *selector; + (*pos) += 3; nargs = longest_to_int (exp->elts[pc + 2].longconst); fprintf_unfiltered (stream, "["); @@ -228,6 +236,7 @@ print_subexp_standard (struct expression *exp, int *pos, if (nargs) { char *s, *nextS; + s = alloca (strlen (selector) + 1); strcpy (s, selector); for (tem = 0; tem < nargs; tem++) @@ -291,6 +300,7 @@ print_subexp_standard (struct expression *exp, int *pos, if (tem > 0) { struct value_print_options opts; + get_user_print_options (&opts); LA_PRINT_STRING (stream, builtin_type (exp->gdbarch)->builtin_char, tempstr, nargs - 1, NULL, 0, &opts); -- 2.34.1