990840a Convert struct target_ops to C++

Authored and Committed by palves 6 years ago
51 files changed. 3389 lines added. 3876 lines removed.
gdb/auxv.c
file modified
+6 -7
gdb/auxv.h
file modified
+1 -2
gdb/avr-tdep.c
file modified
+2 -2
gdb/breakpoint.c
file modified
+3 -4
gdb/elfread.c
file modified
+4 -6
gdb/eval.c
file modified
+1 -1
gdb/exceptions.c
file modified
+5 -1
gdb/frame.c
file modified
+1 -1
gdb/gdbarch-selftests.c
file modified
+2 -2
gdb/gnu-v3-abi.c
file modified
+1 -1
gdb/ia64-tdep.c
file modified
+1 -1
gdb/ia64-vms-tdep.c
file modified
+1 -1
gdb/infcall.c
file modified
+2 -2
gdb/infcmd.c
file modified
+18 -18
gdb/infrun.c
file modified
+6 -6
gdb/linux-tdep.c
file modified
+9 -9
gdb/make-target-delegates
file modified
+122 -83
gdb/mi/mi-main.c
file modified
+5 -8
gdb/minsyms.c
file modified
+2 -2
gdb/parse.c
file modified
+1 -1
gdb/ppc-linux-nat.c
file modified
+1 -1
gdb/ppc-linux-tdep.c
file modified
+5 -5
gdb/procfs.c
file modified
+1 -1
gdb/regcache.c
file modified
+25 -39
gdb/remote.c
file modified
+6 -6
gdb/rs6000-tdep.c
file modified
+1 -1
gdb/s390-linux-nat.c
file modified
+1 -1
gdb/s390-tdep.c
file modified
+1 -1
gdb/solib-aix.c
file modified
+1 -1
gdb/solib-darwin.c
file modified
+1 -1
gdb/solib-dsbt.c
file modified
+2 -2
gdb/solib-spu.c
file modified
+3 -3
gdb/solib-svr4.c
file modified
+9 -9
gdb/solib-target.c
file modified
+1 -1
gdb/sparc-tdep.c
file modified
+1 -1
gdb/sparc64-tdep.c
file modified
+2 -2
gdb/spu-tdep.c
file modified
+15 -15
gdb/symfile.c
file modified
+1 -1
gdb/target-debug.h
file modified
+6 -0
gdb/target-delegates.c
file modified
+2306 -2730
gdb/target-descriptions.c
file modified
+2 -2
gdb/target-memory.c
file modified
+2 -2
gdb/target.c
file modified
+377 -469
gdb/target.h
file modified
+416 -414
gdb/testsuite/gdb.base/breakpoint-in-ro-region.exp
file modified
+2 -2
gdb/testsuite/gdb.base/sss-bp-on-user-bp-2.exp
file modified
+2 -2
gdb/tracepoint.c
file modified
+1 -1
gdb/valops.c
file modified
+2 -2
gdb/valprint.c
file modified
+1 -1
gdb/value.c
file modified
+1 -1
gdb/windows-tdep.c
file modified
+1 -1
    Convert struct target_ops to C++
    
    I.e., use C++ virtual methods and inheritance instead of tables of
    function pointers.
    
    Unfortunately, there's no way to do a smooth transition.  ALL native
    targets in the tree must be converted at the same time.  I've tested
    all I could with cross compilers and with help from GCC compile farm,
    but naturally I haven't been able to test many of the ports.  Still, I
    made a best effort to port everything over, and while I expect some
    build problems due to typos and such, which should be trivial to fix,
    I don't expect any design problems.  Since the patch would be too big
    to review and manage as a single unit, I split it in many chunks.
    This patch contains the core changes.  The following patches that have
    "target_ops/C++:" in their subject line each converts some target or
    targets over.  For pushing, all the "target_ops/C++:" patches must be
    squashed into this patch and pushed together, to avoid breaking the
    build (as much as possible).  I also haven't written ChangeLog entries
    for this part of the series yet, because it's going to be very
    mechanical, and I'd rather send this out sooner than later, in order
    to hopefuly get some help with testing on native ports that I don't
    have access to.
    
    * Implementation notes:
    
    - The flattened current_target is gone.  References to current_target
      or current_target.beneath are replaced to references to target_stack
      (the top of the stack) directly.
    
    - To keep "set debug target" working, This adds a new debug_stratum
      layer that sits on top of the stack, prints the debug, and delegates
      to the target beneath.
    
      In addition, this makes the shortname and longname properties of
      target_ops be virtual methods instead of data fields, and makes the
      debug target defer those to the target beneath.  This is so that
      debug code sprinkled around that does "if (debugtarget) ..."  can
      transparently print the name of the target beneath.
    
      A patch later in the series actually splits out the
      shortname/longname methods to a separate structure, but I preferred
      to keep that chance separate as it is associated with changing a bit
      the design of how targets are registered and open.
    
    - Since you can't check whether a C++ virtual method is overriden, the
      old method of checking whether a target_ops implements a method by
      comparing the function pointer must be replaced with something else.
      This is fixed by adding a parallel "can_do_foo" target_ops methods.
      E.g.,:
    
        +  for (t = target_stack; t != NULL; t = t->beneath)
    	 {
        -      if (t->to_create_inferior != NULL)
        +      if (t->can_create_inferior ())
    	    break;
    	 }
    
    - make-target-delegates was adjusted to generate C++ classes and
      methods.
    
      It needed tweaks to grok "virtual" in front of the target method
      name, and for the fact that methods are no longer function pointers.
      (In particular, the current code parsing the return type was simple
      because it could simply parse up until the '(' in '(*to_foo)'.
    
      It now generates a couple C++ classes that inherit target_ops:
      dummy_target and debug_target.
    
      Since we need to generate the class declarations as well, i.e., we
      need to emit methods twice, we now generate the code in two passes.
    
    - We can no longer use functions like x86_use_watchpoints to install
      custom methods on an arbitrary base target.
    
      The patch (actually patches until it's all squashed before pushing)
      replaces instances of such a pattern with template mixins.  A case
      seen in this patch in isolation is memory_breakpoint_target defined
      in target.h.
    
    gdb/ChangeLog:
    2018-04-18  Pedro Alves  <palves@redhat.com>
    	    John Baldwin  <jhb@freebsd.org>
    
    	# TBD
        
file modified
+6 -7
file modified
+1 -2
file modified
+2 -2
file modified
+3 -4
file modified
+4 -6
file modified
+1 -1
file modified
+5 -1
file modified
+1 -1
file modified
+2 -2
file modified
+1 -1
file modified
+1 -1
file modified
+1 -1
file modified
+2 -2
file modified
+18 -18
file modified
+6 -6
file modified
+9 -9
file modified
+122 -83
file modified
+5 -8
file modified
+2 -2
file modified
+1 -1
file modified
+1 -1
file modified
+5 -5
file modified
+1 -1
file modified
+25 -39
file modified
+6 -6
file modified
+1 -1
file modified
+1 -1
file modified
+1 -1
file modified
+1 -1
file modified
+1 -1
file modified
+2 -2
file modified
+3 -3
file modified
+9 -9
file modified
+1 -1
file modified
+1 -1
file modified
+2 -2
file modified
+15 -15
file modified
+1 -1
file modified
+6 -0
file modified
+2306 -2730
file modified
+2 -2
file modified
+2 -2
file modified
+377 -469
file modified
+416 -414
file modified
+1 -1
file modified
+2 -2
file modified
+1 -1
file modified
+1 -1
file modified
+1 -1