| OLD | NEW |
| 1 /* The find command. | 1 /* The find command. |
| 2 | 2 |
| 3 Copyright (C) 2008-2012 Free Software Foundation, Inc. | 3 Copyright (C) 2008-2012 Free Software Foundation, Inc. |
| 4 | 4 |
| 5 This file is part of GDB. | 5 This file is part of GDB. |
| 6 | 6 |
| 7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
| 8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
| 9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
| 10 (at your option) any later version. | 10 (at your option) any later version. |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 | 163 |
| 164 if (*s == ',') | 164 if (*s == ',') |
| 165 ++s; | 165 ++s; |
| 166 | 166 |
| 167 /* Fetch the search string. */ | 167 /* Fetch the search string. */ |
| 168 | 168 |
| 169 while (*s != '\0') | 169 while (*s != '\0') |
| 170 { | 170 { |
| 171 LONGEST x; | 171 LONGEST x; |
| 172 int val_bytes; | 172 int val_bytes; |
| 173 ULONGEST pattern_buf_size_need; |
| 173 | 174 |
| 174 while (isspace (*s)) | 175 while (isspace (*s)) |
| 175 ++s; | 176 ++s; |
| 176 | 177 |
| 177 v = parse_to_comma_and_eval (&s); | 178 v = parse_to_comma_and_eval (&s); |
| 178 val_bytes = TYPE_LENGTH (value_type (v)); | 179 val_bytes = TYPE_LENGTH (value_type (v)); |
| 179 | 180 |
| 180 /* Keep it simple and assume size == 'g' when watching for when we | 181 /* Keep it simple and assume size == 'g' when watching for when we |
| 181 need to grow the pattern buf. */ | 182 need to grow the pattern buf. */ |
| 182 if ((pattern_buf_end - pattern_buf + max (val_bytes, sizeof (int64_t))) | 183 pattern_buf_size_need = (pattern_buf_end - pattern_buf |
| 183 » > pattern_buf_size) | 184 » » » + max (val_bytes, sizeof (int64_t))); |
| 185 if (pattern_buf_size_need > pattern_buf_size) |
| 184 { | 186 { |
| 185 size_t current_offset = pattern_buf_end - pattern_buf; | 187 size_t current_offset = pattern_buf_end - pattern_buf; |
| 186 | 188 |
| 187 » pattern_buf_size *= 2; | 189 » pattern_buf_size = pattern_buf_size_need * 2; |
| 188 pattern_buf = xrealloc (pattern_buf, pattern_buf_size); | 190 pattern_buf = xrealloc (pattern_buf, pattern_buf_size); |
| 189 pattern_buf_end = pattern_buf + current_offset; | 191 pattern_buf_end = pattern_buf + current_offset; |
| 190 } | 192 } |
| 191 | 193 |
| 192 if (size != '\0') | 194 if (size != '\0') |
| 193 { | 195 { |
| 194 x = value_as_long (v); | 196 x = value_as_long (v); |
| 195 switch (size) | 197 switch (size) |
| 196 { | 198 { |
| 197 case 'b': | 199 case 'b': |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 and if not specified the size is taken from the type of the expression\n\ | 334 and if not specified the size is taken from the type of the expression\n\ |
| 333 in the current language.\n\ | 335 in the current language.\n\ |
| 334 Note that this means for example that in the case of C-like languages\n\ | 336 Note that this means for example that in the case of C-like languages\n\ |
| 335 a search for an untyped 0x42 will search for \"(int) 0x42\"\n\ | 337 a search for an untyped 0x42 will search for \"(int) 0x42\"\n\ |
| 336 which is typically four bytes.\n\ | 338 which is typically four bytes.\n\ |
| 337 \n\ | 339 \n\ |
| 338 The address of the last match is stored as the value of \"$_\".\n\ | 340 The address of the last match is stored as the value of \"$_\".\n\ |
| 339 Convenience variable \"$numfound\" is set to the number of matches."), | 341 Convenience variable \"$numfound\" is set to the number of matches."), |
| 340 &cmdlist); | 342 &cmdlist); |
| 341 } | 343 } |
| OLD | NEW |