This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This patch tries to do a better job on catching assignments inside if statement. The main problems were coming from: 1) complex #define containing also if or else statement parts with assignments on continuation lines that were wrongly reported as "if assignment" error. 2) statement of the if or else part on the same line as the 'if' keyword as in: if (a<b) {c = 5} 3) missed real errors because they were not located at the line containing the 'if' keyword like in the expression if ((self == NULL) && (test = get_sect (self)) { The patch tries to find the matching close brace of the opening brace, possibly on later lines by merging them (handles 3) and does not check text after that close brace, thus avoiding errors like 1) or 2). The patch is a bit complicated, mainly because it counts the brace levels. Pierre Muller Pascal language support maintainer for GDB List of false positive removed by this patch, preceded by the type: There a few ??) cases where I did not understand why the outcome changed... 2) gdb/ada-lang.h:235: if ((s) < (m)) (v) = grow_vect (v, &(s), m, sizeof *(v)); 1) gdb/ada-lex.l:65: if ( *lexptr == '\000' ) \ :66: (RESULT) = YY_NULL; \ :67: else \ :68: { \ :69: *(BUF) = *lexptr; \ :70: (RESULT) = 1; \ :71: lexptr += 1; \ :72: } 2) gdb/cli/cli-cmds.c:873: if (first_line < 1) first_line = 1; 1) gdb/cp-name-parser.y:1226: else if (type == TYPE || type == MTYPE) \ :1227: { \ :1228: inner_p = &d_left (*inner_p); \ :1229: type = (*inner_p)->type; \ :1230: } 1) gdb/cp-name-parser.y:1532: if (strncmp (tokstart, string, sizeof (string) - 1) == 0) \ :1533: { \ :1534: lexptr = tokstart + sizeof (string) - 1; \ :1535: yylval.lval = comp; \ :1536: return DEMANGLER_SPECIAL; \ :1537: } 1) gdb/cp-name-parser.y:1540: if (lexptr[1] == string[1]) \ :1541: { \ :1542: lexptr += 2; \ :1543: yylval.opname = string; \ :1544: return token; \ :1545: } 1) gdb/cp-name-parser.y:1548: if (lexptr[1] == string[1] && lexptr[2] == string[2]) \ :1549: { \ :1550: lexptr += 3; \ :1551: yylval.opname = string; \ :1552: return token; \ :1553: } 2) gdb/cp-name-parser.y:402: if ($3) $$ = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $3); } 2) gdb/cp-name-parser.y:405: if ($3) $$ = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $3); } 2) gdb/cp-name-parser.y:409: if ($2) $$ = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $2); } 2) gdb/cp-name-parser.y:424: if ($2.start) $$ = fill_comp (DEMANGLE_COMPONENT_LOCAL_NAME, $$, $2.start); 2) gdb/cp-name-parser.y:726: { $$ = $1 | $2; if ($1 & $2 & INT_LONG) $$ = $1 | INT_LLONG; } 2) gdb/cp-name-parser.y:825: if ($2.fn.comp) { $$.last = $2.fn.last; *$2.last = $2.fn.comp; } 2) gdb/cp-name-parser.y:830: if ($1.fn.comp) { $$.last = $1.fn.last; *$1.last = $1.fn.comp; } 2) gdb/cp-name-parser.y:837: if ($2.fn.comp) { $$.last = $2.fn.last; *$2.last = $2.fn.comp; } 2) gdb/cp-name-parser.y:841: if ($1.fn.comp) { $$.last = $1.fn.last; *$1.last = $1.fn.comp; } 2) gdb/cp-name-parser.y:852: if ($1.fn.comp) { $$.last = $1.fn.last; *$1.last = $1.fn.comp; } 2) gdb/cp-name-parser.y:889: if ($1.fn.comp) { $$.last = $1.fn.last; *$1.last = $1.fn.comp; } 1) gdb/dbxread.c:858: if (bfd_get_sign_extend_vma (abfd)) \ :859: (intern).n_value = bfd_h_get_signed_32 (abfd, (extern)->e_value); \ :860: else \ :861: (intern).n_value = bfd_h_get_32 (abfd, (extern)->e_value); \ :862: } 1) gdb/f-lang.c:730: if (saved_bf_list == NULL) \ :731: { \ :732: tmp_bf_ptr = allocate_saved_bf_node(); \ :733: \ :734: tmp_bf_ptr->symnum_bf = (bf_sym); \ :735: tmp_bf_ptr->symnum_fcn = (fcn_sym); \ :736: tmp_bf_ptr->next = NULL; \ :737: \ :738: current_head_bf_list = saved_bf_list = tmp_bf_ptr; \ :739: saved_bf_list_end = tmp_bf_ptr; \ :740: } \ :741: else \ :742: { \ :743: tmp_bf_ptr = allocate_saved_bf_node(); \ :744: \ :745: tmp_bf_ptr->symnum_bf = (bf_sym); \ :746: tmp_bf_ptr->symnum_fcn = (fcn_sym); \ :747: tmp_bf_ptr->next = NULL; \ :748: \ :749: saved_bf_list_end->next = tmp_bf_ptr; \ :750: saved_bf_list_end = tmp_bf_ptr; \ :751: } 2) gdb/gnu-nat.c:2307: do if (ret != KERN_SUCCESS) { errstr = #str; goto out; } while(0) 1) gdb/infrun.c:194: if ((sigs)[signum]) \ :195: (flags)[signum] = 1; \ :196: } while (0) 1) gdb/infrun.c:202: if ((sigs)[signum]) \ :203: (flags)[signum] = 0; \ :204: } while (0) 1) gdb/linespec.c:936: if ((ii = strstr (arg, " if ")) != NULL || 2) gdb/rs6000-tdep.c:888: if (epilogue_start < func_start) epilogue_start = func_start; 2) gdb/rs6000-tdep.c:891: if (epilogue_end > func_end) epilogue_end = func_end; 1) gdb/stabsread.c:208: if (**(pp) == '\\' || (**(pp) == '?' && (*(pp))[1] == '\0')) \ :209: *(pp) = next_symbol_text (objfile); \ :210: } while (0) 2) gdb/target.c:2387: if (dest < src) *dest = *src; 1) gdb/target.c:392: if (!current_target.FIELD) \ :393: current_target.FIELD = (TARGET)->FIELD 1) gdb/target.c:492: if (!current_target.field) \ :493: current_target.field = value 1) gdb/vec.h:470: if (extend) \ :471: *vec_ = (VEC(T) *) vec_o_reserve (*vec_, alloc_, \ :472: offsetof (VEC(T),vec), sizeof (T)); \ :473: \ :474: return extend; \ :475: } \ :476: \ :477: static inline void VEC_OP (T,safe_grow) \ :478: (VEC(T) **vec_, int size_ VEC_ASSERT_DECL) \ :479: { \ :480: vec_assert (size_ >= 0 && VEC_OP(T,length) (*vec_) <= (unsigned)size_, \ :481: "safe_grow"); \ :482: VEC_OP (T,reserve) (vec_, (int)(*vec_ ? (*vec_)->num : 0) - size_ \ :483: VEC_ASSERT_PASS); \ :484: (*vec_)->num = size_; \ :485: } \ :486: \ :487: static inline T *VEC_OP (T,safe_push) \ :488: (VEC(T) **vec_, const T obj_ VEC_ASSERT_DECL) \ :489: { \ :490: VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS); \ :491: \ :492: return VEC_OP (T,quick_push) (*vec_, obj_ VEC_ASSERT_PASS); \ :493: } \ :494: \ :495: static inline T *VEC_OP (T,safe_insert) \ :496: (VEC(T) **vec_, unsigned ix_, const T obj_ VEC_ASSERT_DECL) \ :497: { \ :498: VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS); \ :499: \ :500: return VEC_OP (T,quick_insert) (*vec_, ix_, obj_ VEC_ASSERT_PASS); \ :501: } 1) gdb/vec.h:674: if (lessthan_ (middle_elem_, obj_)) \ :675: { \ :676: first_ = middle_; \ :677: ++first_; \ :678: len_ = len_ - half_ - 1; \ :679: } \ :680: else \ :681: len_ = half_; \ :682: } \ :683: return first_; \ :684: } 1) gdb/vec.h:724: if (extend) \ :725: *vec_ = (VEC(T) *) vec_p_reserve (*vec_, alloc_); \ :726: \ :727: return extend; \ :728: } \ :729: \ :730: static inline void VEC_OP (T,safe_grow) \ :731: (VEC(T) **vec_, int size_ VEC_ASSERT_DECL) \ :732: { \ :733: vec_assert (size_ >= 0 && VEC_OP(T,length) (*vec_) <= (unsigned)size_, \ :734: "safe_grow"); \ :735: VEC_OP (T,reserve) \ :736: (vec_, (int)(*vec_ ? (*vec_)->num : 0) - size_ VEC_ASSERT_PASS); \ :737: (*vec_)->num = size_; \ :738: } \ :739: \ :740: static inline T *VEC_OP (T,safe_push) \ :741: (VEC(T) **vec_, T obj_ VEC_ASSERT_DECL) \ :742: { \ :743: VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS); \ :744: \ :745: return VEC_OP (T,quick_push) (*vec_, obj_ VEC_ASSERT_PASS); \ :746: } \ :747: \ :748: static inline T *VEC_OP (T,safe_insert) \ :749: (VEC(T) **vec_, unsigned ix_, T obj_ VEC_ASSERT_DECL) \ :750: { \ :751: VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS); \ :752: \ :753: return VEC_OP (T,quick_insert) (*vec_, ix_, obj_ VEC_ASSERT_PASS); \ :754: } 1) gdb/vec.h:914: if (lessthan_ (middle_elem_, obj_)) \ :915: { \ :916: first_ = middle_; \ :917: ++first_; \ :918: len_ = len_ - half_ - 1; \ :919: } \ :920: else \ :921: len_ = half_; \ :922: } \ :923: return first_; \ :924: } 1) gdb/vec.h:966: if (extend) \ :967: *vec_ = (VEC(T) *) \ :968: vec_o_reserve (*vec_, alloc_, offsetof (VEC(T),vec), sizeof (T)); \ :969: \ :970: return extend; \ :971: } \ :972: \ :973: static inline void VEC_OP (T,safe_grow) \ :974: (VEC(T) **vec_, int size_ VEC_ASSERT_DECL) \ :975: { \ :976: vec_assert (size_ >= 0 && VEC_OP(T,length) (*vec_) <= (unsigned)size_, \ :977: "safe_grow"); \ :978: VEC_OP (T,reserve) \ :979: (vec_, (int)(*vec_ ? (*vec_)->num : 0) - size_ VEC_ASSERT_PASS); \ :980: (*vec_)->num = size_; \ :981: } \ :982: \ :983: static inline T *VEC_OP (T,safe_push) \ :984: (VEC(T) **vec_, const T *obj_ VEC_ASSERT_DECL) \ :985: { \ :986: VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS); \ :987: \ :988: return VEC_OP (T,quick_push) (*vec_, obj_ VEC_ASSERT_PASS); \ :989: } \ :990: \ :991: static inline T *VEC_OP (T,safe_insert) \ :992: (VEC(T) **vec_, unsigned ix_, const T *obj_ VEC_ASSERT_DECL) \ :993: { \ :994: VEC_OP (T,reserve) (vec_, 1 VEC_ASSERT_PASS); \ :995: \ :996: return VEC_OP (T,quick_insert) (*vec_, ix_, obj_ VEC_ASSERT_PASS); \ :997: } 1) gdb/xcoffread.c:836: if (namestr[0] == '.') ++namestr; \ :837: prim_record_minimal_symbol_and_info (namestr, (ADDR), (TYPE), \ :838: (SECTION), (asection *)NULL, (OBJFILE)); \ :839: misc_func_recorded = 1; \ :840: } New errors found with new test: 3) gdb/dbxread.c:1367: if ((namestring[0] == '-' && namestring[1] == 'l') :1368: || (namestring[(nsl = strlen (namestring)) - 1] == 'o' :1369: && namestring[nsl - 2] == '.')) 3) gdb/gdbtypes.c:1506: else if (TYPE_CODE (type) == TYPE_CODE_ARRAY :1507: && TYPE_NFIELDS (type) == 1 :1508: && (TYPE_CODE (range_type = TYPE_INDEX_TYPE (type)) :1509: == TYPE_CODE_RANGE)) 3) gdb/jv-valprint.c:71: if (TYPE_CODE (type) == TYPE_CODE_STRUCT && name != NULL :72: && (i = strlen (name), name[i - 1] == ']')) 3) gdb/linespec.c:1314: if (sym_class && :1315: (t = check_typedef (SYMBOL_TYPE (sym_class)), :1316: (TYPE_CODE (t) == TYPE_CODE_STRUCT :1317: || TYPE_CODE (t) == TYPE_CODE_UNION))) > gdb/linespec.c:937: (ii = strstr (arg, "\tif ")) != NULL || :938: (ii = strstr (arg, " if\t")) != NULL || :939: (ii = strstr (arg, "\tif\t")) != NULL || :940: (ii = strstr (arg, " if(")) != NULL || :941: (ii = strstr (arg, "\tif( ")) != NULL) 3) gdb/linux-nat.c:3556: if (core_regset_p :3557: && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg", :3558: sizeof (gregs))) != NULL :3559: && regset->collect_regset != NULL) 3) gdb/linux-nat.c:3606: if (core_regset_p :3607: && (regset = gdbarch_regset_from_core_section (gdbarch, ".reg2", :3608: sizeof (fpregs))) != NULL :3609: && regset->collect_regset != NULL) 3) gdb/printcmd.c:1018: if (obj_section_addr (osect) <= sect_addr :1019: && sect_addr < obj_section_endaddr (osect) :1020: && (msymbol = lookup_minimal_symbol_by_pc_section (sect_addr, osect))) ??) I don't get why this was not in the old list! ??) gdb/procfs.c:3325: if ((thread = create_procinfo (pi->pid, lwpid)) == NULL) ??) gdb/remote.c:2126: if (!(result = (*stepfunction) (&resultthreadlist[i++], context))) 3) gdb/scm-lang.c:167: if (in_eval_c () :168: && (sym = lookup_symbol ("env", :169: expression_context_block, :170: VAR_DOMAIN, (int *) NULL)) != NULL) 3) gdb/tracepoint.c:1028: if (*p == '\0' || :1029: (t->step_count = strtol (p, &p, 0)) == 0) ??) gdb/tracepoint.c:1898: if ((target_frameno = (int) strtol (++reply, &reply, 16)) == -1) ??) gdb/tracepoint.c:1936: if ((target_tracept = (int) strtol (++reply, &reply, 16)) == -1) 3) gdb/tui/tui-source.c:197: if (c == '\r' :198: && (c = fgetc (stream)) != '\n' :199: && c != EOF) 3) gdb/v850-tdep.c:585: else if (((insn & 0x07ff) == (0x0760 | E_SP_REGNUM) :586: || (pi->uses_fp :587: && (insn & 0x07ff) == (0x0760 | E_FP_REGNUM))) :588: && pifsr :589: && v850_is_save_register (reg = (insn >> 11) & 0x1f)) 3) gdb/v850-tdep.c:597: else if (ep_used :598: && ((insn & 0x0781) == 0x0501) :599: && pifsr :600: && v850_is_save_register (reg = (insn >> 11) & 0x1f)) 3) gdb/valarith.c:1382: else if (code1 == code2 :1383: && ((len = (int) TYPE_LENGTH (type1)) :1384: == (int) TYPE_LENGTH (type2)))
Attachment:
gdb_if.patch
Description: Binary data
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |