GNU Binutils with patches for OS216
Révision | 5625a2864147f4d92b22edfeeab7600818988be2 (tree) |
---|---|
l'heure | 2017-04-25 09:43:06 |
Auteur | Pedro Alves <palves@redh...> |
Commiter | Pedro Alves |
Don't memset non-POD types: struct bp_location
struct bp_location is not a POD, so we shouldn't be using memset to
initialize it.
Caught like this:
from src/gdb/breakpoint.c:20:
gdb/ChangeLog:
2017-04-25 Pedro Alves <palves@redhat.com>
* ada-lang.c (ada_catchpoint_location): Now a "class". Remove
"base" field and inherit from "bp_location" instead. Add
non-default ctor.
(allocate_location_exception): Use new non-default ctor.
* breakpoint.c (get_first_locp_gte_addr): Remove memset call.
(init_bp_location): Convert to ...
(bp_location::bp_location): ... this new ctor, and remove memset
call.
(base_breakpoint_allocate_location): Use the new non-default ctor.
* breakpoint.h (bp_location): Now a class. Declare default and
non-default ctors. In-class initialize all members.
(init_bp_location): Remove declaration.
@@ -1,5 +1,20 @@ | ||
1 | 1 | 2017-04-25 Pedro Alves <palves@redhat.com> |
2 | 2 | |
3 | + * ada-lang.c (ada_catchpoint_location): Now a "class". Remove | |
4 | + "base" field and inherit from "bp_location" instead. Add | |
5 | + non-default ctor. | |
6 | + (allocate_location_exception): Use new non-default ctor. | |
7 | + * breakpoint.c (get_first_locp_gte_addr): Remove memset call. | |
8 | + (init_bp_location): Convert to ... | |
9 | + (bp_location::bp_location): ... this new ctor, and remove memset | |
10 | + call. | |
11 | + (base_breakpoint_allocate_location): Use the new non-default ctor. | |
12 | + * breakpoint.h (bp_location): Now a class. Declare default and | |
13 | + non-default ctors. In-class initialize all members. | |
14 | + (init_bp_location): Remove declaration. | |
15 | + | |
16 | +2017-04-25 Pedro Alves <palves@redhat.com> | |
17 | + | |
3 | 18 | * common/enum-flags.h (enum_flags): Don't implement copy ctor and |
4 | 19 | assignment operator. |
5 | 20 |
@@ -12224,14 +12224,14 @@ static char *ada_exception_catchpoint_cond_string (const char *excep_string); | ||
12224 | 12224 | when symbols change. */ |
12225 | 12225 | |
12226 | 12226 | /* An instance of this type is used to represent an Ada catchpoint |
12227 | - breakpoint location. It includes a "struct bp_location" as a kind | |
12228 | - of base class; users downcast to "struct bp_location *" when | |
12229 | - needed. */ | |
12227 | + breakpoint location. */ | |
12230 | 12228 | |
12231 | -struct ada_catchpoint_location | |
12229 | +class ada_catchpoint_location : public bp_location | |
12232 | 12230 | { |
12233 | - /* The base class. */ | |
12234 | - struct bp_location base; | |
12231 | +public: | |
12232 | + ada_catchpoint_location (const bp_location_ops *ops, breakpoint *owner) | |
12233 | + : bp_location (ops, owner) | |
12234 | + {} | |
12235 | 12235 | |
12236 | 12236 | /* The condition that checks whether the exception that was raised |
12237 | 12237 | is the specific exception the user specified on catchpoint |
@@ -12347,12 +12347,7 @@ static struct bp_location * | ||
12347 | 12347 | allocate_location_exception (enum ada_exception_catchpoint_kind ex, |
12348 | 12348 | struct breakpoint *self) |
12349 | 12349 | { |
12350 | - struct ada_catchpoint_location *loc; | |
12351 | - | |
12352 | - loc = new ada_catchpoint_location (); | |
12353 | - init_bp_location (&loc->base, &ada_catchpoint_location_ops, self); | |
12354 | - loc->excep_cond_expr = NULL; | |
12355 | - return &loc->base; | |
12350 | + return new ada_catchpoint_location (&ada_catchpoint_location_ops, self); | |
12356 | 12351 | } |
12357 | 12352 | |
12358 | 12353 | /* Implement the RE_SET method in the breakpoint_ops structure for all |
@@ -947,7 +947,6 @@ get_first_locp_gte_addr (CORE_ADDR address) | ||
947 | 947 | struct bp_location **locp_found = NULL; |
948 | 948 | |
949 | 949 | /* Initialize the dummy location's address field. */ |
950 | - memset (&dummy_loc, 0, sizeof (struct bp_location)); | |
951 | 950 | dummy_loc.address = address; |
952 | 951 | |
953 | 952 | /* Find a close match to the first location at ADDRESS. */ |
@@ -7300,11 +7299,9 @@ adjust_breakpoint_address (struct gdbarch *gdbarch, | ||
7300 | 7299 | } |
7301 | 7300 | } |
7302 | 7301 | |
7303 | -void | |
7304 | -init_bp_location (struct bp_location *loc, const struct bp_location_ops *ops, | |
7305 | - struct breakpoint *owner) | |
7302 | +bp_location::bp_location (const bp_location_ops *ops, breakpoint *owner) | |
7306 | 7303 | { |
7307 | - memset (loc, 0, sizeof (*loc)); | |
7304 | + bp_location *loc = this; | |
7308 | 7305 | |
7309 | 7306 | gdb_assert (ops != NULL); |
7310 | 7307 |
@@ -12824,11 +12821,7 @@ base_breakpoint_dtor (struct breakpoint *self) | ||
12824 | 12821 | static struct bp_location * |
12825 | 12822 | base_breakpoint_allocate_location (struct breakpoint *self) |
12826 | 12823 | { |
12827 | - struct bp_location *loc; | |
12828 | - | |
12829 | - loc = new struct bp_location (); | |
12830 | - init_bp_location (loc, &bp_location_ops, self); | |
12831 | - return loc; | |
12824 | + return new bp_location (&bp_location_ops, self); | |
12832 | 12825 | } |
12833 | 12826 | |
12834 | 12827 | static void |
@@ -310,20 +310,25 @@ struct bp_location_ops | ||
310 | 310 | void (*dtor) (struct bp_location *self); |
311 | 311 | }; |
312 | 312 | |
313 | -struct bp_location | |
313 | +class bp_location | |
314 | 314 | { |
315 | +public: | |
316 | + bp_location () = default; | |
317 | + | |
318 | + bp_location (const bp_location_ops *ops, breakpoint *owner); | |
319 | + | |
315 | 320 | /* Chain pointer to the next breakpoint location for |
316 | 321 | the same parent breakpoint. */ |
317 | - struct bp_location *next; | |
322 | + bp_location *next = NULL; | |
318 | 323 | |
319 | 324 | /* Methods associated with this location. */ |
320 | - const struct bp_location_ops *ops; | |
325 | + const bp_location_ops *ops = NULL; | |
321 | 326 | |
322 | 327 | /* The reference count. */ |
323 | - int refc; | |
328 | + int refc = 0; | |
324 | 329 | |
325 | 330 | /* Type of this breakpoint location. */ |
326 | - enum bp_loc_type loc_type; | |
331 | + bp_loc_type loc_type {}; | |
327 | 332 | |
328 | 333 | /* Each breakpoint location must belong to exactly one higher-level |
329 | 334 | breakpoint. This pointer is NULL iff this bp_location is no |
@@ -331,7 +336,7 @@ struct bp_location | ||
331 | 336 | is deleted, its locations may still be found in the |
332 | 337 | moribund_locations list, or if we had stopped for it, in |
333 | 338 | bpstats. */ |
334 | - struct breakpoint *owner; | |
339 | + breakpoint *owner = NULL; | |
335 | 340 | |
336 | 341 | /* Conditional. Break only if this expression's value is nonzero. |
337 | 342 | Unlike string form of condition, which is associated with |
@@ -360,32 +365,32 @@ struct bp_location | ||
360 | 365 | duplicates of this location and thus we don't need to call |
361 | 366 | force_breakpoint_reinsertion (...) for this location. */ |
362 | 367 | |
363 | - enum condition_status condition_changed; | |
368 | + condition_status condition_changed {}; | |
364 | 369 | |
365 | 370 | agent_expr_up cmd_bytecode; |
366 | 371 | |
367 | 372 | /* Signals that breakpoint conditions and/or commands need to be |
368 | 373 | re-synched with the target. This has no use other than |
369 | 374 | target-side breakpoints. */ |
370 | - char needs_update; | |
375 | + bool needs_update = false; | |
371 | 376 | |
372 | 377 | /* This location's address is in an unloaded solib, and so this |
373 | 378 | location should not be inserted. It will be automatically |
374 | 379 | enabled when that solib is loaded. */ |
375 | - char shlib_disabled; | |
380 | + bool shlib_disabled = false; | |
376 | 381 | |
377 | 382 | /* Is this particular location enabled. */ |
378 | - char enabled; | |
383 | + bool enabled = false; | |
379 | 384 | |
380 | 385 | /* Nonzero if this breakpoint is now inserted. */ |
381 | - char inserted; | |
386 | + bool inserted = false; | |
382 | 387 | |
383 | 388 | /* Nonzero if this is a permanent breakpoint. There is a breakpoint |
384 | 389 | instruction hard-wired into the target's code. Don't try to |
385 | 390 | write another breakpoint instruction on top of it, or restore its |
386 | 391 | value. Step over it using the architecture's |
387 | 392 | gdbarch_skip_permanent_breakpoint method. */ |
388 | - char permanent; | |
393 | + bool permanent = false; | |
389 | 394 | |
390 | 395 | /* Nonzero if this is not the first breakpoint in the list |
391 | 396 | for the given address. location of tracepoint can _never_ |
@@ -393,7 +398,7 @@ struct bp_location | ||
393 | 398 | kinds of breakpoints, because two locations at the same |
394 | 399 | address may have different actions, so both of these locations |
395 | 400 | should be downloaded and so that `tfind N' always works. */ |
396 | - char duplicate; | |
401 | + bool duplicate = false; | |
397 | 402 | |
398 | 403 | /* If we someday support real thread-specific breakpoints, then |
399 | 404 | the breakpoint location will need a thread identifier. */ |
@@ -403,7 +408,7 @@ struct bp_location | ||
403 | 408 | |
404 | 409 | /* Architecture associated with this location's address. May be |
405 | 410 | different from the breakpoint architecture. */ |
406 | - struct gdbarch *gdbarch; | |
411 | + struct gdbarch *gdbarch = NULL; | |
407 | 412 | |
408 | 413 | /* The program space associated with this breakpoint location |
409 | 414 | address. Note that an address space may be represented in more |
@@ -411,26 +416,26 @@ struct bp_location | ||
411 | 416 | its own program space, but there will only be one address space |
412 | 417 | for all of them), but we must not insert more than one location |
413 | 418 | at the same address in the same address space. */ |
414 | - struct program_space *pspace; | |
419 | + program_space *pspace = NULL; | |
415 | 420 | |
416 | 421 | /* Note that zero is a perfectly valid code address on some platforms |
417 | 422 | (for example, the mn10200 (OBSOLETE) and mn10300 simulators). NULL |
418 | 423 | is not a special value for this field. Valid for all types except |
419 | 424 | bp_loc_other. */ |
420 | - CORE_ADDR address; | |
425 | + CORE_ADDR address = 0; | |
421 | 426 | |
422 | 427 | /* For hardware watchpoints, the size of the memory region being |
423 | 428 | watched. For hardware ranged breakpoints, the size of the |
424 | 429 | breakpoint range. */ |
425 | - int length; | |
430 | + int length = 0; | |
426 | 431 | |
427 | 432 | /* Type of hardware watchpoint. */ |
428 | - enum target_hw_bp_type watchpoint_type; | |
433 | + target_hw_bp_type watchpoint_type {}; | |
429 | 434 | |
430 | 435 | /* For any breakpoint type with an address, this is the section |
431 | 436 | associated with the address. Used primarily for overlay |
432 | 437 | debugging. */ |
433 | - struct obj_section *section; | |
438 | + obj_section *section = NULL; | |
434 | 439 | |
435 | 440 | /* Address at which breakpoint was requested, either by the user or |
436 | 441 | by GDB for internal breakpoints. This will usually be the same |
@@ -438,24 +443,24 @@ struct bp_location | ||
438 | 443 | ADJUST_BREAKPOINT_ADDRESS has computed a different address at |
439 | 444 | which to place the breakpoint in order to comply with a |
440 | 445 | processor's architectual constraints. */ |
441 | - CORE_ADDR requested_address; | |
446 | + CORE_ADDR requested_address = 0; | |
442 | 447 | |
443 | 448 | /* An additional address assigned with this location. This is currently |
444 | 449 | only used by STT_GNU_IFUNC resolver breakpoints to hold the address |
445 | 450 | of the resolver function. */ |
446 | - CORE_ADDR related_address; | |
451 | + CORE_ADDR related_address = 0; | |
447 | 452 | |
448 | 453 | /* If the location comes from a probe point, this is the probe associated |
449 | 454 | with it. */ |
450 | - struct bound_probe probe; | |
455 | + bound_probe probe {}; | |
451 | 456 | |
452 | - char *function_name; | |
457 | + char *function_name = NULL; | |
453 | 458 | |
454 | 459 | /* Details of the placed breakpoint, when inserted. */ |
455 | - struct bp_target_info target_info; | |
460 | + bp_target_info target_info {}; | |
456 | 461 | |
457 | 462 | /* Similarly, for the breakpoint at an overlay's LMA, if necessary. */ |
458 | - struct bp_target_info overlay_target_info; | |
463 | + bp_target_info overlay_target_info {}; | |
459 | 464 | |
460 | 465 | /* In a non-stop mode, it's possible that we delete a breakpoint, |
461 | 466 | but as we do that, some still running thread hits that breakpoint. |
@@ -466,19 +471,19 @@ struct bp_location | ||
466 | 471 | breakpoint was deleted, we retire all locations of that breakpoint. |
467 | 472 | This variable keeps a number of events still to go, when |
468 | 473 | it becomes 0 this location is retired. */ |
469 | - int events_till_retirement; | |
474 | + int events_till_retirement = 0; | |
470 | 475 | |
471 | 476 | /* Line number which was used to place this location. |
472 | 477 | |
473 | 478 | Breakpoint placed into a comment keeps it's user specified line number |
474 | 479 | despite ADDRESS resolves into a different line number. */ |
475 | 480 | |
476 | - int line_number; | |
481 | + int line_number = 0; | |
477 | 482 | |
478 | 483 | /* Symtab which was used to place this location. This is used |
479 | 484 | to find the corresponding source file name. */ |
480 | 485 | |
481 | - struct symtab *symtab; | |
486 | + struct symtab *symtab = NULL; | |
482 | 487 | }; |
483 | 488 | |
484 | 489 | /* The possible return values for print_bpstat, print_it_normal, |
@@ -1205,10 +1210,6 @@ extern void until_break_command (char *, int, int); | ||
1205 | 1210 | |
1206 | 1211 | /* Initialize a struct bp_location. */ |
1207 | 1212 | |
1208 | -extern void init_bp_location (struct bp_location *loc, | |
1209 | - const struct bp_location_ops *ops, | |
1210 | - struct breakpoint *owner); | |
1211 | - | |
1212 | 1213 | extern void update_breakpoint_locations (struct breakpoint *b, |
1213 | 1214 | struct program_space *filter_pspace, |
1214 | 1215 | struct symtabs_and_lines sals, |