| OLD | NEW |
| 1 /* Symbol table lookup for the GNU debugger, GDB. | 1 /* Symbol table lookup for the GNU debugger, GDB. |
| 2 | 2 |
| 3 Copyright (C) 1986-2004, 2007-2012 Free Software Foundation, Inc. | 3 Copyright (C) 1986-2004, 2007-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 15 matching lines...) Expand all Loading... |
| 26 #include "value.h" | 26 #include "value.h" |
| 27 #include "symfile.h" | 27 #include "symfile.h" |
| 28 #include "objfiles.h" | 28 #include "objfiles.h" |
| 29 #include "gdbcmd.h" | 29 #include "gdbcmd.h" |
| 30 #include "call-cmds.h" | 30 #include "call-cmds.h" |
| 31 #include "gdb_regex.h" | 31 #include "gdb_regex.h" |
| 32 #include "expression.h" | 32 #include "expression.h" |
| 33 #include "language.h" | 33 #include "language.h" |
| 34 #include "demangle.h" | 34 #include "demangle.h" |
| 35 #include "inferior.h" | 35 #include "inferior.h" |
| 36 #include "linespec.h" | |
| 37 #include "source.h" | 36 #include "source.h" |
| 38 #include "filenames.h" /* for FILENAME_CMP */ | 37 #include "filenames.h" /* for FILENAME_CMP */ |
| 39 #include "objc-lang.h" | 38 #include "objc-lang.h" |
| 40 #include "d-lang.h" | 39 #include "d-lang.h" |
| 41 #include "ada-lang.h" | 40 #include "ada-lang.h" |
| 41 #include "go-lang.h" |
| 42 #include "p-lang.h" | 42 #include "p-lang.h" |
| 43 #include "addrmap.h" | 43 #include "addrmap.h" |
| 44 | 44 |
| 45 #include "hashtab.h" | 45 #include "hashtab.h" |
| 46 | 46 |
| 47 #include "gdb_obstack.h" | 47 #include "gdb_obstack.h" |
| 48 #include "block.h" | 48 #include "block.h" |
| 49 #include "dictionary.h" | 49 #include "dictionary.h" |
| 50 | 50 |
| 51 #include <sys/types.h> | 51 #include <sys/types.h> |
| 52 #include <fcntl.h> | 52 #include <fcntl.h> |
| 53 #include "gdb_string.h" | 53 #include "gdb_string.h" |
| 54 #include "gdb_stat.h" | 54 #include "gdb_stat.h" |
| 55 #include <ctype.h> | 55 #include <ctype.h> |
| 56 #include "cp-abi.h" | 56 #include "cp-abi.h" |
| 57 #include "cp-support.h" | 57 #include "cp-support.h" |
| 58 #include "observer.h" | 58 #include "observer.h" |
| 59 #include "gdb_assert.h" | 59 #include "gdb_assert.h" |
| 60 #include "solist.h" | 60 #include "solist.h" |
| 61 #include "macrotab.h" | 61 #include "macrotab.h" |
| 62 #include "macroscope.h" | 62 #include "macroscope.h" |
| 63 | 63 |
| 64 #include "psymtab.h" | 64 #include "psymtab.h" |
| 65 | 65 |
| 66 /* Prototypes for local functions */ | 66 /* Prototypes for local functions */ |
| 67 | 67 |
| 68 static void completion_list_add_name (char *, char *, int, char *, char *); | |
| 69 | |
| 70 static void rbreak_command (char *, int); | 68 static void rbreak_command (char *, int); |
| 71 | 69 |
| 72 static void types_info (char *, int); | 70 static void types_info (char *, int); |
| 73 | 71 |
| 74 static void functions_info (char *, int); | 72 static void functions_info (char *, int); |
| 75 | 73 |
| 76 static void variables_info (char *, int); | 74 static void variables_info (char *, int); |
| 77 | 75 |
| 78 static void sources_info (char *, int); | 76 static void sources_info (char *, int); |
| 79 | 77 |
| 80 static void output_source_filename (const char *, int *); | |
| 81 | |
| 82 static int find_line_common (struct linetable *, int, int *, int); | 78 static int find_line_common (struct linetable *, int, int *, int); |
| 83 | 79 |
| 84 static struct symbol *lookup_symbol_aux (const char *name, | 80 static struct symbol *lookup_symbol_aux (const char *name, |
| 85 const struct block *block, | 81 const struct block *block, |
| 86 const domain_enum domain, | 82 const domain_enum domain, |
| 87 enum language language, | 83 enum language language, |
| 88 int *is_a_field_of_this); | 84 int *is_a_field_of_this); |
| 89 | 85 |
| 90 static | 86 static |
| 91 struct symbol *lookup_symbol_aux_local (const char *name, | 87 struct symbol *lookup_symbol_aux_local (const char *name, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 103 int block_index, | 99 int block_index, |
| 104 const char *name, | 100 const char *name, |
| 105 const domain_enum domain); | 101 const domain_enum domain); |
| 106 | 102 |
| 107 static void print_msymbol_info (struct minimal_symbol *); | 103 static void print_msymbol_info (struct minimal_symbol *); |
| 108 | 104 |
| 109 void _initialize_symtab (void); | 105 void _initialize_symtab (void); |
| 110 | 106 |
| 111 /* */ | 107 /* */ |
| 112 | 108 |
| 109 /* When non-zero, print debugging messages related to symtab creation. */ |
| 110 int symtab_create_debug = 0; |
| 111 |
| 113 /* Non-zero if a file may be known by two different basenames. | 112 /* Non-zero if a file may be known by two different basenames. |
| 114 This is the uncommon case, and significantly slows down gdb. | 113 This is the uncommon case, and significantly slows down gdb. |
| 115 Default set to "off" to not slow down the common case. */ | 114 Default set to "off" to not slow down the common case. */ |
| 116 int basenames_may_differ = 0; | 115 int basenames_may_differ = 0; |
| 117 | 116 |
| 118 /* Allow the user to configure the debugger behavior with respect | 117 /* Allow the user to configure the debugger behavior with respect |
| 119 to multiple-choice menus when more than one symbol matches during | 118 to multiple-choice menus when more than one symbol matches during |
| 120 a symbol lookup. */ | 119 a symbol lookup. */ |
| 121 | 120 |
| 122 const char multiple_symbols_ask[] = "ask"; | 121 const char multiple_symbols_ask[] = "ask"; |
| 123 const char multiple_symbols_all[] = "all"; | 122 const char multiple_symbols_all[] = "all"; |
| 124 const char multiple_symbols_cancel[] = "cancel"; | 123 const char multiple_symbols_cancel[] = "cancel"; |
| 125 static const char *multiple_symbols_modes[] = | 124 static const char *const multiple_symbols_modes[] = |
| 126 { | 125 { |
| 127 multiple_symbols_ask, | 126 multiple_symbols_ask, |
| 128 multiple_symbols_all, | 127 multiple_symbols_all, |
| 129 multiple_symbols_cancel, | 128 multiple_symbols_cancel, |
| 130 NULL | 129 NULL |
| 131 }; | 130 }; |
| 132 static const char *multiple_symbols_mode = multiple_symbols_all; | 131 static const char *multiple_symbols_mode = multiple_symbols_all; |
| 133 | 132 |
| 134 /* Read-only accessor to AUTO_SELECT_MODE. */ | 133 /* Read-only accessor to AUTO_SELECT_MODE. */ |
| 135 | 134 |
| 136 const char * | 135 const char * |
| 137 multiple_symbols_select_mode (void) | 136 multiple_symbols_select_mode (void) |
| 138 { | 137 { |
| 139 return multiple_symbols_mode; | 138 return multiple_symbols_mode; |
| 140 } | 139 } |
| 141 | 140 |
| 142 /* Block in which the most recently searched-for symbol was found. | 141 /* Block in which the most recently searched-for symbol was found. |
| 143 Might be better to make this a parameter to lookup_symbol and | 142 Might be better to make this a parameter to lookup_symbol and |
| 144 value_of_this. */ | 143 value_of_this. */ |
| 145 | 144 |
| 146 const struct block *block_found; | 145 const struct block *block_found; |
| 147 | 146 |
| 147 /* See whether FILENAME matches SEARCH_NAME using the rule that we |
| 148 advertise to the user. (The manual's description of linespecs |
| 149 describes what we advertise). SEARCH_LEN is the length of |
| 150 SEARCH_NAME. We assume that SEARCH_NAME is a relative path. |
| 151 Returns true if they match, false otherwise. */ |
| 152 |
| 153 int |
| 154 compare_filenames_for_search (const char *filename, const char *search_name, |
| 155 int search_len) |
| 156 { |
| 157 int len = strlen (filename); |
| 158 |
| 159 if (len < search_len) |
| 160 return 0; |
| 161 |
| 162 /* The tail of FILENAME must match. */ |
| 163 if (FILENAME_CMP (filename + len - search_len, search_name) != 0) |
| 164 return 0; |
| 165 |
| 166 /* Either the names must completely match, or the character |
| 167 preceding the trailing SEARCH_NAME segment of FILENAME must be a |
| 168 directory separator. */ |
| 169 return (len == search_len |
| 170 || IS_DIR_SEPARATOR (filename[len - search_len - 1]) |
| 171 || (HAS_DRIVE_SPEC (filename) |
| 172 && STRIP_DRIVE_SPEC (filename) == &filename[len - search_len])); |
| 173 } |
| 174 |
| 148 /* Check for a symtab of a specific name by searching some symtabs. | 175 /* Check for a symtab of a specific name by searching some symtabs. |
| 149 This is a helper function for callbacks of iterate_over_symtabs. | 176 This is a helper function for callbacks of iterate_over_symtabs. |
| 150 | 177 |
| 151 The return value, NAME, FULL_PATH, REAL_PATH, CALLBACK, and DATA | 178 The return value, NAME, FULL_PATH, REAL_PATH, CALLBACK, and DATA |
| 152 are identical to the `map_symtabs_matching_filename' method of | 179 are identical to the `map_symtabs_matching_filename' method of |
| 153 quick_symbol_functions. | 180 quick_symbol_functions. |
| 154 | 181 |
| 155 FIRST and AFTER_LAST indicate the range of symtabs to search. | 182 FIRST and AFTER_LAST indicate the range of symtabs to search. |
| 156 AFTER_LAST is one past the last symtab to search; NULL means to | 183 AFTER_LAST is one past the last symtab to search; NULL means to |
| 157 search until the end of the list. */ | 184 search until the end of the list. */ |
| 158 | 185 |
| 159 int | 186 int |
| 160 iterate_over_some_symtabs (const char *name, | 187 iterate_over_some_symtabs (const char *name, |
| 161 const char *full_path, | 188 const char *full_path, |
| 162 const char *real_path, | 189 const char *real_path, |
| 163 int (*callback) (struct symtab *symtab, | 190 int (*callback) (struct symtab *symtab, |
| 164 void *data), | 191 void *data), |
| 165 void *data, | 192 void *data, |
| 166 struct symtab *first, | 193 struct symtab *first, |
| 167 struct symtab *after_last) | 194 struct symtab *after_last) |
| 168 { | 195 { |
| 169 struct symtab *s = NULL; | 196 struct symtab *s = NULL; |
| 170 struct cleanup *cleanup; | |
| 171 const char* base_name = lbasename (name); | 197 const char* base_name = lbasename (name); |
| 198 int name_len = strlen (name); |
| 199 int is_abs = IS_ABSOLUTE_PATH (name); |
| 172 | 200 |
| 173 for (s = first; s != NULL && s != after_last; s = s->next) | 201 for (s = first; s != NULL && s != after_last; s = s->next) |
| 174 { | 202 { |
| 203 /* Exact match is always ok. */ |
| 175 if (FILENAME_CMP (name, s->filename) == 0) | 204 if (FILENAME_CMP (name, s->filename) == 0) |
| 176 { | 205 { |
| 177 if (callback (s, data)) | 206 if (callback (s, data)) |
| 178 return 1; | 207 return 1; |
| 179 } | 208 } |
| 180 | 209 |
| 210 if (!is_abs && compare_filenames_for_search (s->filename, name, name_len)) |
| 211 { |
| 212 if (callback (s, data)) |
| 213 return 1; |
| 214 } |
| 215 |
| 181 /* Before we invoke realpath, which can get expensive when many | 216 /* Before we invoke realpath, which can get expensive when many |
| 182 files are involved, do a quick comparison of the basenames. */ | 217 files are involved, do a quick comparison of the basenames. */ |
| 183 if (! basenames_may_differ | 218 if (! basenames_may_differ |
| 184 && FILENAME_CMP (base_name, lbasename (s->filename)) != 0) | 219 && FILENAME_CMP (base_name, lbasename (s->filename)) != 0) |
| 185 continue; | 220 continue; |
| 186 | 221 |
| 187 /* If the user gave us an absolute path, try to find the file in | 222 /* If the user gave us an absolute path, try to find the file in |
| 188 this symtab and use its absolute path. */ | 223 this symtab and use its absolute path. */ |
| 189 | 224 |
| 190 if (full_path != NULL) | 225 if (full_path != NULL) |
| 191 { | 226 { |
| 192 const char *fp = symtab_to_fullname (s); | 227 const char *fp = symtab_to_fullname (s); |
| 193 | 228 |
| 194 if (fp != NULL && FILENAME_CMP (full_path, fp) == 0) | 229 if (fp != NULL && FILENAME_CMP (full_path, fp) == 0) |
| 195 { | 230 { |
| 196 if (callback (s, data)) | 231 if (callback (s, data)) |
| 197 return 1; | 232 return 1; |
| 198 } | 233 } |
| 234 |
| 235 if (fp != NULL && !is_abs && compare_filenames_for_search (fp, name, |
| 236 name_len)) |
| 237 { |
| 238 if (callback (s, data)) |
| 239 return 1; |
| 240 } |
| 199 } | 241 } |
| 200 | 242 |
| 201 if (real_path != NULL) | 243 if (real_path != NULL) |
| 202 { | 244 { |
| 203 char *fullname = symtab_to_fullname (s); | 245 char *fullname = symtab_to_fullname (s); |
| 204 | 246 |
| 205 if (fullname != NULL) | 247 if (fullname != NULL) |
| 206 { | 248 { |
| 207 char *rp = gdb_realpath (fullname); | 249 char *rp = gdb_realpath (fullname); |
| 208 | 250 |
| 209 make_cleanup (xfree, rp); | 251 make_cleanup (xfree, rp); |
| 210 if (FILENAME_CMP (real_path, rp) == 0) | 252 if (FILENAME_CMP (real_path, rp) == 0) |
| 211 { | 253 { |
| 212 if (callback (s, data)) | 254 if (callback (s, data)) |
| 213 return 1; | 255 return 1; |
| 214 } | 256 } |
| 257 |
| 258 if (!is_abs && compare_filenames_for_search (rp, name, name_len)) |
| 259 { |
| 260 if (callback (s, data)) |
| 261 return 1; |
| 262 } |
| 215 } | 263 } |
| 216 } | 264 } |
| 217 } | 265 } |
| 218 | 266 |
| 219 /* Now, search for a matching tail (only if name doesn't have any dirs). */ | |
| 220 | |
| 221 if (lbasename (name) == name) | |
| 222 { | |
| 223 for (s = first; s != NULL && s != after_last; s = s->next) | |
| 224 { | |
| 225 if (FILENAME_CMP (lbasename (s->filename), name) == 0) | |
| 226 { | |
| 227 if (callback (s, data)) | |
| 228 return 1; | |
| 229 } | |
| 230 } | |
| 231 } | |
| 232 | |
| 233 return 0; | 267 return 0; |
| 234 } | 268 } |
| 235 | 269 |
| 236 /* Check for a symtab of a specific name; first in symtabs, then in | 270 /* Check for a symtab of a specific name; first in symtabs, then in |
| 237 psymtabs. *If* there is no '/' in the name, a match after a '/' | 271 psymtabs. *If* there is no '/' in the name, a match after a '/' |
| 238 in the symtab filename will also work. | 272 in the symtab filename will also work. |
| 239 | 273 |
| 240 Calls CALLBACK with each symtab that is found and with the supplied | 274 Calls CALLBACK with each symtab that is found and with the supplied |
| 241 DATA. If CALLBACK returns true, the search stops. */ | 275 DATA. If CALLBACK returns true, the search stops. */ |
| 242 | 276 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 353 |
| 320 | 354 |
| 321 /* Mangle a GDB method stub type. This actually reassembles the pieces of the | 355 /* Mangle a GDB method stub type. This actually reassembles the pieces of the |
| 322 full method name, which consist of the class name (from T), the unadorned | 356 full method name, which consist of the class name (from T), the unadorned |
| 323 method name from METHOD_ID, and the signature for the specific overload, | 357 method name from METHOD_ID, and the signature for the specific overload, |
| 324 specified by SIGNATURE_ID. Note that this function is g++ specific. */ | 358 specified by SIGNATURE_ID. Note that this function is g++ specific. */ |
| 325 | 359 |
| 326 char * | 360 char * |
| 327 gdb_mangle_name (struct type *type, int method_id, int signature_id) | 361 gdb_mangle_name (struct type *type, int method_id, int signature_id) |
| 328 { | 362 { |
error: old chunk mismatch |
None
| OLD | NEW |