| OLD | NEW |
| 1 /* MI Command Set - breakpoint and watchpoint commands. | 1 /* MI Command Set - breakpoint and watchpoint commands. |
| 2 Copyright (C) 2000-2002, 2007-2012 Free Software Foundation, Inc. | 2 Copyright (C) 2000-2002, 2007-2012 Free Software Foundation, Inc. |
| 3 Contributed by Cygnus Solutions (a Red Hat company). | 3 Contributed by Cygnus Solutions (a Red Hat company). |
| 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 25 matching lines...) Expand all Loading... |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 /* True if MI breakpoint observers have been registered. */ | 38 /* True if MI breakpoint observers have been registered. */ |
| 39 | 39 |
| 40 static int mi_breakpoint_observers_installed; | 40 static int mi_breakpoint_observers_installed; |
| 41 | 41 |
| 42 /* Control whether breakpoint_notify may act. */ | 42 /* Control whether breakpoint_notify may act. */ |
| 43 | 43 |
| 44 static int mi_can_breakpoint_notify; | 44 static int mi_can_breakpoint_notify; |
| 45 | 45 |
| 46 /* Output a single breakpoint, when allowed. */ | 46 /* Output a single breakpoint, when allowed. */ |
| 47 | 47 |
| 48 static void | 48 static void |
| 49 breakpoint_notify (struct breakpoint *b) | 49 breakpoint_notify (struct breakpoint *b) |
| 50 { | 50 { |
| 51 if (mi_can_breakpoint_notify) | 51 if (mi_can_breakpoint_notify) |
| 52 gdb_breakpoint_query (current_uiout, b->number, NULL); | 52 gdb_breakpoint_query (current_uiout, b->number, NULL); |
| 53 } | 53 } |
| 54 | 54 |
| 55 enum bp_type | 55 enum bp_type |
| 56 { | 56 { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 {"i", IGNORE_COUNT_OPT, 1}, | 91 {"i", IGNORE_COUNT_OPT, 1}, |
| 92 {"p", THREAD_OPT, 1}, | 92 {"p", THREAD_OPT, 1}, |
| 93 {"f", PENDING_OPT, 0}, | 93 {"f", PENDING_OPT, 0}, |
| 94 {"d", DISABLE_OPT, 0}, | 94 {"d", DISABLE_OPT, 0}, |
| 95 {"a", TRACEPOINT_OPT, 0}, | 95 {"a", TRACEPOINT_OPT, 0}, |
| 96 { 0, 0, 0 } | 96 { 0, 0, 0 } |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 /* Parse arguments. It could be -r or -h or -t, <location> or ``--'' | 99 /* Parse arguments. It could be -r or -h or -t, <location> or ``--'' |
| 100 to denote the end of the option list. */ | 100 to denote the end of the option list. */ |
| 101 int optind = 0; | 101 int oind = 0; |
| 102 char *optarg; | 102 char *oarg; |
| 103 | 103 |
| 104 while (1) | 104 while (1) |
| 105 { | 105 { |
| 106 int opt = mi_getopt ("-break-insert", argc, argv, | 106 int opt = mi_getopt ("-break-insert", argc, argv, |
| 107 » » » opts, &optind, &optarg); | 107 » » » opts, &oind, &oarg); |
| 108 if (opt < 0) | 108 if (opt < 0) |
| 109 break; | 109 break; |
| 110 switch ((enum opt) opt) | 110 switch ((enum opt) opt) |
| 111 { | 111 { |
| 112 case TEMP_OPT: | 112 case TEMP_OPT: |
| 113 temp_p = 1; | 113 temp_p = 1; |
| 114 break; | 114 break; |
| 115 case HARDWARE_OPT: | 115 case HARDWARE_OPT: |
| 116 hardware = 1; | 116 hardware = 1; |
| 117 break; | 117 break; |
| 118 case CONDITION_OPT: | 118 case CONDITION_OPT: |
| 119 » condition = optarg; | 119 » condition = oarg; |
| 120 break; | 120 break; |
| 121 case IGNORE_COUNT_OPT: | 121 case IGNORE_COUNT_OPT: |
| 122 » ignore_count = atol (optarg); | 122 » ignore_count = atol (oarg); |
| 123 break; | 123 break; |
| 124 case THREAD_OPT: | 124 case THREAD_OPT: |
| 125 » thread = atol (optarg); | 125 » thread = atol (oarg); |
| 126 break; | 126 break; |
| 127 case PENDING_OPT: | 127 case PENDING_OPT: |
| 128 pending = 1; | 128 pending = 1; |
| 129 break; | 129 break; |
| 130 case DISABLE_OPT: | 130 case DISABLE_OPT: |
| 131 enabled = 0; | 131 enabled = 0; |
| 132 break; | 132 break; |
| 133 case TRACEPOINT_OPT: | 133 case TRACEPOINT_OPT: |
| 134 tracepoint = 1; | 134 tracepoint = 1; |
| 135 break; | 135 break; |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 if (optind >= argc) | 139 if (oind >= argc) |
| 140 error (_("-break-insert: Missing <location>")); | 140 error (_("-break-insert: Missing <location>")); |
| 141 if (optind < argc - 1) | 141 if (oind < argc - 1) |
| 142 error (_("-break-insert: Garbage following <location>")); | 142 error (_("-break-insert: Garbage following <location>")); |
| 143 address = argv[optind]; | 143 address = argv[oind]; |
| 144 | 144 |
| 145 /* Now we have what we need, let's insert the breakpoint! */ | 145 /* Now we have what we need, let's insert the breakpoint! */ |
| 146 if (! mi_breakpoint_observers_installed) | 146 if (! mi_breakpoint_observers_installed) |
| 147 { | 147 { |
| 148 observer_attach_breakpoint_created (breakpoint_notify); | 148 observer_attach_breakpoint_created (breakpoint_notify); |
| 149 mi_breakpoint_observers_installed = 1; | 149 mi_breakpoint_observers_installed = 1; |
| 150 } | 150 } |
| 151 | 151 |
| 152 back_to = make_cleanup_restore_integer (&mi_can_breakpoint_notify); | 152 back_to = make_cleanup_restore_integer (&mi_can_breakpoint_notify); |
| 153 mi_can_breakpoint_notify = 1; | 153 mi_can_breakpoint_notify = 1; |
| 154 | 154 |
| 155 /* Note that to request a fast tracepoint, the client uses the | 155 /* Note that to request a fast tracepoint, the client uses the |
| 156 "hardware" flag, although there's nothing of hardware related to | 156 "hardware" flag, although there's nothing of hardware related to |
| 157 fast tracepoints -- one can implement slow tracepoints with | 157 fast tracepoints -- one can implement slow tracepoints with |
| 158 hardware breakpoints, but fast tracepoints are always software. | 158 hardware breakpoints, but fast tracepoints are always software. |
| 159 "fast" is a misnomer, actually, "jump" would be more appropriate. | 159 "fast" is a misnomer, actually, "jump" would be more appropriate. |
| 160 A simulator or an emulator could conceivably implement fast | 160 A simulator or an emulator could conceivably implement fast |
| 161 regular non-jump based tracepoints. */ | 161 regular non-jump based tracepoints. */ |
| 162 type_wanted = (tracepoint | 162 type_wanted = (tracepoint |
| 163 ? (hardware ? bp_fast_tracepoint : bp_tracepoint) | 163 ? (hardware ? bp_fast_tracepoint : bp_tracepoint) |
| 164 : (hardware ? bp_hardware_breakpoint : bp_breakpoint)); | 164 : (hardware ? bp_hardware_breakpoint : bp_breakpoint)); |
| 165 | 165 |
| 166 create_breakpoint (get_current_arch (), address, condition, thread, | 166 create_breakpoint (get_current_arch (), address, condition, thread, |
| 167 NULL, |
| 167 0 /* condition and thread are valid. */, | 168 0 /* condition and thread are valid. */, |
| 168 temp_p, type_wanted, | 169 temp_p, type_wanted, |
| 169 ignore_count, | 170 ignore_count, |
| 170 pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE, | 171 pending ? AUTO_BOOLEAN_TRUE : AUTO_BOOLEAN_FALSE, |
| 171 &bkpt_breakpoint_ops, 0, enabled, 0, 0); | 172 &bkpt_breakpoint_ops, 0, enabled, 0, 0); |
| 172 do_cleanups (back_to); | 173 do_cleanups (back_to); |
| 173 | 174 |
| 174 } | 175 } |
| 175 | 176 |
| 176 enum wp_type | 177 enum wp_type |
| (...skipping 25 matching lines...) Expand all Loading... |
| 202 else | 203 else |
| 203 { | 204 { |
| 204 error (_("Could not find tracepoint %d"), n); | 205 error (_("Could not find tracepoint %d"), n); |
| 205 } | 206 } |
| 206 } | 207 } |
| 207 | 208 |
| 208 /* Insert a watchpoint. The type of watchpoint is specified by the | 209 /* Insert a watchpoint. The type of watchpoint is specified by the |
| 209 first argument: | 210 first argument: |
| 210 -break-watch <expr> --> insert a regular wp. | 211 -break-watch <expr> --> insert a regular wp. |
| 211 -break-watch -r <expr> --> insert a read watchpoint. | 212 -break-watch -r <expr> --> insert a read watchpoint. |
| 212 -break-watch -a <expr> --> insert an access wp. */ | 213 -break-watch -a <expr> --> insert an access wp. */ |
| 213 | 214 |
| 214 void | 215 void |
| 215 mi_cmd_break_watch (char *command, char **argv, int argc) | 216 mi_cmd_break_watch (char *command, char **argv, int argc) |
| 216 { | 217 { |
| 217 char *expr = NULL; | 218 char *expr = NULL; |
| 218 enum wp_type type = REG_WP; | 219 enum wp_type type = REG_WP; |
| 219 enum opt | 220 enum opt |
| 220 { | 221 { |
| 221 READ_OPT, ACCESS_OPT | 222 READ_OPT, ACCESS_OPT |
| 222 }; | 223 }; |
| 223 static const struct mi_opt opts[] = | 224 static const struct mi_opt opts[] = |
| 224 { | 225 { |
| 225 {"r", READ_OPT, 0}, | 226 {"r", READ_OPT, 0}, |
| 226 {"a", ACCESS_OPT, 0}, | 227 {"a", ACCESS_OPT, 0}, |
| 227 { 0, 0, 0 } | 228 { 0, 0, 0 } |
| 228 }; | 229 }; |
| 229 | 230 |
| 230 /* Parse arguments. */ | 231 /* Parse arguments. */ |
| 231 int optind = 0; | 232 int oind = 0; |
| 232 char *optarg; | 233 char *oarg; |
| 233 | 234 |
| 234 while (1) | 235 while (1) |
| 235 { | 236 { |
| 236 int opt = mi_getopt ("-break-watch", argc, argv, | 237 int opt = mi_getopt ("-break-watch", argc, argv, |
| 237 » » » opts, &optind, &optarg); | 238 » » » opts, &oind, &oarg); |
| 238 | 239 |
| 239 if (opt < 0) | 240 if (opt < 0) |
| 240 break; | 241 break; |
| 241 switch ((enum opt) opt) | 242 switch ((enum opt) opt) |
| 242 { | 243 { |
| 243 case READ_OPT: | 244 case READ_OPT: |
| 244 type = READ_WP; | 245 type = READ_WP; |
| 245 break; | 246 break; |
| 246 case ACCESS_OPT: | 247 case ACCESS_OPT: |
| 247 type = ACCESS_WP; | 248 type = ACCESS_WP; |
| 248 break; | 249 break; |
| 249 } | 250 } |
| 250 } | 251 } |
| 251 if (optind >= argc) | 252 if (oind >= argc) |
| 252 error (_("-break-watch: Missing <expression>")); | 253 error (_("-break-watch: Missing <expression>")); |
| 253 if (optind < argc - 1) | 254 if (oind < argc - 1) |
| 254 error (_("-break-watch: Garbage following <expression>")); | 255 error (_("-break-watch: Garbage following <expression>")); |
| 255 expr = argv[optind]; | 256 expr = argv[oind]; |
| 256 | 257 |
| 257 /* Now we have what we need, let's insert the watchpoint! */ | 258 /* Now we have what we need, let's insert the watchpoint! */ |
| 258 switch (type) | 259 switch (type) |
| 259 { | 260 { |
| 260 case REG_WP: | 261 case REG_WP: |
| 261 watch_command_wrapper (expr, FROM_TTY, 0); | 262 watch_command_wrapper (expr, FROM_TTY, 0); |
| 262 break; | 263 break; |
| 263 case READ_WP: | 264 case READ_WP: |
| 264 rwatch_command_wrapper (expr, FROM_TTY, 0); | 265 rwatch_command_wrapper (expr, FROM_TTY, 0); |
| 265 break; | 266 break; |
| 266 case ACCESS_WP: | 267 case ACCESS_WP: |
| 267 awatch_command_wrapper (expr, FROM_TTY, 0); | 268 awatch_command_wrapper (expr, FROM_TTY, 0); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 | 319 |
| 319 if (is_tracepoint (b)) | 320 if (is_tracepoint (b)) |
| 320 break_command = read_command_lines_1 (mi_read_next_line, 1, | 321 break_command = read_command_lines_1 (mi_read_next_line, 1, |
| 321 check_tracepoint_command, b); | 322 check_tracepoint_command, b); |
| 322 else | 323 else |
| 323 break_command = read_command_lines_1 (mi_read_next_line, 1, 0, 0); | 324 break_command = read_command_lines_1 (mi_read_next_line, 1, 0, 0); |
| 324 | 325 |
| 325 breakpoint_set_commands (b, break_command); | 326 breakpoint_set_commands (b, break_command); |
| 326 } | 327 } |
| 327 | 328 |
| OLD | NEW |