• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

修订版5625a2864147f4d92b22edfeeab7600818988be2 (tree)
时间2017-04-25 09:43:06
作者Pedro Alves <palves@redh...>
CommiterPedro Alves

Log Message

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:

src/gdb/breakpoint.c: In function ‘bp_location** get_first_locp_gte_addr(CORE_ADDR)’:
src/gdb/breakpoint.c:950:53: error: use of deleted function ‘void* memset(T*, int, size_t) [with T = bp_location; <template-parameter-1-2> = void; size_t = long unsigned int]’
memset (&dummy_loc, 0, sizeof (struct bp_location));


In file included from src/gdb/defs.h:28:0,

from src/gdb/breakpoint.c:20:

src/gdb/common/common-defs.h:126:7: note: declared here
void *memset (T *s, int c, size_t n) = delete;


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.

更改概述

差异

--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,20 @@
11 2017-04-25 Pedro Alves <palves@redhat.com>
22
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+
318 * common/enum-flags.h (enum_flags): Don't implement copy ctor and
419 assignment operator.
520
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -12224,14 +12224,14 @@ static char *ada_exception_catchpoint_cond_string (const char *excep_string);
1222412224 when symbols change. */
1222512225
1222612226 /* 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. */
1223012228
12231-struct ada_catchpoint_location
12229+class ada_catchpoint_location : public bp_location
1223212230 {
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+ {}
1223512235
1223612236 /* The condition that checks whether the exception that was raised
1223712237 is the specific exception the user specified on catchpoint
@@ -12347,12 +12347,7 @@ static struct bp_location *
1234712347 allocate_location_exception (enum ada_exception_catchpoint_kind ex,
1234812348 struct breakpoint *self)
1234912349 {
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);
1235612351 }
1235712352
1235812353 /* Implement the RE_SET method in the breakpoint_ops structure for all
--- a/gdb/breakpoint.c
+++ b/gdb/breakpoint.c
@@ -947,7 +947,6 @@ get_first_locp_gte_addr (CORE_ADDR address)
947947 struct bp_location **locp_found = NULL;
948948
949949 /* Initialize the dummy location's address field. */
950- memset (&dummy_loc, 0, sizeof (struct bp_location));
951950 dummy_loc.address = address;
952951
953952 /* Find a close match to the first location at ADDRESS. */
@@ -7300,11 +7299,9 @@ adjust_breakpoint_address (struct gdbarch *gdbarch,
73007299 }
73017300 }
73027301
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)
73067303 {
7307- memset (loc, 0, sizeof (*loc));
7304+ bp_location *loc = this;
73087305
73097306 gdb_assert (ops != NULL);
73107307
@@ -12824,11 +12821,7 @@ base_breakpoint_dtor (struct breakpoint *self)
1282412821 static struct bp_location *
1282512822 base_breakpoint_allocate_location (struct breakpoint *self)
1282612823 {
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);
1283212825 }
1283312826
1283412827 static void
--- a/gdb/breakpoint.h
+++ b/gdb/breakpoint.h
@@ -310,20 +310,25 @@ struct bp_location_ops
310310 void (*dtor) (struct bp_location *self);
311311 };
312312
313-struct bp_location
313+class bp_location
314314 {
315+public:
316+ bp_location () = default;
317+
318+ bp_location (const bp_location_ops *ops, breakpoint *owner);
319+
315320 /* Chain pointer to the next breakpoint location for
316321 the same parent breakpoint. */
317- struct bp_location *next;
322+ bp_location *next = NULL;
318323
319324 /* Methods associated with this location. */
320- const struct bp_location_ops *ops;
325+ const bp_location_ops *ops = NULL;
321326
322327 /* The reference count. */
323- int refc;
328+ int refc = 0;
324329
325330 /* Type of this breakpoint location. */
326- enum bp_loc_type loc_type;
331+ bp_loc_type loc_type {};
327332
328333 /* Each breakpoint location must belong to exactly one higher-level
329334 breakpoint. This pointer is NULL iff this bp_location is no
@@ -331,7 +336,7 @@ struct bp_location
331336 is deleted, its locations may still be found in the
332337 moribund_locations list, or if we had stopped for it, in
333338 bpstats. */
334- struct breakpoint *owner;
339+ breakpoint *owner = NULL;
335340
336341 /* Conditional. Break only if this expression's value is nonzero.
337342 Unlike string form of condition, which is associated with
@@ -360,32 +365,32 @@ struct bp_location
360365 duplicates of this location and thus we don't need to call
361366 force_breakpoint_reinsertion (...) for this location. */
362367
363- enum condition_status condition_changed;
368+ condition_status condition_changed {};
364369
365370 agent_expr_up cmd_bytecode;
366371
367372 /* Signals that breakpoint conditions and/or commands need to be
368373 re-synched with the target. This has no use other than
369374 target-side breakpoints. */
370- char needs_update;
375+ bool needs_update = false;
371376
372377 /* This location's address is in an unloaded solib, and so this
373378 location should not be inserted. It will be automatically
374379 enabled when that solib is loaded. */
375- char shlib_disabled;
380+ bool shlib_disabled = false;
376381
377382 /* Is this particular location enabled. */
378- char enabled;
383+ bool enabled = false;
379384
380385 /* Nonzero if this breakpoint is now inserted. */
381- char inserted;
386+ bool inserted = false;
382387
383388 /* Nonzero if this is a permanent breakpoint. There is a breakpoint
384389 instruction hard-wired into the target's code. Don't try to
385390 write another breakpoint instruction on top of it, or restore its
386391 value. Step over it using the architecture's
387392 gdbarch_skip_permanent_breakpoint method. */
388- char permanent;
393+ bool permanent = false;
389394
390395 /* Nonzero if this is not the first breakpoint in the list
391396 for the given address. location of tracepoint can _never_
@@ -393,7 +398,7 @@ struct bp_location
393398 kinds of breakpoints, because two locations at the same
394399 address may have different actions, so both of these locations
395400 should be downloaded and so that `tfind N' always works. */
396- char duplicate;
401+ bool duplicate = false;
397402
398403 /* If we someday support real thread-specific breakpoints, then
399404 the breakpoint location will need a thread identifier. */
@@ -403,7 +408,7 @@ struct bp_location
403408
404409 /* Architecture associated with this location's address. May be
405410 different from the breakpoint architecture. */
406- struct gdbarch *gdbarch;
411+ struct gdbarch *gdbarch = NULL;
407412
408413 /* The program space associated with this breakpoint location
409414 address. Note that an address space may be represented in more
@@ -411,26 +416,26 @@ struct bp_location
411416 its own program space, but there will only be one address space
412417 for all of them), but we must not insert more than one location
413418 at the same address in the same address space. */
414- struct program_space *pspace;
419+ program_space *pspace = NULL;
415420
416421 /* Note that zero is a perfectly valid code address on some platforms
417422 (for example, the mn10200 (OBSOLETE) and mn10300 simulators). NULL
418423 is not a special value for this field. Valid for all types except
419424 bp_loc_other. */
420- CORE_ADDR address;
425+ CORE_ADDR address = 0;
421426
422427 /* For hardware watchpoints, the size of the memory region being
423428 watched. For hardware ranged breakpoints, the size of the
424429 breakpoint range. */
425- int length;
430+ int length = 0;
426431
427432 /* Type of hardware watchpoint. */
428- enum target_hw_bp_type watchpoint_type;
433+ target_hw_bp_type watchpoint_type {};
429434
430435 /* For any breakpoint type with an address, this is the section
431436 associated with the address. Used primarily for overlay
432437 debugging. */
433- struct obj_section *section;
438+ obj_section *section = NULL;
434439
435440 /* Address at which breakpoint was requested, either by the user or
436441 by GDB for internal breakpoints. This will usually be the same
@@ -438,24 +443,24 @@ struct bp_location
438443 ADJUST_BREAKPOINT_ADDRESS has computed a different address at
439444 which to place the breakpoint in order to comply with a
440445 processor's architectual constraints. */
441- CORE_ADDR requested_address;
446+ CORE_ADDR requested_address = 0;
442447
443448 /* An additional address assigned with this location. This is currently
444449 only used by STT_GNU_IFUNC resolver breakpoints to hold the address
445450 of the resolver function. */
446- CORE_ADDR related_address;
451+ CORE_ADDR related_address = 0;
447452
448453 /* If the location comes from a probe point, this is the probe associated
449454 with it. */
450- struct bound_probe probe;
455+ bound_probe probe {};
451456
452- char *function_name;
457+ char *function_name = NULL;
453458
454459 /* Details of the placed breakpoint, when inserted. */
455- struct bp_target_info target_info;
460+ bp_target_info target_info {};
456461
457462 /* 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 {};
459464
460465 /* In a non-stop mode, it's possible that we delete a breakpoint,
461466 but as we do that, some still running thread hits that breakpoint.
@@ -466,19 +471,19 @@ struct bp_location
466471 breakpoint was deleted, we retire all locations of that breakpoint.
467472 This variable keeps a number of events still to go, when
468473 it becomes 0 this location is retired. */
469- int events_till_retirement;
474+ int events_till_retirement = 0;
470475
471476 /* Line number which was used to place this location.
472477
473478 Breakpoint placed into a comment keeps it's user specified line number
474479 despite ADDRESS resolves into a different line number. */
475480
476- int line_number;
481+ int line_number = 0;
477482
478483 /* Symtab which was used to place this location. This is used
479484 to find the corresponding source file name. */
480485
481- struct symtab *symtab;
486+ struct symtab *symtab = NULL;
482487 };
483488
484489 /* The possible return values for print_bpstat, print_it_normal,
@@ -1205,10 +1210,6 @@ extern void until_break_command (char *, int, int);
12051210
12061211 /* Initialize a struct bp_location. */
12071212
1208-extern void init_bp_location (struct bp_location *loc,
1209- const struct bp_location_ops *ops,
1210- struct breakpoint *owner);
1211-
12121213 extern void update_breakpoint_locations (struct breakpoint *b,
12131214 struct program_space *filter_pspace,
12141215 struct symtabs_and_lines sals,