From c5aa993b1f4add48fbdc6cc3117059f616e49875 Mon Sep 17 00:00:00 2001 From: Jason Molenda Date: Wed, 7 Jul 1999 20:19:36 +0000 Subject: import gdb-1999-07-07 post reformat --- gdb/ChangeLog | 4 + gdb/a29k-tdep.c | 257 +- gdb/a68v-nat.c | 95 +- gdb/abug-rom.c | 128 +- gdb/alpha-nat.c | 91 +- gdb/alpha-tdep.c | 840 +++--- gdb/altos-xdep.c | 116 +- gdb/annotate.c | 35 +- gdb/annotate.h | 31 +- gdb/arc-tdep.c | 140 +- gdb/arm-tdep.c | 787 +++--- gdb/arm-xdep.c | 283 +- gdb/ax-gdb.c | 510 ++-- gdb/ax-gdb.h | 101 +- gdb/ax-general.c | 183 +- gdb/ax.h | 301 +- gdb/bcache.c | 71 +- gdb/bcache.h | 63 +- gdb/blockframe.c | 285 +- gdb/breakpoint.c | 4181 ++++++++++++++-------------- gdb/breakpoint.h | 672 ++--- gdb/buildsym.c | 46 +- gdb/buildsym.h | 31 +- gdb/c-lang.c | 452 +-- gdb/c-lang.h | 37 +- gdb/c-typeprint.c | 573 ++-- gdb/c-valprint.c | 223 +- gdb/call-cmds.h | 23 +- gdb/ch-exp.c | 1114 ++++---- gdb/ch-lang.c | 243 +- gdb/ch-lang.h | 29 +- gdb/ch-typeprint.c | 476 ++-- gdb/ch-valprint.c | 99 +- gdb/coff-solib.c | 111 +- gdb/coff-solib.h | 69 +- gdb/coffread.c | 1490 +++++----- gdb/command.c | 378 +-- gdb/command.h | 150 +- gdb/complaints.c | 96 +- gdb/complaints.h | 39 +- gdb/config/a29k/nm-ultra3.h | 25 +- gdb/config/a29k/tm-a29k.h | 197 +- gdb/config/a29k/tm-ultra3.h | 131 +- gdb/config/a29k/tm-vx29k.h | 55 +- gdb/config/a29k/xm-ultra3.h | 45 +- gdb/config/alpha/nm-linux.h | 31 +- gdb/config/alpha/nm-osf.h | 31 +- gdb/config/alpha/nm-osf2.h | 31 +- gdb/config/alpha/nm-osf3.h | 25 +- gdb/config/alpha/tm-alpha.h | 62 +- gdb/config/alpha/tm-alphalinux.h | 31 +- gdb/config/alpha/xm-alphalinux.h | 25 +- gdb/config/alpha/xm-alphaosf.h | 25 +- gdb/config/arc/tm-arc.h | 66 +- gdb/config/arm/nm-arm.h | 25 +- gdb/config/arm/tm-arm.h | 75 +- gdb/config/arm/xm-arm.h | 27 +- gdb/config/convex/tm-convex.h | 294 +- gdb/config/d10v/tm-d10v.h | 57 +- gdb/config/d30v/tm-d30v.h | 83 +- gdb/config/fr30/tm-fr30.h | 45 +- gdb/config/gould/tm-np1.h | 304 +-- gdb/config/gould/tm-pn.h | 336 +-- gdb/config/gould/xm-np1.h | 22 +- gdb/config/gould/xm-pn.h | 16 +- gdb/config/h8300/tm-h8300.h | 50 +- gdb/config/h8500/tm-h8500.h | 49 +- gdb/config/i386/nm-fbsd.h | 31 +- gdb/config/i386/nm-gnu.h | 25 +- gdb/config/i386/nm-go32.h | 28 +- gdb/config/i386/nm-i386aix.h | 27 +- gdb/config/i386/nm-i386bsd.h | 27 +- gdb/config/i386/nm-i386lynx.h | 25 +- gdb/config/i386/nm-i386mach.h | 27 +- gdb/config/i386/nm-i386sco.h | 27 +- gdb/config/i386/nm-i386sco4.h | 31 +- gdb/config/i386/nm-i386sco5.h | 29 +- gdb/config/i386/nm-i386sol2.h | 27 +- gdb/config/i386/nm-i386v.h | 27 +- gdb/config/i386/nm-i386v4.h | 25 +- gdb/config/i386/nm-i386v42mp.h | 26 +- gdb/config/i386/nm-linux.h | 27 +- gdb/config/i386/nm-m3.h | 25 +- gdb/config/i386/nm-nbsd.h | 27 +- gdb/config/i386/nm-ptx4.h | 27 +- gdb/config/i386/nm-sun386.h | 31 +- gdb/config/i386/nm-symmetry.h | 27 +- gdb/config/i386/tm-cygwin.h | 3 +- gdb/config/i386/tm-fbsd.h | 31 +- gdb/config/i386/tm-go32.h | 31 +- gdb/config/i386/tm-i386.h | 51 +- gdb/config/i386/tm-i386aix.h | 29 +- gdb/config/i386/tm-i386bsd.h | 27 +- gdb/config/i386/tm-i386gnu.h | 31 +- gdb/config/i386/tm-i386lynx.h | 31 +- gdb/config/i386/tm-i386m3.h | 31 +- gdb/config/i386/tm-i386mk.h | 25 +- gdb/config/i386/tm-i386nw.h | 28 +- gdb/config/i386/tm-i386os9k.h | 29 +- gdb/config/i386/tm-i386sco5.h | 27 +- gdb/config/i386/tm-i386sol2.h | 29 +- gdb/config/i386/tm-i386v.h | 31 +- gdb/config/i386/tm-i386v4.h | 29 +- gdb/config/i386/tm-i386v42mp.h | 31 +- gdb/config/i386/tm-linux.h | 27 +- gdb/config/i386/tm-nbsd.h | 27 +- gdb/config/i386/tm-ptx.h | 45 +- gdb/config/i386/tm-ptx4.h | 25 +- gdb/config/i386/tm-sun386.h | 38 +- gdb/config/i386/tm-symmetry.h | 38 +- gdb/config/i386/xm-cygwin.h | 31 +- gdb/config/i386/xm-go32.h | 31 +- gdb/config/i386/xm-i386aix.h | 27 +- gdb/config/i386/xm-i386bsd.h | 27 +- gdb/config/i386/xm-i386gnu.h | 25 +- gdb/config/i386/xm-i386lynx.h | 25 +- gdb/config/i386/xm-i386m3.h | 31 +- gdb/config/i386/xm-i386mach.h | 27 +- gdb/config/i386/xm-i386mk.h | 25 +- gdb/config/i386/xm-i386sco.h | 31 +- gdb/config/i386/xm-i386v.h | 46 +- gdb/config/i386/xm-i386v32.h | 25 +- gdb/config/i386/xm-i386v4.h | 31 +- gdb/config/i386/xm-linux.h | 27 +- gdb/config/i386/xm-nbsd.h | 25 +- gdb/config/i386/xm-ptx.h | 31 +- gdb/config/i386/xm-ptx4.h | 25 +- gdb/config/i386/xm-sun386.h | 25 +- gdb/config/i386/xm-symmetry.h | 31 +- gdb/config/i386/xm-windows.h | 31 +- gdb/config/i960/tm-i960.h | 73 +- gdb/config/i960/tm-mon960.h | 29 +- gdb/config/i960/tm-nindy960.h | 31 +- gdb/config/i960/tm-vx960.h | 31 +- gdb/config/m32r/tm-m32r.h | 45 +- gdb/config/m68k/nm-apollo68b.h | 27 +- gdb/config/m68k/nm-apollo68v.h | 25 +- gdb/config/m68k/nm-delta68.h | 25 +- gdb/config/m68k/nm-dpx2.h | 31 +- gdb/config/m68k/nm-hp300bsd.h | 31 +- gdb/config/m68k/nm-hp300hpux.h | 31 +- gdb/config/m68k/nm-linux.h | 31 +- gdb/config/m68k/nm-m68klynx.h | 25 +- gdb/config/m68k/nm-nbsd.h | 25 +- gdb/config/m68k/nm-news.h | 27 +- gdb/config/m68k/nm-sun2.h | 31 +- gdb/config/m68k/nm-sun3.h | 31 +- gdb/config/m68k/nm-sysv4.h | 25 +- gdb/config/m68k/tm-3b1.h | 31 +- gdb/config/m68k/tm-apollo68b.h | 31 +- gdb/config/m68k/tm-cisco.h | 31 +- gdb/config/m68k/tm-delta68.h | 27 +- gdb/config/m68k/tm-dpx2.h | 31 +- gdb/config/m68k/tm-es1800.h | 31 +- gdb/config/m68k/tm-hp300bsd.h | 31 +- gdb/config/m68k/tm-hp300hpux.h | 31 +- gdb/config/m68k/tm-isi.h | 29 +- gdb/config/m68k/tm-linux.h | 31 +- gdb/config/m68k/tm-m68k.h | 47 +- gdb/config/m68k/tm-m68klynx.h | 31 +- gdb/config/m68k/tm-m68kv4.h | 29 +- gdb/config/m68k/tm-mac.h | 25 +- gdb/config/m68k/tm-monitor.h | 27 +- gdb/config/m68k/tm-nbsd.h | 31 +- gdb/config/m68k/tm-news.h | 37 +- gdb/config/m68k/tm-os68k.h | 31 +- gdb/config/m68k/tm-st2000.h | 25 +- gdb/config/m68k/tm-sun2.h | 25 +- gdb/config/m68k/tm-sun2os4.h | 25 +- gdb/config/m68k/tm-sun3.h | 31 +- gdb/config/m68k/tm-sun3os4.h | 25 +- gdb/config/m68k/tm-vx68.h | 31 +- gdb/config/m68k/xm-3b1.h | 31 +- gdb/config/m68k/xm-altos.h | 46 +- gdb/config/m68k/xm-apollo68b.h | 27 +- gdb/config/m68k/xm-apollo68v.h | 46 +- gdb/config/m68k/xm-delta68.h | 31 +- gdb/config/m68k/xm-dpx2.h | 25 +- gdb/config/m68k/xm-hp300bsd.h | 27 +- gdb/config/m68k/xm-hp300hpux.h | 27 +- gdb/config/m68k/xm-isi.h | 29 +- gdb/config/m68k/xm-linux.h | 27 +- gdb/config/m68k/xm-m68k.h | 26 +- gdb/config/m68k/xm-m68klynx.h | 25 +- gdb/config/m68k/xm-m68kv4.h | 31 +- gdb/config/m68k/xm-mpw.h | 25 +- gdb/config/m68k/xm-nbsd.h | 25 +- gdb/config/m68k/xm-news.h | 27 +- gdb/config/m68k/xm-news1000.h | 25 +- gdb/config/m68k/xm-sun2.h | 27 +- gdb/config/m68k/xm-sun3.h | 27 +- gdb/config/m68k/xm-sun3os4.h | 25 +- gdb/config/m88k/nm-cxux.h | 27 +- gdb/config/m88k/nm-delta88v4.h | 25 +- gdb/config/m88k/nm-m88k.h | 25 +- gdb/config/m88k/tm-cxux.h | 33 +- gdb/config/m88k/tm-delta88.h | 25 +- gdb/config/m88k/tm-delta88v4.h | 31 +- gdb/config/m88k/tm-m88k.h | 53 +- gdb/config/m88k/xm-cxux.h | 30 +- gdb/config/m88k/xm-delta88.h | 29 +- gdb/config/m88k/xm-delta88v4.h | 25 +- gdb/config/m88k/xm-dgux.h | 31 +- gdb/config/m88k/xm-m88k.h | 25 +- gdb/config/mips/nm-irix3.h | 31 +- gdb/config/mips/nm-irix4.h | 27 +- gdb/config/mips/nm-irix5.h | 27 +- gdb/config/mips/nm-mips.h | 25 +- gdb/config/mips/nm-news-mips.h | 29 +- gdb/config/mips/nm-riscos.h | 25 +- gdb/config/mips/tm-bigmips.h | 25 +- gdb/config/mips/tm-bigmips64.h | 25 +- gdb/config/mips/tm-embed.h | 31 +- gdb/config/mips/tm-embed64.h | 25 +- gdb/config/mips/tm-embedl.h | 25 +- gdb/config/mips/tm-embedl64.h | 25 +- gdb/config/mips/tm-irix3.h | 27 +- gdb/config/mips/tm-irix5.h | 27 +- gdb/config/mips/tm-mips.h | 104 +- gdb/config/mips/tm-mips64.h | 29 +- gdb/config/mips/tm-mipsm3.h | 27 +- gdb/config/mips/tm-mipsv4.h | 27 +- gdb/config/mips/tm-tx39.h | 25 +- gdb/config/mips/tm-tx39l.h | 25 +- gdb/config/mips/tm-vr4100.h | 25 +- gdb/config/mips/tm-vr4300.h | 25 +- gdb/config/mips/tm-vr4300el.h | 25 +- gdb/config/mips/tm-vr5000.h | 25 +- gdb/config/mips/tm-vr5000el.h | 25 +- gdb/config/mips/tm-vxmips.h | 31 +- gdb/config/mips/xm-irix3.h | 27 +- gdb/config/mips/xm-irix4.h | 27 +- gdb/config/mips/xm-irix5.h | 29 +- gdb/config/mips/xm-mips.h | 27 +- gdb/config/mips/xm-mipsm3.h | 29 +- gdb/config/mips/xm-mipsv4.h | 27 +- gdb/config/mips/xm-news-mips.h | 25 +- gdb/config/mips/xm-riscos.h | 31 +- gdb/config/mn10200/tm-mn10200.h | 33 +- gdb/config/mn10300/tm-mn10300.h | 39 +- gdb/config/nm-gnu.h | 3 +- gdb/config/nm-lynx.h | 29 +- gdb/config/nm-m3.h | 36 +- gdb/config/nm-nbsd.h | 27 +- gdb/config/nm-sysv4.h | 31 +- gdb/config/none/nm-none.h | 25 +- gdb/config/none/tm-none.h | 25 +- gdb/config/none/xm-none.h | 25 +- gdb/config/ns32k/nm-nbsd.h | 31 +- gdb/config/ns32k/nm-umax.h | 25 +- gdb/config/ns32k/tm-merlin.h | 39 +- gdb/config/ns32k/tm-nbsd.h | 26 +- gdb/config/ns32k/tm-ns32km3.h | 25 +- gdb/config/ns32k/tm-umax.h | 39 +- gdb/config/ns32k/xm-merlin.h | 25 +- gdb/config/ns32k/xm-nbsd.h | 25 +- gdb/config/ns32k/xm-ns32km3.h | 25 +- gdb/config/ns32k/xm-umax.h | 26 +- gdb/config/pa/nm-hppab.h | 29 +- gdb/config/pa/nm-hppah.h | 56 +- gdb/config/pa/nm-hppah11.h | 25 +- gdb/config/pa/nm-hppao.h | 31 +- gdb/config/pa/tm-hppa.h | 362 +-- gdb/config/pa/tm-hppah.h | 31 +- gdb/config/pa/tm-hppao.h | 4 +- gdb/config/pa/xm-hppab.h | 31 +- gdb/config/pa/xm-hppah.h | 29 +- gdb/config/powerpc/nm-aix.h | 25 +- gdb/config/powerpc/nm-macos.h | 25 +- gdb/config/powerpc/nm-solaris.h | 31 +- gdb/config/powerpc/tm-cygwin.h | 4 +- gdb/config/powerpc/tm-macos.h | 25 +- gdb/config/powerpc/tm-ppc-aix.h | 31 +- gdb/config/powerpc/tm-ppc-eabi.h | 27 +- gdb/config/powerpc/tm-ppc-nw.h | 31 +- gdb/config/powerpc/tm-ppc-sim.h | 26 +- gdb/config/powerpc/tm-ppcle-eabi.h | 31 +- gdb/config/powerpc/tm-ppcle-sim.h | 26 +- gdb/config/powerpc/tm-solaris.h | 35 +- gdb/config/powerpc/xm-aix.h | 25 +- gdb/config/powerpc/xm-cygwin.h | 31 +- gdb/config/powerpc/xm-linux.h | 25 +- gdb/config/powerpc/xm-mpw.h | 25 +- gdb/config/powerpc/xm-solaris.h | 25 +- gdb/config/pyr/tm-pyr.h | 194 +- gdb/config/pyr/xm-pyr.h | 50 +- gdb/config/romp/xm-rtbsd.h | 30 +- gdb/config/rs6000/nm-rs6000.h | 31 +- gdb/config/rs6000/nm-rs6000ly.h | 25 +- gdb/config/rs6000/tm-rs6000-aix4.h | 25 +- gdb/config/rs6000/tm-rs6000.h | 177 +- gdb/config/rs6000/tm-rs6000ly.h | 31 +- gdb/config/rs6000/xm-aix4.h | 26 +- gdb/config/rs6000/xm-rs6000.h | 26 +- gdb/config/rs6000/xm-rs6000ly.h | 31 +- gdb/config/sh/tm-sh.h | 37 +- gdb/config/sparc/nm-linux.h | 27 +- gdb/config/sparc/nm-nbsd.h | 31 +- gdb/config/sparc/nm-sparclynx.h | 25 +- gdb/config/sparc/nm-sun4os4.h | 31 +- gdb/config/sparc/nm-sun4sol2.h | 27 +- gdb/config/sparc/tm-linux.h | 31 +- gdb/config/sparc/tm-nbsd.h | 31 +- gdb/config/sparc/tm-sp64.h | 85 +- gdb/config/sparc/tm-sp64sim.h | 31 +- gdb/config/sparc/tm-sparc.h | 79 +- gdb/config/sparc/tm-sparclet.h | 35 +- gdb/config/sparc/tm-sparclite.h | 51 +- gdb/config/sparc/tm-sparclynx.h | 31 +- gdb/config/sparc/tm-spc-em.h | 31 +- gdb/config/sparc/tm-sun4os4.h | 31 +- gdb/config/sparc/tm-sun4sol2.h | 35 +- gdb/config/sparc/tm-vxsparc.h | 26 +- gdb/config/sparc/xm-linux.h | 29 +- gdb/config/sparc/xm-nbsd.h | 25 +- gdb/config/sparc/xm-sparc.h | 25 +- gdb/config/sparc/xm-sparclynx.h | 25 +- gdb/config/sparc/xm-sun4os4.h | 31 +- gdb/config/sparc/xm-sun4sol2.h | 31 +- gdb/config/tahoe/tm-tahoe.h | 32 +- gdb/config/tahoe/xm-tahoe.h | 31 +- gdb/config/tic80/tm-tic80.h | 45 +- gdb/config/tm-lynx.h | 31 +- gdb/config/tm-nbsd.h | 25 +- gdb/config/tm-sunos.h | 27 +- gdb/config/tm-sysv4.h | 31 +- gdb/config/tm-vxworks.h | 25 +- gdb/config/v850/tm-v850.h | 45 +- gdb/config/vax/nm-vax.h | 27 +- gdb/config/vax/tm-vax.h | 35 +- gdb/config/vax/xm-vax.h | 31 +- gdb/config/vax/xm-vaxult.h | 2 +- gdb/config/vax/xm-vaxult2.h | 2 +- gdb/config/w65/tm-w65.h | 33 +- gdb/config/xm-aix4.h | 27 +- gdb/config/xm-lynx.h | 27 +- gdb/config/xm-mpw.h | 31 +- gdb/config/xm-nbsd.h | 25 +- gdb/config/xm-sysv4.h | 31 +- gdb/config/z8k/tm-z8k.h | 64 +- gdb/convex-tdep.c | 570 ++-- gdb/convex-xdep.c | 446 +-- gdb/core-aout.c | 53 +- gdb/core-regset.c | 77 +- gdb/core-sol2.c | 43 +- gdb/corefile.c | 131 +- gdb/corelow.c | 111 +- gdb/cp-valprint.c | 347 +-- gdb/cpu32bug-rom.c | 128 +- gdb/cxux-nat.c | 452 +-- gdb/d10v-tdep.c | 276 +- gdb/d30v-tdep.c | 369 +-- gdb/dbug-rom.c | 128 +- gdb/dbxread.c | 700 ++--- gdb/dcache.c | 146 +- gdb/dcache.h | 43 +- gdb/defs.h | 28 +- gdb/delta68-nat.c | 49 +- gdb/demangle.c | 6 +- gdb/dink32-rom.c | 52 +- gdb/dpx2-nat.c | 31 +- gdb/dsrec.c | 104 +- gdb/dst.h | 1708 ++++++------ gdb/dstread.c | 2270 +++++++-------- gdb/dve3900-rom.c | 510 ++-- gdb/dwarf2read.c | 495 ++-- gdb/dwarfread.c | 2487 ++++++++--------- gdb/elfread.c | 296 +- gdb/environ.c | 31 +- gdb/environ.h | 53 +- gdb/eval.c | 610 ++--- gdb/event-loop.c | 23 +- gdb/event-loop.h | 11 +- gdb/event-top.c | 81 +- gdb/exec.c | 245 +- gdb/expprint.c | 426 +-- gdb/expression.h | 591 ++-- gdb/f-lang.c | 537 ++-- gdb/f-lang.h | 89 +- gdb/f-typeprint.c | 98 +- gdb/f-valprint.c | 586 ++-- gdb/findvar.c | 216 +- gdb/fork-child.c | 81 +- gdb/fr30-tdep.c | 322 +-- gdb/frame.h | 73 +- gdb/gdb-stabs.h | 87 +- gdb/gdb_stat.h | 31 +- gdb/gdb_string.h | 55 +- gdb/gdbarch.c | 1139 ++++---- gdb/gdbarch.h | 538 ++-- gdb/gdbcmd.h | 25 +- gdb/gdbcore.h | 82 +- gdb/gdbserver/gdbreplay.c | 83 +- gdb/gdbserver/low-hppabsd.c | 59 +- gdb/gdbserver/low-linux.c | 77 +- gdb/gdbserver/low-lynx.c | 345 +-- gdb/gdbserver/low-sim.c | 57 +- gdb/gdbserver/low-sparc.c | 69 +- gdb/gdbserver/low-sun3.c | 51 +- gdb/gdbserver/remote-utils.c | 69 +- gdb/gdbserver/server.c | 53 +- gdb/gdbserver/server.h | 33 +- gdb/gdbserver/utils.c | 31 +- gdb/gdbthread.h | 35 +- gdb/gdbtypes.c | 1640 +++++------ gdb/gdbtypes.h | 782 +++--- gdb/gnu-nat.c | 712 ++--- gdb/gnu-nat.h | 77 +- gdb/gnu-regex.c | 3 +- gdb/gnu-regex.h | 3 +- gdb/go32-nat.c | 342 ++- gdb/gould-tdep.c | 330 +-- gdb/gould-xdep.c | 88 +- gdb/h8300-tdep.c | 228 +- gdb/h8500-tdep.c | 63 +- gdb/hp-psymtab-read.c | 175 +- gdb/hp-symtab-read.c | 2848 +++++++++---------- gdb/hp300ux-nat.c | 85 +- gdb/hppa-tdep.c | 1859 ++++++------- gdb/hppab-nat.c | 97 +- gdb/hppah-nat.c | 163 +- gdb/hppam3-nat.c | 57 +- gdb/hpread.c | 190 +- gdb/hpread.h | 71 +- gdb/hpux-thread.c | 117 +- gdb/i386-tdep.c | 255 +- gdb/i386aix-nat.c | 147 +- gdb/i386b-nat.c | 182 +- gdb/i386gnu-nat.c | 171 +- gdb/i386ly-tdep.c | 28 +- gdb/i386m3-nat.c | 179 +- gdb/i386mach-nat.c | 88 +- gdb/i386v-nat.c | 122 +- gdb/i386v4-nat.c | 141 +- gdb/i387-tdep.c | 123 +- gdb/i960-tdep.c | 542 ++-- gdb/infcmd.c | 516 ++-- gdb/inferior.h | 51 +- gdb/inflow.c | 203 +- gdb/infptrace.c | 146 +- gdb/infrun.c | 3203 +++++++++++----------- gdb/inftarg.c | 361 +-- gdb/infttrace.c | 5310 +++++++++++++++++++----------------- gdb/irix4-nat.c | 73 +- gdb/irix5-nat.c | 750 ++--- gdb/isi-xdep.c | 28 +- gdb/jv-lang.c | 302 +- gdb/jv-lang.h | 31 +- gdb/jv-typeprint.c | 43 +- gdb/jv-valprint.c | 93 +- gdb/kdb-start.c | 31 +- gdb/language.c | 1256 ++++----- gdb/language.h | 261 +- gdb/lynx-nat.c | 489 ++-- gdb/m2-lang.c | 413 +-- gdb/m2-lang.h | 31 +- gdb/m2-typeprint.c | 31 +- gdb/m2-valprint.c | 29 +- gdb/m3-nat.c | 1983 +++++++------- gdb/m32r-rom.c | 352 +-- gdb/m32r-tdep.c | 391 +-- gdb/m68k-tdep.c | 355 +-- gdb/m68klinux-nat.c | 65 +- gdb/m68knbsd-nat.c | 74 +- gdb/m88k-nat.c | 187 +- gdb/m88k-tdep.c | 332 +-- gdb/mac-defs.h | 2 - gdb/mac-nat.c | 153 +- gdb/mac-xdep.c | 190 +- gdb/main.c | 320 +-- gdb/maint.c | 106 +- gdb/mdebugread.c | 939 +++---- gdb/mem-break.c | 27 +- gdb/minimon.h | 967 +++---- gdb/minsyms.c | 245 +- gdb/mips-nat.c | 65 +- gdb/mips-tdep.c | 1869 +++++++------ gdb/mipsm3-nat.c | 197 +- gdb/mipsread.c | 96 +- gdb/mipsv4-nat.c | 61 +- gdb/mn10200-tdep.c | 149 +- gdb/mn10300-tdep.c | 171 +- gdb/mon960-rom.c | 178 +- gdb/monitor.c | 703 ++--- gdb/monitor.h | 160 +- gdb/news-xdep.c | 65 +- gdb/nindy-tdep.c | 91 +- gdb/nlmread.c | 89 +- gdb/ns32k-tdep.c | 88 +- gdb/ns32km3-nat.c | 67 +- gdb/ns32knbsd-nat.c | 434 +-- gdb/objfiles.c | 508 ++-- gdb/objfiles.h | 420 +-- gdb/ocd.c | 232 +- gdb/ocd.h | 69 +- gdb/op50-rom.c | 130 +- gdb/os9kread.c | 959 ++++--- gdb/osfsolib.c | 590 ++-- gdb/parse.c | 395 +-- gdb/parser-defs.h | 89 +- gdb/partial-stab.h | 1407 +++++----- gdb/ppc-bdm.c | 226 +- gdb/ppcbug-rom.c | 146 +- gdb/printcmd.c | 644 ++--- gdb/procfs.c | 2583 +++++++++--------- gdb/ptx4-nat.c | 256 +- gdb/pyr-tdep.c | 440 +-- gdb/pyr-xdep.c | 254 +- gdb/remote-adapt.c | 980 ++++--- gdb/remote-array.c | 1229 +++++---- gdb/remote-bug.c | 470 ++-- gdb/remote-d10v.c | 260 +- gdb/remote-e7000.c | 411 +-- gdb/remote-eb.c | 318 ++- gdb/remote-es.c | 861 +++--- gdb/remote-est.c | 132 +- gdb/remote-hms.c | 192 +- gdb/remote-mips.c | 1269 ++++----- gdb/remote-mm.c | 1874 +++++++------ gdb/remote-nindy.c | 441 +-- gdb/remote-nrom.c | 160 +- gdb/remote-os9k.c | 715 ++--- gdb/remote-rdi.c | 149 +- gdb/remote-rdp.c | 271 +- gdb/remote-sds.c | 125 +- gdb/remote-sim.c | 219 +- gdb/remote-st.c | 348 +-- gdb/remote-udi.c | 1045 +++---- gdb/remote-utils.c | 218 +- gdb/remote-utils.h | 109 +- gdb/remote-vx.c | 338 +-- gdb/remote-vx29k.c | 50 +- gdb/remote-vx68.c | 29 +- gdb/remote-vx960.c | 46 +- gdb/remote-vxmips.c | 119 +- gdb/remote-vxsparc.c | 57 +- gdb/remote.c | 916 ++++--- gdb/rom68k-rom.c | 127 +- gdb/rs6000-nat.c | 398 +-- gdb/rs6000-tdep.c | 1229 +++++---- gdb/scm-exp.c | 238 +- gdb/scm-lang.c | 59 +- gdb/scm-lang.h | 16 +- gdb/scm-tags.h | 84 +- gdb/scm-valprint.c | 51 +- gdb/ser-e7kpc.c | 172 +- gdb/ser-go32.c | 554 ++-- gdb/ser-mac.c | 96 +- gdb/ser-ocd.c | 30 +- gdb/ser-tcp.c | 119 +- gdb/ser-unix.c | 261 +- gdb/serial.c | 148 +- gdb/serial.h | 115 +- gdb/sh-tdep.c | 225 +- gdb/sh3-rom.c | 185 +- gdb/signals.h | 31 +- gdb/sol-thread.c | 480 ++-- gdb/solib.c | 994 +++---- gdb/solib.h | 71 +- gdb/somread.c | 393 +-- gdb/somsolib.c | 827 +++--- gdb/somsolib.h | 73 +- gdb/source.c | 545 ++-- gdb/sparc-nat.c | 201 +- gdb/sparc-tdep.c | 502 ++-- gdb/sparcl-tdep.c | 208 +- gdb/sparclet-rom.c | 191 +- gdb/srec.h | 29 +- gdb/stabsread.c | 2098 +++++++------- gdb/stabsread.h | 127 +- gdb/stack.c | 514 ++-- gdb/standalone.c | 91 +- gdb/stop-gdb.c | 49 +- gdb/stuff.c | 56 +- gdb/sun3-nat.c | 110 +- gdb/sun386-nat.c | 91 +- gdb/symfile.c | 1476 +++++----- gdb/symfile.h | 203 +- gdb/symm-nat.c | 924 ++++--- gdb/symm-tdep.c | 131 +- gdb/symmisc.c | 502 ++-- gdb/symtab.c | 2793 +++++++++---------- gdb/symtab.h | 1016 +++---- gdb/tahoe-tdep.c | 120 +- gdb/target.c | 814 +++--- gdb/target.h | 667 ++--- gdb/terminal.h | 27 +- gdb/thread.c | 208 +- gdb/tic80-tdep.c | 184 +- gdb/top.c | 574 ++-- gdb/top.h | 29 +- gdb/tracepoint.c | 1804 ++++++------ gdb/tracepoint.h | 144 +- gdb/tui/tui.c | 246 +- gdb/tui/tui.h | 149 +- gdb/tui/tuiCommand.c | 54 +- gdb/tui/tuiCommand.h | 17 +- gdb/tui/tuiData.c | 378 +-- gdb/tui/tuiData.h | 328 ++- gdb/tui/tuiDataWin.c | 112 +- gdb/tui/tuiDataWin.h | 29 +- gdb/tui/tuiDisassem.c | 90 +- gdb/tui/tuiDisassem.h | 17 +- gdb/tui/tuiGeneralWin.c | 84 +- gdb/tui/tuiGeneralWin.h | 38 +- gdb/tui/tuiIO.c | 188 +- gdb/tui/tuiIO.h | 25 +- gdb/tui/tuiLayout.c | 218 +- gdb/tui/tuiLayout.h | 22 +- gdb/tui/tuiRegs.c | 228 +- gdb/tui/tuiRegs.h | 27 +- gdb/tui/tuiSource.c | 102 +- gdb/tui/tuiSource.h | 17 +- gdb/tui/tuiSourceWin.c | 228 +- gdb/tui/tuiSourceWin.h | 85 +- gdb/tui/tuiStack.c | 94 +- gdb/tui/tuiStack.h | 33 +- gdb/tui/tuiWin.c | 304 +-- gdb/tui/tuiWin.h | 29 +- gdb/typeprint.c | 85 +- gdb/typeprint.h | 27 +- gdb/ultra3-nat.c | 330 ++- gdb/ultra3-xdep.c | 135 +- gdb/umax-xdep.c | 31 +- gdb/utils.c | 804 +++--- gdb/v850-tdep.c | 291 +- gdb/v850ice.c | 603 ++-- gdb/valarith.c | 433 +-- gdb/valops.c | 1152 ++++---- gdb/valprint.c | 567 ++-- gdb/valprint.h | 34 +- gdb/value.h | 245 +- gdb/values.c | 370 +-- gdb/vax-tdep.c | 79 +- gdb/w65-tdep.c | 5 +- gdb/w89k-rom.c | 136 +- gdb/win32-nat.c | 288 +- gdb/xcoffread.c | 774 +++--- gdb/xcoffsolib.c | 173 +- gdb/xcoffsolib.h | 77 +- gdb/xmodem.c | 61 +- gdb/xmodem.h | 27 +- gdb/z8k-tdep.c | 43 +- 643 files changed, 70843 insertions(+), 66727 deletions(-) (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index b1d8b8f..e0e094d 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 1999-07-07 Stan Shebs + * All C files except *-stub.c and *-share/*: Indent to GNU + standard, using indent 1.9.1. + * defs.h: Make indent ignore this file, macros confuse it. + * gnu-regex.c, gnu-regex.h: Don't let indent mess with these. Wed Jul 7 13:06:24 1999 Andrew Cagney diff --git a/gdb/a29k-tdep.c b/gdb/a29k-tdep.c index 2aab6a4..92474a1 100644 --- a/gdb/a29k-tdep.c +++ b/gdb/a29k-tdep.c @@ -3,21 +3,22 @@ Free Software Foundation, Inc. Contributed by Cygnus Support. Written by Jim Kingdon. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "gdbcore.h" @@ -59,10 +60,10 @@ struct prologue_info { CORE_ADDR pc; /* First addr after fn prologue */ unsigned rsize, msize; /* register stack frame size, mem stack ditto */ - unsigned mfp_used : 1; /* memory frame pointer used */ - unsigned rsize_valid : 1; /* Validity bits for the above */ - unsigned msize_valid : 1; - unsigned mfp_valid : 1; + unsigned mfp_used:1; /* memory frame pointer used */ + unsigned rsize_valid:1; /* Validity bits for the above */ + unsigned msize_valid:1; + unsigned mfp_valid:1; }; /* Examine the prologue of a function which starts at PC. Return @@ -94,7 +95,7 @@ examine_prologue (pc, rsize, msize, mfp_used) struct prologue_info *mi = 0; if (msymbol != NULL) - mi = (struct prologue_info *) msymbol -> info; + mi = (struct prologue_info *) msymbol->info; if (mi != 0) { @@ -124,21 +125,21 @@ examine_prologue (pc, rsize, msize, mfp_used) *msize = 0; if (mfp_used != NULL) *mfp_used = 0; - + /* Prologue must start with subtracting a constant from gr1. Normally this is sub gr1,gr1,. */ insn = read_memory_integer (p, 4); if ((insn & 0xffffff00) != 0x25010100) { /* If the frame is large, instead of a single instruction it - might be a pair of instructions: - const , - sub gr1,gr1, - */ + might be a pair of instructions: + const , + sub gr1,gr1, + */ int reg; /* Possible value for rsize. */ unsigned int rsize0; - + if ((insn & 0xff000000) != 0x03000000) { p = pc; @@ -172,7 +173,7 @@ examine_prologue (pc, rsize, msize, mfp_used) * way down. */ insn = read_memory_integer (p, 4); - if ((insn & 0xff00ffff) == (0x5e000100|RAB_HW_REGNUM)) + if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM)) { p += 4; } @@ -191,9 +192,9 @@ examine_prologue (pc, rsize, msize, mfp_used) else { /* However, for large frames it can be - const , - add lr1,gr1, - */ + const , + add lr1,gr1, + */ int reg; CORE_ADDR q; @@ -221,8 +222,8 @@ examine_prologue (pc, rsize, msize, mfp_used) to be looking for a "sub" instruction here, but the mask was set up to lose all the time. */ insn = read_memory_integer (p, 4); - if (((insn & 0xff80ffff) == (0x15800000|(MSP_HW_REGNUM<<8))) /* add */ - || ((insn & 0xff80ffff) == (0x81800000|(MSP_HW_REGNUM<<8)))) /* sll */ + if (((insn & 0xff80ffff) == (0x15800000 | (MSP_HW_REGNUM << 8))) /* add */ + || ((insn & 0xff80ffff) == (0x81800000 | (MSP_HW_REGNUM << 8)))) /* sll */ { p += 4; if (mfp_used != NULL) @@ -238,24 +239,24 @@ examine_prologue (pc, rsize, msize, mfp_used) Normally this is just sub msp,msp, - */ + */ insn = read_memory_integer (p, 4); - if ((insn & 0xffffff00) == - (0x25000000|(MSP_HW_REGNUM<<16)|(MSP_HW_REGNUM<<8))) + if ((insn & 0xffffff00) == + (0x25000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8))) { p += 4; - if (msize != NULL) + if (msize != NULL) *msize = insn & 0xff; } else { /* For large frames, instead of a single instruction it might - be + be - const , - consth , ; optional - sub msp,msp, - */ + const , + consth , ; optional + sub msp,msp, + */ int reg; unsigned msize0; CORE_ADDR q = p; @@ -276,8 +277,8 @@ examine_prologue (pc, rsize, msize, mfp_used) insn = read_memory_integer (q, 4); } /* Check for sub msp,msp,. */ - if ((insn & 0xffffff00) == - (0x24000000|(MSP_HW_REGNUM<<16)|(MSP_HW_REGNUM<<8)) + if ((insn & 0xffffff00) == + (0x24000000 | (MSP_HW_REGNUM << 16) | (MSP_HW_REGNUM << 8)) && (insn & 0xff) == reg) { p = q + 4; @@ -295,19 +296,19 @@ examine_prologue (pc, rsize, msize, mfp_used) * way down after everything else. */ insn = read_memory_integer (p, 4); - if ((insn & 0xff00ffff) == (0x5e000100|RAB_HW_REGNUM)) + if ((insn & 0xff00ffff) == (0x5e000100 | RAB_HW_REGNUM)) { p += 4; } - done: +done: if (msymbol != NULL) { if (mi == 0) { /* Add a new cache entry. */ - mi = (struct prologue_info *)xmalloc (sizeof (struct prologue_info)); - msymbol -> info = (char *)mi; + mi = (struct prologue_info *) xmalloc (sizeof (struct prologue_info)); + msymbol->info = (char *) mi; mi->rsize_valid = 0; mi->msize_valid = 0; mi->mfp_valid = 0; @@ -353,7 +354,7 @@ a29k_skip_prologue (pc) * msize is return in bytes. */ -static int /* 0/1 - failure/success of finding the tag word */ +static int /* 0/1 - failure/success of finding the tag word */ examine_tag (p, is_trans, argcount, msize, mfp_used) CORE_ADDR p; int *is_trans; @@ -366,19 +367,20 @@ examine_tag (p, is_trans, argcount, msize, mfp_used) tag1 = read_memory_integer (p, 4); if ((tag1 & TAGWORD_ZERO_MASK) != 0) /* Not a tag word */ return 0; - if (tag1 & (1<<23)) /* A two word tag */ + if (tag1 & (1 << 23)) /* A two word tag */ { - tag2 = read_memory_integer (p-4, 4); - if (msize) - *msize = tag2 * 2; + tag2 = read_memory_integer (p - 4, 4); + if (msize) + *msize = tag2 * 2; } - else /* A one word tag */ + else + /* A one word tag */ { - if (msize) - *msize = tag1 & 0x7ff; + if (msize) + *msize = tag1 & 0x7ff; } if (is_trans) - *is_trans = ((tag1 & (1<<21)) ? 1 : 0); + *is_trans = ((tag1 & (1 << 21)) ? 1 : 0); /* Note that this includes the frame pointer and the return address register, so the actual number of registers of arguments is two less. argcount can be zero, however, sometimes, for strange assembler @@ -386,7 +388,7 @@ examine_tag (p, is_trans, argcount, msize, mfp_used) if (argcount) *argcount = (tag1 >> 16) & 0x1f; if (mfp_used) - *mfp_used = ((tag1 & (1<<22)) ? 1 : 0); + *mfp_used = ((tag1 & (1 << 22)) ? 1 : 0); return 1; } @@ -413,8 +415,8 @@ init_frame_info (innermost_frame, frame) frame->frame = read_register (GR1_REGNUM); else frame->frame = frame->next->frame + frame->next->rsize; - -#if 0 /* CALL_DUMMY_LOCATION == ON_STACK */ + +#if 0 /* CALL_DUMMY_LOCATION == ON_STACK */ This wont work; #else if (PC_IN_CALL_DUMMY (p, 0, 0)) @@ -422,34 +424,35 @@ init_frame_info (innermost_frame, frame) { frame->rsize = DUMMY_FRAME_RSIZE; /* This doesn't matter since we never try to get locals or args - from a dummy frame. */ + from a dummy frame. */ frame->msize = 0; /* Dummy frames always use a memory frame pointer. */ - frame->saved_msp = + frame->saved_msp = read_register_stack_integer (frame->frame + DUMMY_FRAME_RSIZE - 4, 4); - frame->flags |= (TRANSPARENT_FRAME|MFP_USED); + frame->flags |= (TRANSPARENT_FRAME | MFP_USED); return; } - + func = find_pc_function (p); if (func != NULL) p = BLOCK_START (SYMBOL_BLOCK_VALUE (func)); else { /* Search backward to find the trace-back tag. However, - do not trace back beyond the start of the text segment - (just as a sanity check to avoid going into never-never land). */ + do not trace back beyond the start of the text segment + (just as a sanity check to avoid going into never-never land). */ #if 1 while (p >= text_start - && ((insn = read_memory_integer (p, 4)) & TAGWORD_ZERO_MASK) != 0) + && ((insn = read_memory_integer (p, 4)) & TAGWORD_ZERO_MASK) != 0) p -= 4; #else /* 0 */ - char pat[4] = {0, 0, 0, 0}; + char pat[4] = + {0, 0, 0, 0}; char mask[4]; char insn_raw[4]; store_unsigned_integer (mask, 4, TAGWORD_ZERO_MASK); /* Enable this once target_search is enabled and tested. */ - target_search (4, pat, mask, p, -4, text_start, p+1, &p, &insn_raw); + target_search (4, pat, mask, p, -4, text_start, p + 1, &p, &insn_raw); insn = extract_unsigned_integer (insn_raw, 4); #endif /* 0 */ @@ -475,18 +478,18 @@ init_frame_info (innermost_frame, frame) If one doesn't exist, try using a more exhaustive search of the prologue. */ - if (examine_tag(p-4,&trans,(int *)NULL,&msize,&mfp_used)) /* Found good tag */ - examine_prologue (p, &rsize, 0, 0); - else /* No tag try prologue */ - examine_prologue (p, &rsize, &msize, &mfp_used); + if (examine_tag (p - 4, &trans, (int *) NULL, &msize, &mfp_used)) /* Found good tag */ + examine_prologue (p, &rsize, 0, 0); + else /* No tag try prologue */ + examine_prologue (p, &rsize, &msize, &mfp_used); frame->rsize = rsize; frame->msize = msize; frame->flags = 0; if (mfp_used) - frame->flags |= MFP_USED; + frame->flags |= MFP_USED; if (trans) - frame->flags |= TRANSPARENT_FRAME; + frame->flags |= TRANSPARENT_FRAME; if (innermost_frame) { frame->saved_msp = read_register (MSP_REGNUM) + msize; @@ -494,10 +497,10 @@ init_frame_info (innermost_frame, frame) else { if (mfp_used) - frame->saved_msp = - read_register_stack_integer (frame->frame + rsize - 4, 4); + frame->saved_msp = + read_register_stack_integer (frame->frame + rsize - 4, 4); else - frame->saved_msp = frame->next->saved_msp + msize; + frame->saved_msp = frame->next->saved_msp + msize; } } @@ -509,7 +512,8 @@ init_extra_frame_info (frame) /* Assume innermost frame. May produce strange results for "info frame" but there isn't any way to tell the difference. */ init_frame_info (1, frame); - else { + else + { /* We're in get_prev_frame. Take care of everything in init_frame_pc. */ ; @@ -522,7 +526,7 @@ init_frame_pc (fromleaf, frame) struct frame_info *frame; { frame->pc = (fromleaf ? SAVED_PC_AFTER_CALL (frame->next) : - frame->next ? FRAME_SAVED_PC (frame->next) : read_pc ()); + frame->next ? FRAME_SAVED_PC (frame->next) : read_pc ()); init_frame_info (fromleaf, frame); } @@ -534,7 +538,7 @@ CORE_ADDR frame_locals_address (fi) struct frame_info *fi; { - if (fi->flags & MFP_USED) + if (fi->flags & MFP_USED) return fi->saved_msp; else return fi->saved_msp - fi->msize; @@ -562,10 +566,11 @@ read_register_stack (memaddr, myaddr, actual_mem_addr, lval) long rsp = read_register (RSP_REGNUM); /* If we don't do this 'info register' stops in the middle. */ - if (memaddr >= rstack_high_address) + if (memaddr >= rstack_high_address) { /* a bogus value */ - static char val[] = {~0, ~0, ~0, ~0}; + static char val[] = + {~0, ~0, ~0, ~0}; /* It's in a local register, but off the end of the stack. */ int regnum = (memaddr - rsp) / 4 + LR0_REGNUM; if (myaddr != NULL) @@ -573,7 +578,7 @@ read_register_stack (memaddr, myaddr, actual_mem_addr, lval) /* Provide bogusness */ memcpy (myaddr, val, 4); } - supply_register(regnum, val); /* More bogusness */ + supply_register (regnum, val); /* More bogusness */ if (lval != NULL) *lval = lval_register; if (actual_mem_addr != NULL) @@ -599,7 +604,7 @@ read_register_stack (memaddr, myaddr, actual_mem_addr, lval) else { /* It's in the memory portion of the register stack. */ - if (myaddr != NULL) + if (myaddr != NULL) read_memory (memaddr, myaddr, 4); if (lval != NULL) *lval = lval_memory; @@ -632,11 +637,11 @@ write_register_stack (memaddr, myaddr, actual_mem_addr) long rfb = read_register (RFB_REGNUM); long rsp = read_register (RSP_REGNUM); /* If we don't do this 'info register' stops in the middle. */ - if (memaddr >= rstack_high_address) + if (memaddr >= rstack_high_address) { /* It's in a register, but off the end of the stack. */ if (actual_mem_addr != NULL) - *actual_mem_addr = 0; + *actual_mem_addr = 0; } else if (memaddr < rfb) { @@ -645,7 +650,7 @@ write_register_stack (memaddr, myaddr, actual_mem_addr) if (regnum < LR0_REGNUM || regnum > LR0_REGNUM + 127) error ("Attempt to read register stack out of range."); if (myaddr != NULL) - write_register (regnum, *(long *)myaddr); + write_register (regnum, *(long *) myaddr); if (actual_mem_addr != NULL) *actual_mem_addr = 0; } @@ -733,7 +738,7 @@ a29k_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lvalp) else if (regnum < LR0_REGNUM || regnum >= LR0_REGNUM + 128) { /* These registers are not saved over procedure calls, - so just print out the current values. */ + so just print out the current values. */ if (raw_buffer != NULL) read_register_gen (regnum, raw_buffer); if (lvalp != NULL) @@ -742,7 +747,7 @@ a29k_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lvalp) *addrp = REGISTER_BYTE (regnum); return; } - + addr = frame->frame + (regnum - LR0_REGNUM) * 4; if (raw_buffer != NULL) read_register_stack (addr, raw_buffer, &addr, &lval); @@ -760,9 +765,9 @@ void pop_frame () { struct frame_info *frame = get_current_frame (); - CORE_ADDR rfb = read_register (RFB_REGNUM); + CORE_ADDR rfb = read_register (RFB_REGNUM); CORE_ADDR gr1 = frame->frame + frame->rsize; - CORE_ADDR lr1; + CORE_ADDR lr1; CORE_ADDR original_lr0; int must_fix_lr0 = 0; int i; @@ -772,54 +777,54 @@ pop_frame () read_register (SP_REGNUM), FRAME_FP (frame))) { - int lrnum = LR0_REGNUM + DUMMY_ARG/4; + int lrnum = LR0_REGNUM + DUMMY_ARG / 4; for (i = 0; i < DUMMY_SAVE_SR128; ++i) - write_register (SR_REGNUM (i + 128),read_register (lrnum++)); + write_register (SR_REGNUM (i + 128), read_register (lrnum++)); for (i = 0; i < DUMMY_SAVE_SR160; ++i) - write_register (SR_REGNUM(i+160), read_register (lrnum++)); + write_register (SR_REGNUM (i + 160), read_register (lrnum++)); for (i = 0; i < DUMMY_SAVE_GREGS; ++i) write_register (RETURN_REGNUM + i, read_register (lrnum++)); /* Restore the PCs and prepare to restore LR0. */ - write_register(PC_REGNUM, read_register (lrnum++)); - write_register(NPC_REGNUM, read_register (lrnum++)); - write_register(PC2_REGNUM, read_register (lrnum++)); + write_register (PC_REGNUM, read_register (lrnum++)); + write_register (NPC_REGNUM, read_register (lrnum++)); + write_register (PC2_REGNUM, read_register (lrnum++)); original_lr0 = read_register (lrnum++); must_fix_lr0 = 1; } /* Restore the memory stack pointer. */ write_register (MSP_REGNUM, frame->saved_msp); - /* Restore the register stack pointer. */ + /* Restore the register stack pointer. */ write_register (GR1_REGNUM, gr1); /* If we popped a dummy frame, restore lr0 now that gr1 has been restored. */ - if (must_fix_lr0) + if (must_fix_lr0) write_register (LR0_REGNUM, original_lr0); - /* Check whether we need to fill registers. */ - lr1 = read_register (LR0_REGNUM + 1); - if (lr1 > rfb) - { - /* Fill. */ + /* Check whether we need to fill registers. */ + lr1 = read_register (LR0_REGNUM + 1); + if (lr1 > rfb) + { + /* Fill. */ int num_bytes = lr1 - rfb; - int i; + int i; long word; - - write_register (RAB_REGNUM, read_register (RAB_REGNUM) + num_bytes); - write_register (RFB_REGNUM, lr1); - for (i = 0; i < num_bytes; i += 4) - { + + write_register (RAB_REGNUM, read_register (RAB_REGNUM) + num_bytes); + write_register (RFB_REGNUM, lr1); + for (i = 0; i < num_bytes; i += 4) + { /* Note: word is in host byte order. */ - word = read_memory_integer (rfb + i, 4); - write_register (LR0_REGNUM + ((rfb - gr1) % 0x80) + i / 4, word); - } + word = read_memory_integer (rfb + i, 4); + write_register (LR0_REGNUM + ((rfb - gr1) % 0x80) + i / 4, word); + } } - flush_cached_frames (); + flush_cached_frames (); } /* Push an empty stack frame, to record the current PC, etc. */ -void +void push_dummy_frame () { long w; @@ -827,13 +832,13 @@ push_dummy_frame () CORE_ADDR msp = read_register (MSP_REGNUM); int lrnum, i; CORE_ADDR original_lr0; - + /* Read original lr0 before changing gr1. This order isn't really needed since GDB happens to have a snapshot of all the regs and doesn't toss it when gr1 is changed. But it's The Right Thing To Do. */ original_lr0 = read_register (LR0_REGNUM); - /* Allocate the new frame. */ + /* Allocate the new frame. */ gr1 = read_register (GR1_REGNUM) - DUMMY_FRAME_RSIZE; write_register (GR1_REGNUM, gr1); @@ -877,7 +882,7 @@ push_dummy_frame () write_register (MSP_REGNUM, msp - 16 * 4); /* Save registers. */ - lrnum = LR0_REGNUM + DUMMY_ARG/4; + lrnum = LR0_REGNUM + DUMMY_ARG / 4; for (i = 0; i < DUMMY_SAVE_SR128; ++i) write_register (lrnum++, read_register (SR_REGNUM (i + 128))); for (i = 0; i < DUMMY_SAVE_SR160; ++i) @@ -918,7 +923,7 @@ setup_arbitrary_frame (argc, argv) if (!frame) fatal ("internal: create_new_frame returned invalid frame id"); - + /* Creating a new frame munges the `frame' value from the current GR1, so we restore it again here. FIXME, untangle all this 29K frame stuff... */ @@ -991,25 +996,25 @@ a29k_get_processor_type () #ifdef GET_LONGJMP_TARGET /* Figure out where the longjmp will land. We expect that we have just entered - longjmp and haven't yet setup the stack frame, so the args are still in the + longjmp and haven't yet setup the stack frame, so the args are still in the output regs. lr2 (LR2_REGNUM) points at the jmp_buf structure from which we extract the pc (JB_PC) that we will land at. The pc is copied into ADDR. This routine returns true on success */ int -get_longjmp_target(pc) +get_longjmp_target (pc) CORE_ADDR *pc; { CORE_ADDR jb_addr; - char buf[sizeof(CORE_ADDR)]; + char buf[sizeof (CORE_ADDR)]; - jb_addr = read_register(LR2_REGNUM); + jb_addr = read_register (LR2_REGNUM); - if (target_read_memory(jb_addr + JB_PC * JB_ELEMENT_SIZE, (char *) buf, - sizeof(CORE_ADDR))) + if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, (char *) buf, + sizeof (CORE_ADDR))) return 0; - *pc = extract_address ((PTR) buf, sizeof(CORE_ADDR)); + *pc = extract_address ((PTR) buf, sizeof (CORE_ADDR)); return 1; } #endif /* GET_LONGJMP_TARGET */ @@ -1024,7 +1029,7 @@ _initialize_a29k_tdep () /* FIXME, there should be a way to make a CORE_ADDR variable settable. */ add_show_from_set (add_set_cmd ("rstack_high_address", class_support, var_uinteger, - (char *)&rstack_high_address, + (char *) &rstack_high_address, "Set top address in memory of the register stack.\n\ Attempts to access registers saved above this address will be ignored\n\ or will produce the value -1.", &setlist), @@ -1033,8 +1038,8 @@ or will produce the value -1.", &setlist), /* FIXME, there should be a way to make a CORE_ADDR variable settable. */ add_show_from_set (add_set_cmd ("call_scratch_address", class_support, var_uinteger, - (char *)&text_end, -"Set address in memory where small amounts of RAM can be used\n\ + (char *) &text_end, + "Set address in memory where small amounts of RAM can be used\n\ when making function calls into the inferior.", &setlist), &showlist); } diff --git a/gdb/a68v-nat.c b/gdb/a68v-nat.c index deb9247..3b4c271 100644 --- a/gdb/a68v-nat.c +++ b/gdb/a68v-nat.c @@ -1,21 +1,22 @@ /* Host-dependent code for Apollo-68ks for GDB, the GNU debugger. Copyright 1986, 1987, 1989, 1991 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "inferior.h" @@ -30,40 +31,40 @@ extern int errno; void fetch_inferior_registers (ignored) - int ignored; + int ignored; { struct ptrace_$data_regs_m68k inferior_registers; struct ptrace_$floating_regs_m68k inferior_fp_registers; struct ptrace_$control_regs_m68k inferior_control_registers; - ptrace_$init_control(&inferior_control_registers); - inferior_fp_registers.size = sizeof(inferior_fp_registers); + ptrace_$init_control (&inferior_control_registers); + inferior_fp_registers.size = sizeof (inferior_fp_registers); registers_fetched (); - + ptrace (PTRACE_GETREGS, inferior_pid, - (PTRACE_ARG3_TYPE) &inferior_registers, + (PTRACE_ARG3_TYPE) & inferior_registers, ptrace_$data_set, - (PTRACE_ARG3_TYPE) &inferior_registers, + (PTRACE_ARG3_TYPE) & inferior_registers, ptrace_$data_set); ptrace (PTRACE_GETREGS, inferior_pid, - (PTRACE_ARG3_TYPE) &inferior_fp_registers, - ptrace_$floating_set_m68k, - (PTRACE_ARG3_TYPE) &inferior_fp_registers, - ptrace_$floating_set_m68k); + (PTRACE_ARG3_TYPE) & inferior_fp_registers, + ptrace_$floating_set_m68k, + (PTRACE_ARG3_TYPE) & inferior_fp_registers, + ptrace_$floating_set_m68k); ptrace (PTRACE_GETREGS, inferior_pid, - (PTRACE_ARG3_TYPE) &inferior_control_registers, - ptrace_$control_set_m68k, - (PTRACE_ARG3_TYPE) &inferior_control_registers, - ptrace_$control_set_m68k); + (PTRACE_ARG3_TYPE) & inferior_control_registers, + ptrace_$control_set_m68k, + (PTRACE_ARG3_TYPE) & inferior_control_registers, + ptrace_$control_set_m68k); bcopy (&inferior_registers, registers, 16 * 4); bcopy (&inferior_fp_registers, ®isters[REGISTER_BYTE (FP0_REGNUM)], sizeof inferior_fp_registers.regs); - *(int *)®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_control_registers.sr; - *(int *)®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_control_registers.pc; + *(int *) ®isters[REGISTER_BYTE (PS_REGNUM)] = inferior_control_registers.sr; + *(int *) ®isters[REGISTER_BYTE (PC_REGNUM)] = inferior_control_registers.pc; } /* Store our register values back into the inferior. @@ -78,44 +79,44 @@ store_inferior_registers (regno) struct ptrace_$floating_regs_m68k inferior_fp_registers; struct ptrace_$control_regs_m68k inferior_control_registers; - ptrace_$init_control(&inferior_control_registers); - inferior_fp_registers.size = sizeof(inferior_fp_registers); + ptrace_$init_control (&inferior_control_registers); + inferior_fp_registers.size = sizeof (inferior_fp_registers); ptrace (PTRACE_GETREGS, inferior_pid, - (PTRACE_ARG3_TYPE) &inferior_fp_registers, - ptrace_$floating_set_m68k, - (PTRACE_ARG3_TYPE) &inferior_fp_registers, - ptrace_$floating_set_m68k); + (PTRACE_ARG3_TYPE) & inferior_fp_registers, + ptrace_$floating_set_m68k, + (PTRACE_ARG3_TYPE) & inferior_fp_registers, + ptrace_$floating_set_m68k); ptrace (PTRACE_GETREGS, inferior_pid, - (PTRACE_ARG3_TYPE) &inferior_control_registers, - ptrace_$control_set_m68k, - (PTRACE_ARG3_TYPE) &inferior_control_registers, - ptrace_$control_set_m68k); + (PTRACE_ARG3_TYPE) & inferior_control_registers, + ptrace_$control_set_m68k, + (PTRACE_ARG3_TYPE) & inferior_control_registers, + ptrace_$control_set_m68k); - bcopy (registers, &inferior_registers, sizeof(inferior_registers)); + bcopy (registers, &inferior_registers, sizeof (inferior_registers)); bcopy (®isters[REGISTER_BYTE (FP0_REGNUM)], inferior_fp_registers.regs, sizeof inferior_fp_registers.regs); - inferior_control_registers.sr = *(int *)®isters[REGISTER_BYTE (PS_REGNUM)]; - inferior_control_registers.pc = *(int *)®isters[REGISTER_BYTE (PC_REGNUM)]; + inferior_control_registers.sr = *(int *) ®isters[REGISTER_BYTE (PS_REGNUM)]; + inferior_control_registers.pc = *(int *) ®isters[REGISTER_BYTE (PC_REGNUM)]; ptrace (PTRACE_SETREGS, inferior_pid, - (PTRACE_ARG3_TYPE) &inferior_registers, + (PTRACE_ARG3_TYPE) & inferior_registers, ptrace_$data_set_m68k, - (PTRACE_ARG3_TYPE) &inferior_registers, + (PTRACE_ARG3_TYPE) & inferior_registers, ptrace_$data_set_m68k); ptrace (PTRACE_SETREGS, inferior_pid, - (PTRACE_ARG3_TYPE) &inferior_fp_registers, + (PTRACE_ARG3_TYPE) & inferior_fp_registers, ptrace_$floating_set_m68k, - (PTRACE_ARG3_TYPE) &inferior_fp_registers, + (PTRACE_ARG3_TYPE) & inferior_fp_registers, ptrace_$floating_set_m68k); ptrace (PTRACE_SETREGS, inferior_pid, - (PTRACE_ARG3_TYPE) &inferior_control_registers, + (PTRACE_ARG3_TYPE) & inferior_control_registers, ptrace_$control_set_m68k, - (PTRACE_ARG3_TYPE) &inferior_control_registers, + (PTRACE_ARG3_TYPE) & inferior_control_registers, ptrace_$control_set_m68k); } diff --git a/gdb/abug-rom.c b/gdb/abug-rom.c index 97ff0f8..e1bd628 100644 --- a/gdb/abug-rom.c +++ b/gdb/abug-rom.c @@ -3,21 +3,22 @@ Written by Rob Savoye of Cygnus Support -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "gdbcore.h" @@ -92,61 +93,62 @@ static char *abug_regnames[NUM_REGS] = static struct target_ops abug_ops; -static char *abug_inits[] = {"\r", NULL}; +static char *abug_inits[] = +{"\r", NULL}; -static struct monitor_ops abug_cmds ; +static struct monitor_ops abug_cmds; -static void -init_abug_cmds(void) +static void +init_abug_cmds (void) { - abug_cmds.flags = MO_CLR_BREAK_USES_ADDR; - abug_cmds.init = abug_inits; /* Init strings */ - abug_cmds.cont = "g\r"; /* continue command */ - abug_cmds.step = "t\r"; /* single step */ - abug_cmds.stop = NULL; /* interrupt command */ - abug_cmds.set_break = "br %x\r"; /* set a breakpoint */ - abug_cmds.clr_break = "nobr %x\r"; /* clear a breakpoint */ - abug_cmds.clr_all_break = "nobr\r"; /* clear all breakpoints */ - abug_cmds.fill = "bf %x:%x %x;b\r"; /* fill (start count val) */ - abug_cmds.setmem.cmdb = "ms %x %02x\r"; /* setmem.cmdb (addr, value) */ - abug_cmds.setmem.cmdw = "ms %x %04x\r"; /* setmem.cmdw (addr, value) */ - abug_cmds.setmem.cmdl = "ms %x %08x\r"; /* setmem.cmdl (addr, value) */ - abug_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */ - abug_cmds.setmem.resp_delim = NULL; /* setreg.resp_delim */ - abug_cmds.setmem.term = NULL; /* setreg.term */ - abug_cmds.setmem.term_cmd = NULL; /* setreg.term_cmd */ - abug_cmds.getmem.cmdb = "md %x:%x;b\r"; /* getmem.cmdb (addr, len) */ - abug_cmds.getmem.cmdw = "md %x:%x;b\r"; /* getmem.cmdw (addr, len) */ - abug_cmds.getmem.cmdl = "md %x:%x;b\r"; /* getmem.cmdl (addr, len) */ - abug_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, len) */ - abug_cmds.getmem.resp_delim = " "; /* getmem.resp_delim */ - abug_cmds.getmem.term = NULL; /* getmem.term */ - abug_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */ - abug_cmds.setreg.cmd = "rm %s %x\r"; /* setreg.cmd (name, value) */ - abug_cmds.setreg.resp_delim = "="; /* setreg.resp_delim */ - abug_cmds.setreg.term = "? "; /* setreg.term */ - abug_cmds.setreg.term_cmd = ".\r" ; /* setreg.term_cmd */ - abug_cmds.getreg.cmd = "rm %s\r"; /* getreg.cmd (name) */ - abug_cmds.getreg.resp_delim = "="; /* getreg.resp_delim */ - abug_cmds.getreg.term = "? "; /* getreg.term */ - abug_cmds.getreg.term_cmd = ".\r" ; /* getreg.term_cmd */ - abug_cmds.dump_registers = "rd\r"; /* dump_registers */ - abug_cmds.register_pattern = "\\(\\w+\\) +=\\([0-9a-fA-F]+\\b\\)"; /* register_pattern */ - abug_cmds.supply_register = abug_supply_register; /* supply_register */ - abug_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */ - abug_cmds.load = "lo 0\r"; /* download command */ - abug_cmds.loadresp = "\n"; /* load response */ - abug_cmds.prompt = "135Bug>"; /* monitor command prompt */ - abug_cmds.line_term = "\r"; /* end-of-line terminator */ - abug_cmds.cmd_end = NULL; /* optional command terminator */ - abug_cmds.target = &abug_ops; /* target operations */ - abug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ - abug_cmds.regnames = abug_regnames; /* registers names */ - abug_cmds.magic = MONITOR_OPS_MAGIC ; /* magic */ -}; + abug_cmds.flags = MO_CLR_BREAK_USES_ADDR; + abug_cmds.init = abug_inits; /* Init strings */ + abug_cmds.cont = "g\r"; /* continue command */ + abug_cmds.step = "t\r"; /* single step */ + abug_cmds.stop = NULL; /* interrupt command */ + abug_cmds.set_break = "br %x\r"; /* set a breakpoint */ + abug_cmds.clr_break = "nobr %x\r"; /* clear a breakpoint */ + abug_cmds.clr_all_break = "nobr\r"; /* clear all breakpoints */ + abug_cmds.fill = "bf %x:%x %x;b\r"; /* fill (start count val) */ + abug_cmds.setmem.cmdb = "ms %x %02x\r"; /* setmem.cmdb (addr, value) */ + abug_cmds.setmem.cmdw = "ms %x %04x\r"; /* setmem.cmdw (addr, value) */ + abug_cmds.setmem.cmdl = "ms %x %08x\r"; /* setmem.cmdl (addr, value) */ + abug_cmds.setmem.cmdll = NULL; /* setmem.cmdll (addr, value) */ + abug_cmds.setmem.resp_delim = NULL; /* setreg.resp_delim */ + abug_cmds.setmem.term = NULL; /* setreg.term */ + abug_cmds.setmem.term_cmd = NULL; /* setreg.term_cmd */ + abug_cmds.getmem.cmdb = "md %x:%x;b\r"; /* getmem.cmdb (addr, len) */ + abug_cmds.getmem.cmdw = "md %x:%x;b\r"; /* getmem.cmdw (addr, len) */ + abug_cmds.getmem.cmdl = "md %x:%x;b\r"; /* getmem.cmdl (addr, len) */ + abug_cmds.getmem.cmdll = NULL; /* getmem.cmdll (addr, len) */ + abug_cmds.getmem.resp_delim = " "; /* getmem.resp_delim */ + abug_cmds.getmem.term = NULL; /* getmem.term */ + abug_cmds.getmem.term_cmd = NULL; /* getmem.term_cmd */ + abug_cmds.setreg.cmd = "rm %s %x\r"; /* setreg.cmd (name, value) */ + abug_cmds.setreg.resp_delim = "="; /* setreg.resp_delim */ + abug_cmds.setreg.term = "? "; /* setreg.term */ + abug_cmds.setreg.term_cmd = ".\r"; /* setreg.term_cmd */ + abug_cmds.getreg.cmd = "rm %s\r"; /* getreg.cmd (name) */ + abug_cmds.getreg.resp_delim = "="; /* getreg.resp_delim */ + abug_cmds.getreg.term = "? "; /* getreg.term */ + abug_cmds.getreg.term_cmd = ".\r"; /* getreg.term_cmd */ + abug_cmds.dump_registers = "rd\r"; /* dump_registers */ + abug_cmds.register_pattern = "\\(\\w+\\) +=\\([0-9a-fA-F]+\\b\\)"; /* register_pattern */ + abug_cmds.supply_register = abug_supply_register; /* supply_register */ + abug_cmds.load_routine = NULL; /* load_routine (defaults to SRECs) */ + abug_cmds.load = "lo 0\r"; /* download command */ + abug_cmds.loadresp = "\n"; /* load response */ + abug_cmds.prompt = "135Bug>"; /* monitor command prompt */ + abug_cmds.line_term = "\r"; /* end-of-line terminator */ + abug_cmds.cmd_end = NULL; /* optional command terminator */ + abug_cmds.target = &abug_ops; /* target operations */ + abug_cmds.stopbits = SERIAL_1_STOPBITS; /* number of stop bits */ + abug_cmds.regnames = abug_regnames; /* registers names */ + abug_cmds.magic = MONITOR_OPS_MAGIC; /* magic */ +}; static void -abug_open(args, from_tty) +abug_open (args, from_tty) char *args; int from_tty; { @@ -156,7 +158,7 @@ abug_open(args, from_tty) void _initialize_abug_rom () { - init_abug_cmds() ; + init_abug_cmds (); init_monitor_ops (&abug_ops); abug_ops.to_shortname = "abug"; diff --git a/gdb/alpha-nat.c b/gdb/alpha-nat.c index 59bd0d8..ebeb9bb 100644 --- a/gdb/alpha-nat.c +++ b/gdb/alpha-nat.c @@ -1,21 +1,22 @@ /* Low level Alpha interface, for GDB when running native. Copyright 1993, 1995, 1996, 1998 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "inferior.h" @@ -23,10 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "target.h" #include #ifdef __linux__ -# include -# include +#include +#include #else -# include +#include #endif #include @@ -62,13 +63,13 @@ get_longjmp_target (pc) CORE_ADDR jb_addr; char raw_buffer[MAX_REGISTER_RAW_SIZE]; - jb_addr = read_register(A0_REGNUM); + jb_addr = read_register (A0_REGNUM); - if (target_read_memory(jb_addr + JB_PC * JB_ELEMENT_SIZE, raw_buffer, - sizeof(CORE_ADDR))) + if (target_read_memory (jb_addr + JB_PC * JB_ELEMENT_SIZE, raw_buffer, + sizeof (CORE_ADDR))) return 0; - *pc = extract_address (raw_buffer, sizeof(CORE_ADDR)); + *pc = extract_address (raw_buffer, sizeof (CORE_ADDR)); return 1; } @@ -78,11 +79,11 @@ get_longjmp_target (pc) CORE_REG_SECT points to the register values themselves, read into memory. CORE_REG_SIZE is the size of that area. WHICH says which set of registers we are handling (0 = int, 2 = float - on machines where they are discontiguous). + on machines where they are discontiguous). REG_ADDR is the offset from u.u_ar0 to the register values relative to - core_reg_sect. This is used with old-fashioned core files to - locate the registers in a large upage-plus-stack ".reg" section. - Original upage address X is at location core_reg_sect+x+reg_addr. + core_reg_sect. This is used with old-fashioned core files to + locate the registers in a large upage-plus-stack ".reg" section. + Original upage address X is at location core_reg_sect+x+reg_addr. */ static void @@ -101,17 +102,18 @@ fetch_osf_core_registers (core_reg_sect, core_reg_size, which, reg_addr) static int core_reg_mapping[NUM_REGS] = { #define EFL (EF_SIZE / 8) - EF_V0, EF_T0, EF_T1, EF_T2, EF_T3, EF_T4, EF_T5, EF_T6, - EF_T7, EF_S0, EF_S1, EF_S2, EF_S3, EF_S4, EF_S5, EF_S6, - EF_A0, EF_A1, EF_A2, EF_A3, EF_A4, EF_A5, EF_T8, EF_T9, - EF_T10, EF_T11, EF_RA, EF_T12, EF_AT, EF_GP, EF_SP, -1, - EFL+0, EFL+1, EFL+2, EFL+3, EFL+4, EFL+5, EFL+6, EFL+7, - EFL+8, EFL+9, EFL+10, EFL+11, EFL+12, EFL+13, EFL+14, EFL+15, - EFL+16, EFL+17, EFL+18, EFL+19, EFL+20, EFL+21, EFL+22, EFL+23, - EFL+24, EFL+25, EFL+26, EFL+27, EFL+28, EFL+29, EFL+30, EFL+31, - EF_PC, -1 + EF_V0, EF_T0, EF_T1, EF_T2, EF_T3, EF_T4, EF_T5, EF_T6, + EF_T7, EF_S0, EF_S1, EF_S2, EF_S3, EF_S4, EF_S5, EF_S6, + EF_A0, EF_A1, EF_A2, EF_A3, EF_A4, EF_A5, EF_T8, EF_T9, + EF_T10, EF_T11, EF_RA, EF_T12, EF_AT, EF_GP, EF_SP, -1, + EFL + 0, EFL + 1, EFL + 2, EFL + 3, EFL + 4, EFL + 5, EFL + 6, EFL + 7, + EFL + 8, EFL + 9, EFL + 10, EFL + 11, EFL + 12, EFL + 13, EFL + 14, EFL + 15, + EFL + 16, EFL + 17, EFL + 18, EFL + 19, EFL + 20, EFL + 21, EFL + 22, EFL + 23, + EFL + 24, EFL + 25, EFL + 26, EFL + 27, EFL + 28, EFL + 29, EFL + 30, EFL + 31, + EF_PC, -1 }; - static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0}; + static char zerobuf[MAX_REGISTER_RAW_SIZE] = + {0}; for (regno = 0; regno < NUM_REGS; regno++) { @@ -144,7 +146,7 @@ fetch_elf_core_registers (core_reg_sect, core_reg_size, which, reg_addr) int which; CORE_ADDR reg_addr; { - if (core_reg_size < 32*8) + if (core_reg_size < 32 * 8) { error ("Core file register section too small (%u bytes).", core_reg_size); return; @@ -153,15 +155,15 @@ fetch_elf_core_registers (core_reg_sect, core_reg_size, which, reg_addr) if (which == 2) { /* The FPU Registers. */ - memcpy (®isters[REGISTER_BYTE (FP0_REGNUM)], core_reg_sect, 31*8); - memset (®isters[REGISTER_BYTE (FP0_REGNUM+31)], 0, 8); + memcpy (®isters[REGISTER_BYTE (FP0_REGNUM)], core_reg_sect, 31 * 8); + memset (®isters[REGISTER_BYTE (FP0_REGNUM + 31)], 0, 8); memset (®ister_valid[FP0_REGNUM], 1, 32); } else { /* The General Registers. */ - memcpy (®isters[REGISTER_BYTE (V0_REGNUM)], core_reg_sect, 31*8); - memcpy (®isters[REGISTER_BYTE (PC_REGNUM)], core_reg_sect+31*8, 8); + memcpy (®isters[REGISTER_BYTE (V0_REGNUM)], core_reg_sect, 31 * 8); + memcpy (®isters[REGISTER_BYTE (PC_REGNUM)], core_reg_sect + 31 * 8, 8); memset (®isters[REGISTER_BYTE (ZERO_REGNUM)], 0, 8); memset (®ister_valid[V0_REGNUM], 1, 32); register_valid[PC_REGNUM] = 1; @@ -201,18 +203,19 @@ kernel_u_size () * See the comment in m68k-tdep.c regarding the utility of these functions. */ -void +void supply_gregset (gregsetp) gregset_t *gregsetp; { register int regi; register long *regp = ALPHA_REGSET_BASE (gregsetp); - static char zerobuf[MAX_REGISTER_RAW_SIZE] = {0}; + static char zerobuf[MAX_REGISTER_RAW_SIZE] = + {0}; for (regi = 0; regi < 31; regi++) - supply_register (regi, (char *)(regp + regi)); + supply_register (regi, (char *) (regp + regi)); - supply_register (PC_REGNUM, (char *)(regp + 31)); + supply_register (PC_REGNUM, (char *) (regp + 31)); /* Fill inaccessible registers with zero. */ supply_register (ZERO_REGNUM, zerobuf); @@ -248,7 +251,7 @@ supply_fpregset (fpregsetp) register long *regp = ALPHA_REGSET_BASE (fpregsetp); for (regi = 0; regi < 32; regi++) - supply_register (regi + FP0_REGNUM, (char *)(regp + regi)); + supply_register (regi + FP0_REGNUM, (char *) (regp + regi)); } void @@ -269,8 +272,8 @@ fill_fpregset (fpregsetp, regno) } } #endif - + /* Register that we are able to handle alpha core file formats. */ static struct core_fns alpha_osf_core_fns = diff --git a/gdb/alpha-tdep.c b/gdb/alpha-tdep.c index 7d851d9..664b131 100644 --- a/gdb/alpha-tdep.c +++ b/gdb/alpha-tdep.c @@ -1,21 +1,22 @@ /* Target-dependent code for the ALPHA architecture, for GDB, the GNU Debugger. Copyright 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "frame.h" @@ -41,7 +42,7 @@ static CORE_ADDR heuristic_proc_start PARAMS ((CORE_ADDR)); static alpha_extra_func_info_t heuristic_proc_desc PARAMS ((CORE_ADDR, CORE_ADDR, - struct frame_info *)); + struct frame_info *)); static alpha_extra_func_info_t find_proc_desc PARAMS ((CORE_ADDR, struct frame_info *)); @@ -57,7 +58,7 @@ static CORE_ADDR after_prologue PARAMS ((CORE_ADDR pc, alpha_extra_func_info_t proc_desc)); static int alpha_in_prologue PARAMS ((CORE_ADDR pc, - alpha_extra_func_info_t proc_desc)); + alpha_extra_func_info_t proc_desc)); static int alpha_about_to_return PARAMS ((CORE_ADDR pc)); @@ -67,7 +68,7 @@ void _initialize_alpha_tdep PARAMS ((void)); time across a 2400 baud serial line. Allows the user to limit this search. */ static unsigned int heuristic_fence_post = 0; - +/* *INDENT-OFF* */ /* Layout of a stack frame on the alpha: | | @@ -110,13 +111,16 @@ static unsigned int heuristic_fence_post = 0; -------------|-------------------------------|<-- sp | | */ +/* *INDENT-ON* */ + + -#define PROC_LOW_ADDR(proc) ((proc)->pdr.adr) /* least address */ +#define PROC_LOW_ADDR(proc) ((proc)->pdr.adr) /* least address */ /* These next two fields are kind of being hijacked. I wonder if iline is too small for the values it needs to hold, if GDB is running on a 32-bit host. */ -#define PROC_HIGH_ADDR(proc) ((proc)->pdr.iline) /* upper address bound */ -#define PROC_DUMMY_FRAME(proc) ((proc)->pdr.cbLineOffset) /*CALL_DUMMY frame */ +#define PROC_HIGH_ADDR(proc) ((proc)->pdr.iline) /* upper address bound */ +#define PROC_DUMMY_FRAME(proc) ((proc)->pdr.cbLineOffset) /*CALL_DUMMY frame */ #define PROC_FRAME_OFFSET(proc) ((proc)->pdr.frameoffset) #define PROC_FRAME_REG(proc) ((proc)->pdr.framereg) #define PROC_REG_MASK(proc) ((proc)->pdr.regmask) @@ -131,21 +135,22 @@ static unsigned int heuristic_fence_post = 0; #define SET_PROC_DESC_IS_DUMMY(proc) ((proc)->pdr.isym = _PROC_MAGIC_) struct linked_proc_info -{ - struct alpha_extra_func_info info; - struct linked_proc_info *next; -} *linked_proc_desc_table = NULL; - + { + struct alpha_extra_func_info info; + struct linked_proc_info *next; + } + *linked_proc_desc_table = NULL; + /* Under GNU/Linux, signal handler invocations can be identified by the designated code sequence that is used to return from a signal handler. In particular, the return address of a signal handler points to the following sequence (the first instruction is quadword aligned): - bis $30,$30,$16 - addq $31,0x67,$0 - call_pal callsys + bis $30,$30,$16 + addq $31,0x67,$0 + call_pal callsys Each instruction has a unique encoding, so we simply attempt to match the instruction the pc is pointing to with any of the above @@ -159,7 +164,7 @@ struct linked_proc_info middle of the designated sequence, in which case there is no guarantee that we are in the middle of a sigreturn syscall. Don't think this will be a problem in praxis, though. -*/ + */ #ifndef TM_LINUXALPHA_H /* HACK: Provide a prototype when compiling this file for non @@ -173,16 +178,23 @@ alpha_linux_sigtramp_offset (pc) unsigned int i[3], w; long off; - if (read_memory_nobpt(pc, (char *) &w, 4) != 0) + if (read_memory_nobpt (pc, (char *) &w, 4) != 0) return -1; off = -1; switch (w) { - case 0x47de0410: off = 0; break; /* bis $30,$30,$16 */ - case 0x43ecf400: off = 4; break; /* addq $31,0x67,$0 */ - case 0x00000083: off = 8; break; /* call_pal callsys */ - default: return -1; + case 0x47de0410: + off = 0; + break; /* bis $30,$30,$16 */ + case 0x43ecf400: + off = 4; + break; /* addq $31,0x67,$0 */ + case 0x00000083: + off = 8; + break; /* call_pal callsys */ + default: + return -1; } pc -= off; if (pc & 0x7) @@ -191,7 +203,7 @@ alpha_linux_sigtramp_offset (pc) return -1; } - if (read_memory_nobpt(pc, (char *) i, sizeof(i)) != 0) + if (read_memory_nobpt (pc, (char *) i, sizeof (i)) != 0) return -1; if (i[0] == 0x47de0410 && i[1] == 0x43ecf400 && i[2] == 0x00000083) @@ -199,8 +211,8 @@ alpha_linux_sigtramp_offset (pc) return -1; } - + /* Under OSF/1, the __sigtramp routine is frameless and has a frame size of zero, but we are able to backtrace through it. */ CORE_ADDR @@ -209,14 +221,14 @@ alpha_osf_skip_sigtramp_frame (frame, pc) CORE_ADDR pc; { char *name; - find_pc_partial_function (pc, &name, (CORE_ADDR *)NULL, (CORE_ADDR *)NULL); + find_pc_partial_function (pc, &name, (CORE_ADDR *) NULL, (CORE_ADDR *) NULL); if (IN_SIGTRAMP (pc, name)) return frame->frame; else return 0; } - + /* Dynamically create a signal-handler caller procedure descriptor for the signal-handler return code starting at address LOW_ADDR. The descriptor is added to the linked_proc_desc_table. */ @@ -236,20 +248,20 @@ push_sigtramp_desc (low_addr) proc_desc = &link->info; proc_desc->numargs = 0; - PROC_LOW_ADDR (proc_desc) = low_addr; - PROC_HIGH_ADDR (proc_desc) = low_addr + 3 * 4; - PROC_DUMMY_FRAME (proc_desc) = 0; - PROC_FRAME_OFFSET (proc_desc) = 0x298; /* sizeof(struct sigcontext_struct) */ - PROC_FRAME_REG (proc_desc) = SP_REGNUM; - PROC_REG_MASK (proc_desc) = 0xffff; - PROC_FREG_MASK (proc_desc) = 0xffff; - PROC_PC_REG (proc_desc) = 26; - PROC_LOCALOFF (proc_desc) = 0; + PROC_LOW_ADDR (proc_desc) = low_addr; + PROC_HIGH_ADDR (proc_desc) = low_addr + 3 * 4; + PROC_DUMMY_FRAME (proc_desc) = 0; + PROC_FRAME_OFFSET (proc_desc) = 0x298; /* sizeof(struct sigcontext_struct) */ + PROC_FRAME_REG (proc_desc) = SP_REGNUM; + PROC_REG_MASK (proc_desc) = 0xffff; + PROC_FREG_MASK (proc_desc) = 0xffff; + PROC_PC_REG (proc_desc) = 26; + PROC_LOCALOFF (proc_desc) = 0; SET_PROC_DESC_IS_DYN_SIGTRAMP (proc_desc); return (proc_desc); } - + /* Guaranteed to set frame->saved_regs to some values (it never leaves it NULL). */ @@ -282,13 +294,13 @@ alpha_find_saved_regs (frame) sigcontext_addr = SIGCONTEXT_ADDR (frame); for (ireg = 0; ireg < 32; ireg++) { - reg_position = sigcontext_addr + SIGFRAME_REGSAVE_OFF + ireg * 8; - frame->saved_regs[ireg] = reg_position; + reg_position = sigcontext_addr + SIGFRAME_REGSAVE_OFF + ireg * 8; + frame->saved_regs[ireg] = reg_position; } for (ireg = 0; ireg < 32; ireg++) { - reg_position = sigcontext_addr + SIGFRAME_FPREGSAVE_OFF + ireg * 8; - frame->saved_regs[FP0_REGNUM + ireg] = reg_position; + reg_position = sigcontext_addr + SIGFRAME_FPREGSAVE_OFF + ireg * 8; + frame->saved_regs[FP0_REGNUM + ireg] = reg_position; } frame->saved_regs[PC_REGNUM] = sigcontext_addr + SIGFRAME_PC_OFF; return; @@ -315,11 +327,11 @@ alpha_find_saved_regs (frame) { frame->saved_regs[returnreg] = reg_position; reg_position += 8; - mask &= ~(1 << returnreg); /* Clear bit for RA so we - don't save again later. */ + mask &= ~(1 << returnreg); /* Clear bit for RA so we + don't save again later. */ } - for (ireg = 0; ireg <= 31 ; ++ireg) + for (ireg = 0; ireg <= 31; ++ireg) if (mask & (1 << ireg)) { frame->saved_regs[ireg] = reg_position; @@ -332,10 +344,10 @@ alpha_find_saved_regs (frame) reg_position = frame->frame + PROC_FREG_OFFSET (proc_desc); mask = PROC_FREG_MASK (proc_desc); - for (ireg = 0; ireg <= 31 ; ++ireg) + for (ireg = 0; ireg <= 31; ++ireg) if (mask & (1 << ireg)) { - frame->saved_regs[FP0_REGNUM+ireg] = reg_position; + frame->saved_regs[FP0_REGNUM + ireg] = reg_position; reg_position += 8; } @@ -343,14 +355,14 @@ alpha_find_saved_regs (frame) } static CORE_ADDR -read_next_frame_reg(fi, regno) +read_next_frame_reg (fi, regno) struct frame_info *fi; int regno; { for (; fi; fi = fi->next) { /* We have to get the saved sp from the sigcontext - if it is a signal handler frame. */ + if it is a signal handler frame. */ if (regno == SP_REGNUM && !fi->signal_handler_caller) return fi->frame; else @@ -358,14 +370,14 @@ read_next_frame_reg(fi, regno) if (fi->saved_regs == NULL) alpha_find_saved_regs (fi); if (fi->saved_regs[regno]) - return read_memory_integer(fi->saved_regs[regno], 8); + return read_memory_integer (fi->saved_regs[regno], 8); } } - return read_register(regno); + return read_register (regno); } CORE_ADDR -alpha_frame_saved_pc(frame) +alpha_frame_saved_pc (frame) struct frame_info *frame; { alpha_extra_func_info_t proc_desc = frame->proc_desc; @@ -373,10 +385,10 @@ alpha_frame_saved_pc(frame) if it is a signal handler frame. */ int pcreg = frame->signal_handler_caller ? PC_REGNUM : frame->pc_reg; - if (proc_desc && PROC_DESC_IS_DUMMY(proc_desc)) - return read_memory_integer(frame->frame - 8, 8); + if (proc_desc && PROC_DESC_IS_DUMMY (proc_desc)) + return read_memory_integer (frame->frame - 8, 8); - return read_next_frame_reg(frame, pcreg); + return read_next_frame_reg (frame, pcreg); } CORE_ADDR @@ -423,177 +435,178 @@ alpha_about_to_return (pc) lines. */ static CORE_ADDR -heuristic_proc_start(pc) - CORE_ADDR pc; +heuristic_proc_start (pc) + CORE_ADDR pc; { - CORE_ADDR start_pc = pc; - CORE_ADDR fence = start_pc - heuristic_fence_post; + CORE_ADDR start_pc = pc; + CORE_ADDR fence = start_pc - heuristic_fence_post; - if (start_pc == 0) return 0; + if (start_pc == 0) + return 0; - if (heuristic_fence_post == UINT_MAX - || fence < VM_MIN_ADDRESS) - fence = VM_MIN_ADDRESS; + if (heuristic_fence_post == UINT_MAX + || fence < VM_MIN_ADDRESS) + fence = VM_MIN_ADDRESS; - /* search back for previous return */ - for (start_pc -= 4; ; start_pc -= 4) - if (start_pc < fence) + /* search back for previous return */ + for (start_pc -= 4;; start_pc -= 4) + if (start_pc < fence) + { + /* It's not clear to me why we reach this point when + stop_soon_quietly, but with this test, at least we + don't print out warnings for every child forked (eg, on + decstation). 22apr93 rich@cygnus.com. */ + if (!stop_soon_quietly) { - /* It's not clear to me why we reach this point when - stop_soon_quietly, but with this test, at least we - don't print out warnings for every child forked (eg, on - decstation). 22apr93 rich@cygnus.com. */ - if (!stop_soon_quietly) + static int blurb_printed = 0; + + if (fence == VM_MIN_ADDRESS) + warning ("Hit beginning of text section without finding"); + else + warning ("Hit heuristic-fence-post without finding"); + + warning ("enclosing function for address 0x%lx", pc); + if (!blurb_printed) { - static int blurb_printed = 0; - - if (fence == VM_MIN_ADDRESS) - warning("Hit beginning of text section without finding"); - else - warning("Hit heuristic-fence-post without finding"); - - warning("enclosing function for address 0x%lx", pc); - if (!blurb_printed) - { - printf_filtered ("\ + printf_filtered ("\ This warning occurs if you are debugging a function without any symbols\n\ (for example, in a stripped executable). In that case, you may wish to\n\ increase the size of the search with the `set heuristic-fence-post' command.\n\ \n\ Otherwise, you told GDB there was a function where there isn't one, or\n\ (more likely) you have encountered a bug in GDB.\n"); - blurb_printed = 1; - } + blurb_printed = 1; } - - return 0; } - else if (alpha_about_to_return (start_pc)) - break; - start_pc += 4; /* skip return */ - return start_pc; + return 0; + } + else if (alpha_about_to_return (start_pc)) + break; + + start_pc += 4; /* skip return */ + return start_pc; } static alpha_extra_func_info_t -heuristic_proc_desc(start_pc, limit_pc, next_frame) - CORE_ADDR start_pc, limit_pc; - struct frame_info *next_frame; +heuristic_proc_desc (start_pc, limit_pc, next_frame) + CORE_ADDR start_pc, limit_pc; + struct frame_info *next_frame; { - CORE_ADDR sp = read_next_frame_reg (next_frame, SP_REGNUM); - CORE_ADDR cur_pc; - int frame_size; - int has_frame_reg = 0; - unsigned long reg_mask = 0; - int pcreg = -1; - - if (start_pc == 0) - return NULL; - memset (&temp_proc_desc, '\0', sizeof(temp_proc_desc)); - memset (&temp_saved_regs, '\0', sizeof(struct frame_saved_regs)); - PROC_LOW_ADDR (&temp_proc_desc) = start_pc; - - if (start_pc + 200 < limit_pc) - limit_pc = start_pc + 200; - frame_size = 0; - for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += 4) - { - char buf[4]; - unsigned long word; - int status; + CORE_ADDR sp = read_next_frame_reg (next_frame, SP_REGNUM); + CORE_ADDR cur_pc; + int frame_size; + int has_frame_reg = 0; + unsigned long reg_mask = 0; + int pcreg = -1; + + if (start_pc == 0) + return NULL; + memset (&temp_proc_desc, '\0', sizeof (temp_proc_desc)); + memset (&temp_saved_regs, '\0', sizeof (struct frame_saved_regs)); + PROC_LOW_ADDR (&temp_proc_desc) = start_pc; + + if (start_pc + 200 < limit_pc) + limit_pc = start_pc + 200; + frame_size = 0; + for (cur_pc = start_pc; cur_pc < limit_pc; cur_pc += 4) + { + char buf[4]; + unsigned long word; + int status; - status = read_memory_nobpt (cur_pc, buf, 4); - if (status) - memory_error (status, cur_pc); - word = extract_unsigned_integer (buf, 4); + status = read_memory_nobpt (cur_pc, buf, 4); + if (status) + memory_error (status, cur_pc); + word = extract_unsigned_integer (buf, 4); - if ((word & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */ - { - if (word & 0x8000) - frame_size += (-word) & 0xffff; - else - /* Exit loop if a positive stack adjustment is found, which - usually means that the stack cleanup code in the function - epilogue is reached. */ - break; - } - else if ((word & 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */ - && (word & 0xffff0000) != 0xb7fe0000) /* reg != $zero */ - { - int reg = (word & 0x03e00000) >> 21; - reg_mask |= 1 << reg; - temp_saved_regs.regs[reg] = sp + (short)word; - - /* Starting with OSF/1-3.2C, the system libraries are shipped - without local symbols, but they still contain procedure - descriptors without a symbol reference. GDB is currently - unable to find these procedure descriptors and uses - heuristic_proc_desc instead. - As some low level compiler support routines (__div*, __add*) - use a non-standard return address register, we have to - add some heuristics to determine the return address register, - or stepping over these routines will fail. - Usually the return address register is the first register - saved on the stack, but assembler optimization might - rearrange the register saves. - So we recognize only a few registers (t7, t9, ra) within - the procedure prologue as valid return address registers. - If we encounter a return instruction, we extract the - the return address register from it. - - FIXME: Rewriting GDB to access the procedure descriptors, - e.g. via the minimal symbol table, might obviate this hack. */ - if (pcreg == -1 - && cur_pc < (start_pc + 80) - && (reg == T7_REGNUM || reg == T9_REGNUM || reg == RA_REGNUM)) - pcreg = reg; - } - else if ((word & 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */ - pcreg = (word >> 16) & 0x1f; - else if (word == 0x47de040f) /* bis sp,sp fp */ - has_frame_reg = 1; - } - if (pcreg == -1) - { - /* If we haven't found a valid return address register yet, - keep searching in the procedure prologue. */ - while (cur_pc < (limit_pc + 80) && cur_pc < (start_pc + 80)) - { - char buf[4]; - unsigned long word; + if ((word & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */ + { + if (word & 0x8000) + frame_size += (-word) & 0xffff; + else + /* Exit loop if a positive stack adjustment is found, which + usually means that the stack cleanup code in the function + epilogue is reached. */ + break; + } + else if ((word & 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */ + && (word & 0xffff0000) != 0xb7fe0000) /* reg != $zero */ + { + int reg = (word & 0x03e00000) >> 21; + reg_mask |= 1 << reg; + temp_saved_regs.regs[reg] = sp + (short) word; + + /* Starting with OSF/1-3.2C, the system libraries are shipped + without local symbols, but they still contain procedure + descriptors without a symbol reference. GDB is currently + unable to find these procedure descriptors and uses + heuristic_proc_desc instead. + As some low level compiler support routines (__div*, __add*) + use a non-standard return address register, we have to + add some heuristics to determine the return address register, + or stepping over these routines will fail. + Usually the return address register is the first register + saved on the stack, but assembler optimization might + rearrange the register saves. + So we recognize only a few registers (t7, t9, ra) within + the procedure prologue as valid return address registers. + If we encounter a return instruction, we extract the + the return address register from it. + + FIXME: Rewriting GDB to access the procedure descriptors, + e.g. via the minimal symbol table, might obviate this hack. */ + if (pcreg == -1 + && cur_pc < (start_pc + 80) + && (reg == T7_REGNUM || reg == T9_REGNUM || reg == RA_REGNUM)) + pcreg = reg; + } + else if ((word & 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */ + pcreg = (word >> 16) & 0x1f; + else if (word == 0x47de040f) /* bis sp,sp fp */ + has_frame_reg = 1; + } + if (pcreg == -1) + { + /* If we haven't found a valid return address register yet, + keep searching in the procedure prologue. */ + while (cur_pc < (limit_pc + 80) && cur_pc < (start_pc + 80)) + { + char buf[4]; + unsigned long word; - if (read_memory_nobpt (cur_pc, buf, 4)) - break; - cur_pc += 4; - word = extract_unsigned_integer (buf, 4); + if (read_memory_nobpt (cur_pc, buf, 4)) + break; + cur_pc += 4; + word = extract_unsigned_integer (buf, 4); - if ((word & 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */ - && (word & 0xffff0000) != 0xb7fe0000) /* reg != $zero */ - { - int reg = (word & 0x03e00000) >> 21; - if (reg == T7_REGNUM || reg == T9_REGNUM || reg == RA_REGNUM) - { - pcreg = reg; - break; - } - } - else if ((word & 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */ - { - pcreg = (word >> 16) & 0x1f; - break; - } - } - } + if ((word & 0xfc1f0000) == 0xb41e0000 /* stq reg,n($sp) */ + && (word & 0xffff0000) != 0xb7fe0000) /* reg != $zero */ + { + int reg = (word & 0x03e00000) >> 21; + if (reg == T7_REGNUM || reg == T9_REGNUM || reg == RA_REGNUM) + { + pcreg = reg; + break; + } + } + else if ((word & 0xffe0ffff) == 0x6be08001) /* ret zero,reg,1 */ + { + pcreg = (word >> 16) & 0x1f; + break; + } + } + } - if (has_frame_reg) - PROC_FRAME_REG(&temp_proc_desc) = GCC_FP_REGNUM; - else - PROC_FRAME_REG(&temp_proc_desc) = SP_REGNUM; - PROC_FRAME_OFFSET(&temp_proc_desc) = frame_size; - PROC_REG_MASK(&temp_proc_desc) = reg_mask; - PROC_PC_REG(&temp_proc_desc) = (pcreg == -1) ? RA_REGNUM : pcreg; - PROC_LOCALOFF(&temp_proc_desc) = 0; /* XXX - bogus */ - return &temp_proc_desc; + if (has_frame_reg) + PROC_FRAME_REG (&temp_proc_desc) = GCC_FP_REGNUM; + else + PROC_FRAME_REG (&temp_proc_desc) = SP_REGNUM; + PROC_FRAME_OFFSET (&temp_proc_desc) = frame_size; + PROC_REG_MASK (&temp_proc_desc) = reg_mask; + PROC_PC_REG (&temp_proc_desc) = (pcreg == -1) ? RA_REGNUM : pcreg; + PROC_LOCALOFF (&temp_proc_desc) = 0; /* XXX - bogus */ + return &temp_proc_desc; } /* This returns the PC of the first inst after the prologue. If we can't @@ -616,7 +629,7 @@ after_prologue (pc, proc_desc) return PROC_LOW_ADDR (proc_desc); /* "prologue" is in kernel */ /* If function is frameless, then we need to do it the hard way. I - strongly suspect that frameless always means prologueless... */ + strongly suspect that frameless always means prologueless... */ if (PROC_FRAME_REG (proc_desc) == SP_REGNUM && PROC_FRAME_OFFSET (proc_desc) == 0) return 0; @@ -657,8 +670,8 @@ alpha_in_prologue (pc, proc_desc) static alpha_extra_func_info_t find_proc_desc (pc, next_frame) - CORE_ADDR pc; - struct frame_info *next_frame; + CORE_ADDR pc; + struct frame_info *next_frame; { alpha_extra_func_info_t proc_desc; struct block *b; @@ -693,7 +706,7 @@ find_proc_desc (pc, next_frame) return found_proc_desc; } - b = block_for_pc(pc); + b = block_for_pc (pc); find_pc_partial_function (pc, NULL, &startaddr, NULL); if (b == NULL) @@ -717,57 +730,57 @@ find_proc_desc (pc, next_frame) if (sym) { - /* IF this is the topmost frame AND - * (this proc does not have debugging information OR - * the PC is in the procedure prologue) - * THEN create a "heuristic" proc_desc (by analyzing - * the actual code) to replace the "official" proc_desc. - */ - proc_desc = (alpha_extra_func_info_t)SYMBOL_VALUE(sym); - if (next_frame == NULL) - { - if (PROC_DESC_IS_DUMMY (proc_desc) || alpha_in_prologue (pc, proc_desc)) - { - alpha_extra_func_info_t found_heuristic = - heuristic_proc_desc (PROC_LOW_ADDR (proc_desc), - pc, next_frame); - if (found_heuristic) - { - PROC_LOCALOFF (found_heuristic) = - PROC_LOCALOFF (proc_desc); - PROC_PC_REG (found_heuristic) = PROC_PC_REG (proc_desc); - proc_desc = found_heuristic; - } - } - } + /* IF this is the topmost frame AND + * (this proc does not have debugging information OR + * the PC is in the procedure prologue) + * THEN create a "heuristic" proc_desc (by analyzing + * the actual code) to replace the "official" proc_desc. + */ + proc_desc = (alpha_extra_func_info_t) SYMBOL_VALUE (sym); + if (next_frame == NULL) + { + if (PROC_DESC_IS_DUMMY (proc_desc) || alpha_in_prologue (pc, proc_desc)) + { + alpha_extra_func_info_t found_heuristic = + heuristic_proc_desc (PROC_LOW_ADDR (proc_desc), + pc, next_frame); + if (found_heuristic) + { + PROC_LOCALOFF (found_heuristic) = + PROC_LOCALOFF (proc_desc); + PROC_PC_REG (found_heuristic) = PROC_PC_REG (proc_desc); + proc_desc = found_heuristic; + } + } + } } else { long offset; /* Is linked_proc_desc_table really necessary? It only seems to be used - by procedure call dummys. However, the procedures being called ought - to have their own proc_descs, and even if they don't, - heuristic_proc_desc knows how to create them! */ + by procedure call dummys. However, the procedures being called ought + to have their own proc_descs, and even if they don't, + heuristic_proc_desc knows how to create them! */ register struct linked_proc_info *link; for (link = linked_proc_desc_table; link; link = link->next) - if (PROC_LOW_ADDR(&link->info) <= pc - && PROC_HIGH_ADDR(&link->info) > pc) - return &link->info; + if (PROC_LOW_ADDR (&link->info) <= pc + && PROC_HIGH_ADDR (&link->info) > pc) + return &link->info; /* If PC is inside a dynamically generated sigtramp handler, - create and push a procedure descriptor for that code: */ + create and push a procedure descriptor for that code: */ offset = DYNAMIC_SIGTRAMP_OFFSET (pc); if (offset >= 0) return push_sigtramp_desc (pc - offset); /* If heuristic_fence_post is non-zero, determine the procedure - start address by examining the instructions. - This allows us to find the start address of static functions which - have no symbolic information, as startaddr would have been set to - the preceding global function start address by the - find_pc_partial_function call above. */ + start address by examining the instructions. + This allows us to find the start address of static functions which + have no symbolic information, as startaddr would have been set to + the preceding global function start address by the + find_pc_partial_function call above. */ if (startaddr == 0 || heuristic_fence_post != 0) startaddr = heuristic_proc_start (pc); @@ -780,38 +793,38 @@ find_proc_desc (pc, next_frame) alpha_extra_func_info_t cached_proc_desc; CORE_ADDR -alpha_frame_chain(frame) - struct frame_info *frame; +alpha_frame_chain (frame) + struct frame_info *frame; { - alpha_extra_func_info_t proc_desc; - CORE_ADDR saved_pc = FRAME_SAVED_PC(frame); - - if (saved_pc == 0 || inside_entry_file (saved_pc)) - return 0; - - proc_desc = find_proc_desc(saved_pc, frame); - if (!proc_desc) - return 0; - - cached_proc_desc = proc_desc; - - /* Fetch the frame pointer for a dummy frame from the procedure - descriptor. */ - if (PROC_DESC_IS_DUMMY(proc_desc)) - return (CORE_ADDR) PROC_DUMMY_FRAME(proc_desc); - - /* If no frame pointer and frame size is zero, we must be at end - of stack (or otherwise hosed). If we don't check frame size, - we loop forever if we see a zero size frame. */ - if (PROC_FRAME_REG (proc_desc) == SP_REGNUM - && PROC_FRAME_OFFSET (proc_desc) == 0 - /* The previous frame from a sigtramp frame might be frameless - and have frame size zero. */ - && !frame->signal_handler_caller) - return FRAME_PAST_SIGTRAMP_FRAME (frame, saved_pc); - else - return read_next_frame_reg(frame, PROC_FRAME_REG(proc_desc)) - + PROC_FRAME_OFFSET(proc_desc); + alpha_extra_func_info_t proc_desc; + CORE_ADDR saved_pc = FRAME_SAVED_PC (frame); + + if (saved_pc == 0 || inside_entry_file (saved_pc)) + return 0; + + proc_desc = find_proc_desc (saved_pc, frame); + if (!proc_desc) + return 0; + + cached_proc_desc = proc_desc; + + /* Fetch the frame pointer for a dummy frame from the procedure + descriptor. */ + if (PROC_DESC_IS_DUMMY (proc_desc)) + return (CORE_ADDR) PROC_DUMMY_FRAME (proc_desc); + + /* If no frame pointer and frame size is zero, we must be at end + of stack (or otherwise hosed). If we don't check frame size, + we loop forever if we see a zero size frame. */ + if (PROC_FRAME_REG (proc_desc) == SP_REGNUM + && PROC_FRAME_OFFSET (proc_desc) == 0 + /* The previous frame from a sigtramp frame might be frameless + and have frame size zero. */ + && !frame->signal_handler_caller) + return FRAME_PAST_SIGTRAMP_FRAME (frame, saved_pc); + else + return read_next_frame_reg (frame, PROC_FRAME_REG (proc_desc)) + + PROC_FRAME_OFFSET (proc_desc); } void @@ -820,7 +833,7 @@ init_extra_frame_info (frame) { /* Use proc_desc calculated in frame_chain */ alpha_extra_func_info_t proc_desc = - frame->next ? cached_proc_desc : find_proc_desc(frame->pc, frame->next); + frame->next ? cached_proc_desc : find_proc_desc (frame->pc, frame->next); frame->saved_regs = NULL; frame->localoff = 0; @@ -829,21 +842,21 @@ init_extra_frame_info (frame) if (proc_desc) { /* Get the locals offset and the saved pc register from the - procedure descriptor, they are valid even if we are in the - middle of the prologue. */ - frame->localoff = PROC_LOCALOFF(proc_desc); - frame->pc_reg = PROC_PC_REG(proc_desc); + procedure descriptor, they are valid even if we are in the + middle of the prologue. */ + frame->localoff = PROC_LOCALOFF (proc_desc); + frame->pc_reg = PROC_PC_REG (proc_desc); /* Fixup frame-pointer - only needed for top frame */ /* Fetch the frame pointer for a dummy frame from the procedure - descriptor. */ - if (PROC_DESC_IS_DUMMY(proc_desc)) - frame->frame = (CORE_ADDR) PROC_DUMMY_FRAME(proc_desc); + descriptor. */ + if (PROC_DESC_IS_DUMMY (proc_desc)) + frame->frame = (CORE_ADDR) PROC_DUMMY_FRAME (proc_desc); /* This may not be quite right, if proc has a real frame register. - Get the value of the frame relative sp, procedure might have been - interrupted by a signal at it's very start. */ + Get the value of the frame relative sp, procedure might have been + interrupted by a signal at it's very start. */ else if (frame->pc == PROC_LOW_ADDR (proc_desc) && !PROC_DESC_IS_DYN_SIGTRAMP (proc_desc)) frame->frame = read_next_frame_reg (frame->next, SP_REGNUM); @@ -859,10 +872,10 @@ init_extra_frame_info (frame) alpha_find_saved_registers will do that for us. We can't use frame->signal_handler_caller, it is not yet set. */ find_pc_partial_function (frame->pc, &name, - (CORE_ADDR *)NULL,(CORE_ADDR *)NULL); + (CORE_ADDR *) NULL, (CORE_ADDR *) NULL); if (!IN_SIGTRAMP (frame->pc, name)) { - frame->saved_regs = (CORE_ADDR*) + frame->saved_regs = (CORE_ADDR *) frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS); memcpy (frame->saved_regs, temp_saved_regs.regs, SIZEOF_FRAME_SAVED_REGS); frame->saved_regs[PC_REGNUM] @@ -919,9 +932,14 @@ alpha_push_arguments (nargs, args, sp, struct_return, struct_addr) int i; int accumulate_size = struct_return ? 8 : 0; int arg_regs_size = ALPHA_NUM_ARG_REGS * 8; - struct alpha_arg { char *contents; int len; int offset; }; + struct alpha_arg + { + char *contents; + int len; + int offset; + }; struct alpha_arg *alpha_args = - (struct alpha_arg*)alloca (nargs * sizeof (struct alpha_arg)); + (struct alpha_arg *) alloca (nargs * sizeof (struct alpha_arg)); register struct alpha_arg *m_arg; char raw_buffer[sizeof (CORE_ADDR)]; int required_arg_regs; @@ -950,7 +968,7 @@ alpha_push_arguments (nargs, args, sp, struct_return, struct_addr) m_arg->len = TYPE_LENGTH (arg_type); m_arg->offset = accumulate_size; accumulate_size = (accumulate_size + m_arg->len + 7) & ~7; - m_arg->contents = VALUE_CONTENTS(arg); + m_arg->contents = VALUE_CONTENTS (arg); } /* Determine required argument register loads, loading an argument register @@ -961,15 +979,15 @@ alpha_push_arguments (nargs, args, sp, struct_return, struct_addr) /* Make room for the arguments on the stack. */ if (accumulate_size < arg_regs_size) - accumulate_size = arg_regs_size; + accumulate_size = arg_regs_size; sp -= accumulate_size; /* Keep sp aligned to a multiple of 16 as the compiler does it too. */ sp &= ~15; /* `Push' arguments on the stack. */ - for (i = nargs; m_arg--, --i >= 0; ) - write_memory(sp + m_arg->offset, m_arg->contents, m_arg->len); + for (i = nargs; m_arg--, --i >= 0;) + write_memory (sp + m_arg->offset, m_arg->contents, m_arg->len); if (struct_return) { store_address (raw_buffer, sizeof (CORE_ADDR), struct_addr); @@ -990,7 +1008,7 @@ alpha_push_arguments (nargs, args, sp, struct_return, struct_addr) } void -alpha_push_dummy_frame() +alpha_push_dummy_frame () { int ireg; struct linked_proc_info *link; @@ -1000,10 +1018,10 @@ alpha_push_dummy_frame() char raw_buffer[MAX_REGISTER_RAW_SIZE]; unsigned long mask; - link = (struct linked_proc_info *) xmalloc(sizeof (struct linked_proc_info)); + link = (struct linked_proc_info *) xmalloc (sizeof (struct linked_proc_info)); link->next = linked_proc_desc_table; linked_proc_desc_table = link; - + proc_desc = &link->info; /* @@ -1013,15 +1031,15 @@ alpha_push_dummy_frame() * * Dummy frame layout: * (high memory) - * Saved PC + * Saved PC * Saved F30 * ... * Saved F0 - * Saved R29 - * ... - * Saved R0 - * Saved R26 (RA) - * Parameter build area + * Saved R29 + * ... + * Saved R0 + * Saved R26 (RA) + * Parameter build area * (low memory) */ @@ -1035,27 +1053,27 @@ alpha_push_dummy_frame() alpha_frame_saved_pc knows where the pc is saved in a dummy frame. */ #define SPECIAL_REG_SAVE_COUNT 1 - PROC_REG_MASK(proc_desc) = GEN_REG_SAVE_MASK; - PROC_FREG_MASK(proc_desc) = FLOAT_REG_SAVE_MASK; + PROC_REG_MASK (proc_desc) = GEN_REG_SAVE_MASK; + PROC_FREG_MASK (proc_desc) = FLOAT_REG_SAVE_MASK; /* PROC_REG_OFFSET is the offset from the dummy frame to the saved RA, but keep SP aligned to a multiple of 16. */ - PROC_REG_OFFSET(proc_desc) = - - ((8 * (SPECIAL_REG_SAVE_COUNT + PROC_REG_OFFSET (proc_desc) = + -((8 * (SPECIAL_REG_SAVE_COUNT + GEN_REG_SAVE_COUNT + FLOAT_REG_SAVE_COUNT) - + 15) & ~15); - PROC_FREG_OFFSET(proc_desc) = - PROC_REG_OFFSET(proc_desc) + 8 * GEN_REG_SAVE_COUNT; + + 15) & ~15); + PROC_FREG_OFFSET (proc_desc) = + PROC_REG_OFFSET (proc_desc) + 8 * GEN_REG_SAVE_COUNT; /* Save general registers. The return address register is the first saved register, all other registers follow in ascending order. The PC is saved immediately below the SP. */ - save_address = sp + PROC_REG_OFFSET(proc_desc); + save_address = sp + PROC_REG_OFFSET (proc_desc); store_address (raw_buffer, 8, read_register (RA_REGNUM)); write_memory (save_address, raw_buffer, 8); save_address += 8; - mask = PROC_REG_MASK(proc_desc) & 0xffffffffL; + mask = PROC_REG_MASK (proc_desc) & 0xffffffffL; for (ireg = 0; mask; ireg++, mask >>= 1) if (mask & 1) { @@ -1070,8 +1088,8 @@ alpha_push_dummy_frame() write_memory (sp - 8, raw_buffer, 8); /* Save floating point registers. */ - save_address = sp + PROC_FREG_OFFSET(proc_desc); - mask = PROC_FREG_MASK(proc_desc) & 0xffffffffL; + save_address = sp + PROC_FREG_OFFSET (proc_desc); + mask = PROC_FREG_MASK (proc_desc) & 0xffffffffL; for (ireg = 0; mask; ireg++, mask >>= 1) if (mask & 1) { @@ -1092,21 +1110,21 @@ alpha_push_dummy_frame() is set to the virtual frame (pseudo) register, it's value will always be read as zero and will help us to catch any errors in the dummy frame retrieval code. */ - PROC_DUMMY_FRAME(proc_desc) = sp; - PROC_FRAME_REG(proc_desc) = FP_REGNUM; - PROC_FRAME_OFFSET(proc_desc) = 0; - sp += PROC_REG_OFFSET(proc_desc); + PROC_DUMMY_FRAME (proc_desc) = sp; + PROC_FRAME_REG (proc_desc) = FP_REGNUM; + PROC_FRAME_OFFSET (proc_desc) = 0; + sp += PROC_REG_OFFSET (proc_desc); write_register (SP_REGNUM, sp); - PROC_LOW_ADDR(proc_desc) = CALL_DUMMY_ADDRESS (); - PROC_HIGH_ADDR(proc_desc) = PROC_LOW_ADDR(proc_desc) + 4; + PROC_LOW_ADDR (proc_desc) = CALL_DUMMY_ADDRESS (); + PROC_HIGH_ADDR (proc_desc) = PROC_LOW_ADDR (proc_desc) + 4; - SET_PROC_DESC_IS_DUMMY(proc_desc); - PROC_PC_REG(proc_desc) = RA_REGNUM; + SET_PROC_DESC_IS_DUMMY (proc_desc); + PROC_PC_REG (proc_desc) = RA_REGNUM; } void -alpha_pop_frame() +alpha_pop_frame () { register int regnum; struct frame_info *frame = get_current_frame (); @@ -1117,31 +1135,31 @@ alpha_pop_frame() /* we need proc_desc to know how to restore the registers; if it is NULL, construct (a temporary) one */ if (proc_desc == NULL) - proc_desc = find_proc_desc(frame->pc, frame->next); + proc_desc = find_proc_desc (frame->pc, frame->next); /* Question: should we copy this proc_desc and save it in frame->proc_desc? If we do, who will free it? For now, we don't save a copy... */ - write_register (PC_REGNUM, FRAME_SAVED_PC(frame)); + write_register (PC_REGNUM, FRAME_SAVED_PC (frame)); if (frame->saved_regs == NULL) alpha_find_saved_regs (frame); if (proc_desc) { - for (regnum = 32; --regnum >= 0; ) - if (PROC_REG_MASK(proc_desc) & (1 << regnum)) + for (regnum = 32; --regnum >= 0;) + if (PROC_REG_MASK (proc_desc) & (1 << regnum)) write_register (regnum, read_memory_integer (frame->saved_regs[regnum], 8)); - for (regnum = 32; --regnum >= 0; ) - if (PROC_FREG_MASK(proc_desc) & (1 << regnum)) + for (regnum = 32; --regnum >= 0;) + if (PROC_FREG_MASK (proc_desc) & (1 << regnum)) write_register (regnum + FP0_REGNUM, - read_memory_integer (frame->saved_regs[regnum + FP0_REGNUM], 8)); + read_memory_integer (frame->saved_regs[regnum + FP0_REGNUM], 8)); } write_register (SP_REGNUM, new_sp); flush_cached_frames (); - if (proc_desc && (PROC_DESC_IS_DUMMY(proc_desc) + if (proc_desc && (PROC_DESC_IS_DUMMY (proc_desc) || PROC_DESC_IS_DYN_SIGTRAMP (proc_desc))) { struct linked_proc_info *pi_ptr, *prev_ptr; @@ -1180,74 +1198,74 @@ alpha_skip_prologue (pc, lenient) CORE_ADDR pc; int lenient; { - unsigned long inst; - int offset; - CORE_ADDR post_prologue_pc; - char buf[4]; + unsigned long inst; + int offset; + CORE_ADDR post_prologue_pc; + char buf[4]; #ifdef GDB_TARGET_HAS_SHARED_LIBS - /* Silently return the unaltered pc upon memory errors. - This could happen on OSF/1 if decode_line_1 tries to skip the - prologue for quickstarted shared library functions when the - shared library is not yet mapped in. - Reading target memory is slow over serial lines, so we perform - this check only if the target has shared libraries. */ - if (target_read_memory (pc, buf, 4)) - return pc; + /* Silently return the unaltered pc upon memory errors. + This could happen on OSF/1 if decode_line_1 tries to skip the + prologue for quickstarted shared library functions when the + shared library is not yet mapped in. + Reading target memory is slow over serial lines, so we perform + this check only if the target has shared libraries. */ + if (target_read_memory (pc, buf, 4)) + return pc; #endif - /* See if we can determine the end of the prologue via the symbol table. - If so, then return either PC, or the PC after the prologue, whichever - is greater. */ - - post_prologue_pc = after_prologue (pc, NULL); + /* See if we can determine the end of the prologue via the symbol table. + If so, then return either PC, or the PC after the prologue, whichever + is greater. */ - if (post_prologue_pc != 0) - return max (pc, post_prologue_pc); + post_prologue_pc = after_prologue (pc, NULL); - /* Can't determine prologue from the symbol table, need to examine - instructions. */ + if (post_prologue_pc != 0) + return max (pc, post_prologue_pc); - /* Skip the typical prologue instructions. These are the stack adjustment - instruction and the instructions that save registers on the stack - or in the gcc frame. */ - for (offset = 0; offset < 100; offset += 4) - { - int status; + /* Can't determine prologue from the symbol table, need to examine + instructions. */ - status = read_memory_nobpt (pc + offset, buf, 4); - if (status) - memory_error (status, pc + offset); - inst = extract_unsigned_integer (buf, 4); - - /* The alpha has no delay slots. But let's keep the lenient stuff, - we might need it for something else in the future. */ - if (lenient && 0) - continue; - - if ((inst & 0xffff0000) == 0x27bb0000) /* ldah $gp,n($t12) */ - continue; - if ((inst & 0xffff0000) == 0x23bd0000) /* lda $gp,n($gp) */ - continue; - if ((inst & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */ - continue; - if ((inst & 0xffe01fff) == 0x43c0153e) /* subq $sp,n,$sp */ - continue; - - if ((inst & 0xfc1f0000) == 0xb41e0000 - && (inst & 0xffff0000) != 0xb7fe0000) - continue; /* stq reg,n($sp) */ - /* reg != $zero */ - if ((inst & 0xfc1f0000) == 0x9c1e0000 - && (inst & 0xffff0000) != 0x9ffe0000) - continue; /* stt reg,n($sp) */ - /* reg != $zero */ - if (inst == 0x47de040f) /* bis sp,sp,fp */ - continue; - - break; + /* Skip the typical prologue instructions. These are the stack adjustment + instruction and the instructions that save registers on the stack + or in the gcc frame. */ + for (offset = 0; offset < 100; offset += 4) + { + int status; + + status = read_memory_nobpt (pc + offset, buf, 4); + if (status) + memory_error (status, pc + offset); + inst = extract_unsigned_integer (buf, 4); + + /* The alpha has no delay slots. But let's keep the lenient stuff, + we might need it for something else in the future. */ + if (lenient && 0) + continue; + + if ((inst & 0xffff0000) == 0x27bb0000) /* ldah $gp,n($t12) */ + continue; + if ((inst & 0xffff0000) == 0x23bd0000) /* lda $gp,n($gp) */ + continue; + if ((inst & 0xffff0000) == 0x23de0000) /* lda $sp,n($sp) */ + continue; + if ((inst & 0xffe01fff) == 0x43c0153e) /* subq $sp,n,$sp */ + continue; + + if ((inst & 0xfc1f0000) == 0xb41e0000 + && (inst & 0xffff0000) != 0xb7fe0000) + continue; /* stq reg,n($sp) */ + /* reg != $zero */ + if ((inst & 0xfc1f0000) == 0x9c1e0000 + && (inst & 0xffff0000) != 0x9ffe0000) + continue; /* stt reg,n($sp) */ + /* reg != $zero */ + if (inst == 0x47de040f) /* bis sp,sp,fp */ + continue; + + break; } - return pc + offset; + return pc + offset; } #if 0 @@ -1266,16 +1284,16 @@ alpha_in_lenient_prologue (startaddr, pc) /* The alpha needs a conversion between register and memory format if the register is a floating point register and - memory format is float, as the register format must be double + memory format is float, as the register format must be double or - memory format is an integer with 4 bytes or less, as the representation - of integers in floating point registers is different. */ + memory format is an integer with 4 bytes or less, as the representation + of integers in floating point registers is different. */ void alpha_register_convert_to_virtual (regnum, valtype, raw_buffer, virtual_buffer) - int regnum; - struct type *valtype; - char *raw_buffer; - char *virtual_buffer; + int regnum; + struct type *valtype; + char *raw_buffer; + char *virtual_buffer; { if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum)) { @@ -1301,10 +1319,10 @@ alpha_register_convert_to_virtual (regnum, valtype, raw_buffer, virtual_buffer) void alpha_register_convert_to_raw (valtype, regnum, virtual_buffer, raw_buffer) - struct type *valtype; - int regnum; - char *virtual_buffer; - char *raw_buffer; + struct type *valtype; + int regnum; + char *virtual_buffer; + char *raw_buffer; { if (TYPE_LENGTH (valtype) >= REGISTER_RAW_SIZE (regnum)) { @@ -1336,9 +1354,9 @@ alpha_register_convert_to_raw (valtype, regnum, virtual_buffer, raw_buffer) void alpha_extract_return_value (valtype, regbuf, valbuf) - struct type *valtype; - char regbuf[REGISTER_BYTES]; - char *valbuf; + struct type *valtype; + char regbuf[REGISTER_BYTES]; + char *valbuf; { if (TYPE_CODE (valtype) == TYPE_CODE_FLT) alpha_register_convert_to_virtual (FP0_REGNUM, valtype, @@ -1353,13 +1371,13 @@ alpha_extract_return_value (valtype, regbuf, valbuf) void alpha_store_return_value (valtype, valbuf) - struct type *valtype; - char *valbuf; + struct type *valtype; + char *valbuf; { char raw_buffer[MAX_REGISTER_RAW_SIZE]; int regnum = V0_REGNUM; int length = TYPE_LENGTH (valtype); - + if (TYPE_CODE (valtype) == TYPE_CODE_FLT) { regnum = FP0_REGNUM; diff --git a/gdb/altos-xdep.c b/gdb/altos-xdep.c index 0704ddd..bc7245a 100644 --- a/gdb/altos-xdep.c +++ b/gdb/altos-xdep.c @@ -40,7 +40,7 @@ /* OBSOLETE #endif */ /* OBSOLETE */ /* OBSOLETE #include "gdbcore.h" */ -/* OBSOLETE #include /* After a.out.h *x/ */ +/* OBSOLETE #include /* After a.out.h *x/ */ /* OBSOLETE #include */ /* OBSOLETE #include "gdb_stat.h" */ /* OBSOLETE */ @@ -79,22 +79,22 @@ /* OBSOLETE make_cleanup (free, filename); */ /* OBSOLETE */ /* OBSOLETE if (have_inferior_p ()) */ -/* OBSOLETE error ("To look at a core file, you must kill the program with \"kill\"."); */ +/* OBSOLETE error ("To look at a core file, you must kill the program with \"kill\"."); */ /* OBSOLETE corechan = open (filename, O_RDONLY, 0); */ /* OBSOLETE if (corechan < 0) */ -/* OBSOLETE perror_with_name (filename); */ +/* OBSOLETE perror_with_name (filename); */ /* OBSOLETE /* 4.2-style (and perhaps also sysV-style) core dump file. *x/ */ /* OBSOLETE { */ -/* OBSOLETE struct user u; */ +/* OBSOLETE struct user u; */ /* OBSOLETE */ -/* OBSOLETE unsigned int reg_offset; */ +/* OBSOLETE unsigned int reg_offset; */ /* OBSOLETE */ -/* OBSOLETE val = myread (corechan, &u, sizeof u); */ -/* OBSOLETE if (val < 0) */ -/* OBSOLETE perror_with_name ("Not a core file: reading upage"); */ -/* OBSOLETE if (val != sizeof u) */ -/* OBSOLETE error ("Not a core file: could only read %d bytes", val); */ -/* OBSOLETE data_start = exec_data_start; */ +/* OBSOLETE val = myread (corechan, &u, sizeof u); */ +/* OBSOLETE if (val < 0) */ +/* OBSOLETE perror_with_name ("Not a core file: reading upage"); */ +/* OBSOLETE if (val != sizeof u) */ +/* OBSOLETE error ("Not a core file: could only read %d bytes", val); */ +/* OBSOLETE data_start = exec_data_start; */ /* OBSOLETE */ /* OBSOLETE #if !defined (NBPG) */ /* OBSOLETE #define NBPG NBPP */ @@ -103,56 +103,56 @@ /* OBSOLETE #define UPAGES USIZE */ /* OBSOLETE #endif */ /* OBSOLETE */ -/* OBSOLETE data_end = data_start + NBPG * u.u_dsize; */ -/* OBSOLETE stack_start = stack_end - NBPG * u.u_ssize; */ -/* OBSOLETE data_offset = NBPG * UPAGES + exec_data_start % NBPG /* Not sure about this //jkp *x/; */ -/* OBSOLETE stack_offset = NBPG * (UPAGES + u.u_dsize); */ -/* OBSOLETE */ -/* OBSOLETE /* Some machines put an absolute address in here and some put */ -/* OBSOLETE the offset in the upage of the regs. *x/ */ -/* OBSOLETE reg_offset = (int) u.u_state; */ -/* OBSOLETE if (reg_offset > NBPG * UPAGES) */ -/* OBSOLETE reg_offset -= KERNEL_U_ADDR; */ -/* OBSOLETE */ -/* OBSOLETE memcpy (&core_aouthdr, &u.u_exdata, sizeof (AOUTHDR)); */ -/* OBSOLETE printf_unfiltered ("Core file is from \"%s\".\n", u.u_comm); */ -/* OBSOLETE */ -/* OBSOLETE /* I don't know where to find this info. */ -/* OBSOLETE So, for now, mark it as not available. *x/ */ -/* OBSOLETE N_SET_MAGIC (core_aouthdr, 0); */ -/* OBSOLETE */ -/* OBSOLETE /* Read the register values out of the core file and store */ -/* OBSOLETE them where `read_register' will find them. *x/ */ -/* OBSOLETE */ -/* OBSOLETE { */ -/* OBSOLETE register int regno; */ -/* OBSOLETE */ -/* OBSOLETE for (regno = 0; regno < NUM_REGS; regno++) */ -/* OBSOLETE { */ -/* OBSOLETE char buf[MAX_REGISTER_RAW_SIZE]; */ -/* OBSOLETE */ -/* OBSOLETE val = lseek (corechan, register_addr (regno, reg_offset), 0); */ -/* OBSOLETE if (val < 0 */ -/* OBSOLETE || (val = myread (corechan, buf, sizeof buf)) < 0) */ -/* OBSOLETE { */ -/* OBSOLETE char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) */ -/* OBSOLETE + 30); */ -/* OBSOLETE strcpy (buffer, "Reading register "); */ -/* OBSOLETE strcat (buffer, REGISTER_NAME (regno)); */ -/* OBSOLETE */ -/* OBSOLETE perror_with_name (buffer); */ -/* OBSOLETE } */ -/* OBSOLETE */ -/* OBSOLETE supply_register (regno, buf); */ -/* OBSOLETE } */ -/* OBSOLETE } */ +/* OBSOLETE data_end = data_start + NBPG * u.u_dsize; */ +/* OBSOLETE stack_start = stack_end - NBPG * u.u_ssize; */ +/* OBSOLETE data_offset = NBPG * UPAGES + exec_data_start % NBPG /* Not sure about this //jkp *x/; */ +/* OBSOLETE stack_offset = NBPG * (UPAGES + u.u_dsize); */ +/* OBSOLETE */ +/* OBSOLETE /* Some machines put an absolute address in here and some put */ +/* OBSOLETE the offset in the upage of the regs. *x/ */ +/* OBSOLETE reg_offset = (int) u.u_state; */ +/* OBSOLETE if (reg_offset > NBPG * UPAGES) */ +/* OBSOLETE reg_offset -= KERNEL_U_ADDR; */ +/* OBSOLETE */ +/* OBSOLETE memcpy (&core_aouthdr, &u.u_exdata, sizeof (AOUTHDR)); */ +/* OBSOLETE printf_unfiltered ("Core file is from \"%s\".\n", u.u_comm); */ +/* OBSOLETE */ +/* OBSOLETE /* I don't know where to find this info. */ +/* OBSOLETE So, for now, mark it as not available. *x/ */ +/* OBSOLETE N_SET_MAGIC (core_aouthdr, 0); */ +/* OBSOLETE */ +/* OBSOLETE /* Read the register values out of the core file and store */ +/* OBSOLETE them where `read_register' will find them. *x/ */ +/* OBSOLETE */ +/* OBSOLETE { */ +/* OBSOLETE register int regno; */ +/* OBSOLETE */ +/* OBSOLETE for (regno = 0; regno < NUM_REGS; regno++) */ +/* OBSOLETE { */ +/* OBSOLETE char buf[MAX_REGISTER_RAW_SIZE]; */ +/* OBSOLETE */ +/* OBSOLETE val = lseek (corechan, register_addr (regno, reg_offset), 0); */ +/* OBSOLETE if (val < 0 */ +/* OBSOLETE || (val = myread (corechan, buf, sizeof buf)) < 0) */ +/* OBSOLETE { */ +/* OBSOLETE char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) */ +/* OBSOLETE + 30); */ +/* OBSOLETE strcpy (buffer, "Reading register "); */ +/* OBSOLETE strcat (buffer, REGISTER_NAME (regno)); */ +/* OBSOLETE */ +/* OBSOLETE perror_with_name (buffer); */ +/* OBSOLETE } */ +/* OBSOLETE */ +/* OBSOLETE supply_register (regno, buf); */ +/* OBSOLETE } */ +/* OBSOLETE } */ /* OBSOLETE } */ /* OBSOLETE if (filename[0] == '/') */ -/* OBSOLETE corefile = savestring (filename, strlen (filename)); */ +/* OBSOLETE corefile = savestring (filename, strlen (filename)); */ /* OBSOLETE else */ -/* OBSOLETE { */ -/* OBSOLETE corefile = concat (current_directory, "/", filename, NULL); */ -/* OBSOLETE } */ +/* OBSOLETE { */ +/* OBSOLETE corefile = concat (current_directory, "/", filename, NULL); */ +/* OBSOLETE } */ /* OBSOLETE */ /* OBSOLETE flush_cached_frames (); */ /* OBSOLETE select_frame (get_current_frame (), 0); */ diff --git a/gdb/annotate.c b/gdb/annotate.c index 3b4ab3c..1c235a5 100644 --- a/gdb/annotate.c +++ b/gdb/annotate.c @@ -1,21 +1,22 @@ /* Annotation routines for GDB. Copyright 1986, 89, 90, 91, 92, 95, 98, 1999 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "annotate.h" @@ -92,9 +93,9 @@ annotate_starting () else { if (annotation_level > 1) - { - printf_filtered ("\n\032\032starting\n"); - } + { + printf_filtered ("\n\032\032starting\n"); + } } } @@ -106,7 +107,7 @@ annotate_stopped () else { if (annotation_level > 1) - printf_filtered ("\n\032\032stopped\n"); + printf_filtered ("\n\032\032stopped\n"); } } @@ -119,7 +120,7 @@ annotate_exited (exitstatus) else { if (annotation_level > 1) - printf_filtered ("\n\032\032exited %d\n", exitstatus); + printf_filtered ("\n\032\032exited %d\n", exitstatus); } } diff --git a/gdb/annotate.h b/gdb/annotate.h index 406ee04..1a509b1 100644 --- a/gdb/annotate.h +++ b/gdb/annotate.h @@ -1,21 +1,22 @@ /* Annotation routines for GDB. Copyright 1986, 1989, 1990, 1991, 1992, 1999 Free Software Foundation, Inc. -This file is part of GDB. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "symtab.h" #include "gdbtypes.h" diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c index 16e259b..6e0cf8d 100644 --- a/gdb/arc-tdep.c +++ b/gdb/arc-tdep.c @@ -1,21 +1,22 @@ /* ARC target-dependent stuff. Copyright (C) 1995, 1997 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "frame.h" @@ -32,12 +33,20 @@ char *arc_cpu_type; char *tmp_arc_cpu_type; /* Table of cpu names. */ -struct { - char *name; - int value; -} arc_cpu_type_table[] = { - { "base", bfd_mach_arc_base }, - { NULL, 0 } +struct + { + char *name; + int value; + } +arc_cpu_type_table[] = +{ + { + "base", bfd_mach_arc_base + } + , + { + NULL, 0 + } }; /* Used by simulator. */ @@ -81,7 +90,7 @@ static void codestream_read PARAMS ((unsigned int *, int)); static void codestream_seek PARAMS ((CORE_ADDR)); static unsigned int codestream_fill PARAMS ((int)); -#define CODESTREAM_BUFSIZ 16 +#define CODESTREAM_BUFSIZ 16 static CORE_ADDR codestream_next_addr; static CORE_ADDR codestream_addr; static unsigned int codestream_buf[CODESTREAM_BUFSIZ]; @@ -99,9 +108,9 @@ static int codestream_cnt; ? codestream_fill (0) \ : codestream_buf[codestream_off++]) -static unsigned int +static unsigned int codestream_fill (peek_flag) - int peek_flag; + int peek_flag; { codestream_addr = codestream_next_addr; codestream_next_addr += CODESTREAM_BUFSIZ * sizeof (codestream_buf[0]); @@ -121,7 +130,7 @@ codestream_fill (peek_flag) for (j = 0; j < n / 2; ++j) tmp = p[j], p[j] = p[n - 1 - j], p[n - 1 - j] = tmp; } - + if (peek_flag) return codestream_peek (); else @@ -130,7 +139,7 @@ codestream_fill (peek_flag) static void codestream_seek (place) - CORE_ADDR place; + CORE_ADDR place; { codestream_next_addr = place / CODESTREAM_BUFSIZ; codestream_next_addr *= CODESTREAM_BUFSIZ; @@ -203,16 +212,16 @@ arc_get_frame_setup (pc) { insn = codestream_get (); /* Frame may not be necessary, even though blink is saved. - At least this is something we recognize. */ + At least this is something we recognize. */ frame_size = 0; } - if ((insn & BUILD_INSN (-1, 0, -1, -1, -1)) /* st fp,[sp] */ + if ((insn & BUILD_INSN (-1, 0, -1, -1, -1)) /* st fp,[sp] */ == BUILD_INSN (2, 0, SP_REGNUM, FP_REGNUM, 0)) - { + { insn = codestream_get (); if ((insn & BUILD_INSN (-1, -1, -1, -1, 0)) - != BUILD_INSN (12, FP_REGNUM, SP_REGNUM, SP_REGNUM, 0)) + != BUILD_INSN (12, FP_REGNUM, SP_REGNUM, SP_REGNUM, 0)) return -1; /* Check for stack adjustment sub sp,sp,N. */ @@ -229,7 +238,7 @@ arc_get_frame_setup (pc) if (frame_size < 0) return -1; - codestream_get (); + codestream_get (); /* This sequence is used to get the address of the return buffer for a function that returns a structure. */ @@ -283,8 +292,8 @@ arc_skip_prologue (pc, frameless_p) insn = codestream_peek (); if ((insn & BUILD_INSN (-1, 0, -1, 0, 0)) != BUILD_INSN (2, 0, SP_REGNUM, 0, 0)) - break; /* not st insn */ - if (! ARC_CALL_SAVED_REG (X_C (insn))) + break; /* not st insn */ + if (!ARC_CALL_SAVED_REG (X_C (insn))) break; codestream_get (); } @@ -360,11 +369,11 @@ frame_find_saved_regs (fip, fsrp) dummy_bottom = fip->frame - 4 - REGISTER_BYTES - CALL_DUMMY_LENGTH; /* Check if the PC is in the stack, in a dummy frame. */ - if (dummy_bottom <= fip->pc && fip->pc <= fip->frame) + if (dummy_bottom <= fip->pc && fip->pc <= fip->frame) { /* all regs were saved by push_call_dummy () */ adr = fip->frame; - for (i = 0; i < NUM_REGS; i++) + for (i = 0; i < NUM_REGS; i++) { adr -= REGISTER_RAW_SIZE (i); fsrp->regs[i] = adr; @@ -374,7 +383,7 @@ frame_find_saved_regs (fip, fsrp) locals = arc_get_frame_setup (get_pc_function_start (fip->pc)); - if (locals >= 0) + if (locals >= 0) { /* Set `adr' to the value of `sp'. */ adr = fip->frame - locals; @@ -382,9 +391,9 @@ frame_find_saved_regs (fip, fsrp) { insn = codestream_get (); if ((insn & BUILD_INSN (-1, 0, -1, 0, 0)) - != BUILD_INSN (2, 0, SP_REGNUM, 0, 0)) + != BUILD_INSN (2, 0, SP_REGNUM, 0, 0)) break; - regnum = X_C (insn); + regnum = X_C (insn); offset = X_D (insn); fsrp->regs[regnum] = adr + offset; } @@ -402,7 +411,7 @@ push_dummy_frame () char regbuf[MAX_REGISTER_RAW_SIZE]; read_register_gen (PC_REGNUM, regbuf); - write_memory (sp+4, regbuf, REGISTER_SIZE); + write_memory (sp + 4, regbuf, REGISTER_SIZE); read_register_gen (FP_REGNUM, regbuf); write_memory (sp, regbuf, REGISTER_SIZE); write_register (FP_REGNUM, sp); @@ -411,7 +420,7 @@ push_dummy_frame () read_register_gen (regnum, regbuf); sp = push_bytes (sp, regbuf, REGISTER_RAW_SIZE (regnum)); } - sp += (2*REGISTER_SIZE); + sp += (2 * REGISTER_SIZE); write_register (SP_REGNUM, sp); } @@ -423,10 +432,10 @@ pop_frame () int regnum; struct frame_saved_regs fsr; char regbuf[MAX_REGISTER_RAW_SIZE]; - + fp = FRAME_FP (frame); get_frame_saved_regs (frame, &fsr); - for (regnum = 0; regnum < NUM_REGS; regnum++) + for (regnum = 0; regnum < NUM_REGS; regnum++) { CORE_ADDR adr; adr = fsr.regs[regnum]; @@ -447,11 +456,12 @@ pop_frame () typedef enum { - NORMAL4, /* a normal 4 byte insn */ - NORMAL8, /* a normal 8 byte insn */ - BRANCH4, /* a 4 byte branch insn, including ones without delay slots */ - BRANCH8, /* an 8 byte branch insn, including ones with delay slots */ -} insn_type; + NORMAL4, /* a normal 4 byte insn */ + NORMAL8, /* a normal 8 byte insn */ + BRANCH4, /* a 4 byte branch insn, including ones without delay slots */ + BRANCH8, /* an 8 byte branch insn, including ones with delay slots */ +} +insn_type; /* Return the type of INSN and store in TARGET the destination address of a branch if this is one. */ @@ -466,26 +476,30 @@ get_insn_type (insn, pc, target) switch (insn >> 27) { - case 0 : case 1 : case 2 : /* load/store insns */ + case 0: + case 1: + case 2: /* load/store insns */ if (LIMM_P (X_A (insn)) || LIMM_P (X_B (insn)) || LIMM_P (X_C (insn))) return NORMAL8; return NORMAL4; - case 4 : case 5 : case 6 : /* branch insns */ + case 4: + case 5: + case 6: /* branch insns */ *target = pc + 4 + X_L (insn); /* ??? It isn't clear that this is always the right answer. - The problem occurs when the next insn is an 8 byte insn. If the - branch is conditional there's no worry as there shouldn't be an 8 - byte insn following. The programmer may be cheating if s/he knows - the branch will never be taken, but we don't deal with that. - Note that the programmer is also allowed to play games by putting - an insn with long immediate data in the delay slot and then duplicate - the long immediate data at the branch target. Ugh! */ + The problem occurs when the next insn is an 8 byte insn. If the + branch is conditional there's no worry as there shouldn't be an 8 + byte insn following. The programmer may be cheating if s/he knows + the branch will never be taken, but we don't deal with that. + Note that the programmer is also allowed to play games by putting + an insn with long immediate data in the delay slot and then duplicate + the long immediate data at the branch target. Ugh! */ if (X_N (insn) == 0) return BRANCH4; return BRANCH8; - case 7 : /* jump insns */ + case 7: /* jump insns */ if (LIMM_P (X_B (insn))) { limm = read_memory_integer (pc + 4, 4); @@ -499,7 +513,7 @@ get_insn_type (insn, pc, target) if (X_Q (insn) == 0 && X_N (insn) == 0) return BRANCH4; return BRANCH8; - default : /* arithmetic insns, etc. */ + default: /* arithmetic insns, etc. */ if (LIMM_P (X_A (insn)) || LIMM_P (X_B (insn)) || LIMM_P (X_C (insn))) @@ -518,7 +532,7 @@ get_insn_type (insn, pc, target) void arc_software_single_step (ignore, insert_breakpoints_p) - enum target_signal ignore; /* sig but we don't need it */ + enum target_signal ignore; /* sig but we don't need it */ int insert_breakpoints_p; { static CORE_ADDR next_pc, target; @@ -543,10 +557,10 @@ arc_software_single_step (ignore, insert_breakpoints_p) brktrg_p = 0; if ((type == BRANCH4 || type == BRANCH8) - /* Watch out for branches to the following location. - We just stored a breakpoint there and another call to - target_insert_breakpoint will think the real insn is the - breakpoint we just stored there. */ + /* Watch out for branches to the following location. + We just stored a breakpoint there and another call to + target_insert_breakpoint will think the real insn is the + breakpoint we just stored there. */ && target != next_pc) { brktrg_p = 1; @@ -575,7 +589,7 @@ arc_software_single_step (ignore, insert_breakpoints_p) This routine returns true on success. */ int -get_longjmp_target(pc) +get_longjmp_target (pc) CORE_ADDR *pc; { char buf[TARGET_PTR_BIT / TARGET_CHAR_BIT]; @@ -583,7 +597,7 @@ get_longjmp_target(pc) sp = read_register (SP_REGNUM); - if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack */ + if (target_read_memory (sp + SP_ARG0, /* Offset of first arg on stack */ buf, TARGET_PTR_BIT / TARGET_CHAR_BIT)) return 0; @@ -644,7 +658,7 @@ arc_set_cpu_type_command (args, from_tty) return; } - + if (!arc_set_cpu_type (tmp_arc_cpu_type)) { error ("Unknown cpu type `%s'.", tmp_arc_cpu_type); diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 70db37e..eb760af 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -2,21 +2,22 @@ Copyright (C) 1988, 1989, 1991, 1992, 1993, 1995-1999 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "frame.h" @@ -28,13 +29,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "coff/internal.h" /* Internal format of COFF symbols in BFD */ /* - The following macros are actually wrong. Neither arm nor thumb can - or should set the lsb on addr. - The thumb addresses are mod 2, so (addr & 2) would be a good heuristic - to use when checking for thumb (see arm_pc_is_thumb() below). - Unfortunately, something else depends on these (incorrect) macros, so - fixing them actually breaks gdb. I didn't have time to investigate. Z.R. -*/ + The following macros are actually wrong. Neither arm nor thumb can + or should set the lsb on addr. + The thumb addresses are mod 2, so (addr & 2) would be a good heuristic + to use when checking for thumb (see arm_pc_is_thumb() below). + Unfortunately, something else depends on these (incorrect) macros, so + fixing them actually breaks gdb. I didn't have time to investigate. Z.R. + */ /* Thumb function addresses are odd (bit 0 is set). Here are some macros to test, set, or clear bit 0 of addresses. */ #define IS_THUMB_ADDR(addr) ((addr) & 1) @@ -47,25 +48,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define ROUND_UP(n,a) (((n) + (a) - 1) & ~((a) - 1)) static char *APCS_register_names[] = -{ "a1", "a2", "a3", "a4", /* 0 1 2 3 */ - "v1", "v2", "v3", "v4", /* 4 5 6 7 */ - "v5", "v6", "sl", "fp", /* 8 9 10 11 */ - "ip", "sp", "lr", "pc", /* 12 13 14 15 */ - "f0", "f1", "f2", "f3", /* 16 17 18 19 */ - "f4", "f5", "f6", "f7", /* 20 21 22 23 */ - "fps","ps" } /* 24 25 */; +{"a1", "a2", "a3", "a4", /* 0 1 2 3 */ + "v1", "v2", "v3", "v4", /* 4 5 6 7 */ + "v5", "v6", "sl", "fp", /* 8 9 10 11 */ + "ip", "sp", "lr", "pc", /* 12 13 14 15 */ + "f0", "f1", "f2", "f3", /* 16 17 18 19 */ + "f4", "f5", "f6", "f7", /* 20 21 22 23 */ + "fps", "ps"} /* 24 25 */ ; /* These names are the ones which gcc emits, and I find them less confusing. Toggle between them using the `othernames' command. */ static char *additional_register_names[] = -{ "r0", "r1", "r2", "r3", /* 0 1 2 3 */ - "r4", "r5", "r6", "r7", /* 4 5 6 7 */ - "r8", "r9", "r10", "r11", /* 8 9 10 11 */ - "r12", "r13", "r14", "pc", /* 12 13 14 15 */ - "f0", "f1", "f2", "f3", /* 16 17 18 19 */ - "f4", "f5", "f6", "f7", /* 20 21 22 23 */ - "fps","ps" } /* 24 25 */; +{"r0", "r1", "r2", "r3", /* 0 1 2 3 */ + "r4", "r5", "r6", "r7", /* 4 5 6 7 */ + "r8", "r9", "r10", "r11", /* 8 9 10 11 */ + "r12", "r13", "r14", "pc", /* 12 13 14 15 */ + "f0", "f1", "f2", "f3", /* 16 17 18 19 */ + "f4", "f5", "f6", "f7", /* 20 21 22 23 */ + "fps", "ps"} /* 24 25 */ ; /* By default use the APCS registers names */ @@ -86,7 +87,7 @@ arm_frame_chain_valid (chain, thisframe) CORE_ADDR chain; struct frame_info *thisframe; { -#define LOWEST_PC 0x20 /* the first 0x20 bytes are the trap vectors. */ +#define LOWEST_PC 0x20 /* the first 0x20 bytes are the trap vectors. */ return (chain != 0 && (FRAME_SAVED_PC (thisframe) >= LOWEST_PC)); } @@ -113,7 +114,7 @@ int arm_pc_is_thumb (memaddr) bfd_vma memaddr; { - struct minimal_symbol * sym; + struct minimal_symbol *sym; CORE_ADDR sp; /* If bit 0 of the address is set, assume this is a Thumb address. */ @@ -124,7 +125,7 @@ arm_pc_is_thumb (memaddr) sym = lookup_minimal_symbol_by_pc (memaddr); if (sym) { - return (MSYMBOL_IS_SPECIAL(sym)); + return (MSYMBOL_IS_SPECIAL (sym)); } else return 0; @@ -137,9 +138,9 @@ int arm_pc_is_thumb_dummy (memaddr) bfd_vma memaddr; { - CORE_ADDR sp = read_sp(); + CORE_ADDR sp = read_sp (); - if (PC_IN_CALL_DUMMY (memaddr, sp, sp+64)) + if (PC_IN_CALL_DUMMY (memaddr, sp, sp + 64)) return caller_is_thumb; else return 0; @@ -176,12 +177,12 @@ arm_frameless_function_invocation (fi) } /* A typical Thumb prologue looks like this: - push {r7, lr} - add sp, sp, #-28 - add r7, sp, #12 + push {r7, lr} + add sp, sp, #-28 + add r7, sp, #12 Sometimes the latter instruction may be replaced by: - mov r7, sp -*/ + mov r7, sp + */ static CORE_ADDR thumb_skip_prologue (pc) @@ -193,10 +194,10 @@ thumb_skip_prologue (pc) { unsigned short insn = read_memory_unsigned_integer (current_pc, 2); - if ( (insn & 0xfe00) != 0xb400 /* push {..., r7, lr} */ - && (insn & 0xff00) != 0xb000 /* add sp, #simm */ - && (insn & 0xff00) != 0xaf00 /* add r7, sp, #imm */ - && insn != 0x466f /* mov r7, sp */ + if ((insn & 0xfe00) != 0xb400 /* push {..., r7, lr} */ + && (insn & 0xff00) != 0xb000 /* add sp, #simm */ + && (insn & 0xff00) != 0xaf00 /* add r7, sp, #imm */ + && insn != 0x466f /* mov r7, sp */ && (insn & 0xffc0) != 0x4640) /* mov r0-r7, r8-r15 */ break; } @@ -206,15 +207,15 @@ thumb_skip_prologue (pc) /* APCS (ARM procedure call standard) defines the following prologue: - mov ip, sp - [stmfd sp!, {a1,a2,a3,a4}] - stmfd sp!, {...,fp,ip,lr,pc} - [stfe f7, [sp, #-12]!] - [stfe f6, [sp, #-12]!] - [stfe f5, [sp, #-12]!] - [stfe f4, [sp, #-12]!] - sub fp, ip, #nn // nn == 20 or 4 depending on second ins -*/ + mov ip, sp + [stmfd sp!, {a1,a2,a3,a4}] + stmfd sp!, {...,fp,ip,lr,pc} + [stfe f7, [sp, #-12]!] + [stfe f6, [sp, #-12]!] + [stfe f5, [sp, #-12]!] + [stfe f4, [sp, #-12]!] + sub fp, ip, #nn // nn == 20 or 4 depending on second ins + */ CORE_ADDR arm_skip_prologue (pc) @@ -226,7 +227,7 @@ arm_skip_prologue (pc) struct symtab_and_line sal; /* See what the symbol table says. */ - if (find_pc_partial_function (pc, NULL, & func_addr, & func_end)) + if (find_pc_partial_function (pc, NULL, &func_addr, &func_end)) { sal = find_pc_line (func_addr, 0); if (sal.line != 0 && sal.end < func_end) @@ -241,18 +242,18 @@ arm_skip_prologue (pc) by disassembling the instructions. */ skip_pc = pc; inst = read_memory_integer (skip_pc, 4); - if (inst != 0xe1a0c00d) /* mov ip, sp */ + if (inst != 0xe1a0c00d) /* mov ip, sp */ return pc; skip_pc += 4; inst = read_memory_integer (skip_pc, 4); - if ((inst & 0xfffffff0) == 0xe92d0000) /* stmfd sp!,{a1,a2,a3,a4} */ + if ((inst & 0xfffffff0) == 0xe92d0000) /* stmfd sp!,{a1,a2,a3,a4} */ { skip_pc += 4; inst = read_memory_integer (skip_pc, 4); } - if ((inst & 0xfffff800) != 0xe92dd800) /* stmfd sp!,{...,fp,ip,lr,pc} */ + if ((inst & 0xfffff800) != 0xe92dd800) /* stmfd sp!,{...,fp,ip,lr,pc} */ return pc; skip_pc += 4; @@ -264,28 +265,26 @@ arm_skip_prologue (pc) /* We may have either one sfmfd instruction here, or several stfe insns, depending on the version of floating point code we support. */ - if ((inst & 0xffbf0fff) == 0xec2d0200) /* sfmfd fn, , [sp]! */ + if ((inst & 0xffbf0fff) == 0xec2d0200) /* sfmfd fn, , [sp]! */ { skip_pc += 4; inst = read_memory_integer (skip_pc, 4); } else { - while ((inst & 0xffff8fff) == 0xed6d0103) /* stfe fn, [sp, #-12]! */ - { - skip_pc += 4; - inst = read_memory_integer (skip_pc, 4); - } + while ((inst & 0xffff8fff) == 0xed6d0103) /* stfe fn, [sp, #-12]! */ + { + skip_pc += 4; + inst = read_memory_integer (skip_pc, 4); + } } - if ((inst & 0xfffff000) == 0xe24cb000) /* sub fp, ip, #nn */ + if ((inst & 0xfffff000) == 0xe24cb000) /* sub fp, ip, #nn */ skip_pc += 4; return skip_pc; } - - - +/* *INDENT-OFF* */ /* Function: thumb_scan_prologue (helper function for arm_scan_prologue) This function decodes a Thumb function prologue to determine: 1) the size of the stack frame @@ -306,29 +305,33 @@ arm_skip_prologue (pc) SP -> -12 additional stack space (12 bytes) The frame size would thus be 36 bytes, and the frame offset would be 12 bytes. The frame register is R7. */ - +/* *INDENT-ON* */ + + + + static void thumb_scan_prologue (fi) - struct frame_info * fi; + struct frame_info *fi; { CORE_ADDR prologue_start; CORE_ADDR prologue_end; CORE_ADDR current_pc; - int saved_reg[16]; /* which register has been copied to register n? */ - int i; + int saved_reg[16]; /* which register has been copied to register n? */ + int i; - if (find_pc_partial_function (fi->pc, NULL, & prologue_start, & prologue_end)) + if (find_pc_partial_function (fi->pc, NULL, &prologue_start, &prologue_end)) { struct symtab_and_line sal = find_pc_line (prologue_start, 0); - if (sal.line == 0) /* no line info, use current PC */ + if (sal.line == 0) /* no line info, use current PC */ prologue_end = fi->pc; else if (sal.end < prologue_end) /* next line begins after fn end */ - prologue_end = sal.end; /* (probably means no prologue) */ + prologue_end = sal.end; /* (probably means no prologue) */ } else - prologue_end = prologue_start + 40; /* We're in the boondocks: allow for */ - /* 16 pushes, an add, and "mv fp,sp" */ + prologue_end = prologue_start + 40; /* We're in the boondocks: allow for */ + /* 16 pushes, an add, and "mv fp,sp" */ prologue_end = min (prologue_end, fi->pc); @@ -349,7 +352,7 @@ thumb_scan_prologue (fi) insn = read_memory_unsigned_integer (current_pc, 2); - if ((insn & 0xfe00) == 0xb400) /* push { rlist } */ + if ((insn & 0xfe00) == 0xb400) /* push { rlist } */ { /* Bits 0-7 contain a mask for registers R0-R7. Bit 8 says whether to save LR (R14). */ @@ -358,7 +361,7 @@ thumb_scan_prologue (fi) /* Calculate offsets of saved R0-R7 and LR. */ for (regno = LR_REGNUM; regno >= 0; regno--) if (mask & (1 << regno)) - { + { fi->framesize += 4; fi->fsr.regs[saved_reg[regno]] = -(fi->framesize); saved_reg[regno] = regno; /* reset saved register map */ @@ -366,17 +369,17 @@ thumb_scan_prologue (fi) } else if ((insn & 0xff00) == 0xb000) /* add sp, #simm */ { - offset = (insn & 0x7f) << 2; /* get scaled offset */ - if (insn & 0x80) /* is it signed? */ - offset = -offset; + offset = (insn & 0x7f) << 2; /* get scaled offset */ + if (insn & 0x80) /* is it signed? */ + offset = -offset; fi->framesize -= offset; } else if ((insn & 0xff00) == 0xaf00) /* add r7, sp, #imm */ { fi->framereg = THUMB_FP_REGNUM; - fi->frameoffset = (insn & 0xff) << 2; /* get scaled offset */ + fi->frameoffset = (insn & 0xff) << 2; /* get scaled offset */ } - else if (insn == 0x466f) /* mov r7, sp */ + else if (insn == 0x466f) /* mov r7, sp */ { fi->framereg = THUMB_FP_REGNUM; fi->frameoffset = 0; @@ -384,12 +387,12 @@ thumb_scan_prologue (fi) } else if ((insn & 0xffc0) == 0x4640) /* mov r0-r7, r8-r15 */ { - int lo_reg = insn & 7; /* dest. register (r0-r7) */ + int lo_reg = insn & 7; /* dest. register (r0-r7) */ int hi_reg = ((insn >> 3) & 7) + 8; /* source register (r8-15) */ - saved_reg[lo_reg] = hi_reg; /* remember hi reg was saved */ + saved_reg[lo_reg] = hi_reg; /* remember hi reg was saved */ } else - break; /* anything else isn't prologue */ + break; /* anything else isn't prologue */ } } @@ -399,23 +402,23 @@ thumb_scan_prologue (fi) return non-zero. Otherwise do not copy anything and return zero. The information saved in the cache includes: - * the frame register number; - * the size of the stack frame; - * the offsets of saved regs (relative to the old SP); and - * the offset from the stack pointer to the frame pointer + * the frame register number; + * the size of the stack frame; + * the offsets of saved regs (relative to the old SP); and + * the offset from the stack pointer to the frame pointer The cache contains only one entry, since this is adequate for the typical sequence of prologue scan requests we get. When performing a backtrace, GDB will usually ask to scan the same function twice in a row (once to get the frame chain, and once to fill in the extra frame information). -*/ + */ static struct frame_info prologue_cache; static int check_prologue_cache (fi) - struct frame_info * fi; + struct frame_info *fi; { int i; @@ -435,19 +438,19 @@ check_prologue_cache (fi) /* Function: save_prologue_cache Copy the prologue information from fi to the prologue cache. -*/ + */ static void save_prologue_cache (fi) - struct frame_info * fi; + struct frame_info *fi; { int i; - prologue_cache.pc = fi->pc; - prologue_cache.framereg = fi->framereg; - prologue_cache.framesize = fi->framesize; + prologue_cache.pc = fi->pc; + prologue_cache.framereg = fi->framereg; + prologue_cache.framesize = fi->framesize; prologue_cache.frameoffset = fi->frameoffset; - + for (i = 0; i <= NUM_REGS; i++) prologue_cache.fsr.regs[i] = fi->fsr.regs[i]; } @@ -455,30 +458,30 @@ save_prologue_cache (fi) /* Function: arm_scan_prologue This function decodes an ARM function prologue to determine: - 1) the size of the stack frame - 2) which registers are saved on it - 3) the offsets of saved regs - 4) the offset from the stack pointer to the frame pointer + 1) the size of the stack frame + 2) which registers are saved on it + 3) the offsets of saved regs + 4) the offset from the stack pointer to the frame pointer This information is stored in the "extra" fields of the frame_info. A typical Arm function prologue might look like this: - mov ip, sp - stmfd sp!, {fp, ip, lr, pc} - sub fp, ip, #4 - sub sp, sp, #16 + mov ip, sp + stmfd sp!, {fp, ip, lr, pc} + sub fp, ip, #4 + sub sp, sp, #16 Which would create this stack frame (offsets relative to FP): - IP -> 4 (caller's stack) - FP -> 0 PC (points to address of stmfd instruction + 12 in callee) - -4 LR (return address in caller) - -8 IP (copy of caller's SP) - -12 FP (caller's FP) - SP -> -28 Local variables + IP -> 4 (caller's stack) + FP -> 0 PC (points to address of stmfd instruction + 12 in callee) + -4 LR (return address in caller) + -8 IP (copy of caller's SP) + -12 FP (caller's FP) + SP -> -28 Local variables The frame size would thus be 32 bytes, and the frame offset would be 28 bytes. */ static void arm_scan_prologue (fi) - struct frame_info * fi; + struct frame_info *fi; { int regno, sp_offset, fp_offset; CORE_ADDR prologue_start, prologue_end, current_pc; @@ -488,8 +491,8 @@ arm_scan_prologue (fi) return; /* Assume there is no frame until proven otherwise. */ - fi->framereg = SP_REGNUM; - fi->framesize = 0; + fi->framereg = SP_REGNUM; + fi->framesize = 0; fi->frameoffset = 0; /* Check for Thumb prologue. */ @@ -508,17 +511,17 @@ arm_scan_prologue (fi) in the function and the first source line. */ struct symtab_and_line sal = find_pc_line (prologue_start, 0); - if (sal.line == 0) /* no line info, use current PC */ + if (sal.line == 0) /* no line info, use current PC */ prologue_end = fi->pc; else if (sal.end < prologue_end) /* next line begins after fn end */ - prologue_end = sal.end; /* (probably means no prologue) */ + prologue_end = sal.end; /* (probably means no prologue) */ } else { /* Get address of the stmfd in the prologue of the callee; the saved PC is the address of the stmfd + 12. */ - prologue_start = ADDR_BITS_REMOVE(read_memory_integer (fi->frame, 4)) - 12; - prologue_end = prologue_start + 40; /* FIXME: should be big enough */ + prologue_start = ADDR_BITS_REMOVE (read_memory_integer (fi->frame, 4)) - 12; + prologue_end = prologue_start + 40; /* FIXME: should be big enough */ } /* Now search the prologue looking for instructions that set up the @@ -543,29 +546,29 @@ arm_scan_prologue (fi) } else if ((insn & 0xfffff000) == 0xe24cb000) /* sub fp, ip #n */ { - unsigned imm = insn & 0xff; /* immediate value */ - unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */ - imm = (imm >> rot) | (imm << (32-rot)); + unsigned imm = insn & 0xff; /* immediate value */ + unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */ + imm = (imm >> rot) | (imm << (32 - rot)); fp_offset = -imm; fi->framereg = FP_REGNUM; } else if ((insn & 0xfffff000) == 0xe24dd000) /* sub sp, sp #n */ { - unsigned imm = insn & 0xff; /* immediate value */ - unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */ - imm = (imm >> rot) | (imm << (32-rot)); + unsigned imm = insn & 0xff; /* immediate value */ + unsigned rot = (insn & 0xf00) >> 7; /* rotate amount */ + imm = (imm >> rot) | (imm << (32 - rot)); sp_offset -= imm; } - else if ((insn & 0xffff7fff) == 0xed6d0103) /* stfe f?, [sp, -#c]! */ + else if ((insn & 0xffff7fff) == 0xed6d0103) /* stfe f?, [sp, -#c]! */ { sp_offset -= 12; regno = F0_REGNUM + ((insn >> 12) & 0x07); fi->fsr.regs[regno] = sp_offset; } - else if (insn == 0xe1a0c00d) /* mov ip, sp */ + else if (insn == 0xe1a0c00d) /* mov ip, sp */ continue; else - break; /* not a recognized prologue instruction */ + break; /* not a recognized prologue instruction */ } /* The frame size is just the negative of the offset (from the original SP) @@ -573,7 +576,7 @@ arm_scan_prologue (fi) [new FP] - [new SP]. */ fi->framesize = -sp_offset; fi->frameoffset = fp_offset - sp_offset; - + save_prologue_cache (fi); } @@ -587,23 +590,22 @@ arm_scan_prologue (fi) static CORE_ADDR arm_find_callers_reg (fi, regnum) - struct frame_info * fi; + struct frame_info *fi; int regnum; { for (; fi; fi = fi->next) - -#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ + +#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) return generic_read_register_dummy (fi->pc, fi->frame, regnum); else #endif - if (fi->fsr.regs[regnum] != 0) - return read_memory_integer (fi->fsr.regs[regnum], - REGISTER_RAW_SIZE(regnum)); + if (fi->fsr.regs[regnum] != 0) + return read_memory_integer (fi->fsr.regs[regnum], + REGISTER_RAW_SIZE (regnum)); return read_register (regnum); } - - +/* *INDENT-OFF* */ /* Function: frame_chain Given a GDB frame, determine the address of the calling function's frame. This will be used to create a new GDB frame struct, and then @@ -619,27 +621,31 @@ arm_find_callers_reg (fi, regnum) read_memory_integer ((thisframe)->frame - 12, 4) :\ 0) */ +/* *INDENT-ON* */ + + + CORE_ADDR arm_frame_chain (fi) - struct frame_info * fi; + struct frame_info *fi; { -#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ +#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ CORE_ADDR fn_start, callers_pc, fp; /* is this a dummy frame? */ if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) - return fi->frame; /* dummy frame same as caller's frame */ + return fi->frame; /* dummy frame same as caller's frame */ /* is caller-of-this a dummy frame? */ - callers_pc = FRAME_SAVED_PC(fi); /* find out who called us: */ + callers_pc = FRAME_SAVED_PC (fi); /* find out who called us: */ fp = arm_find_callers_reg (fi, FP_REGNUM); - if (PC_IN_CALL_DUMMY (callers_pc, fp, fp)) - return fp; /* dummy frame's frame may bear no relation to ours */ + if (PC_IN_CALL_DUMMY (callers_pc, fp, fp)) + return fp; /* dummy frame's frame may bear no relation to ours */ if (find_pc_partial_function (fi->pc, 0, &fn_start, 0)) if (fn_start == entry_point_address ()) - return 0; /* in _start fn, don't chain further */ + return 0; /* in _start fn, don't chain further */ #endif CORE_ADDR caller_pc, fn_start; struct frame_info caller_fi; @@ -660,9 +666,9 @@ arm_frame_chain (fi) frame register number. */ if (arm_pc_is_thumb (caller_pc) != arm_pc_is_thumb (fi->pc)) { - memset (& caller_fi, 0, sizeof (caller_fi)); + memset (&caller_fi, 0, sizeof (caller_fi)); caller_fi.pc = caller_pc; - arm_scan_prologue (& caller_fi); + arm_scan_prologue (&caller_fi); framereg = caller_fi.framereg; } @@ -683,7 +689,7 @@ arm_frame_chain (fi) void arm_init_extra_frame_info (fi) - struct frame_info * fi; + struct frame_info *fi; { int reg; @@ -692,29 +698,29 @@ arm_init_extra_frame_info (fi) memset (fi->fsr.regs, '\000', sizeof fi->fsr.regs); -#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ +#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) { /* We need to setup fi->frame here because run_stack_dummy gets it wrong - by assuming it's always FP. */ - fi->frame = generic_read_register_dummy (fi->pc, fi->frame, SP_REGNUM); - fi->framesize = 0; + by assuming it's always FP. */ + fi->frame = generic_read_register_dummy (fi->pc, fi->frame, SP_REGNUM); + fi->framesize = 0; fi->frameoffset = 0; return; } - else + else #endif { arm_scan_prologue (fi); - if (!fi->next) /* this is the innermost frame? */ + if (!fi->next) /* this is the innermost frame? */ fi->frame = read_register (fi->framereg); - else /* not the innermost frame */ - /* If we have an FP, the callee saved it. */ - if (fi->framereg == FP_REGNUM || fi->framereg == THUMB_FP_REGNUM) - if (fi->next->fsr.regs[fi->framereg] != 0) - fi->frame = read_memory_integer (fi->next->fsr.regs[fi->framereg], - 4); + else + /* not the innermost frame */ + /* If we have an FP, the callee saved it. */ if (fi->framereg == FP_REGNUM || fi->framereg == THUMB_FP_REGNUM) + if (fi->next->fsr.regs[fi->framereg] != 0) + fi->frame = read_memory_integer (fi->next->fsr.regs[fi->framereg], + 4); /* Calculate actual addresses of saved registers using offsets determined by arm_scan_prologue. */ @@ -730,15 +736,15 @@ arm_init_extra_frame_info (fi) in the stack anywhere, otherwise we get it from the registers. The old definition of this function was a macro: - #define FRAME_SAVED_PC(FRAME) \ - ADDR_BITS_REMOVE (read_memory_integer ((FRAME)->frame - 4, 4)) -*/ + #define FRAME_SAVED_PC(FRAME) \ + ADDR_BITS_REMOVE (read_memory_integer ((FRAME)->frame - 4, 4)) + */ CORE_ADDR arm_frame_saved_pc (fi) - struct frame_info * fi; + struct frame_info *fi; { -#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ +#if 0 /* FIXME: enable this code if we convert to new call dummy scheme. */ if (PC_IN_CALL_DUMMY (fi->pc, fi->frame, fi->frame)) return generic_read_register_dummy (fi->pc, fi->frame, PC_REGNUM); else @@ -759,7 +765,7 @@ arm_target_read_fp () if (read_register (PS_REGNUM) & 0x20) /* Bit 5 is Thumb state bit */ return read_register (THUMB_FP_REGNUM); /* R7 if Thumb */ else - return read_register (FP_REGNUM); /* R11 if ARM */ + return read_register (FP_REGNUM); /* R11 if ARM */ } @@ -792,13 +798,13 @@ arm_push_dummy_frame () stm instruction stores the PC, it stores the address of the stm instruction itself plus 12. */ fp = sp = push_word (sp, prologue_start + 12); - sp = push_word (sp, read_register (PC_REGNUM)); /* FIXME: was PS_REGNUM */ + sp = push_word (sp, read_register (PC_REGNUM)); /* FIXME: was PS_REGNUM */ sp = push_word (sp, old_sp); sp = push_word (sp, read_register (FP_REGNUM)); - - for (regnum = 10; regnum >= 0; regnum --) + + for (regnum = 10; regnum >= 0; regnum--) sp = push_word (sp, read_register (regnum)); - + write_register (FP_REGNUM, fp); write_register (THUMB_FP_REGNUM, fp); write_register (SP_REGNUM, sp); @@ -810,36 +816,36 @@ arm_push_dummy_frame () different dummies: * ARM calling ARM: uses the call dummy in tm-arm.h, which has already - been copied into the dummy parameter to this function. + been copied into the dummy parameter to this function. * ARM calling Thumb: uses the call dummy in tm-arm.h, but with the - "mov pc,r4" instruction patched to be a "bx r4" instead. + "mov pc,r4" instruction patched to be a "bx r4" instead. * Thumb calling anything: uses the Thumb dummy defined below, which - works for calling both ARM and Thumb functions. + works for calling both ARM and Thumb functions. All three call dummies expect to receive the target function address in R4, with the low bit set if it's a Thumb function. -*/ + */ void arm_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p) - char * dummy; - CORE_ADDR pc; - CORE_ADDR fun; - int nargs; - value_ptr * args; - struct type * type; - int gcc_p; + char *dummy; + CORE_ADDR pc; + CORE_ADDR fun; + int nargs; + value_ptr *args; + struct type *type; + int gcc_p; { static short thumb_dummy[4] = { - 0xf000, 0xf801, /* bl label */ - 0xdf18, /* swi 24 */ - 0x4720, /* label: bx r4 */ + 0xf000, 0xf801, /* bl label */ + 0xdf18, /* swi 24 */ + 0x4720, /* label: bx r4 */ }; static unsigned long arm_bx_r4 = 0xe12fff14; /* bx r4 instruction */ /* Set flag indicating whether the current PC is in a Thumb function. */ - caller_is_thumb = arm_pc_is_thumb (read_pc()); + caller_is_thumb = arm_pc_is_thumb (read_pc ()); /* If the target function is Thumb, set the low bit of the function address. And if the CPU is currently in ARM mode, patch the second instruction @@ -879,7 +885,7 @@ arm_fix_call_dummy (dummy, pc, fun, nargs, args, type, gcc_p) as a place-holder now. This implements the CALL_DUMMY_BREAK_OFFSET macro. -*/ + */ int arm_call_dummy_breakpoint_offset () @@ -892,24 +898,25 @@ arm_call_dummy_breakpoint_offset () CORE_ADDR -arm_push_arguments(nargs, args, sp, struct_return, struct_addr) - int nargs; - value_ptr * args; - CORE_ADDR sp; - int struct_return; - CORE_ADDR struct_addr; +arm_push_arguments (nargs, args, sp, struct_return, struct_addr) + int nargs; + value_ptr *args; + CORE_ADDR sp; + int struct_return; + CORE_ADDR struct_addr; { int argreg; int float_argreg; int argnum; int stack_offset; - struct stack_arg { + struct stack_arg + { char *val; int len; int offset; }; struct stack_arg *stack_args = - (struct stack_arg*)alloca (nargs * sizeof (struct stack_arg)); + (struct stack_arg *) alloca (nargs * sizeof (struct stack_arg)); int nstack_args = 0; @@ -919,7 +926,7 @@ arm_push_arguments(nargs, args, sp, struct_return, struct_addr) /* the struct_return pointer occupies the first parameter-passing reg */ if (struct_return) - write_register (argreg++, struct_addr); + write_register (argreg++, struct_addr); /* The offset onto the stack at which we will start copying parameters (after the registers are used up) begins at 16 in the old ABI. @@ -927,16 +934,16 @@ arm_push_arguments(nargs, args, sp, struct_return, struct_addr) stack_offset = REGISTER_SIZE * 4; /* Process args from left to right. Store as many as allowed in - registers, save the rest to be pushed on the stack */ - for(argnum = 0; argnum < nargs; argnum++) + registers, save the rest to be pushed on the stack */ + for (argnum = 0; argnum < nargs; argnum++) { - char * val; - value_ptr arg = args[argnum]; - struct type * arg_type = check_typedef (VALUE_TYPE (arg)); - struct type * target_type = TYPE_TARGET_TYPE (arg_type); - int len = TYPE_LENGTH (arg_type); + char *val; + value_ptr arg = args[argnum]; + struct type *arg_type = check_typedef (VALUE_TYPE (arg)); + struct type *target_type = TYPE_TARGET_TYPE (arg_type); + int len = TYPE_LENGTH (arg_type); enum type_code typecode = TYPE_CODE (arg_type); - CORE_ADDR regval; + CORE_ADDR regval; int newarg; val = (char *) VALUE_CONTENTS (arg); @@ -952,7 +959,7 @@ arm_push_arguments(nargs, args, sp, struct_return, struct_addr) store_address (val, len, MAKE_THUMB_ADDR (regval)); } -#define MAPCS_FLOAT 0 /* --mapcs-float not implemented by the compiler yet */ +#define MAPCS_FLOAT 0 /* --mapcs-float not implemented by the compiler yet */ #if MAPCS_FLOAT /* Up to four floating point arguments can be passed in floating point registers on ARM (not on Thumb). */ @@ -975,15 +982,15 @@ arm_push_arguments(nargs, args, sp, struct_return, struct_addr) { if (argreg <= ARM_LAST_ARG_REGNUM) { - int partial_len = len < REGISTER_SIZE ? len : REGISTER_SIZE; + int partial_len = len < REGISTER_SIZE ? len : REGISTER_SIZE; regval = extract_address (val, partial_len); /* It's a simple argument being passed in a general register. */ write_register (argreg, regval); argreg++; - len -= partial_len; - val += partial_len; + len -= partial_len; + val += partial_len; } else { @@ -995,13 +1002,13 @@ arm_push_arguments(nargs, args, sp, struct_return, struct_addr) } } } - /* now do the real stack pushing, process args right to left */ - while(nstack_args--) - { - sp -= stack_args[nstack_args].len; - write_memory(sp, stack_args[nstack_args].val, - stack_args[nstack_args].len); - } + /* now do the real stack pushing, process args right to left */ + while (nstack_args--) + { + sp -= stack_args[nstack_args].len; + write_memory (sp, stack_args[nstack_args].val, + stack_args[nstack_args].len); + } /* Return adjusted stack pointer. */ return sp; @@ -1010,14 +1017,14 @@ arm_push_arguments(nargs, args, sp, struct_return, struct_addr) void arm_pop_frame () { - struct frame_info *frame = get_current_frame(); + struct frame_info *frame = get_current_frame (); int regnum; CORE_ADDR old_SP; old_SP = read_register (frame->framereg); for (regnum = 0; regnum < NUM_REGS; regnum++) if (frame->fsr.regs[regnum] != 0) - write_register (regnum, + write_register (regnum, read_memory_integer (frame->fsr.regs[regnum], 4)); write_register (PC_REGNUM, FRAME_SAVED_PC (frame)); @@ -1030,61 +1037,69 @@ static void print_fpu_flags (flags) int flags; { - if (flags & (1 << 0)) fputs ("IVO ", stdout); - if (flags & (1 << 1)) fputs ("DVZ ", stdout); - if (flags & (1 << 2)) fputs ("OFL ", stdout); - if (flags & (1 << 3)) fputs ("UFL ", stdout); - if (flags & (1 << 4)) fputs ("INX ", stdout); - putchar ('\n'); + if (flags & (1 << 0)) + fputs ("IVO ", stdout); + if (flags & (1 << 1)) + fputs ("DVZ ", stdout); + if (flags & (1 << 2)) + fputs ("OFL ", stdout); + if (flags & (1 << 3)) + fputs ("UFL ", stdout); + if (flags & (1 << 4)) + fputs ("INX ", stdout); + putchar ('\n'); } void arm_float_info () { - register unsigned long status = read_register (FPS_REGNUM); - int type; - - type = (status >> 24) & 127; - printf ("%s FPU type %d\n", - (status & (1<<31)) ? "Hardware" : "Software", - type); - fputs ("mask: ", stdout); - print_fpu_flags (status >> 16); - fputs ("flags: ", stdout); - print_fpu_flags (status); + register unsigned long status = read_register (FPS_REGNUM); + int type; + + type = (status >> 24) & 127; + printf ("%s FPU type %d\n", + (status & (1 << 31)) ? "Hardware" : "Software", + type); + fputs ("mask: ", stdout); + print_fpu_flags (status >> 16); + fputs ("flags: ", stdout); + print_fpu_flags (status); } static void arm_othernames () { - if (arm_register_names == APCS_register_names) { - arm_register_names = additional_register_names; - arm_toggle_regnames (); - } else { - arm_register_names = APCS_register_names; - arm_toggle_regnames (); - } - + if (arm_register_names == APCS_register_names) + { + arm_register_names = additional_register_names; + arm_toggle_regnames (); + } + else + { + arm_register_names = APCS_register_names; + arm_toggle_regnames (); + } + } /* FIXME: Fill in with the 'right thing', see asm template in arm-convert.s */ -void +void convert_from_extended (ptr, dbl) - void * ptr; - double * dbl; + void *ptr; + double *dbl; { - *dbl = *(double*)ptr; + *dbl = *(double *) ptr; } -void +void convert_to_extended (dbl, ptr) - void * ptr; - double * dbl; + void *ptr; + double *dbl; { - *(double*)ptr = *dbl; + *(double *) ptr = *dbl; } static int @@ -1123,10 +1138,10 @@ condition_true (cond, status_reg) return (((status_reg & FLAG_N) == 0) != ((status_reg & FLAG_V) == 0)); case INST_GT: return (((status_reg & FLAG_Z) == 0) && - (((status_reg & FLAG_N) == 0) == ((status_reg & FLAG_V) == 0))); + (((status_reg & FLAG_N) == 0) == ((status_reg & FLAG_V) == 0))); case INST_LE: return (((status_reg & FLAG_Z) != 0) || - (((status_reg & FLAG_N) == 0) != ((status_reg & FLAG_V) == 0))); + (((status_reg & FLAG_N) == 0) != ((status_reg & FLAG_V) == 0))); } return 1; } @@ -1150,42 +1165,43 @@ shifted_reg_val (inst, carry, pc_val, status_reg) unsigned long res, shift; int rm = bits (inst, 0, 3); unsigned long shifttype = bits (inst, 5, 6); - - if (bit(inst, 4)) + + if (bit (inst, 4)) { int rs = bits (inst, 8, 11); shift = (rs == 15 ? pc_val + 8 : read_register (rs)) & 0xFF; } else shift = bits (inst, 7, 11); - - res = (rm == 15 + + res = (rm == 15 ? ((pc_val | (ARM_PC_32 ? 0 : status_reg)) - + (bit (inst, 4) ? 12 : 8)) + + (bit (inst, 4) ? 12 : 8)) : read_register (rm)); switch (shifttype) { - case 0: /* LSL */ + case 0: /* LSL */ res = shift >= 32 ? 0 : res << shift; break; - - case 1: /* LSR */ + + case 1: /* LSR */ res = shift >= 32 ? 0 : res >> shift; break; - case 2: /* ASR */ - if (shift >= 32) shift = 31; + case 2: /* ASR */ + if (shift >= 32) + shift = 31; res = ((res & 0x80000000L) ? ~((~res) >> shift) : res >> shift); break; - case 3: /* ROR/RRX */ + case 3: /* ROR/RRX */ shift &= 31; if (shift == 0) res = (res >> 1) | (carry ? 0x80000000L : 0); else - res = (res >> shift) | (res << (32-shift)); + res = (res >> shift) | (res << (32 - shift)); break; } @@ -1201,7 +1217,7 @@ bitcount (val) { int nbits; for (nbits = 0; val != 0; nbits++) - val &= val - 1; /* delete rightmost 1-bit in val */ + val &= val - 1; /* delete rightmost 1-bit in val */ return nbits; } @@ -1210,9 +1226,9 @@ static CORE_ADDR thumb_get_next_pc (pc) CORE_ADDR pc; { - unsigned long pc_val = ((unsigned long)pc) + 4; /* PC after prefetch */ + unsigned long pc_val = ((unsigned long) pc) + 4; /* PC after prefetch */ unsigned short inst1 = read_memory_integer (pc, 2); - CORE_ADDR nextpc = pc + 2; /* default is next instruction */ + CORE_ADDR nextpc = pc + 2; /* default is next instruction */ unsigned long offset; if ((inst1 & 0xff00) == 0xbd00) /* pop {rlist, pc} */ @@ -1231,7 +1247,7 @@ thumb_get_next_pc (pc) else if ((inst1 & 0xf000) == 0xd000) /* conditional branch */ { unsigned long status = read_register (PS_REGNUM); - unsigned long cond = bits (inst1, 8, 11); + unsigned long cond = bits (inst1, 8, 11); if (cond != 0x0f && condition_true (cond, status)) /* 0x0f = SWI */ nextpc = pc_val + (sbits (inst1, 0, 7) << 1); } @@ -1242,7 +1258,7 @@ thumb_get_next_pc (pc) else if ((inst1 & 0xf800) == 0xf000) /* long branch with link */ { unsigned short inst2 = read_memory_integer (pc + 2, 2); - offset = (sbits (inst1, 0, 10) << 12) + (bits (inst2, 0, 10) << 1); + offset = (sbits (inst1, 0, 10) << 12) + (bits (inst2, 0, 10) << 1); nextpc = pc_val + offset; } @@ -1265,93 +1281,98 @@ arm_get_next_pc (pc) pc_val = (unsigned long) pc; this_instr = read_memory_integer (pc, 4); status = read_register (PS_REGNUM); - nextpc = (CORE_ADDR) (pc_val + 4); /* Default case */ + nextpc = (CORE_ADDR) (pc_val + 4); /* Default case */ if (condition_true (bits (this_instr, 28, 31), status)) { switch (bits (this_instr, 24, 27)) { - case 0x0: case 0x1: /* data processing */ - case 0x2: case 0x3: + case 0x0: + case 0x1: /* data processing */ + case 0x2: + case 0x3: { unsigned long operand1, operand2, result = 0; unsigned long rn; int c; - + if (bits (this_instr, 12, 15) != 15) break; if (bits (this_instr, 22, 25) == 0 - && bits (this_instr, 4, 7) == 9) /* multiply */ + && bits (this_instr, 4, 7) == 9) /* multiply */ error ("Illegal update to pc in instruction"); /* Multiply into PC */ c = (status & FLAG_C) ? 1 : 0; rn = bits (this_instr, 16, 19); operand1 = (rn == 15) ? pc_val + 8 : read_register (rn); - + if (bit (this_instr, 25)) { unsigned long immval = bits (this_instr, 0, 7); unsigned long rotate = 2 * bits (this_instr, 8, 11); - operand2 = ((immval >> rotate) | (immval << (32-rotate))) - & 0xffffffff; + operand2 = ((immval >> rotate) | (immval << (32 - rotate))) + & 0xffffffff; } - else /* operand 2 is a shifted register */ + else /* operand 2 is a shifted register */ operand2 = shifted_reg_val (this_instr, c, pc_val, status); - + switch (bits (this_instr, 21, 24)) { - case 0x0: /*and*/ + case 0x0: /*and */ result = operand1 & operand2; break; - case 0x1: /*eor*/ + case 0x1: /*eor */ result = operand1 ^ operand2; break; - case 0x2: /*sub*/ + case 0x2: /*sub */ result = operand1 - operand2; break; - case 0x3: /*rsb*/ + case 0x3: /*rsb */ result = operand2 - operand1; break; - case 0x4: /*add*/ + case 0x4: /*add */ result = operand1 + operand2; break; - case 0x5: /*adc*/ + case 0x5: /*adc */ result = operand1 + operand2 + c; break; - case 0x6: /*sbc*/ + case 0x6: /*sbc */ result = operand1 - operand2 + c; break; - case 0x7: /*rsc*/ + case 0x7: /*rsc */ result = operand2 - operand1 + c; break; - case 0x8: case 0x9: case 0xa: case 0xb: /* tst, teq, cmp, cmn */ + case 0x8: + case 0x9: + case 0xa: + case 0xb: /* tst, teq, cmp, cmn */ result = (unsigned long) nextpc; break; - case 0xc: /*orr*/ + case 0xc: /*orr */ result = operand1 | operand2; break; - case 0xd: /*mov*/ + case 0xd: /*mov */ /* Always step into a function. */ result = operand2; - break; + break; - case 0xe: /*bic*/ + case 0xe: /*bic */ result = operand1 & ~operand2; break; - case 0xf: /*mvn*/ + case 0xf: /*mvn */ result = ~operand2; break; } @@ -1361,18 +1382,20 @@ arm_get_next_pc (pc) error ("Infinite loop detected"); break; } - - case 0x4: case 0x5: /* data transfer */ - case 0x6: case 0x7: + + case 0x4: + case 0x5: /* data transfer */ + case 0x6: + case 0x7: if (bit (this_instr, 20)) { /* load */ if (bits (this_instr, 12, 15) == 15) { /* rd == pc */ - unsigned long rn; + unsigned long rn; unsigned long base; - + if (bit (this_instr, 22)) error ("Illegal update to pc in instruction"); @@ -1384,18 +1407,18 @@ arm_get_next_pc (pc) /* pre-indexed */ int c = (status & FLAG_C) ? 1 : 0; unsigned long offset = - (bit (this_instr, 25) - ? shifted_reg_val (this_instr, c, pc_val) - : bits (this_instr, 0, 11)); + (bit (this_instr, 25) + ? shifted_reg_val (this_instr, c, pc_val) + : bits (this_instr, 0, 11)); if (bit (this_instr, 23)) base += offset; else base -= offset; } - nextpc = (CORE_ADDR) read_memory_integer ((CORE_ADDR) base, + nextpc = (CORE_ADDR) read_memory_integer ((CORE_ADDR) base, 4); - + nextpc = ADDR_BITS_REMOVE (nextpc); if (nextpc == pc) @@ -1403,8 +1426,9 @@ arm_get_next_pc (pc) } } break; - - case 0x8: case 0x9: /* block transfer */ + + case 0x8: + case 0x9: /* block transfer */ if (bit (this_instr, 20)) { /* LDM */ @@ -1418,18 +1442,18 @@ arm_get_next_pc (pc) /* up */ unsigned long reglist = bits (this_instr, 0, 14); offset = bitcount (reglist) * 4; - if (bit (this_instr, 24)) /* pre */ + if (bit (this_instr, 24)) /* pre */ offset += 4; } else if (bit (this_instr, 24)) offset = -4; - + { - unsigned long rn_val = - read_register (bits (this_instr, 16, 19)); + unsigned long rn_val = + read_register (bits (this_instr, 16, 19)); nextpc = (CORE_ADDR) read_memory_integer ((CORE_ADDR) (rn_val - + offset), + + offset), 4); } nextpc = ADDR_BITS_REMOVE (nextpc); @@ -1438,9 +1462,9 @@ arm_get_next_pc (pc) } } break; - - case 0xb: /* branch & link */ - case 0xa: /* branch */ + + case 0xb: /* branch & link */ + case 0xa: /* branch */ { nextpc = BranchDest (pc, this_instr); @@ -1449,10 +1473,11 @@ arm_get_next_pc (pc) error ("Infinite loop detected"); break; } - - case 0xc: case 0xd: - case 0xe: /* coproc ops */ - case 0xf: /* SWI */ + + case 0xc: + case 0xd: + case 0xe: /* coproc ops */ + case 0xf: /* SWI */ break; default: @@ -1470,15 +1495,15 @@ arm_get_next_pc (pc) static int gdb_print_insn_arm (memaddr, info) bfd_vma memaddr; - disassemble_info * info; + disassemble_info *info; { if (arm_pc_is_thumb (memaddr)) { - static asymbol * asym; - static combined_entry_type ce; - static struct coff_symbol_struct csym; - static struct _bfd fake_bfd; - static bfd_target fake_target; + static asymbol *asym; + static combined_entry_type ce; + static struct coff_symbol_struct csym; + static struct _bfd fake_bfd; + static bfd_target fake_target; if (csym.native == NULL) { @@ -1486,22 +1511,22 @@ gdb_print_insn_arm (memaddr, info) solely so that the code in print_insn_little_arm() and print_insn_big_arm() in opcodes/arm-dis.c will detect the presence of a Thumb symbol and switch to decoding Thumb instructions. */ - - fake_target.flavour = bfd_target_coff_flavour; - fake_bfd.xvec = & fake_target; + + fake_target.flavour = bfd_target_coff_flavour; + fake_bfd.xvec = &fake_target; ce.u.syment.n_sclass = C_THUMBEXTFUNC; - csym.native = & ce; - csym.symbol.the_bfd = & fake_bfd; - csym.symbol.name = "fake"; - asym = (asymbol *) & csym; + csym.native = &ce; + csym.symbol.the_bfd = &fake_bfd; + csym.symbol.name = "fake"; + asym = (asymbol *) & csym; } - + memaddr = UNMAKE_THUMB_ADDR (memaddr); - info->symbols = & asym; + info->symbols = &asym; } else info->symbols = NULL; - + if (TARGET_BYTE_ORDER == BIG_ENDIAN) return print_insn_big_arm (memaddr, info); else @@ -1509,10 +1534,10 @@ gdb_print_insn_arm (memaddr, info) } /* Sequence of bytes for breakpoint instruction. */ -#define ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7} /* Recognized illegal opcodes */ -#define ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE} -#define THUMB_LE_BREAKPOINT {0xfe,0xdf} -#define THUMB_BE_BREAKPOINT {0xdf,0xfe} +#define ARM_LE_BREAKPOINT {0xFE,0xDE,0xFF,0xE7} /* Recognized illegal opcodes */ +#define ARM_BE_BREAKPOINT {0xE7,0xFF,0xDE,0xFE} +#define THUMB_LE_BREAKPOINT {0xfe,0xdf} +#define THUMB_BE_BREAKPOINT {0xdf,0xfe} /* The following has been superseded by BREAKPOINT_FOR_PC, but is defined merely to keep mem-break.c happy. */ @@ -1528,40 +1553,40 @@ gdb_print_insn_arm (memaddr, info) unsigned char * arm_breakpoint_from_pc (pcptr, lenptr) - CORE_ADDR * pcptr; - int * lenptr; + CORE_ADDR *pcptr; + int *lenptr; { if (arm_pc_is_thumb (*pcptr) || arm_pc_is_thumb_dummy (*pcptr)) { if (TARGET_BYTE_ORDER == BIG_ENDIAN) - { - static char thumb_breakpoint[] = THUMB_BE_BREAKPOINT; - *pcptr = UNMAKE_THUMB_ADDR (*pcptr); - *lenptr = sizeof (thumb_breakpoint); - return thumb_breakpoint; - } + { + static char thumb_breakpoint[] = THUMB_BE_BREAKPOINT; + *pcptr = UNMAKE_THUMB_ADDR (*pcptr); + *lenptr = sizeof (thumb_breakpoint); + return thumb_breakpoint; + } else - { - static char thumb_breakpoint[] = THUMB_LE_BREAKPOINT; - *pcptr = UNMAKE_THUMB_ADDR (*pcptr); - *lenptr = sizeof (thumb_breakpoint); - return thumb_breakpoint; - } + { + static char thumb_breakpoint[] = THUMB_LE_BREAKPOINT; + *pcptr = UNMAKE_THUMB_ADDR (*pcptr); + *lenptr = sizeof (thumb_breakpoint); + return thumb_breakpoint; + } } else { if (TARGET_BYTE_ORDER == BIG_ENDIAN) - { - static char arm_breakpoint[] = ARM_BE_BREAKPOINT; - *lenptr = sizeof (arm_breakpoint); - return arm_breakpoint; - } + { + static char arm_breakpoint[] = ARM_BE_BREAKPOINT; + *lenptr = sizeof (arm_breakpoint); + return arm_breakpoint; + } else - { - static char arm_breakpoint[] = ARM_LE_BREAKPOINT; - *lenptr = sizeof (arm_breakpoint); - return arm_breakpoint; - } + { + static char arm_breakpoint[] = ARM_LE_BREAKPOINT; + *lenptr = sizeof (arm_breakpoint); + return arm_breakpoint; + } } } /* Return non-zero if the PC is inside a call thunk (aka stub or trampoline). @@ -1570,7 +1595,7 @@ arm_breakpoint_from_pc (pcptr, lenptr) int arm_in_call_stub (pc, name) CORE_ADDR pc; - char * name; + char *name; { CORE_ADDR start_addr; @@ -1592,7 +1617,7 @@ CORE_ADDR arm_skip_stub (pc) CORE_ADDR pc; { - char * name; + char *name; CORE_ADDR start_addr; /* Find the starting address and name of the function containing the PC. */ @@ -1604,50 +1629,50 @@ arm_skip_stub (pc) { /* Use the name suffix to determine which register contains the target PC. */ - static char *table[15] = - { "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", - "r8", "r9", "sl", "fp", "ip", "sp", "lr" - }; + static char *table[15] = + {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", + "r8", "r9", "sl", "fp", "ip", "sp", "lr" + }; int regno; for (regno = 0; regno <= 14; regno++) if (strcmp (&name[10], table[regno]) == 0) return read_register (regno); } - return 0; /* not a stub */ + return 0; /* not a stub */ } void _initialize_arm_tdep () { - int regname_is_APCS = (arm_register_names == APCS_register_names); + int regname_is_APCS = (arm_register_names == APCS_register_names); tm_print_insn = gdb_print_insn_arm; - + /* Sync the opcode insn printer with our register viewer: */ if (arm_toggle_regnames () != regname_is_APCS) arm_toggle_regnames (); - + add_com ("othernames", class_obscure, arm_othernames, "Switch to the other set of register names."); /* ??? Maybe this should be a boolean. */ add_show_from_set (add_set_cmd ("apcs32", no_class, - var_zinteger, (char *)&arm_apcs_32, - "Set usage of ARM 32-bit mode.\n", &setlist), - & showlist); + var_zinteger, (char *) &arm_apcs_32, + "Set usage of ARM 32-bit mode.\n", &setlist), + &showlist); } /* Test whether the coff symbol specific value corresponds to a Thumb function */ int -coff_sym_is_thumb(int val) +coff_sym_is_thumb (int val) { - return (val == C_THUMBEXT || - val == C_THUMBSTAT || - val == C_THUMBEXTFUNC || - val == C_THUMBSTATFUNC || - val == C_THUMBLABEL); + return (val == C_THUMBEXT || + val == C_THUMBSTAT || + val == C_THUMBEXTFUNC || + val == C_THUMBSTATFUNC || + val == C_THUMBLABEL); } diff --git a/gdb/arm-xdep.c b/gdb/arm-xdep.c index 19781c2..48c416d 100644 --- a/gdb/arm-xdep.c +++ b/gdb/arm-xdep.c @@ -1,21 +1,22 @@ /* Acorn Risc Machine host machine support. Copyright (C) 1988, 1989, 1991 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "frame.h" @@ -42,7 +43,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ void fetch_inferior_registers (regno) - int regno; /* Original value discarded */ + int regno; /* Original value discarded */ { register unsigned int regaddr; char buf[MAX_REGISTER_RAW_SIZE]; @@ -51,34 +52,35 @@ fetch_inferior_registers (regno) struct user u; unsigned int offset = (char *) &u.u_ar0 - (char *) &u; offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) - - KERNEL_U_ADDR; + - KERNEL_U_ADDR; registers_fetched (); - + for (regno = 0; regno < 16; regno++) { regaddr = offset + regno * 4; - *(int *)&buf[0] = ptrace (PT_READ_U, inferior_pid, - (PTRACE_ARG3_TYPE) regaddr, 0); + *(int *) &buf[0] = ptrace (PT_READ_U, inferior_pid, + (PTRACE_ARG3_TYPE) regaddr, 0); if (regno == PC_REGNUM) - *(int *)&buf[0] = GET_PC_PART(*(int *)&buf[0]); + *(int *) &buf[0] = GET_PC_PART (*(int *) &buf[0]); supply_register (regno, buf); } - *(int *)&buf[0] = ptrace (PT_READ_U, inferior_pid, - (PTRACE_ARG3_TYPE) (offset + PC*4), 0); - supply_register (PS_REGNUM, buf); /* set virtual register ps same as pc */ + *(int *) &buf[0] = ptrace (PT_READ_U, inferior_pid, + (PTRACE_ARG3_TYPE) (offset + PC * 4), 0); + supply_register (PS_REGNUM, buf); /* set virtual register ps same as pc */ /* read the floating point registers */ - offset = (char *) &u.u_fp_regs - (char *)&u; - *(int *)buf = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0); + offset = (char *) &u.u_fp_regs - (char *) &u; + *(int *) buf = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0); supply_register (FPS_REGNUM, buf); - for (regno = 16; regno < 24; regno++) { + for (regno = 16; regno < 24; regno++) + { regaddr = offset + 4 + 12 * (regno - 16); - for (i = 0; i < 12; i += sizeof(int)) - *(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid, - (PTRACE_ARG3_TYPE) (regaddr + i), 0); + for (i = 0; i < 12; i += sizeof (int)) + *(int *) &buf[i] = ptrace (PT_READ_U, inferior_pid, + (PTRACE_ARG3_TYPE) (regaddr + i), 0); supply_register (regno, buf); - } + } } /* Store our register values back into the inferior. @@ -96,15 +98,17 @@ store_inferior_registers (regno) unsigned long value; unsigned int offset = (char *) &u.u_ar0 - (char *) &u; offset = ptrace (PT_READ_U, inferior_pid, (PTRACE_ARG3_TYPE) offset, 0) - - KERNEL_U_ADDR; + - KERNEL_U_ADDR; - if (regno >= 0) { - if (regno >= 16) return; + if (regno >= 0) + { + if (regno >= 16) + return; regaddr = offset + 4 * regno; errno = 0; - value = read_register(regno); + value = read_register (regno); if (regno == PC_REGNUM) - value = SET_PC_PART(read_register (PS_REGNUM), value); + value = SET_PC_PART (read_register (PS_REGNUM), value); ptrace (PT_WRITE_U, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value); if (errno != 0) { @@ -112,20 +116,21 @@ store_inferior_registers (regno) perror_with_name (buf); } } - else for (regno = 0; regno < 15; regno++) - { - regaddr = offset + regno * 4; - errno = 0; - value = read_register(regno); - if (regno == PC_REGNUM) - value = SET_PC_PART(read_register (PS_REGNUM), value); - ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value); - if (errno != 0) - { - sprintf (buf, "writing all regs, number %d", regno); - perror_with_name (buf); - } - } + else + for (regno = 0; regno < 15; regno++) + { + regaddr = offset + regno * 4; + errno = 0; + value = read_register (regno); + if (regno == PC_REGNUM) + value = SET_PC_PART (read_register (PS_REGNUM), value); + ptrace (6, inferior_pid, (PTRACE_ARG3_TYPE) regaddr, value); + if (errno != 0) + { + sprintf (buf, "writing all regs, number %d", regno); + perror_with_name (buf); + } + } } /* Work with core dump and executable files, for GDB. @@ -135,20 +140,21 @@ store_inferior_registers (regno) by the execfile. e.g. prog shares Xt which shares X11 which shares c. */ -struct shared_library { - struct exec_header header; - char name[SHLIBLEN]; - CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file */ - long data_offset; /* offset of data section in file */ - int chan; /* file descriptor for the file */ - struct shared_library *shares; /* library this one shares */ +struct shared_library +{ + struct exec_header header; + char name[SHLIBLEN]; + CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file */ + long data_offset; /* offset of data section in file */ + int chan; /* file descriptor for the file */ + struct shared_library *shares; /* library this one shares */ }; static struct shared_library *shlib = 0; /* Hook for `exec_file_command' command to call. */ extern void (*exec_file_display_hook) (); - + static CORE_ADDR unshared_text_start; /* extended header from exec file (for shared library info) */ @@ -184,7 +190,7 @@ core_file_command (filename, from_tty) { filename = tilde_expand (filename); make_cleanup (free, filename); - + if (have_inferior_p ()) error ("To look at a core file, you must kill the program with \"kill\"."); corechan = open (filename, O_RDONLY, 0); @@ -218,7 +224,7 @@ core_file_command (filename, from_tty) reg_offset = (int) u.u_ar0; if (reg_offset > NBPG * UPAGES) reg_offset -= KERNEL_U_ADDR; - fp_reg_offset = (char *) &u.u_fp_regs - (char *)&u; + fp_reg_offset = (char *) &u.u_fp_regs - (char *) &u; /* I don't know where to find this info. So, for now, mark it as not available. */ @@ -235,26 +241,26 @@ core_file_command (filename, from_tty) char buf[MAX_REGISTER_RAW_SIZE]; if (regno < 16) - val = lseek (corechan, reg_offset + 4 * regno, 0); + val = lseek (corechan, reg_offset + 4 * regno, 0); else if (regno < 24) - val = lseek (corechan, fp_reg_offset + 4 + 12*(regno - 24), 0); + val = lseek (corechan, fp_reg_offset + 4 + 12 * (regno - 24), 0); else if (regno == 24) - val = lseek (corechan, fp_reg_offset, 0); + val = lseek (corechan, fp_reg_offset, 0); else if (regno == 25) - val = lseek (corechan, reg_offset + 4 * PC, 0); + val = lseek (corechan, reg_offset + 4 * PC, 0); if (val < 0 || (val = myread (corechan, buf, sizeof buf)) < 0) { - char * buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) - + 30); + char *buffer = (char *) alloca (strlen (REGISTER_NAME (regno)) + + 30); strcpy (buffer, "Reading register "); strcat (buffer, REGISTER_NAME (regno)); - + perror_with_name (buffer); } if (regno == PC_REGNUM) - *(int *)buf = GET_PC_PART(*(int *)buf); + *(int *) buf = GET_PC_PART (*(int *) buf); supply_register (regno, buf); } } @@ -282,20 +288,21 @@ core_file_command (filename, from_tty) by the execfile. e.g. prog shares Xt which shares X11 which shares c. */ -struct shared_library { - struct exec_header header; - char name[SHLIBLEN]; - CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file */ - long data_offset; /* offset of data section in file */ - int chan; /* file descriptor for the file */ - struct shared_library *shares; /* library this one shares */ +struct shared_library +{ + struct exec_header header; + char name[SHLIBLEN]; + CORE_ADDR text_start; /* CORE_ADDR of 1st byte of text, this file */ + long data_offset; /* offset of data section in file */ + int chan; /* file descriptor for the file */ + struct shared_library *shares; /* library this one shares */ }; static struct shared_library *shlib = 0; /* Hook for `exec_file_command' command to call. */ extern void (*exec_file_display_hook) (); - + static CORE_ADDR unshared_text_start; /* extended header from exec file (for shared library info) */ @@ -325,10 +332,11 @@ exec_file_command (filename, from_tty) if (execchan >= 0) close (execchan); execchan = -1; - if (shlib) { - close_shared_library(shlib); + if (shlib) + { + close_shared_library (shlib); shlib = 0; - } + } /* Now open and digest the file the user requested, if any. */ @@ -348,7 +356,7 @@ exec_file_command (filename, from_tty) #ifdef HEADER_SEEK_FD HEADER_SEEK_FD (execchan); #endif - + val = myread (execchan, &exec_header, sizeof exec_header); exec_aouthdr = exec_header.a_exec; @@ -359,21 +367,23 @@ exec_file_command (filename, from_tty) /* Look for shared library if needed */ if (exec_header.a_exec.a_magic & MF_USES_SL) - shlib = open_shared_library(exec_header.a_shlibname, text_start); + shlib = open_shared_library (exec_header.a_shlibname, text_start); text_offset = N_TXTOFF (exec_aouthdr); exec_data_offset = N_TXTOFF (exec_aouthdr) + exec_aouthdr.a_text; - if (shlib) { - unshared_text_start = shared_text_end(shlib) & ~0x7fff; + if (shlib) + { + unshared_text_start = shared_text_end (shlib) & ~0x7fff; stack_start = shlib->header.a_exec.a_sldatabase; stack_end = STACK_END_ADDR; - } else - unshared_text_start = 0x8000; + } + else + unshared_text_start = 0x8000; text_end = unshared_text_start + exec_aouthdr.a_text; exec_data_start = unshared_text_start + exec_aouthdr.a_text; - exec_data_end = exec_data_start + exec_aouthdr.a_data; + exec_data_end = exec_data_start + exec_aouthdr.a_data; data_start = exec_data_start; data_end += exec_data_start; @@ -421,19 +431,19 @@ xfer_core_file (memaddr, myaddr, len) xferchan = 0; /* Determine which file the next bunch of addresses reside in, - and where in the file. Set the file's read/write pointer - to point at the proper place for the desired address - and set xferfile and xferchan for the correct file. + and where in the file. Set the file's read/write pointer + to point at the proper place for the desired address + and set xferfile and xferchan for the correct file. - If desired address is nonexistent, leave them zero. + If desired address is nonexistent, leave them zero. - i is set to the number of bytes that can be handled - along with the next address. + i is set to the number of bytes that can be handled + along with the next address. - We put the most likely tests first for efficiency. */ + We put the most likely tests first for efficiency. */ /* Note that if there is no core file - data_start and data_end are equal. */ + data_start and data_end are equal. */ if (memaddr >= data_start && memaddr < data_end) { i = min (len, data_end - memaddr); @@ -442,29 +452,33 @@ xfer_core_file (memaddr, myaddr, len) xferchan = corechan; } /* Note that if there is no core file - stack_start and stack_end define the shared library data. */ + stack_start and stack_end define the shared library data. */ else if (memaddr >= stack_start && memaddr < stack_end) { - if (corechan < 0) { - struct shared_library *lib; - for (lib = shlib; lib; lib = lib->shares) - if (memaddr >= lib->header.a_exec.a_sldatabase && - memaddr < lib->header.a_exec.a_sldatabase + - lib->header.a_exec.a_data) - break; - if (lib) { - i = min (len, lib->header.a_exec.a_sldatabase + - lib->header.a_exec.a_data - memaddr); - fileptr = lib->data_offset + memaddr - - lib->header.a_exec.a_sldatabase; - xferfile = execfile; - xferchan = lib->chan; + if (corechan < 0) + { + struct shared_library *lib; + for (lib = shlib; lib; lib = lib->shares) + if (memaddr >= lib->header.a_exec.a_sldatabase && + memaddr < lib->header.a_exec.a_sldatabase + + lib->header.a_exec.a_data) + break; + if (lib) + { + i = min (len, lib->header.a_exec.a_sldatabase + + lib->header.a_exec.a_data - memaddr); + fileptr = lib->data_offset + memaddr - + lib->header.a_exec.a_sldatabase; + xferfile = execfile; + xferchan = lib->chan; } - } else { - i = min (len, stack_end - memaddr); - fileptr = memaddr - stack_start + stack_offset; - xferfile = &corefile; - xferchan = corechan; + } + else + { + i = min (len, stack_end - memaddr); + fileptr = memaddr - stack_start + stack_offset; + xferfile = &corefile; + xferchan = corechan; } } else if (corechan < 0 @@ -477,22 +491,25 @@ xfer_core_file (memaddr, myaddr, len) } else if (memaddr >= text_start && memaddr < text_end) { - struct shared_library *lib; - for (lib = shlib; lib; lib = lib->shares) - if (memaddr >= lib->text_start && - memaddr < lib->text_start + lib->header.a_exec.a_text) - break; - if (lib) { - i = min (len, lib->header.a_exec.a_text + - lib->text_start - memaddr); - fileptr = memaddr - lib->text_start + text_offset; - xferfile = &execfile; - xferchan = lib->chan; - } else { - i = min (len, text_end - memaddr); - fileptr = memaddr - unshared_text_start + text_offset; - xferfile = &execfile; - xferchan = execchan; + struct shared_library *lib; + for (lib = shlib; lib; lib = lib->shares) + if (memaddr >= lib->text_start && + memaddr < lib->text_start + lib->header.a_exec.a_text) + break; + if (lib) + { + i = min (len, lib->header.a_exec.a_text + + lib->text_start - memaddr); + fileptr = memaddr - lib->text_start + text_offset; + xferfile = &execfile; + xferchan = lib->chan; + } + else + { + i = min (len, text_end - memaddr); + fileptr = memaddr - unshared_text_start + text_offset; + xferfile = &execfile; + xferchan = execchan; } } else if (memaddr < text_start) @@ -500,7 +517,7 @@ xfer_core_file (memaddr, myaddr, len) i = min (len, text_start - memaddr); } else if (memaddr >= text_end - && memaddr < (corechan >= 0? data_start : exec_data_start)) + && memaddr < (corechan >= 0 ? data_start : exec_data_start)) { i = min (len, data_start - memaddr); } @@ -511,11 +528,11 @@ xfer_core_file (memaddr, myaddr, len) } else if (corechan < 0 && memaddr >= exec_data_end) { - i = min (len, - memaddr); + i = min (len, -memaddr); } else if (memaddr >= stack_end && stack_end != 0) { - i = min (len, - memaddr); + i = min (len, -memaddr); } else { @@ -525,7 +542,7 @@ xfer_core_file (memaddr, myaddr, len) } /* Now we know which file to use. - Set up its pointer and transfer the data. */ + Set up its pointer and transfer the data. */ if (xferfile) { if (*xferfile == 0) @@ -541,8 +558,8 @@ xfer_core_file (memaddr, myaddr, len) perror_with_name (*xferfile); } /* If this address is for nonexistent memory, - read zeros if reading, or do nothing if writing. - Actually, we never right. */ + read zeros if reading, or do nothing if writing. + Actually, we never right. */ else { memset (myaddr, '\0', i); diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index f9265e4..6dea775 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1,21 +1,22 @@ /* GDB-specific functions for operating on agent expressions Copyright 1998 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "symtab.h" @@ -43,20 +44,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ pay for the simplicity of this code with less-than-optimal bytecode strings. - Remember, "GBD" stands for "Great Britain, Dammit!" So be careful. */ + Remember, "GBD" stands for "Great Britain, Dammit!" So be careful. */ + - /* Prototypes for local functions. */ /* There's a standard order to the arguments of these functions: union exp_element ** --- pointer into expression struct agent_expr * --- agent expression buffer to generate code into struct axs_value * --- describes value left on top of stack */ - -static struct value *const_var_ref PARAMS ((struct symbol *var)); -static struct value *const_expr PARAMS ((union exp_element **pc)); -static struct value *maybe_const_expr PARAMS ((union exp_element **pc)); + +static struct value *const_var_ref PARAMS ((struct symbol * var)); +static struct value *const_expr PARAMS ((union exp_element ** pc)); +static struct value *maybe_const_expr PARAMS ((union exp_element ** pc)); static void gen_traced_pop PARAMS ((struct agent_expr *, struct axs_value *)); @@ -66,91 +67,91 @@ static void gen_fetch PARAMS ((struct agent_expr *, struct type *)); static void gen_left_shift PARAMS ((struct agent_expr *, int)); -static void gen_frame_args_address PARAMS ((struct agent_expr *)); +static void gen_frame_args_address PARAMS ((struct agent_expr *)); static void gen_frame_locals_address PARAMS ((struct agent_expr *)); -static void gen_offset PARAMS ((struct agent_expr *ax, int offset)); +static void gen_offset PARAMS ((struct agent_expr * ax, int offset)); static void gen_sym_offset PARAMS ((struct agent_expr *, struct symbol *)); -static void gen_var_ref PARAMS ((struct agent_expr *ax, - struct axs_value *value, - struct symbol *var)); - - -static void gen_int_literal PARAMS ((struct agent_expr *ax, - struct axs_value *value, - LONGEST k, struct type *type)); - - -static void require_rvalue PARAMS ((struct agent_expr *ax, - struct axs_value *value)); -static void gen_usual_unary PARAMS ((struct agent_expr *ax, - struct axs_value *value)); -static int type_wider_than PARAMS ((struct type *type1, - struct type *type2)); -static struct type *max_type PARAMS ((struct type *type1, - struct type *type2)); -static void gen_conversion PARAMS ((struct agent_expr *ax, - struct type *from, - struct type *to)); -static int is_nontrivial_conversion PARAMS ((struct type *from, - struct type *to)); -static void gen_usual_arithmetic PARAMS ((struct agent_expr *ax, - struct axs_value *value1, - struct axs_value *value2)); -static void gen_integral_promotions PARAMS ((struct agent_expr *ax, - struct axs_value *value)); -static void gen_cast PARAMS ((struct agent_expr *ax, - struct axs_value *value, - struct type *type)); -static void gen_scale PARAMS ((struct agent_expr *ax, +static void gen_var_ref PARAMS ((struct agent_expr * ax, + struct axs_value * value, + struct symbol * var)); + + +static void gen_int_literal PARAMS ((struct agent_expr * ax, + struct axs_value * value, + LONGEST k, struct type * type)); + + +static void require_rvalue PARAMS ((struct agent_expr * ax, + struct axs_value * value)); +static void gen_usual_unary PARAMS ((struct agent_expr * ax, + struct axs_value * value)); +static int type_wider_than PARAMS ((struct type * type1, + struct type * type2)); +static struct type *max_type PARAMS ((struct type * type1, + struct type * type2)); +static void gen_conversion PARAMS ((struct agent_expr * ax, + struct type * from, + struct type * to)); +static int is_nontrivial_conversion PARAMS ((struct type * from, + struct type * to)); +static void gen_usual_arithmetic PARAMS ((struct agent_expr * ax, + struct axs_value * value1, + struct axs_value * value2)); +static void gen_integral_promotions PARAMS ((struct agent_expr * ax, + struct axs_value * value)); +static void gen_cast PARAMS ((struct agent_expr * ax, + struct axs_value * value, + struct type * type)); +static void gen_scale PARAMS ((struct agent_expr * ax, enum agent_op op, - struct type *type)); -static void gen_add PARAMS ((struct agent_expr *ax, - struct axs_value *value, - struct axs_value *value1, - struct axs_value *value2, + struct type * type)); +static void gen_add PARAMS ((struct agent_expr * ax, + struct axs_value * value, + struct axs_value * value1, + struct axs_value * value2, char *name)); -static void gen_sub PARAMS ((struct agent_expr *ax, - struct axs_value *value, - struct axs_value *value1, - struct axs_value *value2)); -static void gen_binop PARAMS ((struct agent_expr *ax, - struct axs_value *value, - struct axs_value *value1, - struct axs_value *value2, +static void gen_sub PARAMS ((struct agent_expr * ax, + struct axs_value * value, + struct axs_value * value1, + struct axs_value * value2)); +static void gen_binop PARAMS ((struct agent_expr * ax, + struct axs_value * value, + struct axs_value * value1, + struct axs_value * value2, enum agent_op op, enum agent_op op_unsigned, int may_carry, char *name)); -static void gen_logical_not PARAMS ((struct agent_expr *ax, - struct axs_value *value)); -static void gen_complement PARAMS ((struct agent_expr *ax, - struct axs_value *value)); +static void gen_logical_not PARAMS ((struct agent_expr * ax, + struct axs_value * value)); +static void gen_complement PARAMS ((struct agent_expr * ax, + struct axs_value * value)); static void gen_deref PARAMS ((struct agent_expr *, struct axs_value *)); static void gen_address_of PARAMS ((struct agent_expr *, struct axs_value *)); -static int find_field PARAMS ((struct type *type, char *name)); -static void gen_bitfield_ref PARAMS ((struct agent_expr *ax, - struct axs_value *value, - struct type *type, +static int find_field PARAMS ((struct type * type, char *name)); +static void gen_bitfield_ref PARAMS ((struct agent_expr * ax, + struct axs_value * value, + struct type * type, int start, int end)); -static void gen_struct_ref PARAMS ((struct agent_expr *ax, - struct axs_value *value, +static void gen_struct_ref PARAMS ((struct agent_expr * ax, + struct axs_value * value, char *field, char *operator_name, char *operand_name)); -static void gen_repeat PARAMS ((union exp_element **pc, - struct agent_expr *ax, - struct axs_value *value)); -static void gen_sizeof PARAMS ((union exp_element **pc, - struct agent_expr *ax, - struct axs_value *value)); -static void gen_expr PARAMS ((union exp_element **pc, - struct agent_expr *ax, - struct axs_value *value)); - -static void print_axs_value PARAMS ((GDB_FILE *f, struct axs_value *value)); +static void gen_repeat PARAMS ((union exp_element ** pc, + struct agent_expr * ax, + struct axs_value * value)); +static void gen_sizeof PARAMS ((union exp_element ** pc, + struct agent_expr * ax, + struct axs_value * value)); +static void gen_expr PARAMS ((union exp_element ** pc, + struct agent_expr * ax, + struct axs_value * value)); + +static void print_axs_value PARAMS ((GDB_FILE * f, struct axs_value * value)); static void agent_command PARAMS ((char *exp, int from_tty)); - + /* Detecting constant expressions. */ /* If the variable reference at *PC is a constant, return its value. @@ -219,7 +220,7 @@ const_expr (pc) return v; } - /* We could add more operators in here. */ + /* We could add more operators in here. */ case UNOP_NEG: (*pc)++; @@ -247,11 +248,11 @@ maybe_const_expr (pc) /* If we got a value, then update the real PC. */ if (v) *pc = tentative_pc; - + return v; } - + /* Generating bytecode from GDB expressions: general assumptions */ /* Here are a few general assumptions made throughout the code; if you @@ -259,43 +260,43 @@ maybe_const_expr (pc) better scan things pretty thoroughly. - We assume that all values occupy one stack element. For example, - sometimes we'll swap to get at the left argument to a binary - operator. If we decide that void values should occupy no stack - elements, or that synthetic arrays (whose size is determined at - run time, created by the `@' operator) should occupy two stack - elements (address and length), then this will cause trouble. + sometimes we'll swap to get at the left argument to a binary + operator. If we decide that void values should occupy no stack + elements, or that synthetic arrays (whose size is determined at + run time, created by the `@' operator) should occupy two stack + elements (address and length), then this will cause trouble. - We assume the stack elements are infinitely wide, and that we - don't have to worry what happens if the user requests an - operation that is wider than the actual interpreter's stack. - That is, it's up to the interpreter to handle directly all the - integer widths the user has access to. (Woe betide the language - with bignums!) + don't have to worry what happens if the user requests an + operation that is wider than the actual interpreter's stack. + That is, it's up to the interpreter to handle directly all the + integer widths the user has access to. (Woe betide the language + with bignums!) - We don't support side effects. Thus, we don't have to worry about - GCC's generalized lvalues, function calls, etc. + GCC's generalized lvalues, function calls, etc. - We don't support floating point. Many places where we switch on - some type don't bother to include cases for floating point; there - may be even more subtle ways this assumption exists. For - example, the arguments to % must be integers. + some type don't bother to include cases for floating point; there + may be even more subtle ways this assumption exists. For + example, the arguments to % must be integers. - We assume all subexpressions have a static, unchanging type. If - we tried to support convenience variables, this would be a - problem. + we tried to support convenience variables, this would be a + problem. - All values on the stack should always be fully zero- or - sign-extended. - - (I wasn't sure whether to choose this or its opposite --- that - only addresses are assumed extended --- but it turns out that - neither convention completely eliminates spurious extend - operations (if everything is always extended, then you have to - extend after add, because it could overflow; if nothing is - extended, then you end up producing extends whenever you change - sizes), and this is simpler.) */ - + sign-extended. + + (I wasn't sure whether to choose this or its opposite --- that + only addresses are assumed extended --- but it turns out that + neither convention completely eliminates spurious extend + operations (if everything is always extended, then you have to + extend after add, because it could overflow; if nothing is + extended, then you end up producing extends whenever you change + sizes), and this is simpler.) */ + /* Generating bytecode from GDB expressions: the `trace' kludge */ /* The compiler in this file is a general-purpose mechanism for @@ -334,7 +335,7 @@ gen_traced_pop (ax, value) { case axs_rvalue: /* We don't trace rvalues, just the lvalues necessary to - produce them. So just dispose of this value. */ + produce them. So just dispose of this value. */ ax_simple (ax, aop_pop); break; @@ -350,7 +351,7 @@ gen_traced_pop (ax, value) ax_const_l (ax, length); ax_simple (ax, aop_trace); } - break; + break; case axs_lvalue_register: /* We need to mention the register somewhere in the bytecode, @@ -364,9 +365,9 @@ gen_traced_pop (ax, value) /* If we're not tracing, just pop the value. */ ax_simple (ax, aop_pop); } + - /* Generating bytecode from GDB expressions: helper functions */ /* Assume that the lower bits of the top of the stack is a value of @@ -377,7 +378,7 @@ gen_sign_extend (ax, type) struct type *type; { /* Do we need to sign-extend this? */ - if (! TYPE_UNSIGNED (type)) + if (!TYPE_UNSIGNED (type)) ax_ext (ax, type->length * TARGET_CHAR_BIT); } @@ -420,10 +421,18 @@ gen_fetch (ax, type) many bytes long is it? */ switch (type->length) { - case 8 / TARGET_CHAR_BIT: ax_simple (ax, aop_ref8 ); break; - case 16 / TARGET_CHAR_BIT: ax_simple (ax, aop_ref16); break; - case 32 / TARGET_CHAR_BIT: ax_simple (ax, aop_ref32); break; - case 64 / TARGET_CHAR_BIT: ax_simple (ax, aop_ref64); break; + case 8 / TARGET_CHAR_BIT: + ax_simple (ax, aop_ref8); + break; + case 16 / TARGET_CHAR_BIT: + ax_simple (ax, aop_ref16); + break; + case 32 / TARGET_CHAR_BIT: + ax_simple (ax, aop_ref32); + break; + case 64 / TARGET_CHAR_BIT: + ax_simple (ax, aop_ref64); + break; /* Either our caller shouldn't have asked us to dereference that pointer (other code's fault), or we're not @@ -438,9 +447,9 @@ gen_fetch (ax, type) default: /* Either our caller shouldn't have asked us to dereference that - pointer (other code's fault), or we're not implementing - something we should be (this code's fault). In any case, - it's a bug the user shouldn't see. */ + pointer (other code's fault), or we're not implementing + something we should be (this code's fault). In any case, + it's a bug the user shouldn't see. */ error ("GDB bug: ax-gdb.c (gen_fetch): bad type code"); } } @@ -465,9 +474,9 @@ gen_left_shift (ax, distance) ax_simple (ax, aop_rsh_unsigned); } } + - /* Generating bytecode from GDB expressions: symbol references */ /* Generate code to push the base address of the argument portion of @@ -479,7 +488,7 @@ gen_frame_args_address (ax) long frame_reg, frame_offset; TARGET_VIRTUAL_FRAME_POINTER (ax->scope, &frame_reg, &frame_offset); - ax_reg (ax, frame_reg); + ax_reg (ax, frame_reg); gen_offset (ax, frame_offset); } @@ -493,7 +502,7 @@ gen_frame_locals_address (ax) long frame_reg, frame_offset; TARGET_VIRTUAL_FRAME_POINTER (ax->scope, &frame_reg, &frame_offset); - ax_reg (ax, frame_reg); + ax_reg (ax, frame_reg); gen_offset (ax, frame_offset); } @@ -620,9 +629,9 @@ gen_var_ref (ax, value, var) break; /* A lot like LOC_REF_ARG, but the pointer lives directly in a - register, not on the stack. Simpler than LOC_REGISTER and - LOC_REGPARM, because it's just like any other case where the - thing has a real address. */ + register, not on the stack. Simpler than LOC_REGISTER and + LOC_REGPARM, because it's just like any other case where the + thing has a real address. */ case LOC_REGPARM_ADDR: ax_reg (ax, SYMBOL_VALUE (var)); value->kind = axs_lvalue_memory; @@ -630,16 +639,16 @@ gen_var_ref (ax, value, var) case LOC_UNRESOLVED: { - struct minimal_symbol *msym - = lookup_minimal_symbol (SYMBOL_NAME (var), NULL, NULL); - if (! msym) + struct minimal_symbol *msym + = lookup_minimal_symbol (SYMBOL_NAME (var), NULL, NULL); + if (!msym) error ("Couldn't resolve symbol `%s'.", SYMBOL_SOURCE_NAME (var)); - + /* Push the address of the variable. */ ax_const_l (ax, SYMBOL_VALUE_ADDRESS (msym)); value->kind = axs_lvalue_memory; } - break; + break; case LOC_OPTIMIZED_OUT: error ("The variable `%s' has been optimized out.", @@ -652,9 +661,9 @@ gen_var_ref (ax, value, var) break; } } + - /* Generating bytecode from GDB expressions: literals */ static void @@ -668,9 +677,9 @@ gen_int_literal (ax, value, k, type) value->kind = axs_rvalue; value->type = type; } + - /* Generating bytecode from GDB expressions: unary conversions, casts */ /* Take what's on the top of the stack (as described by VALUE), and @@ -696,8 +705,8 @@ require_rvalue (ax, value) /* There's nothing on the stack, but value->u.reg is the register number containing the value. - When we add floating-point support, this is going to have to - change. What about SPARC register pairs, for example? */ + When we add floating-point support, this is going to have to + change. What about SPARC register pairs, for example? */ ax_reg (ax, value->u.reg); gen_extend (ax, value->type); break; @@ -742,7 +751,7 @@ gen_usual_unary (ax, value) break; /* Arrays get converted to a pointer to their first element, and - are no longer an lvalue. */ + are no longer an lvalue. */ case TYPE_CODE_ARRAY: { struct type *elements = TYPE_TARGET_TYPE (value->type); @@ -751,10 +760,10 @@ gen_usual_unary (ax, value) /* We don't need to generate any code; the address of the array is also the address of its first element. */ } - break; + break; - /* Don't try to convert structures and unions to rvalues. Let the - consumer signal an error. */ + /* Don't try to convert structures and unions to rvalues. Let the + consumer signal an error. */ case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: return; @@ -779,7 +788,7 @@ type_wider_than (type1, type2) return (TYPE_LENGTH (type1) > TYPE_LENGTH (type2) || (TYPE_LENGTH (type1) == TYPE_LENGTH (type2) && TYPE_UNSIGNED (type1) - && ! TYPE_UNSIGNED (type2))); + && !TYPE_UNSIGNED (type2))); } @@ -860,10 +869,10 @@ gen_usual_arithmetic (ax, value1, value2) && TYPE_CODE (value2->type) == TYPE_CODE_INT) { /* The ANSI integral promotions seem to work this way: Order the - integer types by size, and then by signedness: an n-bit - unsigned type is considered "wider" than an n-bit signed - type. Promote to the "wider" of the two types, and always - promote at least to int. */ + integer types by size, and then by signedness: an n-bit + unsigned type is considered "wider" than an n-bit signed + type. Promote to the "wider" of the two types, and always + promote at least to int. */ struct type *target = max_type (builtin_type_int, max_type (value1->type, value2->type)); @@ -893,12 +902,12 @@ gen_integral_promotions (ax, value) struct agent_expr *ax; struct axs_value *value; { - if (! type_wider_than (value->type, builtin_type_int)) + if (!type_wider_than (value->type, builtin_type_int)) { gen_conversion (ax, value->type, builtin_type_int); value->type = builtin_type_int; } - else if (! type_wider_than (value->type, builtin_type_unsigned_int)) + else if (!type_wider_than (value->type, builtin_type_unsigned_int)) { gen_conversion (ax, value->type, builtin_type_unsigned_int); value->type = builtin_type_unsigned_int; @@ -940,16 +949,16 @@ gen_cast (ax, value, type) cast like this? */ value->type = type; break; - + case TYPE_CODE_INT: gen_conversion (ax, value->type, type); break; case TYPE_CODE_VOID: /* We could pop the value, and rely on everyone else to check - the type and notice that this value doesn't occupy a stack - slot. But for now, leave the value on the stack, and - preserve the "value == stack element" assumption. */ + the type and notice that this value doesn't occupy a stack + slot. But for now, leave the value on the stack, and + preserve the "value == stack element" assumption. */ break; default: @@ -958,9 +967,9 @@ gen_cast (ax, value, type) value->type = type; } + - /* Generating bytecode from GDB expressions: arithmetic */ /* Scale the integer on the top of the stack by the size of the target @@ -1000,7 +1009,7 @@ gen_add (ax, value, value1, value2, name) ax_simple (ax, aop_swap); gen_scale (ax, aop_mul, value2->type); ax_simple (ax, aop_add); - gen_extend (ax, value2->type); /* Catch overflow. */ + gen_extend (ax, value2->type); /* Catch overflow. */ value->type = value2->type; } @@ -1010,7 +1019,7 @@ gen_add (ax, value, value1, value2, name) { gen_scale (ax, aop_mul, value1->type); ax_simple (ax, aop_add); - gen_extend (ax, value1->type); /* Catch overflow. */ + gen_extend (ax, value1->type); /* Catch overflow. */ value->type = value1->type; } @@ -1020,7 +1029,7 @@ gen_add (ax, value, value1, value2, name) && value2->type->code == TYPE_CODE_INT) { ax_simple (ax, aop_add); - gen_extend (ax, value1->type); /* Catch overflow. */ + gen_extend (ax, value1->type); /* Catch overflow. */ value->type = value1->type; } @@ -1049,20 +1058,20 @@ gen_sub (ax, value, value1, value2) { gen_scale (ax, aop_mul, value1->type); ax_simple (ax, aop_sub); - gen_extend (ax, value1->type); /* Catch overflow. */ + gen_extend (ax, value1->type); /* Catch overflow. */ value->type = value1->type; } /* Is it PTR - PTR? Strictly speaking, the types ought to - match, but this is what the normal GDB expression evaluator - tests for. */ + match, but this is what the normal GDB expression evaluator + tests for. */ else if (value2->type->code == TYPE_CODE_PTR && (TYPE_LENGTH (TYPE_TARGET_TYPE (value1->type)) == TYPE_LENGTH (TYPE_TARGET_TYPE (value2->type)))) { ax_simple (ax, aop_sub); gen_scale (ax, aop_div_unsigned, value1->type); - value->type = builtin_type_long; /* FIXME --- should be ptrdiff_t */ + value->type = builtin_type_long; /* FIXME --- should be ptrdiff_t */ } else error ("\ @@ -1075,10 +1084,10 @@ an integer nor a pointer of the same type."); && value2->type->code == TYPE_CODE_INT) { ax_simple (ax, aop_sub); - gen_extend (ax, value1->type); /* Catch overflow. */ + gen_extend (ax, value1->type); /* Catch overflow. */ value->type = value1->type; } - + else error ("Illegal combination of types in subtraction."); @@ -1103,11 +1112,11 @@ gen_binop (ax, value, value1, value2, op, op_unsigned, may_carry, name) if ((value1->type->code != TYPE_CODE_INT) || (value2->type->code != TYPE_CODE_INT)) error ("Illegal combination of types in %s.", name); - + ax_simple (ax, TYPE_UNSIGNED (value1->type) ? op_unsigned : op); if (may_carry) - gen_extend (ax, value1->type); /* catch overflow */ + gen_extend (ax, value1->type); /* catch overflow */ value->type = value1->type; value->kind = axs_rvalue; } @@ -1141,9 +1150,9 @@ gen_complement (ax, value) ax_simple (ax, aop_bit_not); gen_extend (ax, value->type); } + - /* Generating bytecode from GDB expressions: * & . -> @ sizeof */ /* Dereference the value on the top of the stack. */ @@ -1247,7 +1256,8 @@ gen_bitfield_ref (ax, value, type, start, end) { /* Note that ops[i] fetches 8 << i bits. */ static enum agent_op ops[] - = { aop_ref8, aop_ref16, aop_ref32, aop_ref64 }; + = + {aop_ref8, aop_ref16, aop_ref32, aop_ref64}; static int num_ops = (sizeof (ops) / sizeof (ops[0])); /* We don't want to touch any byte that the bitfield doesn't @@ -1258,19 +1268,19 @@ gen_bitfield_ref (ax, value, type, start, end) It takes some fancy footwork to get the stack to work the way we'd like. Say we're retrieving a bitfield that requires three fetches. Initially, the stack just contains the address: - addr + addr For the first fetch, we duplicate the address - addr addr + addr addr then add the byte offset, do the fetch, and shift and mask as needed, yielding a fragment of the value, properly aligned for the final bitwise or: - addr frag1 + addr frag1 then we swap, and repeat the process: - frag1 addr --- address on top - frag1 addr addr --- duplicate it - frag1 addr frag2 --- get second fragment - frag1 frag2 addr --- swap again - frag1 frag2 frag3 --- get third fragment + frag1 addr --- address on top + frag1 addr addr --- duplicate it + frag1 addr frag2 --- get second fragment + frag1 frag2 addr --- swap again + frag1 frag2 frag3 --- get third fragment Notice that, since the third fragment is the last one, we don't bother duplicating the address this time. Now we have all the fragments on the stack, and we can simply `or' them together, @@ -1279,9 +1289,9 @@ gen_bitfield_ref (ax, value, type, start, end) /* The first and one-after-last bits in the field, but rounded down and up to byte boundaries. */ int bound_start = (start / TARGET_CHAR_BIT) * TARGET_CHAR_BIT; - int bound_end = (((end + TARGET_CHAR_BIT - 1) - / TARGET_CHAR_BIT) - * TARGET_CHAR_BIT); + int bound_end = (((end + TARGET_CHAR_BIT - 1) + / TARGET_CHAR_BIT) + * TARGET_CHAR_BIT); /* current bit offset within the structure */ int offset; @@ -1310,17 +1320,17 @@ gen_bitfield_ref (ax, value, type, start, end) int op_size = 8 << op; /* The stack at this point, from bottom to top, contains zero or - more fragments, then the address. */ - + more fragments, then the address. */ + /* Does this fetch fit within the bitfield? */ if (offset + op_size <= bound_end) { /* Is this the last fragment? */ int last_frag = (offset + op_size == bound_end); - if (! last_frag) - ax_simple (ax, aop_dup); /* keep a copy of the address */ - + if (!last_frag) + ax_simple (ax, aop_dup); /* keep a copy of the address */ + /* Add the offset. */ gen_offset (ax, offset / TARGET_CHAR_BIT); @@ -1332,47 +1342,47 @@ gen_bitfield_ref (ax, value, type, start, end) /* Perform the fetch. */ ax_simple (ax, ops[op]); - - /* Shift the bits we have to their proper position. + + /* Shift the bits we have to their proper position. gen_left_shift will generate right shifts when the operand is negative. - A big-endian field diagram to ponder: - byte 0 byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 byte 7 - +------++------++------++------++------++------++------++------+ - xxxxAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCxxxxxxxxxxx - ^ ^ ^ ^ - bit number 16 32 48 53 + A big-endian field diagram to ponder: + byte 0 byte 1 byte 2 byte 3 byte 4 byte 5 byte 6 byte 7 + +------++------++------++------++------++------++------++------+ + xxxxAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCxxxxxxxxxxx + ^ ^ ^ ^ + bit number 16 32 48 53 These are bit numbers as supplied by GDB. Note that the bit numbers run from right to left once you've fetched the value! - A little-endian field diagram to ponder: - byte 7 byte 6 byte 5 byte 4 byte 3 byte 2 byte 1 byte 0 - +------++------++------++------++------++------++------++------+ - xxxxxxxxxxxAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCxxxx - ^ ^ ^ ^ ^ - bit number 48 32 16 4 0 - - In both cases, the most significant end is on the left - (i.e. normal numeric writing order), which means that you - don't go crazy thinking about `left' and `right' shifts. - - We don't have to worry about masking yet: - - If they contain garbage off the least significant end, then we - must be looking at the low end of the field, and the right - shift will wipe them out. - - If they contain garbage off the most significant end, then we - must be looking at the most significant end of the word, and - the sign/zero extension will wipe them out. - - If we're in the interior of the word, then there is no garbage - on either end, because the ref operators zero-extend. */ + A little-endian field diagram to ponder: + byte 7 byte 6 byte 5 byte 4 byte 3 byte 2 byte 1 byte 0 + +------++------++------++------++------++------++------++------+ + xxxxxxxxxxxAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCxxxx + ^ ^ ^ ^ ^ + bit number 48 32 16 4 0 + + In both cases, the most significant end is on the left + (i.e. normal numeric writing order), which means that you + don't go crazy thinking about `left' and `right' shifts. + + We don't have to worry about masking yet: + - If they contain garbage off the least significant end, then we + must be looking at the low end of the field, and the right + shift will wipe them out. + - If they contain garbage off the most significant end, then we + must be looking at the most significant end of the word, and + the sign/zero extension will wipe them out. + - If we're in the interior of the word, then there is no garbage + on either end, because the ref operators zero-extend. */ if (TARGET_BYTE_ORDER == BIG_ENDIAN) gen_left_shift (ax, end - (offset + op_size)); - else + else gen_left_shift (ax, offset - start); - if (! last_frag) + if (!last_frag) /* Bring the copy of the address up to the top. */ ax_simple (ax, aop_swap); @@ -1433,7 +1443,7 @@ gen_struct_ref (ax, value, field, operator_name, operand_name) error ("Structure does not live in memory."); i = find_field (type, field); - + /* Is this a bitfield? */ if (TYPE_FIELD_PACKED (type, i)) gen_bitfield_ref (ax, value, TYPE_FIELD_TYPE (type, i), @@ -1478,7 +1488,7 @@ gen_repeat (pc, ax, value) struct value *v = const_expr (pc); int length; - if (! v) + if (!v) error ("Right operand of `@' must be a constant, in agent expressions."); if (v->type->code != TYPE_CODE_INT) error ("Right operand of `@' must be an integer."); @@ -1490,9 +1500,9 @@ gen_repeat (pc, ax, value) all we need to do is frob the type of the lvalue. */ { /* FIXME-type-allocation: need a way to free this type when we are - done with it. */ + done with it. */ struct type *range - = create_range_type (0, builtin_type_int, 0, length - 1); + = create_range_type (0, builtin_type_int, 0, length - 1); struct type *array = create_array_type (0, value1.type, range); value->kind = axs_lvalue_memory; @@ -1521,13 +1531,13 @@ gen_sizeof (pc, ax, value) /* Throw away the code we just generated. */ ax->len = start; - + ax_const_l (ax, TYPE_LENGTH (value->type)); value->kind = axs_rvalue; value->type = builtin_type_int; } - + /* Generating bytecode from GDB expressions: general recursive thingy */ /* A gen_expr function written by a Gen-X'er guy. @@ -1545,7 +1555,7 @@ gen_expr (pc, ax, value) /* If we're looking at a constant expression, just push its value. */ { struct value *v = maybe_const_expr (pc); - + if (v) { ax_const_l (ax, value_as_long (v)); @@ -1617,28 +1627,28 @@ gen_expr (pc, ax, value) default: /* We should only list operators in the outer case statement - that we actually handle in the inner case statement. */ + that we actually handle in the inner case statement. */ error ("GDB bug: ax-gdb.c (gen_expr): op case sets don't match"); } break; /* Note that we need to be a little subtle about generating code - for comma. In C, we can do some optimizations here because - we know the left operand is only being evaluated for effect. - However, if the tracing kludge is in effect, then we always - need to evaluate the left hand side fully, so that all the - variables it mentions get traced. */ + for comma. In C, we can do some optimizations here because + we know the left operand is only being evaluated for effect. + However, if the tracing kludge is in effect, then we always + need to evaluate the left hand side fully, so that all the + variables it mentions get traced. */ case BINOP_COMMA: (*pc)++; gen_expr (pc, ax, &value1); /* Don't just dispose of the left operand. We might be tracing, - in which case we want to emit code to trace it if it's an - lvalue. */ + in which case we want to emit code to trace it if it's an + lvalue. */ gen_traced_pop (ax, &value1); gen_expr (pc, ax, value); /* It's the consumer's responsibility to trace the right operand. */ break; - + case OP_LONG: /* some integer constant */ { struct type *type = (*pc)[1].type; @@ -1646,7 +1656,7 @@ gen_expr (pc, ax, value) (*pc) += 4; gen_int_literal (ax, value, k, type); } - break; + break; case OP_VAR_VALUE: gen_var_ref (ax, value, (*pc)[2].symbol); @@ -1661,12 +1671,12 @@ gen_expr (pc, ax, value) value->u.reg = reg; value->type = REGISTER_VIRTUAL_TYPE (reg); } - break; + break; case OP_INTERNALVAR: error ("GDB agent expressions cannot use convenience variables."); - /* Weirdo operator: see comments for gen_repeat for details. */ + /* Weirdo operator: see comments for gen_repeat for details. */ case BINOP_REPEAT: /* Note that gen_repeat handles its own argument evaluation. */ (*pc)++; @@ -1680,7 +1690,7 @@ gen_expr (pc, ax, value) gen_expr (pc, ax, value); gen_cast (ax, value, type); } - break; + break; case UNOP_MEMVAL: { @@ -1697,13 +1707,13 @@ gen_expr (pc, ax, value) value->type = type; value->kind = axs_lvalue_memory; } - break; + break; case UNOP_NEG: (*pc)++; /* -FOO is equivalent to 0 - FOO. */ gen_int_literal (ax, &value1, (LONGEST) 0, builtin_type_int); - gen_usual_unary (ax, &value1); /* shouldn't do much */ + gen_usual_unary (ax, &value1); /* shouldn't do much */ gen_expr (pc, ax, &value2); gen_usual_unary (ax, &value2); gen_usual_arithmetic (ax, &value1, &value2); @@ -1740,8 +1750,8 @@ gen_expr (pc, ax, value) case UNOP_SIZEOF: (*pc)++; /* Notice that gen_sizeof handles its own operand, unlike most - of the other unary operator functions. This is because we - have to throw away the code we generate. */ + of the other unary operator functions. This is because we + have to throw away the code we generate. */ gen_sizeof (pc, ax, value); break; @@ -1760,10 +1770,10 @@ gen_expr (pc, ax, value) "pointer to a structure or union"); else /* If this `if' chain doesn't handle it, then the case list - shouldn't mention it, and we shouldn't be here. */ + shouldn't mention it, and we shouldn't be here. */ error ("GDB bug: ax-gdb.c (gen_expr): unhandled struct case"); } - break; + break; case OP_TYPE: error ("Attempt to use a type name as an expression."); @@ -1772,10 +1782,10 @@ gen_expr (pc, ax, value) error ("Unsupported operator in expression."); } } - - -#if 0 /* not used */ + + +#if 0 /* not used */ /* Generating bytecode from GDB expressions: driver */ /* Given a GDB expression EXPR, produce a string of agent bytecode @@ -1863,9 +1873,9 @@ gen_trace_for_expr (scope, expr) discard_cleanups (old_chain); return ax; } + - /* The "agent" command, for testing: compile and disassemble an expression. */ static void @@ -1901,7 +1911,7 @@ agent_command (exp, from_tty) struct cleanup *old_chain = 0; struct expression *expr; struct agent_expr *agent; - struct frame_info *fi = get_current_frame (); /* need current scope */ + struct frame_info *fi = get_current_frame (); /* need current scope */ /* We don't deal with overlay debugging at the moment. We need to think more carefully about this. If you copy this code into @@ -1912,7 +1922,7 @@ agent_command (exp, from_tty) if (exp == 0) error_no_arg ("expression to translate"); - + expr = parse_expression (exp); old_chain = make_cleanup ((make_cleanup_func) free_current_contents, &expr); agent = gen_trace_for_expr (fi->pc, expr); @@ -1925,8 +1935,8 @@ agent_command (exp, from_tty) do_cleanups (old_chain); dont_repeat (); } - + /* Initialization code. */ void _initialize_ax_gdb PARAMS ((void)); diff --git a/gdb/ax-gdb.h b/gdb/ax-gdb.h index feab188..3764b69 100644 --- a/gdb/ax-gdb.h +++ b/gdb/ax-gdb.h @@ -1,26 +1,27 @@ /* GDB-specific functions for operating on agent expressions Copyright 1998 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #ifndef AX_GDB_H #define AX_GDB_H - + /* Types and enums */ /* GDB stores expressions in the form of a flattened tree (struct @@ -48,62 +49,66 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Different kinds of agent expression static values. */ -enum axs_lvalue_kind { - /* We generated code to compute the subexpression's value. - Constants and arithmetic operators yield this. */ - axs_rvalue, - - /* We generated code to yield the subexpression's value's address on - the top of the stack. If the caller needs an rvalue, it should - call require_rvalue to produce the rvalue from this address. */ - axs_lvalue_memory, - - /* We didn't generate any code, and the stack is undisturbed, - because the subexpression's value lives in a register; u.reg is - the register number. If the caller needs an rvalue, it should - call require_rvalue to produce the rvalue from this register - number. */ - axs_lvalue_register -}; +enum axs_lvalue_kind + { + /* We generated code to compute the subexpression's value. + Constants and arithmetic operators yield this. */ + axs_rvalue, + + /* We generated code to yield the subexpression's value's address on + the top of the stack. If the caller needs an rvalue, it should + call require_rvalue to produce the rvalue from this address. */ + axs_lvalue_memory, + + /* We didn't generate any code, and the stack is undisturbed, + because the subexpression's value lives in a register; u.reg is + the register number. If the caller needs an rvalue, it should + call require_rvalue to produce the rvalue from this register + number. */ + axs_lvalue_register + }; /* Structure describing what we got from a subexpression. Think of this as parallel to value.h's enum lval_type, except that we're describing a value which will exist when the expression is evaluated in the future, not a value we have in our hand. */ -struct axs_value { - enum axs_lvalue_kind kind; /* see above */ - - /* The type of the subexpression. Even if lvalue == axs_lvalue_memory, - this is the type of the value itself; the value on the stack is a - "pointer to" an object of this type. */ - struct type *type; - - union { - /* if kind == axs_lvalue_register, this is the register number */ - int reg; - } u; -}; - +struct axs_value + { + enum axs_lvalue_kind kind; /* see above */ + + /* The type of the subexpression. Even if lvalue == axs_lvalue_memory, + this is the type of the value itself; the value on the stack is a + "pointer to" an object of this type. */ + struct type *type; + + union + { + /* if kind == axs_lvalue_register, this is the register number */ + int reg; + } + u; + }; + /* Translating GDB expressions into agent expressions. */ /* Given a GDB expression EXPR, translate it into the agent bytecode, and return it. FLAGS are from enum expr_to_agent_flags. */ -extern struct agent_expr *expr_to_agent PARAMS ((struct expression *EXPR, - struct axs_value *VALUE)); +extern struct agent_expr *expr_to_agent PARAMS ((struct expression * EXPR, + struct axs_value * VALUE)); /* Given a GDB expression EXPR denoting an lvalue in memory, produce a string of agent bytecode which will leave its address and size on the top of stack. Return the agent expression. */ extern struct agent_expr *expr_to_address_and_size - PARAMS ((struct expression *EXPR)); + PARAMS ((struct expression * EXPR)); /* Given a GDB expression EXPR, return bytecode to trace its value. The result will use the `trace' and `trace_quick' bytecodes to record the value of all memory touched by the expression, and leave no values on the stack. The caller can then use the ax_reqs function to discover which registers the expression uses. */ -extern struct agent_expr *gen_trace_for_expr PARAMS ((CORE_ADDR, +extern struct agent_expr *gen_trace_for_expr PARAMS ((CORE_ADDR, struct expression *)); #endif /* AX_GDB_H */ diff --git a/gdb/ax-general.c b/gdb/ax-general.c index 072817d..6020ed7 100644 --- a/gdb/ax-general.c +++ b/gdb/ax-general.c @@ -1,21 +1,22 @@ /* Functions for manipulating expressions designed to be executed on the agent Copyright 1998 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ /* Despite what the above comment says about this file being part of GDB, we would like to keep these functions free of GDB @@ -27,13 +28,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "value.h" -static void grow_expr PARAMS ((struct agent_expr *x, int n)); +static void grow_expr PARAMS ((struct agent_expr * x, int n)); -static void append_const PARAMS ((struct agent_expr *x, LONGEST val, int n)); +static void append_const PARAMS ((struct agent_expr * x, LONGEST val, int n)); -static LONGEST read_const PARAMS ((struct agent_expr *x, int o, int n)); +static LONGEST read_const PARAMS ((struct agent_expr * x, int o, int n)); -static void generic_ext PARAMS ((struct agent_expr *x, enum agent_op op, int n)); +static void generic_ext PARAMS ((struct agent_expr * x, enum agent_op op, int n)); /* Functions for building expressions. */ @@ -43,10 +44,10 @@ new_agent_expr (scope) CORE_ADDR scope; { struct agent_expr *x = xmalloc (sizeof (*x)); - x->len = 0; + x->len = 0; x->size = 1; /* Change this to a larger value once reallocation code is tested. */ - x->buf = xmalloc (x->size); + x->buf = xmalloc (x->size); x->scope = scope; return x; @@ -115,7 +116,7 @@ read_const (x, o, n) for (i = 0; i < n; i++) accum = (accum << 8) | x->buf[o + i]; - + return accum; } @@ -194,7 +195,8 @@ ax_trace_quick (x, n) for the target, and return the offset in EXPR of that space, so we can backpatch it once we do know the target offset. Use ax_label to do the backpatching. */ -int ax_goto (x, op) +int +ax_goto (x, op) struct agent_expr *x; enum agent_op op; { @@ -208,7 +210,7 @@ int ax_goto (x, op) /* Suppose a given call to ax_goto returns some value PATCH. When you know the offset TARGET that goto should jump to, call - ax_label (EXPR, PATCH, TARGET) + ax_label (EXPR, PATCH, TARGET) to patch TARGET into the ax_goto instruction. */ void ax_label (x, patch, target) @@ -220,7 +222,7 @@ ax_label (x, patch, target) offset; that's our magic sentinel value for unpatched branches. */ if (target < 0 || target >= 0xffff) error ("GDB bug: ax-general.c (ax_label): label target out of range"); - + x->buf[patch] = (target >> 8) & 0xff; x->buf[patch + 1] = target & 0xff; } @@ -233,7 +235,8 @@ ax_const_l (x, l) LONGEST l; { static enum agent_op ops[] - = { aop_const8, aop_const16, aop_const32, aop_const64 }; + = + {aop_const8, aop_const16, aop_const32, aop_const64}; int size; int op; @@ -270,7 +273,8 @@ ax_const_d (x, d) /* Assemble code to push the value of register number REG on the stack. */ -void ax_reg (x, reg) +void +ax_reg (x, reg) struct agent_expr *x; int reg; { @@ -278,67 +282,68 @@ void ax_reg (x, reg) if (reg < 0 || reg > 0xffff) error ("GDB bug: ax-general.c (ax_reg): register number out of range"); grow_expr (x, 3); - x->buf[x->len ] = aop_reg; + x->buf[x->len] = aop_reg; x->buf[x->len + 1] = (reg >> 8) & 0xff; - x->buf[x->len + 2] = (reg ) & 0xff; + x->buf[x->len + 2] = (reg) & 0xff; x->len += 3; } + - /* Functions for disassembling agent expressions, and otherwise debugging the expression compiler. */ -struct aop_map aop_map[] = { - { 0, 0, 0, 0, 0 }, - { "float", 0, 0, 0, 0 }, /* 0x01 */ - { "add", 0, 0, 2, 1 }, /* 0x02 */ - { "sub", 0, 0, 2, 1 }, /* 0x03 */ - { "mul", 0, 0, 2, 1 }, /* 0x04 */ - { "div_signed", 0, 0, 2, 1 }, /* 0x05 */ - { "div_unsigned", 0, 0, 2, 1 }, /* 0x06 */ - { "rem_signed", 0, 0, 2, 1 }, /* 0x07 */ - { "rem_unsigned", 0, 0, 2, 1 }, /* 0x08 */ - { "lsh", 0, 0, 2, 1 }, /* 0x09 */ - { "rsh_signed", 0, 0, 2, 1 }, /* 0x0a */ - { "rsh_unsigned", 0, 0, 2, 1 }, /* 0x0b */ - { "trace", 0, 0, 2, 0 }, /* 0x0c */ - { "trace_quick", 1, 0, 1, 1 }, /* 0x0d */ - { "log_not", 0, 0, 1, 1 }, /* 0x0e */ - { "bit_and", 0, 0, 2, 1 }, /* 0x0f */ - { "bit_or", 0, 0, 2, 1 }, /* 0x10 */ - { "bit_xor", 0, 0, 2, 1 }, /* 0x11 */ - { "bit_not", 0, 0, 1, 1 }, /* 0x12 */ - { "equal", 0, 0, 2, 1 }, /* 0x13 */ - { "less_signed", 0, 0, 2, 1 }, /* 0x14 */ - { "less_unsigned", 0, 0, 2, 1 }, /* 0x15 */ - { "ext", 1, 0, 1, 1 }, /* 0x16 */ - { "ref8", 0, 8, 1, 1 }, /* 0x17 */ - { "ref16", 0, 16, 1, 1 }, /* 0x18 */ - { "ref32", 0, 32, 1, 1 }, /* 0x19 */ - { "ref64", 0, 64, 1, 1 }, /* 0x1a */ - { "ref_float", 0, 0, 1, 1 }, /* 0x1b */ - { "ref_double", 0, 0, 1, 1 }, /* 0x1c */ - { "ref_long_double", 0, 0, 1, 1 }, /* 0x1d */ - { "l_to_d", 0, 0, 1, 1 }, /* 0x1e */ - { "d_to_l", 0, 0, 1, 1 }, /* 0x1f */ - { "if_goto", 2, 0, 1, 0 }, /* 0x20 */ - { "goto", 2, 0, 0, 0 }, /* 0x21 */ - { "const8", 1, 8, 0, 1 }, /* 0x22 */ - { "const16", 2, 16, 0, 1 }, /* 0x23 */ - { "const32", 4, 32, 0, 1 }, /* 0x24 */ - { "const64", 8, 64, 0, 1 }, /* 0x25 */ - { "reg", 2, 0, 0, 1 }, /* 0x26 */ - { "end", 0, 0, 0, 0 }, /* 0x27 */ - { "dup", 0, 0, 1, 2 }, /* 0x28 */ - { "pop", 0, 0, 1, 0 }, /* 0x29 */ - { "zero_ext", 1, 0, 1, 1 }, /* 0x2a */ - { "swap", 0, 0, 2, 2 }, /* 0x2b */ - { 0, 0, 0, 0, 0 }, /* 0x2c */ - { 0, 0, 0, 0, 0 }, /* 0x2d */ - { 0, 0, 0, 0, 0 }, /* 0x2e */ - { 0, 0, 0, 0, 0 }, /* 0x2f */ - { "trace16", 2, 0, 1, 1 }, /* 0x30 */ +struct aop_map aop_map[] = +{ + {0, 0, 0, 0, 0}, + {"float", 0, 0, 0, 0}, /* 0x01 */ + {"add", 0, 0, 2, 1}, /* 0x02 */ + {"sub", 0, 0, 2, 1}, /* 0x03 */ + {"mul", 0, 0, 2, 1}, /* 0x04 */ + {"div_signed", 0, 0, 2, 1}, /* 0x05 */ + {"div_unsigned", 0, 0, 2, 1}, /* 0x06 */ + {"rem_signed", 0, 0, 2, 1}, /* 0x07 */ + {"rem_unsigned", 0, 0, 2, 1}, /* 0x08 */ + {"lsh", 0, 0, 2, 1}, /* 0x09 */ + {"rsh_signed", 0, 0, 2, 1}, /* 0x0a */ + {"rsh_unsigned", 0, 0, 2, 1}, /* 0x0b */ + {"trace", 0, 0, 2, 0}, /* 0x0c */ + {"trace_quick", 1, 0, 1, 1}, /* 0x0d */ + {"log_not", 0, 0, 1, 1}, /* 0x0e */ + {"bit_and", 0, 0, 2, 1}, /* 0x0f */ + {"bit_or", 0, 0, 2, 1}, /* 0x10 */ + {"bit_xor", 0, 0, 2, 1}, /* 0x11 */ + {"bit_not", 0, 0, 1, 1}, /* 0x12 */ + {"equal", 0, 0, 2, 1}, /* 0x13 */ + {"less_signed", 0, 0, 2, 1}, /* 0x14 */ + {"less_unsigned", 0, 0, 2, 1}, /* 0x15 */ + {"ext", 1, 0, 1, 1}, /* 0x16 */ + {"ref8", 0, 8, 1, 1}, /* 0x17 */ + {"ref16", 0, 16, 1, 1}, /* 0x18 */ + {"ref32", 0, 32, 1, 1}, /* 0x19 */ + {"ref64", 0, 64, 1, 1}, /* 0x1a */ + {"ref_float", 0, 0, 1, 1}, /* 0x1b */ + {"ref_double", 0, 0, 1, 1}, /* 0x1c */ + {"ref_long_double", 0, 0, 1, 1}, /* 0x1d */ + {"l_to_d", 0, 0, 1, 1}, /* 0x1e */ + {"d_to_l", 0, 0, 1, 1}, /* 0x1f */ + {"if_goto", 2, 0, 1, 0}, /* 0x20 */ + {"goto", 2, 0, 0, 0}, /* 0x21 */ + {"const8", 1, 8, 0, 1}, /* 0x22 */ + {"const16", 2, 16, 0, 1}, /* 0x23 */ + {"const32", 4, 32, 0, 1}, /* 0x24 */ + {"const64", 8, 64, 0, 1}, /* 0x25 */ + {"reg", 2, 0, 0, 1}, /* 0x26 */ + {"end", 0, 0, 0, 0}, /* 0x27 */ + {"dup", 0, 0, 1, 2}, /* 0x28 */ + {"pop", 0, 0, 1, 0}, /* 0x29 */ + {"zero_ext", 1, 0, 1, 1}, /* 0x2a */ + {"swap", 0, 0, 2, 2}, /* 0x2b */ + {0, 0, 0, 0, 0}, /* 0x2c */ + {0, 0, 0, 0, 0}, /* 0x2d */ + {0, 0, 0, 0, 0}, /* 0x2e */ + {0, 0, 0, 0, 0}, /* 0x2f */ + {"trace16", 2, 0, 1, 1}, /* 0x30 */ }; @@ -356,13 +361,13 @@ ax_print (f, x) if ((sizeof (aop_map) / sizeof (aop_map[0])) != aop_last) error ("GDB bug: ax-general.c (ax_print): opcode map out of sync"); - - for (i = 0; i < x->len; ) + + for (i = 0; i < x->len;) { enum agent_op op = x->buf[i]; if (op >= (sizeof (aop_map) / sizeof (aop_map[0])) - || ! aop_map[op].name) + || !aop_map[op].name) { fprintf_filtered (f, "%3d \n", i, op); i++; @@ -379,7 +384,7 @@ ax_print (f, x) if (aop_map[op].op_size > 0) { fputs_filtered (" ", f); - + print_longest (f, 'd', 0, read_const (x, i + 1, aop_map[op].op_size)); } @@ -440,13 +445,13 @@ ax_reqs (ax, reqs) op = &aop_map[ax->buf[i]]; - if (! op->name) + if (!op->name) { reqs->flaw = agent_flaw_bad_instruction; free (reg_mask); return; } - + if (i + 1 + op->op_size > ax->len) { reqs->flaw = agent_flaw_incomplete_instruction; @@ -477,8 +482,8 @@ ax_reqs (ax, reqs) reqs->max_data_size = op->data_size; /* For jump instructions, check that the target is a valid - offset. If it is, record the fact that that location is a - jump target, and record the height we expect there. */ + offset. If it is, record the fact that that location is a + jump target, and record the height we expect there. */ if (aop_goto == op - aop_map || aop_if_goto == op - aop_map) { @@ -505,13 +510,13 @@ ax_reqs (ax, reqs) heights[target] = height; } } - + /* For unconditional jumps with a successor, check that the successor is a target, and pick up its stack height. */ if (aop_goto == op - aop_map && i + 3 < ax->len) { - if (! targets[i + 3]) + if (!targets[i + 3]) { reqs->flaw = agent_flaw_hole; free (reg_mask); @@ -531,9 +536,9 @@ ax_reqs (ax, reqs) if (byte >= reg_mask_len) { /* It's not appropriate to double here. This isn't a - string buffer. */ + string buffer. */ int new_len = byte + 1; - reg_mask = xrealloc (reg_mask, + reg_mask = xrealloc (reg_mask, new_len * sizeof (reg_mask[0])); memset (reg_mask + reg_mask_len, 0, (new_len - reg_mask_len) * sizeof (reg_mask[0])); diff --git a/gdb/ax.h b/gdb/ax.h index 069dd99..0467626 100644 --- a/gdb/ax.h +++ b/gdb/ax.h @@ -1,21 +1,22 @@ /* Definitions for expressions designed to be executed on the agent Copyright 1998 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #ifndef AGENTEXPR_H #define AGENTEXPR_H @@ -47,8 +48,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ is independent of symbolic information. This means the agent can evaluate them on the fly without reference to data only available to the host GDB. */ - + /* Agent expression data structures. */ /* The type of an element of the agent expression stack. @@ -56,18 +57,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ the value itself has no typing information. GDB generates all bytecode streams, so we don't have to worry about type errors. */ -union agent_val { - LONGEST l; - DOUBLEST d; -}; +union agent_val + { + LONGEST l; + DOUBLEST d; + }; /* A buffer containing a agent expression. */ -struct agent_expr { - unsigned char *buf; - int len; /* number of characters used */ - int size; /* allocated size */ - CORE_ADDR scope; -}; +struct agent_expr + { + unsigned char *buf; + int len; /* number of characters used */ + int size; /* allocated size */ + CORE_ADDR scope; + }; @@ -82,56 +85,57 @@ struct agent_expr { agentexpr.h behaves like an opcode map. If you want to see them grouped logically, see doc/agentexpr.texi. */ -enum agent_op { - aop_float = 0x01, - aop_add = 0x02, - aop_sub = 0x03, - aop_mul = 0x04, - aop_div_signed = 0x05, - aop_div_unsigned = 0x06, - aop_rem_signed = 0x07, - aop_rem_unsigned = 0x08, - aop_lsh = 0x09, - aop_rsh_signed = 0x0a, - aop_rsh_unsigned = 0x0b, - aop_trace = 0x0c, - aop_trace_quick = 0x0d, - aop_log_not = 0x0e, - aop_bit_and = 0x0f, - aop_bit_or = 0x10, - aop_bit_xor = 0x11, - aop_bit_not = 0x12, - aop_equal = 0x13, - aop_less_signed = 0x14, - aop_less_unsigned = 0x15, - aop_ext = 0x16, - aop_ref8 = 0x17, - aop_ref16 = 0x18, - aop_ref32 = 0x19, - aop_ref64 = 0x1a, - aop_ref_float = 0x1b, - aop_ref_double = 0x1c, - aop_ref_long_double = 0x1d, - aop_l_to_d = 0x1e, - aop_d_to_l = 0x1f, - aop_if_goto = 0x20, - aop_goto = 0x21, - aop_const8 = 0x22, - aop_const16 = 0x23, - aop_const32 = 0x24, - aop_const64 = 0x25, - aop_reg = 0x26, - aop_end = 0x27, - aop_dup = 0x28, - aop_pop = 0x29, - aop_zero_ext = 0x2a, - aop_swap = 0x2b, - aop_trace16 = 0x30, - aop_last -}; +enum agent_op + { + aop_float = 0x01, + aop_add = 0x02, + aop_sub = 0x03, + aop_mul = 0x04, + aop_div_signed = 0x05, + aop_div_unsigned = 0x06, + aop_rem_signed = 0x07, + aop_rem_unsigned = 0x08, + aop_lsh = 0x09, + aop_rsh_signed = 0x0a, + aop_rsh_unsigned = 0x0b, + aop_trace = 0x0c, + aop_trace_quick = 0x0d, + aop_log_not = 0x0e, + aop_bit_and = 0x0f, + aop_bit_or = 0x10, + aop_bit_xor = 0x11, + aop_bit_not = 0x12, + aop_equal = 0x13, + aop_less_signed = 0x14, + aop_less_unsigned = 0x15, + aop_ext = 0x16, + aop_ref8 = 0x17, + aop_ref16 = 0x18, + aop_ref32 = 0x19, + aop_ref64 = 0x1a, + aop_ref_float = 0x1b, + aop_ref_double = 0x1c, + aop_ref_long_double = 0x1d, + aop_l_to_d = 0x1e, + aop_d_to_l = 0x1f, + aop_if_goto = 0x20, + aop_goto = 0x21, + aop_const8 = 0x22, + aop_const16 = 0x23, + aop_const32 = 0x24, + aop_const64 = 0x25, + aop_reg = 0x26, + aop_end = 0x27, + aop_dup = 0x28, + aop_pop = 0x29, + aop_zero_ext = 0x2a, + aop_swap = 0x2b, + aop_trace16 = 0x30, + aop_last + }; + - /* Functions for building expressions. */ /* Allocate a new, empty agent expression. */ @@ -141,19 +145,19 @@ extern struct agent_expr *new_agent_expr PARAMS ((CORE_ADDR)); extern void free_agent_expr PARAMS ((struct agent_expr *)); /* Append a simple operator OP to EXPR. */ -extern void ax_simple PARAMS ((struct agent_expr *EXPR, enum agent_op OP)); +extern void ax_simple PARAMS ((struct agent_expr * EXPR, enum agent_op OP)); /* Append the floating-point prefix, for the next bytecode. */ #define ax_float(EXPR) (ax_simple ((EXPR), aop_float)) /* Append a sign-extension instruction to EXPR, to extend an N-bit value. */ -extern void ax_ext PARAMS ((struct agent_expr *EXPR, int N)); +extern void ax_ext PARAMS ((struct agent_expr * EXPR, int N)); /* Append a zero-extension instruction to EXPR, to extend an N-bit value. */ -extern void ax_zero_ext PARAMS ((struct agent_expr *EXPR, int N)); +extern void ax_zero_ext PARAMS ((struct agent_expr * EXPR, int N)); /* Append a trace_quick instruction to EXPR, to record N bytes. */ -extern void ax_trace_quick PARAMS ((struct agent_expr *EXPR, int N)); +extern void ax_trace_quick PARAMS ((struct agent_expr * EXPR, int N)); /* Append a goto op to EXPR. OP is the actual op (must be aop_goto or aop_if_goto). We assume we don't know the target offset yet, @@ -161,123 +165,126 @@ extern void ax_trace_quick PARAMS ((struct agent_expr *EXPR, int N)); for the target, and return the offset in EXPR of that space, so we can backpatch it once we do know the target offset. Use ax_label to do the backpatching. */ -extern int ax_goto PARAMS ((struct agent_expr *EXPR, enum agent_op OP)); +extern int ax_goto PARAMS ((struct agent_expr * EXPR, enum agent_op OP)); /* Suppose a given call to ax_goto returns some value PATCH. When you know the offset TARGET that goto should jump to, call - ax_label (EXPR, PATCH, TARGET) + ax_label (EXPR, PATCH, TARGET) to patch TARGET into the ax_goto instruction. */ -extern void ax_label PARAMS ((struct agent_expr *EXPR, int patch, int target)); +extern void ax_label PARAMS ((struct agent_expr * EXPR, int patch, int target)); /* Assemble code to push a constant on the stack. */ -extern void ax_const_l PARAMS ((struct agent_expr *EXPR, LONGEST l)); -extern void ax_const_d PARAMS ((struct agent_expr *EXPR, LONGEST d)); +extern void ax_const_l PARAMS ((struct agent_expr * EXPR, LONGEST l)); +extern void ax_const_d PARAMS ((struct agent_expr * EXPR, LONGEST d)); /* Assemble code to push the value of register number REG on the stack. */ -extern void ax_reg PARAMS ((struct agent_expr *EXPR, int REG)); - +extern void ax_reg PARAMS ((struct agent_expr * EXPR, int REG)); + /* Functions for printing out expressions, and otherwise debugging things. */ /* Disassemble the expression EXPR, writing to F. */ -extern void ax_print PARAMS ((GDB_FILE *f, struct agent_expr *EXPR)); +extern void ax_print PARAMS ((GDB_FILE * f, struct agent_expr * EXPR)); /* An entry in the opcode map. */ -struct aop_map { +struct aop_map + { - /* The name of the opcode. Null means that this entry is not a - valid opcode --- a hole in the opcode space. */ - char *name; + /* The name of the opcode. Null means that this entry is not a + valid opcode --- a hole in the opcode space. */ + char *name; - /* All opcodes take no operands from the bytecode stream, or take - unsigned integers of various sizes. If this is a positive number - n, then the opcode is followed by an n-byte operand, which should - be printed as an unsigned integer. If this is zero, then the - opcode takes no operands from the bytecode stream. + /* All opcodes take no operands from the bytecode stream, or take + unsigned integers of various sizes. If this is a positive number + n, then the opcode is followed by an n-byte operand, which should + be printed as an unsigned integer. If this is zero, then the + opcode takes no operands from the bytecode stream. - If we get more complicated opcodes in the future, don't add other - magic values of this; that's a crock. Add an `enum encoding' - field to this, or something like that. */ - int op_size; + If we get more complicated opcodes in the future, don't add other + magic values of this; that's a crock. Add an `enum encoding' + field to this, or something like that. */ + int op_size; - /* The size of the data operated upon, in bits, for bytecodes that - care about that (ref and const). Zero for all others. */ - int data_size; + /* The size of the data operated upon, in bits, for bytecodes that + care about that (ref and const). Zero for all others. */ + int data_size; - /* Number of stack elements consumed, and number produced. */ - int consumed, produced; -}; + /* Number of stack elements consumed, and number produced. */ + int consumed, produced; + }; /* Map of the bytecodes, indexed by bytecode number. */ extern struct aop_map aop_map[]; /* Different kinds of flaws an agent expression might have, as detected by agent_reqs. */ -enum agent_flaws { - agent_flaw_none = 0, /* code is good */ +enum agent_flaws + { + agent_flaw_none = 0, /* code is good */ - /* There is an invalid instruction in the stream. */ - agent_flaw_bad_instruction, + /* There is an invalid instruction in the stream. */ + agent_flaw_bad_instruction, - /* There is an incomplete instruction at the end of the expression. */ - agent_flaw_incomplete_instruction, + /* There is an incomplete instruction at the end of the expression. */ + agent_flaw_incomplete_instruction, - /* agent_reqs was unable to prove that every jump target is to a - valid offset. Valid offsets are within the bounds of the - expression, and to a valid instruction boundary. */ - agent_flaw_bad_jump, + /* agent_reqs was unable to prove that every jump target is to a + valid offset. Valid offsets are within the bounds of the + expression, and to a valid instruction boundary. */ + agent_flaw_bad_jump, - /* agent_reqs was unable to prove to its satisfaction that, for each - jump target location, the stack will have the same height whether - that location is reached via a jump or by straight execution. */ - agent_flaw_height_mismatch, + /* agent_reqs was unable to prove to its satisfaction that, for each + jump target location, the stack will have the same height whether + that location is reached via a jump or by straight execution. */ + agent_flaw_height_mismatch, - /* agent_reqs was unable to prove that every instruction following - an unconditional jump was the target of some other jump. */ - agent_flaw_hole -}; + /* agent_reqs was unable to prove that every instruction following + an unconditional jump was the target of some other jump. */ + agent_flaw_hole + }; /* Structure describing the requirements of a bytecode expression. */ -struct agent_reqs { +struct agent_reqs + { + + /* If the following is not equal to agent_flaw_none, the rest of the + information in this structure is suspect. */ + enum agent_flaws flaw; - /* If the following is not equal to agent_flaw_none, the rest of the - information in this structure is suspect. */ - enum agent_flaws flaw; + /* Number of elements left on stack at end; may be negative if expr + only consumes elements. */ + int final_height; - /* Number of elements left on stack at end; may be negative if expr - only consumes elements. */ - int final_height; + /* Maximum and minimum stack height, relative to initial height. */ + int max_height, min_height; - /* Maximum and minimum stack height, relative to initial height. */ - int max_height, min_height; + /* Largest `ref' or `const' opcode used, in bits. Zero means the + expression has no such instructions. */ + int max_data_size; - /* Largest `ref' or `const' opcode used, in bits. Zero means the - expression has no such instructions. */ - int max_data_size; + /* Bit vector of registers used. Register R is used iff - /* Bit vector of registers used. Register R is used iff - - reg_mask[R / 8] & (1 << (R % 8)) + reg_mask[R / 8] & (1 << (R % 8)) - is non-zero. Note! You may not assume that this bitmask is long - enough to hold bits for all the registers of the machine; the - agent expression code has no idea how many registers the machine - has. However, the bitmask is reg_mask_len bytes long, so the - valid register numbers run from 0 to reg_mask_len * 8 - 1. + is non-zero. Note! You may not assume that this bitmask is long + enough to hold bits for all the registers of the machine; the + agent expression code has no idea how many registers the machine + has. However, the bitmask is reg_mask_len bytes long, so the + valid register numbers run from 0 to reg_mask_len * 8 - 1. - We're assuming eight-bit bytes. So sue me. + We're assuming eight-bit bytes. So sue me. - The caller should free reg_list when done. */ - int reg_mask_len; - unsigned char *reg_mask; -}; + The caller should free reg_list when done. */ + int reg_mask_len; + unsigned char *reg_mask; + }; /* Given an agent expression AX, fill in an agent_reqs structure REQS describing it. */ -extern void ax_reqs PARAMS ((struct agent_expr *ax, - struct agent_reqs *reqs)); +extern void ax_reqs PARAMS ((struct agent_expr * ax, + struct agent_reqs * reqs)); #endif /* AGENTEXPR_H */ diff --git a/gdb/bcache.c b/gdb/bcache.c index 0d6d205..97485dd 100644 --- a/gdb/bcache.c +++ b/gdb/bcache.c @@ -2,21 +2,22 @@ Written by Fred Fish (fnf@cygnus.com) Copyright 1995, 1998 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "obstack.h" @@ -30,8 +31,8 @@ static unsigned int hash PARAMS ((void *, int)); static void *lookup_cache PARAMS ((void *, int, int, struct bcache *)); /* FIXME: Incredibly simplistic hash generator. Probably way too expensive - (consider long strings) and unlikely to have good distribution across hash - values for typical input. */ + (consider long strings) and unlikely to have good distribution across hash + values for typical input. */ static unsigned int hash (bytes, count) @@ -68,7 +69,7 @@ lookup_cache (bytes, count, hashval, bcachep) struct hashlink **hashtablep; struct hashlink *linkp; - hashtablep = bcachep -> indextable[count]; + hashtablep = bcachep->indextable[count]; if (hashtablep != NULL) { linkp = hashtablep[hashval]; @@ -79,7 +80,7 @@ lookup_cache (bytes, count, hashval, bcachep) location = BCACHE_DATA (linkp); break; } - linkp = linkp -> next; + linkp = linkp->next; } } return (location); @@ -101,9 +102,9 @@ bcache (bytes, count, bcachep) { /* Rare enough to just stash unique copies */ location = (void *) obstack_alloc (&bcachep->cache, count); - bcachep -> cache_bytes += count; + bcachep->cache_bytes += count; memcpy (location, bytes, count); - bcachep -> bcache_overflows++; + bcachep->bcache_overflows++; } else { @@ -111,26 +112,26 @@ bcache (bytes, count, bcachep) location = lookup_cache (bytes, count, hashval, bcachep); if (location != NULL) { - bcachep -> cache_savings += count; - bcachep -> cache_hits++; + bcachep->cache_savings += count; + bcachep->cache_hits++; } else { - bcachep -> cache_misses++; - hashtablepp = &bcachep -> indextable[count]; + bcachep->cache_misses++; + hashtablepp = &bcachep->indextable[count]; if (*hashtablepp == NULL) { *hashtablepp = (struct hashlink **) obstack_alloc (&bcachep->cache, BCACHE_HASHSIZE * sizeof (struct hashlink *)); - bcachep -> cache_bytes += BCACHE_HASHSIZE * sizeof (struct hashlink *); + bcachep->cache_bytes += BCACHE_HASHSIZE * sizeof (struct hashlink *); memset (*hashtablepp, 0, BCACHE_HASHSIZE * sizeof (struct hashlink *)); } linkpp = &(*hashtablepp)[hashval]; newlink = (struct hashlink *) obstack_alloc (&bcachep->cache, BCACHE_DATA_ALIGNMENT + count); - bcachep -> cache_bytes += BCACHE_DATA_ALIGNMENT + count; + bcachep->cache_bytes += BCACHE_DATA_ALIGNMENT + count; memcpy (BCACHE_DATA (newlink), bytes, count); - newlink -> next = *linkpp; + newlink->next = *linkpp; *linkpp = newlink; location = BCACHE_DATA (newlink); } @@ -149,7 +150,7 @@ print_bcache_statistics (bcachep, id) for (lmax = lcount = tcount = hcount = tidx = 0; tidx < BCACHE_MAXLENGTH; tidx++) { - hashtablep = bcachep -> indextable[tidx]; + hashtablep = bcachep->indextable[tidx]; if (hashtablep != NULL) { tcount++; @@ -159,7 +160,7 @@ print_bcache_statistics (bcachep, id) if (linkp != NULL) { hcount++; - for (temp = 0; linkp != NULL; linkp = linkp -> next) + for (temp = 0; linkp != NULL; linkp = linkp->next) { lcount++; temp++; @@ -175,21 +176,21 @@ print_bcache_statistics (bcachep, id) } } printf_filtered (" Cached '%s' statistics:\n", id); - printf_filtered (" Cache hits: %d\n", bcachep -> cache_hits); - printf_filtered (" Cache misses: %d\n", bcachep -> cache_misses); + printf_filtered (" Cache hits: %d\n", bcachep->cache_hits); + printf_filtered (" Cache misses: %d\n", bcachep->cache_misses); printf_filtered (" Cache hit ratio: "); - if (bcachep -> cache_hits + bcachep -> cache_misses > 0) + if (bcachep->cache_hits + bcachep->cache_misses > 0) { - printf_filtered ("%d%%\n", ((bcachep -> cache_hits) * 100) / - (bcachep -> cache_hits + bcachep -> cache_misses)); + printf_filtered ("%d%%\n", ((bcachep->cache_hits) * 100) / + (bcachep->cache_hits + bcachep->cache_misses)); } else { printf_filtered ("(not applicable)\n"); } - printf_filtered (" Space used for caching: %d\n", bcachep -> cache_bytes); - printf_filtered (" Space saved by cache hits: %d\n", bcachep -> cache_savings); - printf_filtered (" Number of bcache overflows: %d\n", bcachep -> bcache_overflows); + printf_filtered (" Space used for caching: %d\n", bcachep->cache_bytes); + printf_filtered (" Space saved by cache hits: %d\n", bcachep->cache_savings); + printf_filtered (" Number of bcache overflows: %d\n", bcachep->bcache_overflows); printf_filtered (" Number of index buckets used: %d\n", tcount); printf_filtered (" Number of hash table buckets used: %d\n", hcount); printf_filtered (" Number of chained items: %d\n", lcount); diff --git a/gdb/bcache.h b/gdb/bcache.h index 4b753be..ec38324 100644 --- a/gdb/bcache.h +++ b/gdb/bcache.h @@ -2,21 +2,22 @@ Written by Fred Fish (fnf@cygnus.com) Copyright 1995 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #ifndef BCACHE_H #define BCACHE_H 1 @@ -29,13 +30,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ it needs to have the same alignment as the most strict alignment of any type on the host machine. So do it the same way obstack does. */ -struct hashlink { - struct hashlink *next; - union { - char data[1]; - double dummy; - } d; -}; +struct hashlink + { + struct hashlink *next; + union + { + char data[1]; + double dummy; + } + d; + }; /* BCACHE_DATA is used to get the address of the cached data. */ @@ -49,18 +53,19 @@ struct hashlink { #define BCACHE_DATA_ALIGNMENT \ (((char *) BCACHE_DATA((struct hashlink*) 0) - (char *) 0)) -struct bcache { - struct obstack cache; - struct hashlink **indextable[BCACHE_MAXLENGTH]; - int cache_hits; - int cache_misses; - int cache_bytes; - int cache_savings; - int bcache_overflows; -}; +struct bcache + { + struct obstack cache; + struct hashlink **indextable[BCACHE_MAXLENGTH]; + int cache_hits; + int cache_misses; + int cache_bytes; + int cache_savings; + int bcache_overflows; + }; extern void * -bcache PARAMS ((void *bytes, int count, struct bcache *bcachep)); + bcache PARAMS ((void *bytes, int count, struct bcache * bcachep)); extern void print_bcache_statistics PARAMS ((struct bcache *, char *)); diff --git a/gdb/blockframe.c b/gdb/blockframe.c index 87ce8bf..26a26ae 100644 --- a/gdb/blockframe.c +++ b/gdb/blockframe.c @@ -1,23 +1,24 @@ /* Get info from stack frames; convert between frames, blocks, functions and pc values. Copyright 1986, 87, 88, 89, 91, 94, 95, 96, 97, 1998 - Free Software Foundation, Inc. + Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "symtab.h" @@ -45,14 +46,14 @@ default_frame_chain_valid (chain, thisframe) struct frame_info *thisframe; { return ((chain) != 0 - && !inside_main_func ((thisframe) -> pc) - && !inside_entry_func ((thisframe) -> pc)); + && !inside_main_func ((thisframe)->pc) + && !inside_entry_func ((thisframe)->pc)); } /* Use the alternate method of avoiding running up off the end of the frame chain or following frames back into the startup code. See the comments in objfiles.h. */ - + int alternate_frame_chain_valid (chain, thisframe) CORE_ADDR chain; @@ -63,7 +64,7 @@ alternate_frame_chain_valid (chain, thisframe) } /* A very simple method of determining a valid frame */ - + int nonnull_frame_chain_valid (chain, thisframe) CORE_ADDR chain; @@ -91,13 +92,13 @@ inside_entry_file (addr) if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT) { /* Do not stop backtracing if the pc is in the call dummy - at the entry point. */ + at the entry point. */ /* FIXME: Won't always work with zeros for the last two arguments */ - if (PC_IN_CALL_DUMMY (addr, 0, 0)) + if (PC_IN_CALL_DUMMY (addr, 0, 0)) return 0; } - return (addr >= symfile_objfile -> ei.entry_file_lowpc && - addr < symfile_objfile -> ei.entry_file_highpc); + return (addr >= symfile_objfile->ei.entry_file_lowpc && + addr < symfile_objfile->ei.entry_file_highpc); } /* Test a specified PC value to see if it is in the range of addresses @@ -110,7 +111,7 @@ inside_entry_file (addr) int inside_main_func (pc) -CORE_ADDR pc; + CORE_ADDR pc; { if (pc == 0) return 1; @@ -121,22 +122,22 @@ CORE_ADDR pc; This is for FRAME_CHAIN_VALID_ALTERNATE. I do this for coff, because it is unable to set it up and symbol reading time. */ - if (symfile_objfile -> ei.main_func_lowpc == INVALID_ENTRY_LOWPC && - symfile_objfile -> ei.main_func_highpc == INVALID_ENTRY_HIGHPC) + if (symfile_objfile->ei.main_func_lowpc == INVALID_ENTRY_LOWPC && + symfile_objfile->ei.main_func_highpc == INVALID_ENTRY_HIGHPC) { struct symbol *mainsym; mainsym = lookup_symbol ("main", NULL, VAR_NAMESPACE, NULL, NULL); - if (mainsym && SYMBOL_CLASS(mainsym) == LOC_BLOCK) - { - symfile_objfile->ei.main_func_lowpc = + if (mainsym && SYMBOL_CLASS (mainsym) == LOC_BLOCK) + { + symfile_objfile->ei.main_func_lowpc = BLOCK_START (SYMBOL_BLOCK_VALUE (mainsym)); - symfile_objfile->ei.main_func_highpc = + symfile_objfile->ei.main_func_highpc = BLOCK_END (SYMBOL_BLOCK_VALUE (mainsym)); - } + } } - return (symfile_objfile -> ei.main_func_lowpc <= pc && - symfile_objfile -> ei.main_func_highpc > pc); + return (symfile_objfile->ei.main_func_lowpc <= pc && + symfile_objfile->ei.main_func_highpc > pc); } /* Test a specified PC value to see if it is in the range of addresses @@ -158,13 +159,13 @@ inside_entry_func (pc) if (CALL_DUMMY_LOCATION == AT_ENTRY_POINT) { /* Do not stop backtracing if the pc is in the call dummy - at the entry point. */ + at the entry point. */ /* FIXME: Won't always work with zeros for the last two arguments */ if (PC_IN_CALL_DUMMY (pc, 0, 0)) return 0; } - return (symfile_objfile -> ei.entry_func_lowpc <= pc && - symfile_objfile -> ei.entry_func_highpc > pc); + return (symfile_objfile->ei.entry_func_lowpc <= pc && + symfile_objfile->ei.entry_func_highpc > pc); } /* Info about the innermost stack frame (contents of FP register) */ @@ -188,7 +189,7 @@ void frame_saved_regs_zalloc (fi) struct frame_info *fi; { - fi->saved_regs = (CORE_ADDR*) + fi->saved_regs = (CORE_ADDR *) frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS); memset (fi->saved_regs, 0, SIZEOF_FRAME_SAVED_REGS); } @@ -237,7 +238,7 @@ create_new_frame (addr, pc) fi->prev = NULL; fi->frame = addr; fi->pc = pc; - find_pc_partial_function (pc, &name, (CORE_ADDR *)NULL,(CORE_ADDR *)NULL); + find_pc_partial_function (pc, &name, (CORE_ADDR *) NULL, (CORE_ADDR *) NULL); fi->signal_handler_caller = IN_SIGTRAMP (fi->pc, name); #ifdef INIT_EXTRA_FRAME_INFO @@ -266,7 +267,7 @@ flush_cached_frames () obstack_free (&frame_cache_obstack, 0); obstack_init (&frame_cache_obstack); - current_frame = NULL; /* Invalidate cache */ + current_frame = NULL; /* Invalidate cache */ select_frame (NULL, -1); annotate_frames_invalid (); } @@ -306,7 +307,7 @@ frameless_look_for_prologue (frame) after_prologue = func_start; #ifdef SKIP_PROLOGUE_FRAMELESS_P /* This is faster, since only care whether there *is* a prologue, - not how long it is. */ + not how long it is. */ after_prologue = SKIP_PROLOGUE_FRAMELESS_P (after_prologue); #else after_prologue = SKIP_PROLOGUE (after_prologue); @@ -360,9 +361,9 @@ get_prev_frame (next_frame) { #if 0 /* This screws value_of_variable, which just wants a nice clean - NULL return from block_innermost_frame if there are no frames. - I don't think I've ever seen this message happen otherwise. - And returning NULL here is a perfectly legitimate thing to do. */ + NULL return from block_innermost_frame if there are no frames. + I don't think I've ever seen this message happen otherwise. + And returning NULL here is a perfectly legitimate thing to do. */ if (!current_frame) { error ("You haven't set up a process's stack to examine."); @@ -395,18 +396,18 @@ get_prev_frame (next_frame) if (!fromleaf) { /* Two macros defined in tm.h specify the machine-dependent - actions to be performed here. - First, get the frame's chain-pointer. - If that is zero, the frame is the outermost frame or a leaf - called by the outermost frame. This means that if start - calls main without a frame, we'll return 0 (which is fine - anyway). - - Nope; there's a problem. This also returns when the current - routine is a leaf of main. This is unacceptable. We move - this to after the ffi test; I'd rather have backtraces from - start go curfluy than have an abort called from main not show - main. */ + actions to be performed here. + First, get the frame's chain-pointer. + If that is zero, the frame is the outermost frame or a leaf + called by the outermost frame. This means that if start + calls main without a frame, we'll return 0 (which is fine + anyway). + + Nope; there's a problem. This also returns when the current + routine is a leaf of main. This is unacceptable. We move + this to after the ffi test; I'd rather have backtraces from + start go curfluy than have an abort called from main not show + main. */ address = FRAME_CHAIN (next_frame); if (!FRAME_CHAIN_VALID (address, next_frame)) return 0; @@ -432,11 +433,11 @@ get_prev_frame (next_frame) after INIT_EXTRA_FRAME_INFO and come up with a simple way to express what goes on here. - INIT_EXTRA_FRAME_INFO is called from two places: create_new_frame - (where the PC is already set up) and here (where it isn't). - INIT_FRAME_PC is only called from here, always after - INIT_EXTRA_FRAME_INFO. - + INIT_EXTRA_FRAME_INFO is called from two places: create_new_frame + (where the PC is already set up) and here (where it isn't). + INIT_FRAME_PC is only called from here, always after + INIT_EXTRA_FRAME_INFO. + The catch is the MIPS, where INIT_EXTRA_FRAME_INFO requires the PC value (which hasn't been set yet). Some other machines appear to require INIT_EXTRA_FRAME_INFO before they can do INIT_FRAME_PC. Phoo. @@ -448,24 +449,24 @@ get_prev_frame (next_frame) INIT_EXTRA_FRAME_INFO, one possible scheme: SETUP_INNERMOST_FRAME() - Default version is just create_new_frame (read_fp ()), - read_pc ()). Machines with extra frame info would do that (or the - local equivalent) and then set the extra fields. + Default version is just create_new_frame (read_fp ()), + read_pc ()). Machines with extra frame info would do that (or the + local equivalent) and then set the extra fields. SETUP_ARBITRARY_FRAME(argc, argv) - Only change here is that create_new_frame would no longer init extra - frame info; SETUP_ARBITRARY_FRAME would have to do that. + Only change here is that create_new_frame would no longer init extra + frame info; SETUP_ARBITRARY_FRAME would have to do that. INIT_PREV_FRAME(fromleaf, prev) - Replace INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC. This should - also return a flag saying whether to keep the new frame, or - whether to discard it, because on some machines (e.g. mips) it - is really awkward to have FRAME_CHAIN_VALID called *before* - INIT_EXTRA_FRAME_INFO (there is no good way to get information - deduced in FRAME_CHAIN_VALID into the extra fields of the new frame). + Replace INIT_EXTRA_FRAME_INFO and INIT_FRAME_PC. This should + also return a flag saying whether to keep the new frame, or + whether to discard it, because on some machines (e.g. mips) it + is really awkward to have FRAME_CHAIN_VALID called *before* + INIT_EXTRA_FRAME_INFO (there is no good way to get information + deduced in FRAME_CHAIN_VALID into the extra fields of the new frame). std_frame_pc(fromleaf, prev) - This is the default setting for INIT_PREV_FRAME. It just does what - the default INIT_FRAME_PC does. Some machines will call it from - INIT_PREV_FRAME (either at the beginning, the end, or in the middle). - Some machines won't use it. + This is the default setting for INIT_PREV_FRAME. It just does what + the default INIT_FRAME_PC does. Some machines will call it from + INIT_PREV_FRAME (either at the beginning, the end, or in the middle). + Some machines won't use it. kingdon@cygnus.com, 13Apr93, 31Jan94, 14Dec94. */ #ifdef INIT_FRAME_PC_FIRST @@ -473,13 +474,13 @@ get_prev_frame (next_frame) #endif #ifdef INIT_EXTRA_FRAME_INFO - INIT_EXTRA_FRAME_INFO(fromleaf, prev); + INIT_EXTRA_FRAME_INFO (fromleaf, prev); #endif /* This entry is in the frame queue now, which is good since FRAME_SAVED_PC may use that queue to figure out its value (see tm-sparc.h). We want the pc saved in the inferior frame. */ - INIT_FRAME_PC(fromleaf, prev); + INIT_FRAME_PC (fromleaf, prev); /* If ->frame and ->pc are unchanged, we are in the process of getting ourselves into an infinite backtrace. Some architectures check this @@ -497,7 +498,7 @@ get_prev_frame (next_frame) } find_pc_partial_function (prev->pc, &name, - (CORE_ADDR *)NULL,(CORE_ADDR *)NULL); + (CORE_ADDR *) NULL, (CORE_ADDR *) NULL); if (IN_SIGTRAMP (prev->pc, name)) prev->signal_handler_caller = 1; @@ -524,7 +525,7 @@ get_frame_saved_regs (frame, saved_regs_addr) { if (frame->saved_regs == NULL) { - frame->saved_regs = (CORE_ADDR*) + frame->saved_regs = (CORE_ADDR *) frame_obstack_alloc (SIZEOF_FRAME_SAVED_REGS); } if (saved_regs_addr == NULL) @@ -618,13 +619,13 @@ blockvector_for_pc_sect (pc, section, pindex, symtab) struct sec *section; int *pindex; struct symtab *symtab; - + { register struct block *b; register int bot, top, half; struct blockvector *bl; - if (symtab == 0) /* if no symtab specified by caller */ + if (symtab == 0) /* if no symtab specified by caller */ { /* First search all symtabs for one whose file contains our pc */ if ((symtab = find_pc_sect_symtab (pc, section)) == 0) @@ -733,19 +734,19 @@ find_pc_function (pc) /* These variables are used to cache the most recent result * of find_pc_partial_function. */ -static CORE_ADDR cache_pc_function_low = 0; -static CORE_ADDR cache_pc_function_high = 0; -static char *cache_pc_function_name = 0; +static CORE_ADDR cache_pc_function_low = 0; +static CORE_ADDR cache_pc_function_high = 0; +static char *cache_pc_function_name = 0; static struct sec *cache_pc_function_section = NULL; /* Clear cache, e.g. when symbol table is discarded. */ void -clear_pc_function_cache() +clear_pc_function_cache () { cache_pc_function_low = 0; cache_pc_function_high = 0; - cache_pc_function_name = (char *)0; + cache_pc_function_name = (char *) 0; cache_pc_function_section = NULL; } @@ -762,23 +763,23 @@ clear_pc_function_cache() int find_pc_sect_partial_function (pc, section, name, address, endaddr) - CORE_ADDR pc; - asection *section; - char **name; + CORE_ADDR pc; + asection *section; + char **name; CORE_ADDR *address; CORE_ADDR *endaddr; { struct partial_symtab *pst; - struct symbol *f; + struct symbol *f; struct minimal_symbol *msymbol; struct partial_symbol *psb; - struct obj_section *osect; + struct obj_section *osect; int i; CORE_ADDR mapped_pc; mapped_pc = overlay_mapped_address (pc, section); - if (mapped_pc >= cache_pc_function_low && + if (mapped_pc >= cache_pc_function_low && mapped_pc < cache_pc_function_high && section == cache_pc_function_section) goto return_cached_value; @@ -786,11 +787,11 @@ find_pc_sect_partial_function (pc, section, name, address, endaddr) /* If sigtramp is in the u area, it counts as a function (especially important for step_1). */ #if defined SIGTRAMP_START - if (IN_SIGTRAMP (mapped_pc, (char *)NULL)) + if (IN_SIGTRAMP (mapped_pc, (char *) NULL)) { - cache_pc_function_low = SIGTRAMP_START (mapped_pc); - cache_pc_function_high = SIGTRAMP_END (mapped_pc); - cache_pc_function_name = ""; + cache_pc_function_low = SIGTRAMP_START (mapped_pc); + cache_pc_function_high = SIGTRAMP_END (mapped_pc); + cache_pc_function_name = ""; cache_pc_function_section = section; goto return_cached_value; } @@ -819,9 +820,9 @@ find_pc_sect_partial_function (pc, section, name, address, endaddr) || (BLOCK_START (SYMBOL_BLOCK_VALUE (f)) >= SYMBOL_VALUE_ADDRESS (msymbol)))) { - cache_pc_function_low = BLOCK_START (SYMBOL_BLOCK_VALUE (f)); - cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f)); - cache_pc_function_name = SYMBOL_NAME (f); + cache_pc_function_low = BLOCK_START (SYMBOL_BLOCK_VALUE (f)); + cache_pc_function_high = BLOCK_END (SYMBOL_BLOCK_VALUE (f)); + cache_pc_function_name = SYMBOL_NAME (f); cache_pc_function_section = section; goto return_cached_value; } @@ -872,21 +873,21 @@ find_pc_sect_partial_function (pc, section, name, address, endaddr) return 0; } - cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol); - cache_pc_function_name = SYMBOL_NAME (msymbol); + cache_pc_function_low = SYMBOL_VALUE_ADDRESS (msymbol); + cache_pc_function_name = SYMBOL_NAME (msymbol); cache_pc_function_section = section; /* Use the lesser of the next minimal symbol in the same section, or the end of the section, as the end of the function. */ - + /* Step over other symbols at this same address, and symbols in other sections, to find the next symbol in this section with a different address. */ - for (i=1; SYMBOL_NAME (msymbol+i) != NULL; i++) + for (i = 1; SYMBOL_NAME (msymbol + i) != NULL; i++) { - if (SYMBOL_VALUE_ADDRESS (msymbol+i) != SYMBOL_VALUE_ADDRESS (msymbol) - && SYMBOL_BFD_SECTION (msymbol+i) == SYMBOL_BFD_SECTION (msymbol)) + if (SYMBOL_VALUE_ADDRESS (msymbol + i) != SYMBOL_VALUE_ADDRESS (msymbol) + && SYMBOL_BFD_SECTION (msymbol + i) == SYMBOL_BFD_SECTION (msymbol)) break; } @@ -898,33 +899,33 @@ find_pc_sect_partial_function (pc, section, name, address, endaddr) So the end address is the end of the section. */ cache_pc_function_high = osect->endaddr; - return_cached_value: +return_cached_value: if (address) { if (pc_in_unmapped_range (pc, section)) - *address = overlay_unmapped_address (cache_pc_function_low, section); + *address = overlay_unmapped_address (cache_pc_function_low, section); else - *address = cache_pc_function_low; + *address = cache_pc_function_low; } - + if (name) *name = cache_pc_function_name; if (endaddr) { if (pc_in_unmapped_range (pc, section)) - { + { /* Because the high address is actually beyond the end of the function (and therefore possibly beyond the end of the overlay), we must actually convert (high - 1) and then add one to that. */ - *endaddr = 1 + overlay_unmapped_address (cache_pc_function_high - 1, + *endaddr = 1 + overlay_unmapped_address (cache_pc_function_high - 1, section); - } + } else - *endaddr = cache_pc_function_high; + *endaddr = cache_pc_function_high; } return 1; @@ -934,12 +935,12 @@ find_pc_sect_partial_function (pc, section, name, address, endaddr) int find_pc_partial_function (pc, name, address, endaddr) - CORE_ADDR pc; - char **name; + CORE_ADDR pc; + char **name; CORE_ADDR *address; CORE_ADDR *endaddr; { - asection *section; + asection *section; section = find_pc_overlay (pc); return find_pc_sect_partial_function (pc, section, name, address, endaddr); @@ -982,7 +983,7 @@ find_frame_addr_in_frame_chain (frame_addr) { struct frame_info *frame = NULL; - if (frame_addr == (CORE_ADDR)0) + if (frame_addr == (CORE_ADDR) 0) return NULL; while (1) @@ -1015,7 +1016,7 @@ sigtramp_saved_pc (frame) ptrbytes); else sigcontext_addr = read_memory_integer (read_register (SP_REGNUM) - + sigcontext_offs, + + sigcontext_offs, ptrbytes); /* Don't cause a memory_error when accessing sigcontext in case the stack @@ -1131,12 +1132,12 @@ static struct dummy_frame *dummy_frame_stack = NULL; Search the stack of dummy frames for one matching the given PC, FP and SP. This is the work-horse for pc_in_call_dummy and read_register_dummy */ -char * +char * generic_find_dummy_frame (pc, fp) CORE_ADDR pc; CORE_ADDR fp; { - struct dummy_frame * dummyframe; + struct dummy_frame *dummyframe; if (pc != entry_point_address ()) return 0; @@ -1179,7 +1180,7 @@ generic_read_register_dummy (pc, fp, regno) if (dummy_regs) return extract_address (&dummy_regs[REGISTER_BYTE (regno)], - REGISTER_RAW_SIZE(regno)); + REGISTER_RAW_SIZE (regno)); else return 0; } @@ -1216,10 +1217,10 @@ generic_push_dummy_frame () dummy_frame = xmalloc (sizeof (struct dummy_frame)); dummy_frame->registers = xmalloc (REGISTER_BYTES); - dummy_frame->pc = read_register (PC_REGNUM); - dummy_frame->sp = read_register (SP_REGNUM); - dummy_frame->top = dummy_frame->sp; - dummy_frame->fp = fp; + dummy_frame->pc = read_register (PC_REGNUM); + dummy_frame->sp = read_register (SP_REGNUM); + dummy_frame->top = dummy_frame->sp; + dummy_frame->fp = fp; read_register_bytes (0, dummy_frame->registers, REGISTER_BYTES); dummy_frame->next = dummy_frame_stack; dummy_frame_stack = dummy_frame; @@ -1238,10 +1239,10 @@ generic_save_dummy_frame_tos (sp) void generic_pop_current_frame (pop) - void (*pop) PARAMS ((struct frame_info *frame)); + void (*pop) PARAMS ((struct frame_info * frame)); { struct frame_info *frame = get_current_frame (); - if (PC_IN_CALL_DUMMY(frame->pc, frame->frame, frame->frame)) + if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame)) generic_pop_dummy_frame (); else pop (frame); @@ -1271,20 +1272,20 @@ generic_pop_dummy_frame () /* Function: frame_chain_valid Returns true for a user frame or a call_function_by_hand dummy frame, and false for the CRT0 start-up frame. Purpose is to terminate backtrace */ - + int generic_frame_chain_valid (fp, fi) CORE_ADDR fp; struct frame_info *fi; { - if (PC_IN_CALL_DUMMY(FRAME_SAVED_PC(fi), fp, fp)) - return 1; /* don't prune CALL_DUMMY frames */ - else /* fall back to default algorithm (see frame.h) */ + if (PC_IN_CALL_DUMMY (FRAME_SAVED_PC (fi), fp, fp)) + return 1; /* don't prune CALL_DUMMY frames */ + else /* fall back to default algorithm (see frame.h) */ return (fp != 0 && (INNER_THAN (fi->frame, fp) || fi->frame == fp) - && !inside_entry_file (FRAME_SAVED_PC(fi))); + && !inside_entry_file (FRAME_SAVED_PC (fi))); } - + /* Function: fix_call_dummy Stub function. Generic dumy frames typically do not need to fix the frame being created */ @@ -1342,7 +1343,7 @@ generic_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) if (optimized != NULL) *optimized = 0; - if (addrp) /* default assumption: not found in memory */ + if (addrp) /* default assumption: not found in memory */ *addrp = 0; /* Note: since the current frame's registers could only have been @@ -1354,34 +1355,34 @@ generic_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) { if (PC_IN_CALL_DUMMY (frame->pc, frame->frame, frame->frame)) { - if (lval) /* found it in a CALL_DUMMY frame */ + if (lval) /* found it in a CALL_DUMMY frame */ *lval = not_lval; if (raw_buffer) - memcpy (raw_buffer, - generic_find_dummy_frame (frame->pc, frame->frame) + + memcpy (raw_buffer, + generic_find_dummy_frame (frame->pc, frame->frame) + REGISTER_BYTE (regnum), REGISTER_RAW_SIZE (regnum)); - return; + return; } FRAME_INIT_SAVED_REGS (frame); if (frame->saved_regs != NULL && frame->saved_regs[regnum] != 0) { - if (lval) /* found it saved on the stack */ + if (lval) /* found it saved on the stack */ *lval = lval_memory; if (regnum == SP_REGNUM) { - if (raw_buffer) /* SP register treated specially */ - store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), + if (raw_buffer) /* SP register treated specially */ + store_address (raw_buffer, REGISTER_RAW_SIZE (regnum), frame->saved_regs[regnum]); } else { - if (addrp) /* any other register */ + if (addrp) /* any other register */ *addrp = frame->saved_regs[regnum]; if (raw_buffer) - read_memory (frame->saved_regs[regnum], raw_buffer, + read_memory (frame->saved_regs[regnum], raw_buffer, REGISTER_RAW_SIZE (regnum)); } return; @@ -1391,7 +1392,7 @@ generic_get_saved_register (raw_buffer, optimized, addrp, frame, regnum, lval) /* If we get thru the loop to this point, it means the register was not saved in any frame. Return the actual live-register value. */ - if (lval) /* found it in a live register */ + if (lval) /* found it in a live register */ *lval = lval_register; if (addrp) *addrp = REGISTER_BYTE (regnum); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 16a3ad6..ef9dfb8 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -1,22 +1,23 @@ /* Everything about breakpoints, for GDB. Copyright 1986, 87, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 1999 - Free Software Foundation, Inc. + Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include @@ -63,7 +64,7 @@ static void enable_command PARAMS ((char *, int)); static void -map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *))); +map_breakpoint_numbers PARAMS ((char *, void (*)(struct breakpoint *))); static void ignore_command PARAMS ((char *, int)); @@ -103,7 +104,7 @@ static void mention PARAMS ((struct breakpoint *)); struct breakpoint * -set_raw_breakpoint PARAMS ((struct symtab_and_line)); + set_raw_breakpoint PARAMS ((struct symtab_and_line)); static void check_duplicates PARAMS ((CORE_ADDR, asection *)); @@ -118,7 +119,7 @@ static void breakpoint_1 PARAMS ((int, int)); static bpstat -bpstat_alloc PARAMS ((struct breakpoint *, bpstat)); + bpstat_alloc PARAMS ((struct breakpoint *, bpstat)); static int breakpoint_cond_eval PARAMS ((PTR)); @@ -139,23 +140,27 @@ set_breakpoint_count PARAMS ((int)); #if 0 static struct breakpoint * -create_temp_exception_breakpoint PARAMS ((CORE_ADDR)); + create_temp_exception_breakpoint PARAMS ((CORE_ADDR)); #endif -typedef enum { - mark_inserted, - mark_uninserted -} insertion_state_t; +typedef enum + { + mark_inserted, + mark_uninserted + } +insertion_state_t; static int remove_breakpoint PARAMS ((struct breakpoint *, insertion_state_t)); static int print_it_normal PARAMS ((bpstat)); -typedef struct { - enum exception_event_kind kind; - int enable; -} args_for_catchpoint_enable; +typedef struct + { + enum exception_event_kind kind; + int enable; + } +args_for_catchpoint_enable; static int watchpoint_check PARAMS ((PTR)); @@ -187,9 +192,9 @@ static void awatch_command PARAMS ((char *, int)); static void do_enable_breakpoint PARAMS ((struct breakpoint *, enum bpdisp)); -static void create_solib_load_unload_event_breakpoint PARAMS ((char *hookname, int tempflag, char *dll_pathname, char *cond_string, enum bptype bp_kind)); +static void create_solib_load_unload_event_breakpoint PARAMS ((char *hookname, int tempflag, char *dll_pathname, char *cond_string, enum bptype bp_kind)); -static void create_fork_vfork_event_catchpoint PARAMS ((int tempflag, char * cond_string, enum bptype bp_kind)); +static void create_fork_vfork_event_catchpoint PARAMS ((int tempflag, char *cond_string, enum bptype bp_kind)); static void break_at_finish_at_depth_command_1 PARAMS ((char *arg, int flag, int from_tty)); @@ -209,7 +214,7 @@ static char *ep_parse_optional_filename PARAMS ((char **arg)); static void catch_exec_command_1 PARAMS ((char *arg, int tempflag, int from_tty)); -static void create_exception_catchpoint PARAMS ((int tempflag, char *cond_string, enum exception_event_kind ex_event, struct symtab_and_line *sal)); +static void create_exception_catchpoint PARAMS ((int tempflag, char *cond_string, enum exception_event_kind ex_event, struct symtab_and_line * sal)); static void catch_exception_command_1 PARAMS ((enum exception_event_kind ex_event, char *arg, int tempflag, int from_tty)); @@ -235,7 +240,7 @@ void _initialize_breakpoint PARAMS ((void)); void set_breakpoint_count PARAMS ((int)); -extern int addressprint; /* Print machine addresses? */ +extern int addressprint; /* Print machine addresses? */ #if defined (GET_LONGJMP_TARGET) || defined (SOLIB_ADD) static int internal_breakpoint_number = -1; @@ -263,7 +268,7 @@ int must_shift_inst_regs = #else 0 #endif -; + ; /* True if breakpoint hit counts should be displayed in breakpoint info. */ @@ -277,13 +282,13 @@ struct breakpoint *breakpoint_chain; int breakpoint_count; -/* Pointer to current exception event record */ -static struct exception_event_record * current_exception_event; +/* Pointer to current exception event record */ +static struct exception_event_record *current_exception_event; /* Indicator of whether exception catchpoints should be nuked between runs of a program */ int exception_catchpoints_are_fragile = 0; - + /* Indicator of when exception catchpoints set-up should be reinitialized -- e.g. when program is re-run */ int exception_support_initialized = 0; @@ -394,7 +399,7 @@ get_number (pp) else if (*p == '$') { /* Make a copy of the name, so we can null-terminate it - to pass to lookup_internalvar(). */ + to pass to lookup_internalvar(). */ char *varname; char *start = ++p; value_ptr val; @@ -407,8 +412,8 @@ get_number (pp) val = value_of_internalvar (lookup_internalvar (varname)); if (TYPE_CODE (VALUE_TYPE (val)) != TYPE_CODE_INT) error ( -"Convenience variables used to specify breakpoints must have integer values." - ); + "Convenience variables used to specify breakpoints must have integer values." + ); retval = (int) value_as_long (val); } else @@ -449,35 +454,35 @@ condition_command (arg, from_tty) ALL_BREAKPOINTS (b) if (b->number == bnum) - { - if (b->cond) - { - free ((PTR)b->cond); - b->cond = 0; - } - if (b->cond_string != NULL) - free ((PTR)b->cond_string); + { + if (b->cond) + { + free ((PTR) b->cond); + b->cond = 0; + } + if (b->cond_string != NULL) + free ((PTR) b->cond_string); - if (*p == 0) - { - b->cond = 0; - b->cond_string = NULL; - if (from_tty) - printf_filtered ("Breakpoint %d now unconditional.\n", bnum); - } - else - { - arg = p; - /* I don't know if it matters whether this is the string the user - typed in or the decompiled expression. */ - b->cond_string = savestring (arg, strlen (arg)); - b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0); - if (*arg) - error ("Junk at end of expression"); - } - breakpoints_changed (); - return; - } + if (*p == 0) + { + b->cond = 0; + b->cond_string = NULL; + if (from_tty) + printf_filtered ("Breakpoint %d now unconditional.\n", bnum); + } + else + { + arg = p; + /* I don't know if it matters whether this is the string the user + typed in or the decompiled expression. */ + b->cond_string = savestring (arg, strlen (arg)); + b->cond = parse_exp_1 (&arg, block_for_pc (b->address), 0); + if (*arg) + error ("Junk at end of expression"); + } + breakpoints_changed (); + return; + } error ("No breakpoint number %d.", bnum); } @@ -504,18 +509,18 @@ commands_command (arg, from_tty) bnum = get_number (&p); if (p && *p) error ("Unexpected extra arguments following breakpoint number."); - + ALL_BREAKPOINTS (b) if (b->number == bnum) - { - char tmpbuf[128]; - sprintf (tmpbuf, "Type commands for when breakpoint %d is hit, one per line.", bnum); - l = read_command_lines (tmpbuf, from_tty); - free_command_lines (&b->commands); - b->commands = l; - breakpoints_changed (); - return; - } + { + char tmpbuf[128]; + sprintf (tmpbuf, "Type commands for when breakpoint %d is hit, one per line.", bnum); + l = read_command_lines (tmpbuf, from_tty); + free_command_lines (&b->commands); + b->commands = l; + breakpoints_changed (); + return; + } error ("No breakpoint number %d.", bnum); } @@ -541,91 +546,91 @@ read_memory_nobpt (memaddr, myaddr, len) if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL) /* No breakpoints on this machine. */ return target_read_memory (memaddr, myaddr, len); - + ALL_BREAKPOINTS (b) + { + if (b->type == bp_none) + warning ("attempted to read through apparently deleted breakpoint #%d?\n", b->number); + + /* memory breakpoint? */ + if (b->type == bp_watchpoint + || b->type == bp_hardware_watchpoint + || b->type == bp_read_watchpoint + || b->type == bp_access_watchpoint) + continue; + /* bp in memory? */ + if (!b->inserted) + continue; + /* Addresses and length of the part of the breakpoint that + we need to copy. */ + /* XXXX The m68k, sh and h8300 have different local and remote + breakpoint values. BREAKPOINT_FROM_PC still manages to + correctly determine the breakpoints memory address and size + for these targets. */ + bp_addr = b->address; + bp_size = 0; + if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL) + continue; + if (bp_size == 0) + /* bp isn't valid */ + continue; + if (bp_addr + bp_size <= memaddr) + /* The breakpoint is entirely before the chunk of memory we + are reading. */ + continue; + if (bp_addr >= memaddr + len) + /* The breakpoint is entirely after the chunk of memory we are + reading. */ + continue; + /* Copy the breakpoint from the shadow contents, and recurse for + the things before and after. */ { - if (b->type == bp_none) - warning ("attempted to read through apparently deleted breakpoint #%d?\n", b->number); + /* Offset within shadow_contents. */ + int bptoffset = 0; - /* memory breakpoint? */ - if (b->type == bp_watchpoint - || b->type == bp_hardware_watchpoint - || b->type == bp_read_watchpoint - || b->type == bp_access_watchpoint) - continue; - /* bp in memory? */ - if (!b->inserted) - continue; - /* Addresses and length of the part of the breakpoint that - we need to copy. */ - /* XXXX The m68k, sh and h8300 have different local and remote - breakpoint values. BREAKPOINT_FROM_PC still manages to - correctly determine the breakpoints memory address and size - for these targets. */ - bp_addr = b->address; - bp_size = 0; - if (BREAKPOINT_FROM_PC (&bp_addr, &bp_size) == NULL) - continue; - if (bp_size == 0) - /* bp isn't valid */ - continue; - if (bp_addr + bp_size <= memaddr) - /* The breakpoint is entirely before the chunk of memory we - are reading. */ - continue; - if (bp_addr >= memaddr + len) - /* The breakpoint is entirely after the chunk of memory we are - reading. */ - continue; - /* Copy the breakpoint from the shadow contents, and recurse for - the things before and after. */ - { - /* Offset within shadow_contents. */ - int bptoffset = 0; - - if (bp_addr < memaddr) - { - /* Only copy the second part of the breakpoint. */ - bp_size -= memaddr - bp_addr; - bptoffset = memaddr - bp_addr; - bp_addr = memaddr; - } - - if (bp_addr + bp_size > memaddr + len) - { - /* Only copy the first part of the breakpoint. */ - bp_size -= (bp_addr + bp_size) - (memaddr + len); - } - - memcpy (myaddr + bp_addr - memaddr, - b->shadow_contents + bptoffset, bp_size); - - if (bp_addr > memaddr) - { - /* Copy the section of memory before the breakpoint. */ - status = read_memory_nobpt (memaddr, myaddr, bp_addr - memaddr); - if (status != 0) - return status; - } - - if (bp_addr + bp_size < memaddr + len) - { - /* Copy the section of memory after the breakpoint. */ - status = read_memory_nobpt - (bp_addr + bp_size, - myaddr + bp_addr + bp_size - memaddr, - memaddr + len - (bp_addr + bp_size)); - if (status != 0) - return status; - } - return 0; - } + if (bp_addr < memaddr) + { + /* Only copy the second part of the breakpoint. */ + bp_size -= memaddr - bp_addr; + bptoffset = memaddr - bp_addr; + bp_addr = memaddr; + } + + if (bp_addr + bp_size > memaddr + len) + { + /* Only copy the first part of the breakpoint. */ + bp_size -= (bp_addr + bp_size) - (memaddr + len); + } + + memcpy (myaddr + bp_addr - memaddr, + b->shadow_contents + bptoffset, bp_size); + + if (bp_addr > memaddr) + { + /* Copy the section of memory before the breakpoint. */ + status = read_memory_nobpt (memaddr, myaddr, bp_addr - memaddr); + if (status != 0) + return status; + } + + if (bp_addr + bp_size < memaddr + len) + { + /* Copy the section of memory after the breakpoint. */ + status = read_memory_nobpt + (bp_addr + bp_size, + myaddr + bp_addr + bp_size - memaddr, + memaddr + len - (bp_addr + bp_size)); + if (status != 0) + return status; + } + return 0; } + } /* Nothing overlaps. Just call read_memory_noerr. */ return target_read_memory (memaddr, myaddr, len); } - + /* insert_breakpoints is used when starting or continuing the program. remove_breakpoints is used when the program stops. Both return zero if successful, @@ -643,110 +648,110 @@ insert_breakpoints () ALL_BREAKPOINTS_SAFE (b, temp) - { - if (b->type != bp_watchpoint - && b->type != bp_hardware_watchpoint - && b->type != bp_read_watchpoint - && b->type != bp_access_watchpoint - && b->type != bp_catch_fork - && b->type != bp_catch_vfork - && b->type != bp_catch_exec - && b->type != bp_catch_throw - && b->type != bp_catch_catch - && b->enable != disabled - && b->enable != shlib_disabled - && b->enable != call_disabled - && ! b->inserted - && ! b->duplicate) - { - if (b->type == bp_hardware_breakpoint) - val = target_insert_hw_breakpoint(b->address, b->shadow_contents); - else - { - /* Check to see if breakpoint is in an overlay section; - if so, we should set the breakpoint at the LMA address. - Only if the section is currently mapped should we ALSO - set a break at the VMA address. */ - if (overlay_debugging && b->section && - section_is_overlay (b->section)) - { - CORE_ADDR addr; - - addr = overlay_unmapped_address (b->address, b->section); - val = target_insert_breakpoint (addr, b->shadow_contents); - /* This would be the time to check val, to see if the - breakpoint write to the load address succeeded. - However, this might be an ordinary occurrance, eg. if - the unmapped overlay is in ROM. */ - val = 0; /* in case unmapped address failed */ - if (section_is_mapped (b->section)) - val = target_insert_breakpoint (b->address, - b->shadow_contents); - } - else /* ordinary (non-overlay) address */ - val = target_insert_breakpoint(b->address, b->shadow_contents); - } - if (val) - { - /* Can't set the breakpoint. */ + { + if (b->type != bp_watchpoint + && b->type != bp_hardware_watchpoint + && b->type != bp_read_watchpoint + && b->type != bp_access_watchpoint + && b->type != bp_catch_fork + && b->type != bp_catch_vfork + && b->type != bp_catch_exec + && b->type != bp_catch_throw + && b->type != bp_catch_catch + && b->enable != disabled + && b->enable != shlib_disabled + && b->enable != call_disabled + && !b->inserted + && !b->duplicate) + { + if (b->type == bp_hardware_breakpoint) + val = target_insert_hw_breakpoint (b->address, b->shadow_contents); + else + { + /* Check to see if breakpoint is in an overlay section; + if so, we should set the breakpoint at the LMA address. + Only if the section is currently mapped should we ALSO + set a break at the VMA address. */ + if (overlay_debugging && b->section && + section_is_overlay (b->section)) + { + CORE_ADDR addr; + + addr = overlay_unmapped_address (b->address, b->section); + val = target_insert_breakpoint (addr, b->shadow_contents); + /* This would be the time to check val, to see if the + breakpoint write to the load address succeeded. + However, this might be an ordinary occurrance, eg. if + the unmapped overlay is in ROM. */ + val = 0; /* in case unmapped address failed */ + if (section_is_mapped (b->section)) + val = target_insert_breakpoint (b->address, + b->shadow_contents); + } + else /* ordinary (non-overlay) address */ + val = target_insert_breakpoint (b->address, b->shadow_contents); + } + if (val) + { + /* Can't set the breakpoint. */ #if defined (DISABLE_UNSETTABLE_BREAK) - if (DISABLE_UNSETTABLE_BREAK (b->address)) - { - /* See also: disable_breakpoints_in_shlibs. */ - val = 0; - b->enable = shlib_disabled; - if (!disabled_breaks) - { - target_terminal_ours_for_output (); - fprintf_unfiltered (gdb_stderr, - "Cannot insert breakpoint %d:\n", b->number); - printf_filtered ("Temporarily disabling shared library breakpoints:\n"); - } - disabled_breaks = 1; - printf_filtered ("%d ", b->number); - } - else + if (DISABLE_UNSETTABLE_BREAK (b->address)) + { + /* See also: disable_breakpoints_in_shlibs. */ + val = 0; + b->enable = shlib_disabled; + if (!disabled_breaks) + { + target_terminal_ours_for_output (); + fprintf_unfiltered (gdb_stderr, + "Cannot insert breakpoint %d:\n", b->number); + printf_filtered ("Temporarily disabling shared library breakpoints:\n"); + } + disabled_breaks = 1; + printf_filtered ("%d ", b->number); + } + else #endif - { - target_terminal_ours_for_output (); - fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number); + { + target_terminal_ours_for_output (); + fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number); #ifdef ONE_PROCESS_WRITETEXT - fprintf_unfiltered (gdb_stderr, - "The same program may be running in another process.\n"); + fprintf_unfiltered (gdb_stderr, + "The same program may be running in another process.\n"); #endif - memory_error (val, b->address); /* which bombs us out */ - } - } - else - b->inserted = 1; - } + memory_error (val, b->address); /* which bombs us out */ + } + } + else + b->inserted = 1; + } else if (ep_is_exception_catchpoint (b) - && b->enable != disabled - && b->enable != shlib_disabled - && b->enable != call_disabled - && ! b->inserted - && ! b->duplicate) + && b->enable != disabled + && b->enable != shlib_disabled + && b->enable != call_disabled + && !b->inserted + && !b->duplicate) { - /* If we get here, we must have a callback mechanism for exception - events -- with g++ style embedded label support, we insert - ordinary breakpoints and not catchpoints. */ - sprintf (message, message1, b->number); /* Format possible error message */ - - val = target_insert_breakpoint(b->address, b->shadow_contents); - if (val) - { - /* Couldn't set breakpoint for some reason */ - target_terminal_ours_for_output (); - fprintf_unfiltered (gdb_stderr, - "Cannot insert catchpoint %d; disabling it\n", b->number); - b->enable = disabled; - } - else - { - /* Bp set, now make sure callbacks are enabled */ + /* If we get here, we must have a callback mechanism for exception + events -- with g++ style embedded label support, we insert + ordinary breakpoints and not catchpoints. */ + sprintf (message, message1, b->number); /* Format possible error message */ + + val = target_insert_breakpoint (b->address, b->shadow_contents); + if (val) + { + /* Couldn't set breakpoint for some reason */ + target_terminal_ours_for_output (); + fprintf_unfiltered (gdb_stderr, + "Cannot insert catchpoint %d; disabling it\n", b->number); + b->enable = disabled; + } + else + { + /* Bp set, now make sure callbacks are enabled */ int val; - args_for_catchpoint_enable args; + args_for_catchpoint_enable args; args.kind = b->type == bp_catch_catch ? EX_EVENT_CATCH : EX_EVENT_THROW; args.enable = 1; val = catch_errors (cover_target_enable_exception_callback, @@ -756,140 +761,140 @@ insert_breakpoints () { b->inserted = 1; } - /* Check if something went wrong; val == 0 can be ignored */ + /* Check if something went wrong; val == 0 can be ignored */ if (val == -1) { - /* something went wrong */ + /* something went wrong */ target_terminal_ours_for_output (); fprintf_unfiltered (gdb_stderr, "Cannot insert catchpoint %d; disabling it\n", b->number); b->enable = disabled; } - } + } } - else if ((b->type == bp_hardware_watchpoint || - b->type == bp_read_watchpoint || - b->type == bp_access_watchpoint) - && b->enable == enabled - && ! b->inserted - && ! b->duplicate) - { - struct frame_info *saved_frame; - int saved_level, within_current_scope; - value_ptr mark = value_mark (); - value_ptr v; - - /* Save the current frame and level so we can restore it after - evaluating the watchpoint expression on its own frame. */ - saved_frame = selected_frame; - saved_level = selected_frame_level; - - /* Determine if the watchpoint is within scope. */ - if (b->exp_valid_block == NULL) - within_current_scope = 1; - else - { - struct frame_info *fi; - - /* There might be no current frame at this moment if we are - resuming from a step over a breakpoint. - Set up current frame before trying to find the watchpoint - frame. */ - get_current_frame (); - fi = find_frame_addr_in_frame_chain (b->watchpoint_frame); - within_current_scope = (fi != NULL); - if (within_current_scope) - select_frame (fi, -1); - } - - if (within_current_scope) - { - /* Evaluate the expression and cut the chain of values - produced off from the value chain. */ - v = evaluate_expression (b->exp); - value_release_to_mark (mark); - - b->val_chain = v; - b->inserted = 1; - - /* Look at each value on the value chain. */ - for ( ; v; v=v->next) - { - /* If it's a memory location, then we must watch it. */ - if (v->lval == lval_memory) - { - int addr, len, type; - - addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v); - len = TYPE_LENGTH (VALUE_TYPE (v)); - type = 0; - if (b->type == bp_read_watchpoint) - type = 1; - else if (b->type == bp_access_watchpoint) - type = 2; - - val = target_insert_watchpoint (addr, len, type); - if (val == -1) - { - b->inserted = 0; - break; - } - val = 0; - } - } - /* Failure to insert a watchpoint on any memory value in the - value chain brings us here. */ - if (!b->inserted) - warning ("Hardware watchpoint %d: Could not insert watchpoint\n", - b->number); - } - else - { - printf_filtered ("\ + else if ((b->type == bp_hardware_watchpoint || + b->type == bp_read_watchpoint || + b->type == bp_access_watchpoint) + && b->enable == enabled + && !b->inserted + && !b->duplicate) + { + struct frame_info *saved_frame; + int saved_level, within_current_scope; + value_ptr mark = value_mark (); + value_ptr v; + + /* Save the current frame and level so we can restore it after + evaluating the watchpoint expression on its own frame. */ + saved_frame = selected_frame; + saved_level = selected_frame_level; + + /* Determine if the watchpoint is within scope. */ + if (b->exp_valid_block == NULL) + within_current_scope = 1; + else + { + struct frame_info *fi; + + /* There might be no current frame at this moment if we are + resuming from a step over a breakpoint. + Set up current frame before trying to find the watchpoint + frame. */ + get_current_frame (); + fi = find_frame_addr_in_frame_chain (b->watchpoint_frame); + within_current_scope = (fi != NULL); + if (within_current_scope) + select_frame (fi, -1); + } + + if (within_current_scope) + { + /* Evaluate the expression and cut the chain of values + produced off from the value chain. */ + v = evaluate_expression (b->exp); + value_release_to_mark (mark); + + b->val_chain = v; + b->inserted = 1; + + /* Look at each value on the value chain. */ + for (; v; v = v->next) + { + /* If it's a memory location, then we must watch it. */ + if (v->lval == lval_memory) + { + int addr, len, type; + + addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v); + len = TYPE_LENGTH (VALUE_TYPE (v)); + type = 0; + if (b->type == bp_read_watchpoint) + type = 1; + else if (b->type == bp_access_watchpoint) + type = 2; + + val = target_insert_watchpoint (addr, len, type); + if (val == -1) + { + b->inserted = 0; + break; + } + val = 0; + } + } + /* Failure to insert a watchpoint on any memory value in the + value chain brings us here. */ + if (!b->inserted) + warning ("Hardware watchpoint %d: Could not insert watchpoint\n", + b->number); + } + else + { + printf_filtered ("\ Hardware watchpoint %d deleted because the program has left the block in\n\ which its expression is valid.\n", b->number); - if (b->related_breakpoint) - b->related_breakpoint->disposition = del_at_next_stop; - b->disposition = del_at_next_stop; - } + if (b->related_breakpoint) + b->related_breakpoint->disposition = del_at_next_stop; + b->disposition = del_at_next_stop; + } - /* Restore the frame and level. */ - if ((saved_frame != selected_frame) || - (saved_level != selected_frame_level)) - select_and_print_frame (saved_frame, saved_level); - } - else if ((b->type == bp_catch_fork - || b->type == bp_catch_vfork - || b->type == bp_catch_exec) - && b->enable == enabled - && ! b->inserted - && ! b->duplicate) - { - val = -1; - switch (b->type) - { - case bp_catch_fork : - val = target_insert_fork_catchpoint (inferior_pid); - break; - case bp_catch_vfork : - val = target_insert_vfork_catchpoint (inferior_pid); - break; - case bp_catch_exec : - val = target_insert_exec_catchpoint (inferior_pid); - break; - default: - warning ("GDB bug: breakpoint.c (insert_breakpoints): enclosing `if' does not protect `switch'"); - break; - } - if (val < 0) - { - target_terminal_ours_for_output (); - fprintf_unfiltered (gdb_stderr, "Cannot insert catchpoint %d:\n", b->number); - } - else - b->inserted = 1; - } - } + /* Restore the frame and level. */ + if ((saved_frame != selected_frame) || + (saved_level != selected_frame_level)) + select_and_print_frame (saved_frame, saved_level); + } + else if ((b->type == bp_catch_fork + || b->type == bp_catch_vfork + || b->type == bp_catch_exec) + && b->enable == enabled + && !b->inserted + && !b->duplicate) + { + val = -1; + switch (b->type) + { + case bp_catch_fork: + val = target_insert_fork_catchpoint (inferior_pid); + break; + case bp_catch_vfork: + val = target_insert_vfork_catchpoint (inferior_pid); + break; + case bp_catch_exec: + val = target_insert_exec_catchpoint (inferior_pid); + break; + default: + warning ("GDB bug: breakpoint.c (insert_breakpoints): enclosing `if' does not protect `switch'"); + break; + } + if (val < 0) + { + target_terminal_ours_for_output (); + fprintf_unfiltered (gdb_stderr, "Cannot insert catchpoint %d:\n", b->number); + } + else + b->inserted = 1; + } + } if (disabled_breaks) printf_filtered ("\n"); @@ -904,42 +909,42 @@ remove_breakpoints () int val; ALL_BREAKPOINTS (b) - { - if (b->inserted) - { - val = remove_breakpoint (b, mark_uninserted); - if (val != 0) - return val; - } - } + { + if (b->inserted) + { + val = remove_breakpoint (b, mark_uninserted); + if (val != 0) + return val; + } + } return 0; } int reattach_breakpoints (pid) - int pid; + int pid; { register struct breakpoint *b; int val; - int saved_inferior_pid = inferior_pid; + int saved_inferior_pid = inferior_pid; - inferior_pid = pid; /* Because remove_breakpoint will use this global. */ + inferior_pid = pid; /* Because remove_breakpoint will use this global. */ ALL_BREAKPOINTS (b) - { - if (b->inserted) - { - remove_breakpoint (b, mark_inserted); - if (b->type == bp_hardware_breakpoint) - val = target_insert_hw_breakpoint(b->address, b->shadow_contents); - else - val = target_insert_breakpoint(b->address, b->shadow_contents); - if (val != 0) - { - inferior_pid = saved_inferior_pid; - return val; - } - } - } + { + if (b->inserted) + { + remove_breakpoint (b, mark_inserted); + if (b->type == bp_hardware_breakpoint) + val = target_insert_hw_breakpoint (b->address, b->shadow_contents); + else + val = target_insert_breakpoint (b->address, b->shadow_contents); + if (val != 0) + { + inferior_pid = saved_inferior_pid; + return val; + } + } + } inferior_pid = saved_inferior_pid; return 0; } @@ -947,8 +952,8 @@ reattach_breakpoints (pid) void update_breakpoints_after_exec () { - struct breakpoint * b; - struct breakpoint * temp; + struct breakpoint *b; + struct breakpoint *temp; /* Doing this first prevents the badness of having delete_breakpoint() write a breakpoint's current "shadow contents" to lift the bp. That @@ -956,124 +961,124 @@ update_breakpoints_after_exec () mark_breakpoints_out (); ALL_BREAKPOINTS_SAFE (b, temp) - { - /* Solib breakpoints must be explicitly reset after an exec(). */ - if (b->type == bp_shlib_event) - { - delete_breakpoint (b); - continue; - } - - /* Step-resume breakpoints are meaningless after an exec(). */ - if (b->type == bp_step_resume) - { - delete_breakpoint (b); - continue; - } - - /* Ditto the sigtramp handler breakpoints. */ - if (b->type == bp_through_sigtramp) - { - delete_breakpoint (b); - continue; - } - - /* Ditto the exception-handling catchpoints. */ - if ((b->type == bp_catch_catch) || (b->type == bp_catch_throw)) - { - delete_breakpoint (b); - continue; - } - - /* Don't delete an exec catchpoint, because else the inferior - won't stop when it ought! - - Similarly, we probably ought to keep vfork catchpoints, 'cause - on this target, we may not be able to stop when the vfork is seen, - but only when the subsequent exec is seen. (And because deleting - fork catchpoints here but not vfork catchpoints will seem mysterious - to users, keep those too.) - - ??rehrauer: Let's hope that merely clearing out this catchpoint's - target address field, if any, is sufficient to have it be reset - automagically. Certainly on HP-UX that's true. */ - if ((b->type == bp_catch_exec) || - (b->type == bp_catch_vfork) || - (b->type == bp_catch_fork)) - { - b->address = (CORE_ADDR) NULL; - continue; - } - - /* bp_finish is a special case. The only way we ought to be able - to see one of these when an exec() has happened, is if the user - caught a vfork, and then said "finish". Ordinarily a finish just - carries them to the call-site of the current callee, by setting - a temporary bp there and resuming. But in this case, the finish - will carry them entirely through the vfork & exec. - - We don't want to allow a bp_finish to remain inserted now. But - we can't safely delete it, 'cause finish_command has a handle to - the bp on a bpstat, and will later want to delete it. There's a - chance (and I've seen it happen) that if we delete the bp_finish - here, that its storage will get reused by the time finish_command - gets 'round to deleting the "use to be a bp_finish" breakpoint. - We really must allow finish_command to delete a bp_finish. - - In the absense of a general solution for the "how do we know it's - safe to delete something others may have handles to?" problem, what - we'll do here is just uninsert the bp_finish, and let finish_command - delete it. - - (We know the bp_finish is "doomed" in the sense that it's momentary, - and will be deleted as soon as finish_command sees the inferior stopped. - So it doesn't matter that the bp's address is probably bogus in the - new a.out, unlike e.g., the solib breakpoints.) */ - if (b->type == bp_finish) - { - continue; - } - - /* Without a symbolic address, we have little hope of the - pre-exec() address meaning the same thing in the post-exec() - a.out. */ - if (b->addr_string == NULL) - { - delete_breakpoint (b); - continue; - } + { + /* Solib breakpoints must be explicitly reset after an exec(). */ + if (b->type == bp_shlib_event) + { + delete_breakpoint (b); + continue; + } - /* If this breakpoint has survived the above battery of checks, then - it must have a symbolic address. Be sure that it gets reevaluated - to a target address, rather than reusing the old evaluation. */ - b->address = (CORE_ADDR) NULL; - } + /* Step-resume breakpoints are meaningless after an exec(). */ + if (b->type == bp_step_resume) + { + delete_breakpoint (b); + continue; + } + + /* Ditto the sigtramp handler breakpoints. */ + if (b->type == bp_through_sigtramp) + { + delete_breakpoint (b); + continue; + } + + /* Ditto the exception-handling catchpoints. */ + if ((b->type == bp_catch_catch) || (b->type == bp_catch_throw)) + { + delete_breakpoint (b); + continue; + } + + /* Don't delete an exec catchpoint, because else the inferior + won't stop when it ought! + + Similarly, we probably ought to keep vfork catchpoints, 'cause + on this target, we may not be able to stop when the vfork is seen, + but only when the subsequent exec is seen. (And because deleting + fork catchpoints here but not vfork catchpoints will seem mysterious + to users, keep those too.) + + ??rehrauer: Let's hope that merely clearing out this catchpoint's + target address field, if any, is sufficient to have it be reset + automagically. Certainly on HP-UX that's true. */ + if ((b->type == bp_catch_exec) || + (b->type == bp_catch_vfork) || + (b->type == bp_catch_fork)) + { + b->address = (CORE_ADDR) NULL; + continue; + } + + /* bp_finish is a special case. The only way we ought to be able + to see one of these when an exec() has happened, is if the user + caught a vfork, and then said "finish". Ordinarily a finish just + carries them to the call-site of the current callee, by setting + a temporary bp there and resuming. But in this case, the finish + will carry them entirely through the vfork & exec. + + We don't want to allow a bp_finish to remain inserted now. But + we can't safely delete it, 'cause finish_command has a handle to + the bp on a bpstat, and will later want to delete it. There's a + chance (and I've seen it happen) that if we delete the bp_finish + here, that its storage will get reused by the time finish_command + gets 'round to deleting the "use to be a bp_finish" breakpoint. + We really must allow finish_command to delete a bp_finish. + + In the absense of a general solution for the "how do we know it's + safe to delete something others may have handles to?" problem, what + we'll do here is just uninsert the bp_finish, and let finish_command + delete it. + + (We know the bp_finish is "doomed" in the sense that it's momentary, + and will be deleted as soon as finish_command sees the inferior stopped. + So it doesn't matter that the bp's address is probably bogus in the + new a.out, unlike e.g., the solib breakpoints.) */ + if (b->type == bp_finish) + { + continue; + } + + /* Without a symbolic address, we have little hope of the + pre-exec() address meaning the same thing in the post-exec() + a.out. */ + if (b->addr_string == NULL) + { + delete_breakpoint (b); + continue; + } + + /* If this breakpoint has survived the above battery of checks, then + it must have a symbolic address. Be sure that it gets reevaluated + to a target address, rather than reusing the old evaluation. */ + b->address = (CORE_ADDR) NULL; + } } int detach_breakpoints (pid) - int pid; + int pid; { register struct breakpoint *b; int val; - int saved_inferior_pid = inferior_pid; - + int saved_inferior_pid = inferior_pid; + if (pid == inferior_pid) error ("Cannot detach breakpoints of inferior_pid"); - - inferior_pid = pid; /* Because remove_breakpoint will use this global. */ + + inferior_pid = pid; /* Because remove_breakpoint will use this global. */ ALL_BREAKPOINTS (b) - { - if (b->inserted) - { - val = remove_breakpoint (b, mark_inserted); - if (val != 0) - { - inferior_pid = saved_inferior_pid; - return val; - } - } - } + { + if (b->inserted) + { + val = remove_breakpoint (b, mark_inserted); + if (val != 0) + { + inferior_pid = saved_inferior_pid; + return val; + } + } + } inferior_pid = saved_inferior_pid; return 0; } @@ -1081,10 +1086,10 @@ detach_breakpoints (pid) static int remove_breakpoint (b, is) struct breakpoint *b; - insertion_state_t is; + insertion_state_t is; { int val; - + if (b->type == bp_none) warning ("attempted to remove apparently deleted breakpoint #%d?\n", b->number); @@ -1097,17 +1102,17 @@ remove_breakpoint (b, is) && b->type != bp_catch_exec && b->type != bp_catch_catch && b->type != bp_catch_throw) - + { if (b->type == bp_hardware_breakpoint) - val = target_remove_hw_breakpoint(b->address, b->shadow_contents); + val = target_remove_hw_breakpoint (b->address, b->shadow_contents); else { /* Check to see if breakpoint is in an overlay section; if so, we should remove the breakpoint at the LMA address. If that is not equal to the raw address, then we should presumable remove the breakpoint there as well. */ - if (overlay_debugging && b->section && + if (overlay_debugging && b->section && section_is_overlay (b->section)) { CORE_ADDR addr; @@ -1115,29 +1120,29 @@ remove_breakpoint (b, is) addr = overlay_unmapped_address (b->address, b->section); val = target_remove_breakpoint (addr, b->shadow_contents); /* This would be the time to check val, to see if the - shadow breakpoint write to the load address succeeded. - However, this might be an ordinary occurrance, eg. if - the unmapped overlay is in ROM. */ - val = 0; /* in case unmapped address failed */ + shadow breakpoint write to the load address succeeded. + However, this might be an ordinary occurrance, eg. if + the unmapped overlay is in ROM. */ + val = 0; /* in case unmapped address failed */ if (section_is_mapped (b->section)) - val = target_remove_breakpoint (b->address, + val = target_remove_breakpoint (b->address, b->shadow_contents); } - else /* ordinary (non-overlay) address */ - val = target_remove_breakpoint(b->address, b->shadow_contents); + else /* ordinary (non-overlay) address */ + val = target_remove_breakpoint (b->address, b->shadow_contents); } if (val) return val; b->inserted = (is == mark_inserted); } else if ((b->type == bp_hardware_watchpoint || - b->type == bp_read_watchpoint || - b->type == bp_access_watchpoint) + b->type == bp_read_watchpoint || + b->type == bp_access_watchpoint) && b->enable == enabled - && ! b->duplicate) + && !b->duplicate) { value_ptr v, n; - + b->inserted = (is == mark_inserted); /* Walk down the saved value chain. */ for (v = b->val_chain; v; v = v->next) @@ -1147,7 +1152,7 @@ remove_breakpoint (b, is) if (v->lval == lval_memory) { int addr, len, type; - + addr = VALUE_ADDRESS (v) + VALUE_OFFSET (v); len = TYPE_LENGTH (VALUE_TYPE (v)); type = 0; @@ -1166,9 +1171,9 @@ remove_breakpoint (b, is) if ((is == mark_uninserted) && (b->inserted)) warning ("Hardware watchpoint %d: Could not remove watchpoint\n", b->number); - + /* Free the saved value chain. We will construct a new one - the next time the watchpoint is inserted. */ + the next time the watchpoint is inserted. */ for (v = b->val_chain; v; v = n) { n = v->next; @@ -1177,52 +1182,52 @@ remove_breakpoint (b, is) b->val_chain = NULL; } else if ((b->type == bp_catch_fork || - b->type == bp_catch_vfork || - b->type == bp_catch_exec) + b->type == bp_catch_vfork || + b->type == bp_catch_exec) && b->enable == enabled - && ! b->duplicate) + && !b->duplicate) { val = -1; switch (b->type) - { - case bp_catch_fork: - val = target_remove_fork_catchpoint (inferior_pid); - break; - case bp_catch_vfork : - val = target_remove_vfork_catchpoint (inferior_pid); - break; - case bp_catch_exec : - val = target_remove_exec_catchpoint (inferior_pid); - break; + { + case bp_catch_fork: + val = target_remove_fork_catchpoint (inferior_pid); + break; + case bp_catch_vfork: + val = target_remove_vfork_catchpoint (inferior_pid); + break; + case bp_catch_exec: + val = target_remove_exec_catchpoint (inferior_pid); + break; default: warning ("GDB bug: breakpoint.c (remove_breakpoint): enclosing `if' does not protect `switch'"); break; - } + } if (val) return val; b->inserted = (is == mark_inserted); } else if ((b->type == bp_catch_catch || - b->type == bp_catch_throw) - && b->enable == enabled - && ! b->duplicate) + b->type == bp_catch_throw) + && b->enable == enabled + && !b->duplicate) { - val = target_remove_breakpoint(b->address, b->shadow_contents); + val = target_remove_breakpoint (b->address, b->shadow_contents); if (val) - return val; + return val; b->inserted = (is == mark_inserted); } else if (ep_is_exception_catchpoint (b) - && b->inserted /* sometimes previous insert doesn't happen */ - && b->enable == enabled - && ! b->duplicate) + && b->inserted /* sometimes previous insert doesn't happen */ + && b->enable == enabled + && !b->duplicate) { - val = target_remove_breakpoint(b->address, b->shadow_contents); + val = target_remove_breakpoint (b->address, b->shadow_contents); if (val) - return val; - + return val; + b->inserted = (is == mark_inserted); } @@ -1247,65 +1252,65 @@ mark_breakpoints_out () between runs. Note: this function gets called at the end of a run (by generic_mourn_inferior) - and when a run begins (by init_wait_for_inferior). */ + and when a run begins (by init_wait_for_inferior). */ void breakpoint_init_inferior (context) - enum inf_context context; + enum inf_context context; { register struct breakpoint *b, *temp; static int warning_needed = 0; ALL_BREAKPOINTS_SAFE (b, temp) - { - b->inserted = 0; + { + b->inserted = 0; - switch (b->type) - { - case bp_call_dummy: - case bp_watchpoint_scope: + switch (b->type) + { + case bp_call_dummy: + case bp_watchpoint_scope: - /* If the call dummy breakpoint is at the entry point it will - cause problems when the inferior is rerun, so we better - get rid of it. + /* If the call dummy breakpoint is at the entry point it will + cause problems when the inferior is rerun, so we better + get rid of it. - Also get rid of scope breakpoints. */ - delete_breakpoint (b); - break; + Also get rid of scope breakpoints. */ + delete_breakpoint (b); + break; - case bp_watchpoint: - case bp_hardware_watchpoint: - case bp_read_watchpoint: - case bp_access_watchpoint: + case bp_watchpoint: + case bp_hardware_watchpoint: + case bp_read_watchpoint: + case bp_access_watchpoint: - /* Likewise for watchpoints on local expressions. */ - if (b->exp_valid_block != NULL) + /* Likewise for watchpoints on local expressions. */ + if (b->exp_valid_block != NULL) + delete_breakpoint (b); + break; + default: + /* Likewise for exception catchpoints in dynamic-linked + executables where required */ + if (ep_is_exception_catchpoint (b) && + exception_catchpoints_are_fragile) + { + warning_needed = 1; delete_breakpoint (b); - break; - default: - /* Likewise for exception catchpoints in dynamic-linked - executables where required */ - if (ep_is_exception_catchpoint (b) && - exception_catchpoints_are_fragile) - { - warning_needed = 1; - delete_breakpoint (b); - } - break; - } - } + } + break; + } + } if (exception_catchpoints_are_fragile) exception_support_initialized = 0; - /* Don't issue the warning unless it's really needed... */ + /* Don't issue the warning unless it's really needed... */ if (warning_needed && (context != inf_exited)) { warning ("Exception catchpoints from last run were deleted, you must reinsert them explicitly"); warning_needed = 0; - } + } } /* breakpoint_here_p (PC) returns 1 if an enabled breakpoint exists at PC. @@ -1323,14 +1328,14 @@ breakpoint_here_p (pc) && b->enable != shlib_disabled && b->enable != call_disabled && b->address == pc) /* bp is enabled and matches pc */ - { - if (overlay_debugging && - section_is_overlay (b->section) && - !section_is_mapped (b->section)) - continue; /* unmapped overlay -- can't be a match */ - else - return 1; - } + { + if (overlay_debugging && + section_is_overlay (b->section) && + !section_is_mapped (b->section)) + continue; /* unmapped overlay -- can't be a match */ + else + return 1; + } return 0; } @@ -1347,14 +1352,14 @@ breakpoint_inserted_here_p (pc) ALL_BREAKPOINTS (b) if (b->inserted && b->address == pc) /* bp is inserted and matches pc */ - { - if (overlay_debugging && - section_is_overlay (b->section) && - !section_is_mapped (b->section)) - continue; /* unmapped overlay -- can't be a match */ - else - return 1; - } + { + if (overlay_debugging && + section_is_overlay (b->section) && + !section_is_mapped (b->section)) + continue; /* unmapped overlay -- can't be a match */ + else + return 1; + } return 0; } @@ -1370,24 +1375,24 @@ frame_in_dummy (frame) { struct breakpoint *b; - if (! CALL_DUMMY_P) + if (!CALL_DUMMY_P) return 0; if (USE_GENERIC_DUMMY_FRAMES) return generic_pc_in_call_dummy (frame->pc, frame->frame, frame->frame); - + ALL_BREAKPOINTS (b) - { - if (b->type == bp_call_dummy - && b->frame == frame->frame - /* We need to check the PC as well as the frame on the sparc, - for signals.exp in the testsuite. */ - && (frame->pc - >= (b->address - - SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * REGISTER_SIZE)) - && frame->pc <= b->address) - return 1; - } + { + if (b->type == bp_call_dummy + && b->frame == frame->frame + /* We need to check the PC as well as the frame on the sparc, + for signals.exp in the testsuite. */ + && (frame->pc + >= (b->address + - SIZEOF_CALL_DUMMY_WORDS / sizeof (LONGEST) * REGISTER_SIZE)) + && frame->pc <= b->address) + return 1; + } return 0; } @@ -1410,25 +1415,25 @@ breakpoint_thread_match (pc, pid) && b->enable != call_disabled && b->address == pc && (b->thread == -1 || b->thread == thread)) - { - if (overlay_debugging && - section_is_overlay (b->section) && - !section_is_mapped (b->section)) - continue; /* unmapped overlay -- can't be a match */ - else - return 1; - } + { + if (overlay_debugging && + section_is_overlay (b->section) && + !section_is_mapped (b->section)) + continue; /* unmapped overlay -- can't be a match */ + else + return 1; + } return 0; } - + /* bpstat stuff. External routines' interfaces are documented in breakpoint.h. */ int ep_is_catchpoint (ep) - struct breakpoint * ep; + struct breakpoint *ep; { return (ep->type == bp_catch_load) @@ -1440,13 +1445,13 @@ ep_is_catchpoint (ep) || (ep->type == bp_catch_throw) - /* ??rehrauer: Add more kinds here, as are implemented... */ + /* ??rehrauer: Add more kinds here, as are implemented... */ ; } - + int ep_is_shlib_catchpoint (ep) - struct breakpoint * ep; + struct breakpoint *ep; { return (ep->type == bp_catch_load) @@ -1456,7 +1461,7 @@ ep_is_shlib_catchpoint (ep) int ep_is_exception_catchpoint (ep) - struct breakpoint * ep; + struct breakpoint *ep; { return (ep->type == bp_catch_catch) @@ -1482,7 +1487,7 @@ bpstat_clear (bsp) q = p->next; if (p->old_val != NULL) value_free (p->old_val); - free ((PTR)p); + free ((PTR) p); p = q; } *bsp = NULL; @@ -1520,15 +1525,18 @@ bpstat_copy (bs) /* Find the bpstat associated with this breakpoint */ bpstat -bpstat_find_breakpoint(bsp, breakpoint) +bpstat_find_breakpoint (bsp, breakpoint) bpstat bsp; struct breakpoint *breakpoint; { - if (bsp == NULL) return NULL; + if (bsp == NULL) + return NULL; - for (;bsp != NULL; bsp = bsp->next) { - if (bsp->breakpoint_at == breakpoint) return bsp; - } + for (; bsp != NULL; bsp = bsp->next) + { + if (bsp->breakpoint_at == breakpoint) + return bsp; + } return NULL; } @@ -1542,7 +1550,7 @@ bpstat_find_breakpoint(bsp, breakpoint) See wait_for_inferior's use of this function. */ struct breakpoint * bpstat_find_step_resume_breakpoint (bsp) - bpstat bsp; + bpstat bsp; { if (bsp == NULL) error ("Internal error (bpstat_find_step_resume_breakpoint)"); @@ -1550,8 +1558,8 @@ bpstat_find_step_resume_breakpoint (bsp) for (; bsp != NULL; bsp = bsp->next) { if ((bsp->breakpoint_at != NULL) && - (bsp->breakpoint_at->type == bp_step_resume)) - return bsp->breakpoint_at; + (bsp->breakpoint_at->type == bp_step_resume)) + return bsp->breakpoint_at; } error ("Internal error (no step_resume breakpoint found)"); @@ -1579,7 +1587,7 @@ bpstat_num (bsp) if (b == NULL) return -1; /* breakpoint that's been deleted since */ else - return b->number; /* We have its number */ + return b->number; /* We have its number */ } } @@ -1678,13 +1686,13 @@ top: calling the print_it function for each one. The default print_it function, used for breakpoints, is print_it_normal(). (Also see print_it_noop() and print_it_done()). - + Return values from this routine (used by bpstat_print() to decide what to do): 1: Means we printed something, and we do *not* desire that - something to be followed by a location. + something to be followed by a location. 0: Means we printed something, and we *do* desire that - something to be followed by a location. + something to be followed by a location. -1: Means we printed nothing. */ static int @@ -1695,13 +1703,13 @@ print_it_normal (bs) which has since been deleted. */ if (bs->breakpoint_at == NULL || (bs->breakpoint_at->type != bp_breakpoint - && bs->breakpoint_at->type != bp_catch_load - && bs->breakpoint_at->type != bp_catch_unload - && bs->breakpoint_at->type != bp_catch_fork - && bs->breakpoint_at->type != bp_catch_vfork - && bs->breakpoint_at->type != bp_catch_exec - && bs->breakpoint_at->type != bp_catch_catch - && bs->breakpoint_at->type != bp_catch_throw + && bs->breakpoint_at->type != bp_catch_load + && bs->breakpoint_at->type != bp_catch_unload + && bs->breakpoint_at->type != bp_catch_fork + && bs->breakpoint_at->type != bp_catch_vfork + && bs->breakpoint_at->type != bp_catch_exec + && bs->breakpoint_at->type != bp_catch_catch + && bs->breakpoint_at->type != bp_catch_throw && bs->breakpoint_at->type != bp_hardware_breakpoint && bs->breakpoint_at->type != bp_watchpoint && bs->breakpoint_at->type != bp_read_watchpoint @@ -1714,21 +1722,21 @@ print_it_normal (bs) annotate_catchpoint (bs->breakpoint_at->number); printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number); if (bs->breakpoint_at->type == bp_catch_load) - printf_filtered ("loaded"); + printf_filtered ("loaded"); else if (bs->breakpoint_at->type == bp_catch_unload) - printf_filtered ("unloaded"); + printf_filtered ("unloaded"); printf_filtered (" %s), ", bs->breakpoint_at->triggered_dll_pathname); return 0; } else if (bs->breakpoint_at->type == bp_catch_fork || - bs->breakpoint_at->type == bp_catch_vfork) + bs->breakpoint_at->type == bp_catch_vfork) { annotate_catchpoint (bs->breakpoint_at->number); printf_filtered ("\nCatchpoint %d (", bs->breakpoint_at->number); if (bs->breakpoint_at->type == bp_catch_fork) - printf_filtered ("forked"); + printf_filtered ("forked"); else if (bs->breakpoint_at->type == bp_catch_vfork) - printf_filtered ("vforked"); + printf_filtered ("vforked"); printf_filtered (" process %d), ", bs->breakpoint_at->forked_inferior_pid); return 0; } @@ -1736,84 +1744,84 @@ print_it_normal (bs) { annotate_catchpoint (bs->breakpoint_at->number); printf_filtered ("\nCatchpoint %d (exec'd %s), ", - bs->breakpoint_at->number, - bs->breakpoint_at->exec_pathname); + bs->breakpoint_at->number, + bs->breakpoint_at->exec_pathname); return 0; } - else if (bs->breakpoint_at->type == bp_catch_catch) + else if (bs->breakpoint_at->type == bp_catch_catch) { if (current_exception_event && (CURRENT_EXCEPTION_KIND == EX_EVENT_CATCH)) - { - annotate_catchpoint (bs->breakpoint_at->number); - printf_filtered ("\nCatchpoint %d (exception caught), ", bs->breakpoint_at->number); - printf_filtered ("throw location "); - if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE) - printf_filtered ("%s:%d", - CURRENT_EXCEPTION_THROW_FILE, - CURRENT_EXCEPTION_THROW_LINE); - else - printf_filtered ("unknown"); - - printf_filtered (", catch location "); - if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE) - printf_filtered ("%s:%d", - CURRENT_EXCEPTION_CATCH_FILE, - CURRENT_EXCEPTION_CATCH_LINE); - else - printf_filtered ("unknown"); - - printf_filtered ("\n"); - return 1; /* don't bother to print location frame info */ - } + { + annotate_catchpoint (bs->breakpoint_at->number); + printf_filtered ("\nCatchpoint %d (exception caught), ", bs->breakpoint_at->number); + printf_filtered ("throw location "); + if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE) + printf_filtered ("%s:%d", + CURRENT_EXCEPTION_THROW_FILE, + CURRENT_EXCEPTION_THROW_LINE); + else + printf_filtered ("unknown"); + + printf_filtered (", catch location "); + if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE) + printf_filtered ("%s:%d", + CURRENT_EXCEPTION_CATCH_FILE, + CURRENT_EXCEPTION_CATCH_LINE); + else + printf_filtered ("unknown"); + + printf_filtered ("\n"); + return 1; /* don't bother to print location frame info */ + } else - { - return -1; /* really throw, some other bpstat will handle it */ - } + { + return -1; /* really throw, some other bpstat will handle it */ + } } else if (bs->breakpoint_at->type == bp_catch_throw) { if (current_exception_event && (CURRENT_EXCEPTION_KIND == EX_EVENT_THROW)) - { - annotate_catchpoint (bs->breakpoint_at->number); - printf_filtered ("\nCatchpoint %d (exception thrown), ", bs->breakpoint_at->number); - printf_filtered ("throw location "); - if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE) - printf_filtered ("%s:%d", - CURRENT_EXCEPTION_THROW_FILE, - CURRENT_EXCEPTION_THROW_LINE); - else - printf_filtered ("unknown"); - - printf_filtered (", catch location "); - if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE) - printf_filtered ("%s:%d", - CURRENT_EXCEPTION_CATCH_FILE, - CURRENT_EXCEPTION_CATCH_LINE); - else - printf_filtered ("unknown"); - - printf_filtered ("\n"); - return 1; /* don't bother to print location frame info */ - } + { + annotate_catchpoint (bs->breakpoint_at->number); + printf_filtered ("\nCatchpoint %d (exception thrown), ", bs->breakpoint_at->number); + printf_filtered ("throw location "); + if (CURRENT_EXCEPTION_THROW_PC && CURRENT_EXCEPTION_THROW_LINE) + printf_filtered ("%s:%d", + CURRENT_EXCEPTION_THROW_FILE, + CURRENT_EXCEPTION_THROW_LINE); + else + printf_filtered ("unknown"); + + printf_filtered (", catch location "); + if (CURRENT_EXCEPTION_CATCH_PC && CURRENT_EXCEPTION_CATCH_LINE) + printf_filtered ("%s:%d", + CURRENT_EXCEPTION_CATCH_FILE, + CURRENT_EXCEPTION_CATCH_LINE); + else + printf_filtered ("unknown"); + + printf_filtered ("\n"); + return 1; /* don't bother to print location frame info */ + } else - { - return -1; /* really catch, some other bpstat willhandle it */ - } + { + return -1; /* really catch, some other bpstat willhandle it */ + } } else if (bs->breakpoint_at->type == bp_breakpoint || - bs->breakpoint_at->type == bp_hardware_breakpoint) + bs->breakpoint_at->type == bp_hardware_breakpoint) { /* I think the user probably only wants to see one breakpoint - number, not all of them. */ + number, not all of them. */ annotate_breakpoint (bs->breakpoint_at->number); printf_filtered ("\nBreakpoint %d, ", bs->breakpoint_at->number); return 0; } else if ((bs->old_val != NULL) && - (bs->breakpoint_at->type == bp_watchpoint || - bs->breakpoint_at->type == bp_access_watchpoint || - bs->breakpoint_at->type == bp_hardware_watchpoint)) + (bs->breakpoint_at->type == bp_watchpoint || + bs->breakpoint_at->type == bp_access_watchpoint || + bs->breakpoint_at->type == bp_hardware_watchpoint)) { annotate_watchpoint (bs->breakpoint_at->number); mention (bs->breakpoint_at); @@ -1834,7 +1842,7 @@ print_it_normal (bs) mention (bs->breakpoint_at); printf_filtered ("\nValue = "); value_print (bs->breakpoint_at->val, gdb_stdout, 0, - Val_pretty_default); + Val_pretty_default); printf_filtered ("\n"); return -1; } @@ -1853,27 +1861,27 @@ print_it_normal (bs) -1: Means we printed nothing 0: Means we printed something, and expect subsequent - code to print the location. An example is - "Breakpoint 1, " which should be followed by - the location. + code to print the location. An example is + "Breakpoint 1, " which should be followed by + the location. 1 : Means we printed something, but there is no need - to also print the location part of the message. - An example is the catch/throw messages, which - don't require a location appended to the end. */ + to also print the location part of the message. + An example is the catch/throw messages, which + don't require a location appended to the end. */ int bpstat_print (bs) bpstat bs; { int val; - + if (bs == NULL) return -1; val = (*bs->print_it) (bs); if (val >= 0) return val; - + /* Maybe another breakpoint in the chain caused us to stop. (Currently all watchpoints go on the bpstat whether hit or not. That probably could (should) be changed, provided care is taken @@ -1895,7 +1903,7 @@ breakpoint_cond_eval (exp) PTR exp; { value_ptr mark = value_mark (); - int i = !value_true (evaluate_expression ((struct expression *)exp)); + int i = !value_true (evaluate_expression ((struct expression *) exp)); value_free_to_mark (mark); return i; } @@ -1905,7 +1913,7 @@ breakpoint_cond_eval (exp) static bpstat bpstat_alloc (b, cbs) register struct breakpoint *b; - bpstat cbs; /* Current "bs" value */ + bpstat cbs; /* Current "bs" value */ { bpstat bs; @@ -1949,9 +1957,9 @@ watchpoint_check (p) else { /* There is no current frame at this moment. If we're going to have - any chance of handling watchpoints on local variables, we'll need - the frame chain (so we can determine if we're in scope). */ - reinit_frame_cache(); + any chance of handling watchpoints on local variables, we'll need + the frame chain (so we can determine if we're in scope). */ + reinit_frame_cache (); fr = find_frame_addr_in_frame_chain (b->watchpoint_frame); within_current_scope = (fr != NULL); if (within_current_scope) @@ -1960,13 +1968,13 @@ watchpoint_check (p) the user. */ select_frame (fr, -1); } - + if (within_current_scope) { /* We use value_{,free_to_}mark because it could be a *long* time before we return to the command level and - call free_all_values. We can't call free_all_values because - we might be in the middle of evaluating a function call. */ + call free_all_values. We can't call free_all_values because + we might be in the middle of evaluating a function call. */ value_ptr mark = value_mark (); value_ptr new_val = evaluate_expression (bs->breakpoint_at->exp); @@ -1990,13 +1998,13 @@ watchpoint_check (p) else { /* This seems like the only logical thing to do because - if we temporarily ignored the watchpoint, then when - we reenter the block in which it is valid it contains - garbage (in the case of a function, it may have two - garbage values, one before and one after the prologue). - So we can't even detect the first assignment to it and - watch after that (since the garbage may or may not equal - the first value assigned). */ + if we temporarily ignored the watchpoint, then when + we reenter the block in which it is valid it contains + garbage (in the case of a function, it may have two + garbage values, one before and one after the prologue). + So we can't even detect the first assignment to it and + watch after that (since the garbage may or may not equal + the first value assigned). */ printf_filtered ("\ Watchpoint %d deleted because the program has left the block in\n\ which its expression is valid.\n", bs->breakpoint_at->number); @@ -2051,16 +2059,16 @@ print_it_noop (bs) /* Determine whether we stopped at a breakpoint, etc, or whether we don't understand this stop. Result is a chain of bpstat's such that: - if we don't understand the stop, the result is a null pointer. + if we don't understand the stop, the result is a null pointer. - if we understand why we stopped, the result is not null. + if we understand why we stopped, the result is not null. - Each element of the chain refers to a particular breakpoint or - watchpoint at which we have stopped. (We may have stopped for - several reasons concurrently.) + Each element of the chain refers to a particular breakpoint or + watchpoint at which we have stopped. (We may have stopped for + several reasons concurrently.) - Each element of the chain has valid next, breakpoint_at, - commands, FIXME??? fields. */ + Each element of the chain has valid next, breakpoint_at, + commands, FIXME??? fields. */ bpstat bpstat_stop_status (pc, not_a_breakpoint) @@ -2076,94 +2084,149 @@ bpstat_stop_status (pc, not_a_breakpoint) /* Pointer to the last thing in the chain currently. */ bpstat bs = root_bs; static char message1[] = - "Error evaluating expression for watchpoint %d\n"; - char message[sizeof (message1) + 30 /* slop */]; + "Error evaluating expression for watchpoint %d\n"; + char message[sizeof (message1) + 30 /* slop */ ]; /* Get the address where the breakpoint would have been. */ bp_addr = *pc - DECR_PC_AFTER_BREAK; ALL_BREAKPOINTS_SAFE (b, temp) - { - if (b->enable == disabled - || b->enable == shlib_disabled - || b->enable == call_disabled) - continue; - - if (b->type != bp_watchpoint - && b->type != bp_hardware_watchpoint - && b->type != bp_read_watchpoint - && b->type != bp_access_watchpoint - && b->type != bp_hardware_breakpoint - && b->type != bp_catch_fork - && b->type != bp_catch_vfork - && b->type != bp_catch_exec - && b->type != bp_catch_catch - && b->type != bp_catch_throw) /* a non-watchpoint bp */ - if (b->address != bp_addr || /* address doesn't match or */ - (overlay_debugging && /* overlay doesn't match */ - section_is_overlay (b->section) && - !section_is_mapped (b->section))) - continue; - - if (b->type == bp_hardware_breakpoint - && b->address != (*pc - DECR_PC_AFTER_HW_BREAK)) - continue; - - if (b->type != bp_watchpoint - && b->type != bp_hardware_watchpoint - && b->type != bp_read_watchpoint - && b->type != bp_access_watchpoint - && not_a_breakpoint) + { + if (b->enable == disabled + || b->enable == shlib_disabled + || b->enable == call_disabled) + continue; + + if (b->type != bp_watchpoint + && b->type != bp_hardware_watchpoint + && b->type != bp_read_watchpoint + && b->type != bp_access_watchpoint + && b->type != bp_hardware_breakpoint + && b->type != bp_catch_fork + && b->type != bp_catch_vfork + && b->type != bp_catch_exec + && b->type != bp_catch_catch + && b->type != bp_catch_throw) /* a non-watchpoint bp */ + if (b->address != bp_addr || /* address doesn't match or */ + (overlay_debugging && /* overlay doesn't match */ + section_is_overlay (b->section) && + !section_is_mapped (b->section))) continue; - /* Is this a catchpoint of a load or unload? If so, did we - get a load or unload of the specified library? If not, - ignore it. */ - if ((b->type == bp_catch_load) + if (b->type == bp_hardware_breakpoint + && b->address != (*pc - DECR_PC_AFTER_HW_BREAK)) + continue; + + if (b->type != bp_watchpoint + && b->type != bp_hardware_watchpoint + && b->type != bp_read_watchpoint + && b->type != bp_access_watchpoint + && not_a_breakpoint) + continue; + + /* Is this a catchpoint of a load or unload? If so, did we + get a load or unload of the specified library? If not, + ignore it. */ + if ((b->type == bp_catch_load) #if defined(SOLIB_HAVE_LOAD_EVENT) - && (!SOLIB_HAVE_LOAD_EVENT(inferior_pid) - || ((b->dll_pathname != NULL) - && (strcmp (b->dll_pathname, SOLIB_LOADED_LIBRARY_PATHNAME(inferior_pid)) != 0))) + && (!SOLIB_HAVE_LOAD_EVENT (inferior_pid) + || ((b->dll_pathname != NULL) + && (strcmp (b->dll_pathname, SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid)) != 0))) #endif - ) - continue; - - if ((b->type == bp_catch_unload) + ) + continue; + + if ((b->type == bp_catch_unload) #if defined(SOLIB_HAVE_UNLOAD_EVENT) - && (!SOLIB_HAVE_UNLOAD_EVENT(inferior_pid) - || ((b->dll_pathname != NULL) - && (strcmp (b->dll_pathname, SOLIB_UNLOADED_LIBRARY_PATHNAME(inferior_pid)) != 0))) + && (!SOLIB_HAVE_UNLOAD_EVENT (inferior_pid) + || ((b->dll_pathname != NULL) + && (strcmp (b->dll_pathname, SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid)) != 0))) #endif - ) - continue; - - if ((b->type == bp_catch_fork) - && ! target_has_forked (inferior_pid, &b->forked_inferior_pid)) - continue; - - if ((b->type == bp_catch_vfork) - && ! target_has_vforked (inferior_pid, &b->forked_inferior_pid)) - continue; - - if ((b->type == bp_catch_exec) - && ! target_has_execd (inferior_pid, &b->exec_pathname)) - continue; + ) + continue; - if (ep_is_exception_catchpoint (b) && - !(current_exception_event = target_get_current_exception_event ())) - continue; + if ((b->type == bp_catch_fork) + && !target_has_forked (inferior_pid, &b->forked_inferior_pid)) + continue; - /* Come here if it's a watchpoint, or if the break address matches */ + if ((b->type == bp_catch_vfork) + && !target_has_vforked (inferior_pid, &b->forked_inferior_pid)) + continue; - bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */ + if ((b->type == bp_catch_exec) + && !target_has_execd (inferior_pid, &b->exec_pathname)) + continue; - /* Watchpoints may change this, if not found to have triggered. */ - bs->stop = 1; - bs->print = 1; + if (ep_is_exception_catchpoint (b) && + !(current_exception_event = target_get_current_exception_event ())) + continue; - sprintf (message, message1, b->number); - if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint) - { + /* Come here if it's a watchpoint, or if the break address matches */ + + bs = bpstat_alloc (b, bs); /* Alloc a bpstat to explain stop */ + + /* Watchpoints may change this, if not found to have triggered. */ + bs->stop = 1; + bs->print = 1; + + sprintf (message, message1, b->number); + if (b->type == bp_watchpoint || b->type == bp_hardware_watchpoint) + { + switch (catch_errors (watchpoint_check, bs, message, RETURN_MASK_ALL)) + { + case WP_DELETED: + /* We've already printed what needs to be printed. */ + bs->print_it = print_it_done; + /* Stop. */ + break; + case WP_VALUE_CHANGED: + /* Stop. */ + ++(b->hit_count); + break; + case WP_VALUE_NOT_CHANGED: + /* Don't stop. */ + bs->print_it = print_it_noop; + bs->stop = 0; + /* Don't consider this a hit. */ + --(b->hit_count); + continue; + default: + /* Can't happen. */ + /* FALLTHROUGH */ + case 0: + /* Error from catch_errors. */ + printf_filtered ("Watchpoint %d deleted.\n", b->number); + if (b->related_breakpoint) + b->related_breakpoint->disposition = del_at_next_stop; + b->disposition = del_at_next_stop; + /* We've already printed what needs to be printed. */ + bs->print_it = print_it_done; + + /* Stop. */ + break; + } + } + else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint) + { + CORE_ADDR addr; + value_ptr v; + int found = 0; + + addr = target_stopped_data_address (); + if (addr == 0) + continue; + for (v = b->val_chain; v; v = v->next) + { + if (v->lval == lval_memory) + { + CORE_ADDR vaddr; + + vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v); + if (addr == vaddr) + found = 1; + } + } + if (found) switch (catch_errors (watchpoint_check, bs, message, RETURN_MASK_ALL)) { case WP_DELETED: @@ -2172,19 +2235,12 @@ bpstat_stop_status (pc, not_a_breakpoint) /* Stop. */ break; case WP_VALUE_CHANGED: + case WP_VALUE_NOT_CHANGED: /* Stop. */ ++(b->hit_count); break; - case WP_VALUE_NOT_CHANGED: - /* Don't stop. */ - bs->print_it = print_it_noop; - bs->stop = 0; - /* Don't consider this a hit. */ - --(b->hit_count); - continue; default: /* Can't happen. */ - /* FALLTHROUGH */ case 0: /* Error from catch_errors. */ printf_filtered ("Watchpoint %d deleted.\n", b->number); @@ -2193,126 +2249,79 @@ bpstat_stop_status (pc, not_a_breakpoint) b->disposition = del_at_next_stop; /* We've already printed what needs to be printed. */ bs->print_it = print_it_done; - - /* Stop. */ break; } - } - else if (b->type == bp_read_watchpoint || b->type == bp_access_watchpoint) - { - CORE_ADDR addr; - value_ptr v; - int found = 0; - - addr = target_stopped_data_address(); - if (addr == 0) continue; - for (v = b->val_chain; v; v = v->next) - { - if (v->lval == lval_memory) - { - CORE_ADDR vaddr; - - vaddr = VALUE_ADDRESS (v) + VALUE_OFFSET (v); - if (addr == vaddr) - found = 1; - } - } - if (found) - switch (catch_errors (watchpoint_check, bs, message, RETURN_MASK_ALL)) - { - case WP_DELETED: - /* We've already printed what needs to be printed. */ - bs->print_it = print_it_done; - /* Stop. */ - break; - case WP_VALUE_CHANGED: - case WP_VALUE_NOT_CHANGED: - /* Stop. */ - ++(b->hit_count); - break; - default: - /* Can't happen. */ - case 0: - /* Error from catch_errors. */ - printf_filtered ("Watchpoint %d deleted.\n", b->number); - if (b->related_breakpoint) - b->related_breakpoint->disposition = del_at_next_stop; - b->disposition = del_at_next_stop; - /* We've already printed what needs to be printed. */ - bs->print_it = print_it_done; - break; - } - } - else - { - /* By definition, an encountered breakpoint is a triggered - breakpoint. */ - ++(b->hit_count); - - real_breakpoint = 1; - } - - if (b->frame && b->frame != (get_current_frame ())->frame && - (b->type == bp_step_resume && - (INNER_THAN (get_current_frame ()->frame, b->frame)))) - bs->stop = 0; - else - { - int value_is_zero = 0; + } + else + { + /* By definition, an encountered breakpoint is a triggered + breakpoint. */ + ++(b->hit_count); - if (b->cond) - { - /* Need to select the frame, with all that implies - so that the conditions will have the right context. */ - select_frame (get_current_frame (), 0); - value_is_zero - = catch_errors (breakpoint_cond_eval, (b->cond), - "Error in testing breakpoint condition:\n", - RETURN_MASK_ALL); - /* FIXME-someday, should give breakpoint # */ - free_all_values (); - } - if (b->cond && value_is_zero) - { - bs->stop = 0; - /* Don't consider this a hit. */ - --(b->hit_count); - } - else if (b->ignore_count > 0) - { - b->ignore_count--; - bs->stop = 0; - } - else - { - /* We will stop here */ - if (b->disposition == disable) - b->enable = disabled; - bs->commands = b->commands; - if (b->silent) + real_breakpoint = 1; + } + + if (b->frame && b->frame != (get_current_frame ())->frame && + (b->type == bp_step_resume && + (INNER_THAN (get_current_frame ()->frame, b->frame)))) + bs->stop = 0; + else + { + int value_is_zero = 0; + + if (b->cond) + { + /* Need to select the frame, with all that implies + so that the conditions will have the right context. */ + select_frame (get_current_frame (), 0); + value_is_zero + = catch_errors (breakpoint_cond_eval, (b->cond), + "Error in testing breakpoint condition:\n", + RETURN_MASK_ALL); + /* FIXME-someday, should give breakpoint # */ + free_all_values (); + } + if (b->cond && value_is_zero) + { + bs->stop = 0; + /* Don't consider this a hit. */ + --(b->hit_count); + } + else if (b->ignore_count > 0) + { + b->ignore_count--; + bs->stop = 0; + } + else + { + /* We will stop here */ + if (b->disposition == disable) + b->enable = disabled; + bs->commands = b->commands; + if (b->silent) + bs->print = 0; + if (bs->commands && + (STREQ ("silent", bs->commands->line) || + (xdb_commands && STREQ ("Q", bs->commands->line)))) + { + bs->commands = bs->commands->next; bs->print = 0; - if (bs->commands && - (STREQ ("silent", bs->commands->line) || - (xdb_commands && STREQ ("Q", bs->commands->line)))) - { - bs->commands = bs->commands->next; - bs->print = 0; - } - } - } - /* Print nothing for this entry if we dont stop or if we dont print. */ - if (bs->stop == 0 || bs->print == 0) - bs->print_it = print_it_noop; - } + } + } + } + /* Print nothing for this entry if we dont stop or if we dont print. */ + if (bs->stop == 0 || bs->print == 0) + bs->print_it = print_it_noop; + } bs->next = NULL; /* Terminate the chain */ bs = root_bs->next; /* Re-grab the head of the chain */ if (real_breakpoint && bs) { - if (bs->breakpoint_at->type == bp_hardware_breakpoint) + if (bs->breakpoint_at->type == bp_hardware_breakpoint) { - if (DECR_PC_AFTER_HW_BREAK != 0) + if (DECR_PC_AFTER_HW_BREAK != 0) { *pc = *pc - DECR_PC_AFTER_HW_BREAK; write_pc (*pc); @@ -2324,7 +2333,7 @@ bpstat_stop_status (pc, not_a_breakpoint) { *pc = bp_addr; #if defined (SHIFT_INST_REGS) - SHIFT_INST_REGS(); + SHIFT_INST_REGS (); #else /* No SHIFT_INST_REGS. */ write_pc (bp_addr); #endif /* No SHIFT_INST_REGS. */ @@ -2334,7 +2343,7 @@ bpstat_stop_status (pc, not_a_breakpoint) /* The value of a hardware watchpoint hasn't changed, but the intermediate memory locations we are watching may have. */ - if (bs && ! bs->stop && + if (bs && !bs->stop && (bs->breakpoint_at->type == bp_hardware_watchpoint || bs->breakpoint_at->type == bp_read_watchpoint || bs->breakpoint_at->type == bp_access_watchpoint)) @@ -2351,45 +2360,46 @@ bpstat_what (bs) bpstat bs; { /* Classify each bpstat as one of the following. */ - enum class { - /* This bpstat element has no effect on the main_action. */ - no_effect = 0, + enum class + { + /* This bpstat element has no effect on the main_action. */ + no_effect = 0, + + /* There was a watchpoint, stop but don't print. */ + wp_silent, - /* There was a watchpoint, stop but don't print. */ - wp_silent, + /* There was a watchpoint, stop and print. */ + wp_noisy, - /* There was a watchpoint, stop and print. */ - wp_noisy, + /* There was a breakpoint but we're not stopping. */ + bp_nostop, - /* There was a breakpoint but we're not stopping. */ - bp_nostop, + /* There was a breakpoint, stop but don't print. */ + bp_silent, - /* There was a breakpoint, stop but don't print. */ - bp_silent, + /* There was a breakpoint, stop and print. */ + bp_noisy, - /* There was a breakpoint, stop and print. */ - bp_noisy, + /* We hit the longjmp breakpoint. */ + long_jump, - /* We hit the longjmp breakpoint. */ - long_jump, + /* We hit the longjmp_resume breakpoint. */ + long_resume, - /* We hit the longjmp_resume breakpoint. */ - long_resume, + /* We hit the step_resume breakpoint. */ + step_resume, - /* We hit the step_resume breakpoint. */ - step_resume, + /* We hit the through_sigtramp breakpoint. */ + through_sig, - /* We hit the through_sigtramp breakpoint. */ - through_sig, + /* We hit the shared library event breakpoint. */ + shlib_event, - /* We hit the shared library event breakpoint. */ - shlib_event, + /* We caught a shared library event. */ + catch_shlib_event, - /* We caught a shared library event. */ - catch_shlib_event, - - /* This is just used to count how many enums there are. */ - class_last + /* This is just used to count how many enums there are. */ + class_last }; /* Here is the table which drives this routine. So that we can @@ -2426,18 +2436,18 @@ bpstat_what (bs) back and decide something of a lower priority is better. The ordering is: - kc < clr sgl shl slr sn sr ss ts - sgl < clrs shl shlr slr sn sr ss ts - slr < err shl shlr sn sr ss ts - clr < clrs err shl shlr sn sr ss ts - clrs < err shl shlr sn sr ss ts - ss < shl shlr sn sr ts - sn < shl shlr sr ts - sr < shl shlr ts - shl < shlr - ts < - shlr < - + kc < clr sgl shl slr sn sr ss ts + sgl < clrs shl shlr slr sn sr ss ts + slr < err shl shlr sn sr ss ts + clr < clrs err shl shlr sn sr ss ts + clrs < err shl shlr sn sr ss ts + ss < shl shlr sn sr ts + sn < shl shlr sr ts + sr < shl shlr ts + shl < shlr + ts < + shlr < + What I think this means is that we don't need a damned table here. If you just put the rows and columns in the right order, it'd look awfully regular. We could simply walk the bpstat list @@ -2453,24 +2463,36 @@ bpstat_what (bs) one of those and a step_resume_breakpoint is probably very rare (?). */ static const enum bpstat_what_main_action - table[(int)class_last][(int)BPSTAT_WHAT_LAST] = - { - /* old action */ - /* kc ss sn sgl slr clr clrs sr ts shl shlr - */ -/*no_effect*/ {kc, ss, sn, sgl, slr, clr, clrs, sr, ts, shl, shlr}, -/*wp_silent*/ {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr}, -/*wp_noisy*/ {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr}, -/*bp_nostop*/ {sgl, ss, sn, sgl, slr, clrs, clrs, sr, ts, shl, shlr}, -/*bp_silent*/ {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr}, -/*bp_noisy*/ {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr}, -/*long_jump*/ {slr, ss, sn, slr, err, err, err, sr, ts, shl, shlr}, -/*long_resume*/ {clr, ss, sn, clrs, err, err, err, sr, ts, shl, shlr}, -/*step_resume*/ {sr, sr, sr, sr, sr, sr, sr, sr, ts, shl, shlr}, -/*through_sig*/ {ts, ts, ts, ts, ts, ts, ts, ts, ts, shl, shlr}, -/*shlib*/ {shl, shl, shl, shl, shl, shl, shl, shl, ts, shl, shlr}, -/*catch_shlib*/ {shlr, shlr, shlr, shlr, shlr, shlr, shlr, shlr, ts, shlr, shlr} - }; + table[(int) class_last][(int) BPSTAT_WHAT_LAST] = + { + /* old action */ + /* kc ss sn sgl slr clr clrs sr ts shl shlr + */ +/*no_effect */ + {kc, ss, sn, sgl, slr, clr, clrs, sr, ts, shl, shlr}, +/*wp_silent */ + {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr}, +/*wp_noisy */ + {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr}, +/*bp_nostop */ + {sgl, ss, sn, sgl, slr, clrs, clrs, sr, ts, shl, shlr}, +/*bp_silent */ + {ss, ss, sn, ss, ss, ss, ss, sr, ts, shl, shlr}, +/*bp_noisy */ + {sn, sn, sn, sn, sn, sn, sn, sr, ts, shl, shlr}, +/*long_jump */ + {slr, ss, sn, slr, err, err, err, sr, ts, shl, shlr}, +/*long_resume */ + {clr, ss, sn, clrs, err, err, err, sr, ts, shl, shlr}, +/*step_resume */ + {sr, sr, sr, sr, sr, sr, sr, sr, ts, shl, shlr}, +/*through_sig */ + {ts, ts, ts, ts, ts, ts, ts, ts, ts, shl, shlr}, +/*shlib */ + {shl, shl, shl, shl, shl, shl, shl, shl, ts, shl, shlr}, +/*catch_shlib */ + {shlr, shlr, shlr, shlr, shlr, shlr, shlr, shlr, ts, shlr, shlr} + }; #undef kc #undef ss @@ -2551,46 +2573,46 @@ bpstat_what (bs) case bp_watchpoint_scope: bs_class = bp_nostop; break; - case bp_shlib_event: - bs_class = shlib_event; + case bp_shlib_event: + bs_class = shlib_event; + break; + case bp_catch_load: + case bp_catch_unload: + /* Only if this catchpoint triggered should we cause the + step-out-of-dld behaviour. Otherwise, we ignore this + catchpoint. */ + if (bs->stop) + bs_class = catch_shlib_event; + else + bs_class = no_effect; + break; + case bp_catch_fork: + case bp_catch_vfork: + case bp_catch_exec: + if (bs->stop) + { + if (bs->print) + bs_class = bp_noisy; + else + bs_class = bp_silent; + } + else + /* There was a catchpoint, but we're not stopping. This requires + no further action. */ + bs_class = no_effect; + break; + case bp_catch_catch: + if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_CATCH) + bs_class = bp_nostop; + else if (bs->stop) + bs_class = bs->print ? bp_noisy : bp_silent; + break; + case bp_catch_throw: + if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_THROW) + bs_class = bp_nostop; + else if (bs->stop) + bs_class = bs->print ? bp_noisy : bp_silent; break; - case bp_catch_load: - case bp_catch_unload: - /* Only if this catchpoint triggered should we cause the - step-out-of-dld behaviour. Otherwise, we ignore this - catchpoint. */ - if (bs->stop) - bs_class = catch_shlib_event; - else - bs_class = no_effect; - break; - case bp_catch_fork: - case bp_catch_vfork: - case bp_catch_exec: - if (bs->stop) - { - if (bs->print) - bs_class = bp_noisy; - else - bs_class = bp_silent; - } - else - /* There was a catchpoint, but we're not stopping. This requires - no further action. */ - bs_class = no_effect; - break; - case bp_catch_catch: - if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_CATCH) - bs_class = bp_nostop; - else if (bs->stop) - bs_class = bs->print ? bp_noisy : bp_silent; - break; - case bp_catch_throw: - if (!bs->stop || CURRENT_EXCEPTION_KIND != EX_EVENT_THROW) - bs_class = bp_nostop; - else if (bs->stop) - bs_class = bs->print ? bp_noisy : bp_silent; - break; case bp_call_dummy: /* Make sure the action is stop (silent or noisy), so infrun.c pops the dummy frame. */ @@ -2598,7 +2620,7 @@ bpstat_what (bs) retval.call_dummy = 1; break; } - current_action = table[(int)bs_class][(int)current_action]; + current_action = table[(int) bs_class][(int) current_action]; } retval.main_action = current_action; return retval; @@ -2608,13 +2630,13 @@ bpstat_what (bs) without hardware support). This isn't related to a specific bpstat, just to things like whether watchpoints are set. */ -int +int bpstat_should_step () { struct breakpoint *b; ALL_BREAKPOINTS (b) if (b->enable == enabled && b->type == bp_watchpoint) - return 1; + return 1; return 0; } @@ -2625,49 +2647,49 @@ bpstat_have_active_hw_watchpoints () struct breakpoint *b; ALL_BREAKPOINTS (b) if ((b->enable == enabled) && - (b->inserted) && - ((b->type == bp_hardware_watchpoint) || - (b->type == bp_read_watchpoint) || - (b->type == bp_access_watchpoint))) - return 1; + (b->inserted) && + ((b->type == bp_hardware_watchpoint) || + (b->type == bp_read_watchpoint) || + (b->type == bp_access_watchpoint))) + return 1; return 0; } - + /* Given a bpstat that records zero or more triggered eventpoints, this function returns another bpstat which contains only the catchpoints on that first list, if any. */ void bpstat_get_triggered_catchpoints (ep_list, cp_list) - bpstat ep_list; - bpstat * cp_list; -{ - struct bpstats root_bs[1]; - bpstat bs = root_bs; - struct breakpoint * ep; - char * dll_pathname; - + bpstat ep_list; + bpstat *cp_list; +{ + struct bpstats root_bs[1]; + bpstat bs = root_bs; + struct breakpoint *ep; + char *dll_pathname; + bpstat_clear (cp_list); root_bs->next = NULL; - - for (; ep_list != NULL; ep_list = ep_list->next ) + + for (; ep_list != NULL; ep_list = ep_list->next) { /* Is this eventpoint a catchpoint? If not, ignore it. */ ep = ep_list->breakpoint_at; if (ep == NULL) - break; - if ((ep->type != bp_catch_load) && - (ep->type != bp_catch_unload) && - (ep->type != bp_catch_catch) && - (ep->type != bp_catch_throw)) /* pai: (temp) ADD fork/vfork here!! */ - continue; - + break; + if ((ep->type != bp_catch_load) && + (ep->type != bp_catch_unload) && + (ep->type != bp_catch_catch) && + (ep->type != bp_catch_throw)) /* pai: (temp) ADD fork/vfork here!! */ + continue; + /* Yes; add it to the list. */ bs = bpstat_alloc (ep, bs); *bs = *ep_list; bs->next = NULL; bs = root_bs->next; - + #if defined(SOLIB_ADD) /* Also, for each triggered catchpoint, tag it with the name of the library that caused this trigger. (We copy the name now, @@ -2675,11 +2697,11 @@ bpstat_get_triggered_catchpoints (ep_list, cp_list) catchpoint triggers. Clients who may wish to know the name later must get it from the catchpoint itself.) */ if (ep->triggered_dll_pathname != NULL) - free (ep->triggered_dll_pathname); + free (ep->triggered_dll_pathname); if (ep->type == bp_catch_load) - dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid); + dll_pathname = SOLIB_LOADED_LIBRARY_PATHNAME (inferior_pid); else - dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid); + dll_pathname = SOLIB_UNLOADED_LIBRARY_PATHNAME (inferior_pid); #else dll_pathname = NULL; #endif @@ -2691,7 +2713,7 @@ bpstat_get_triggered_catchpoints (ep_list, cp_list) else ep->triggered_dll_pathname = NULL; } - + *cp_list = bs; } @@ -2699,10 +2721,12 @@ bpstat_get_triggered_catchpoints (ep_list, cp_list) If WATCHPOINTS is zero, process only breakpoints; if WATCHPOINTS is nonzero, process only watchpoints. */ -typedef struct { - enum bptype type; - char * description; -} ep_type_description_t; +typedef struct +{ + enum bptype type; + char *description; +} +ep_type_description_t; static void breakpoint_1 (bnum, allflag) @@ -2712,36 +2736,37 @@ breakpoint_1 (bnum, allflag) register struct breakpoint *b; register struct command_line *l; register struct symbol *sym; - CORE_ADDR last_addr = (CORE_ADDR)-1; + CORE_ADDR last_addr = (CORE_ADDR) - 1; int found_a_breakpoint = 0; - static ep_type_description_t bptypes[] = + static ep_type_description_t bptypes[] = { - {bp_none, "?deleted?"}, - {bp_breakpoint, "breakpoint"}, + {bp_none, "?deleted?"}, + {bp_breakpoint, "breakpoint"}, {bp_hardware_breakpoint, "hw breakpoint"}, - {bp_until, "until"}, - {bp_finish, "finish"}, - {bp_watchpoint, "watchpoint"}, + {bp_until, "until"}, + {bp_finish, "finish"}, + {bp_watchpoint, "watchpoint"}, {bp_hardware_watchpoint, "hw watchpoint"}, - {bp_read_watchpoint, "read watchpoint"}, - {bp_access_watchpoint, "acc watchpoint"}, - {bp_longjmp, "longjmp"}, - {bp_longjmp_resume, "longjmp resume"}, - {bp_step_resume, "step resume"}, - {bp_through_sigtramp, "sigtramp"}, - {bp_watchpoint_scope, "watchpoint scope"}, - {bp_call_dummy, "call dummy"}, - {bp_shlib_event, "shlib events"}, - {bp_catch_load, "catch load"}, - {bp_catch_unload, "catch unload"}, - {bp_catch_fork, "catch fork"}, - {bp_catch_vfork, "catch vfork"}, - {bp_catch_exec, "catch exec"}, - {bp_catch_catch, "catch catch"}, - {bp_catch_throw, "catch throw"} - }; - - static char *bpdisps[] = {"del", "dstp", "dis", "keep"}; + {bp_read_watchpoint, "read watchpoint"}, + {bp_access_watchpoint, "acc watchpoint"}, + {bp_longjmp, "longjmp"}, + {bp_longjmp_resume, "longjmp resume"}, + {bp_step_resume, "step resume"}, + {bp_through_sigtramp, "sigtramp"}, + {bp_watchpoint_scope, "watchpoint scope"}, + {bp_call_dummy, "call dummy"}, + {bp_shlib_event, "shlib events"}, + {bp_catch_load, "catch load"}, + {bp_catch_unload, "catch unload"}, + {bp_catch_fork, "catch fork"}, + {bp_catch_vfork, "catch vfork"}, + {bp_catch_exec, "catch exec"}, + {bp_catch_catch, "catch catch"}, + {bp_catch_throw, "catch throw"} + }; + + static char *bpdisps[] = + {"del", "dstp", "dis", "keep"}; static char bpenables[] = "nyn"; char wrap_indent[80]; @@ -2749,236 +2774,236 @@ breakpoint_1 (bnum, allflag) ALL_BREAKPOINTS (b) if (bnum == -1 || bnum == b->number) - { + { /* We only print out user settable breakpoints unless the allflag is set. */ - if (!allflag - && b->type != bp_breakpoint - && b->type != bp_catch_load - && b->type != bp_catch_unload - && b->type != bp_catch_fork - && b->type != bp_catch_vfork - && b->type != bp_catch_exec - && b->type != bp_catch_catch - && b->type != bp_catch_throw - && b->type != bp_hardware_breakpoint - && b->type != bp_watchpoint - && b->type != bp_read_watchpoint - && b->type != bp_access_watchpoint - && b->type != bp_hardware_watchpoint) - continue; + if (!allflag + && b->type != bp_breakpoint + && b->type != bp_catch_load + && b->type != bp_catch_unload + && b->type != bp_catch_fork + && b->type != bp_catch_vfork + && b->type != bp_catch_exec + && b->type != bp_catch_catch + && b->type != bp_catch_throw + && b->type != bp_hardware_breakpoint + && b->type != bp_watchpoint + && b->type != bp_read_watchpoint + && b->type != bp_access_watchpoint + && b->type != bp_hardware_watchpoint) + continue; - if (!found_a_breakpoint++) - { - annotate_breakpoints_headers (); - - annotate_field (0); - printf_filtered ("Num "); - annotate_field (1); - printf_filtered ("Type "); - annotate_field (2); - printf_filtered ("Disp "); - annotate_field (3); - printf_filtered ("Enb "); - if (addressprint) - { - annotate_field (4); - printf_filtered ("Address "); - } - annotate_field (5); - printf_filtered ("What\n"); - - annotate_breakpoints_table (); - } - - annotate_record (); - annotate_field (0); - printf_filtered ("%-3d ", b->number); - annotate_field (1); - if ((int)b->type > (sizeof(bptypes)/sizeof(bptypes[0]))) - error ("bptypes table does not describe type #%d.", (int)b->type); - if ((int)b->type != bptypes[(int)b->type].type) - error ("bptypes table does not describe type #%d?", (int)b->type); - printf_filtered ("%-14s ", bptypes[(int)b->type].description); - annotate_field (2); - printf_filtered ("%-4s ", bpdisps[(int)b->disposition]); - annotate_field (3); - printf_filtered ("%-3c ", bpenables[(int)b->enable]); - - strcpy (wrap_indent, " "); - if (addressprint) - strcat (wrap_indent, " "); - switch (b->type) - { - case bp_watchpoint: - case bp_hardware_watchpoint: - case bp_read_watchpoint: - case bp_access_watchpoint: - /* Field 4, the address, is omitted (which makes the columns - not line up too nicely with the headers, but the effect - is relatively readable). */ - annotate_field (5); - print_expression (b->exp, gdb_stdout); - break; - - case bp_catch_load: - case bp_catch_unload: - /* Field 4, the address, is omitted (which makes the columns - not line up too nicely with the headers, but the effect - is relatively readable). */ - annotate_field (5); - if (b->dll_pathname == NULL) - printf_filtered (" "); - else - printf_filtered ("library \"%s\" ", b->dll_pathname); - break; - - case bp_catch_fork: - case bp_catch_vfork: - /* Field 4, the address, is omitted (which makes the columns - not line up too nicely with the headers, but the effect - is relatively readable). */ - annotate_field (5); - if (b->forked_inferior_pid != 0) - printf_filtered ("process %d ", b->forked_inferior_pid); - break; - - case bp_catch_exec: - /* Field 4, the address, is omitted (which makes the columns - not line up too nicely with the headers, but the effect - is relatively readable). */ - annotate_field (5); - if (b->exec_pathname != NULL) - printf_filtered ("program \"%s\" ", b->exec_pathname); - break; - case bp_catch_catch: - /* Field 4, the address, is omitted (which makes the columns - not line up too nicely with the headers, but the effect - is relatively readable). */ - annotate_field (5); - printf_filtered ("exception catch "); - break; - case bp_catch_throw: - /* Field 4, the address, is omitted (which makes the columns - not line up too nicely with the headers, but the effect - is relatively readable). */ - annotate_field (5); - printf_filtered ("exception throw "); - break; - - case bp_breakpoint: - case bp_hardware_breakpoint: - case bp_until: - case bp_finish: - case bp_longjmp: - case bp_longjmp_resume: - case bp_step_resume: - case bp_through_sigtramp: - case bp_watchpoint_scope: - case bp_call_dummy: - case bp_shlib_event: - if (addressprint) - { - annotate_field (4); - /* FIXME-32x64: need a print_address_numeric with - field width */ - printf_filtered - ("%s ", - local_hex_string_custom - ((unsigned long) b->address, "08l")); - } + if (!found_a_breakpoint++) + { + annotate_breakpoints_headers (); + + annotate_field (0); + printf_filtered ("Num "); + annotate_field (1); + printf_filtered ("Type "); + annotate_field (2); + printf_filtered ("Disp "); + annotate_field (3); + printf_filtered ("Enb "); + if (addressprint) + { + annotate_field (4); + printf_filtered ("Address "); + } + annotate_field (5); + printf_filtered ("What\n"); - annotate_field (5); + annotate_breakpoints_table (); + } - last_addr = b->address; - if (b->source_file) - { - sym = find_pc_sect_function (b->address, b->section); - if (sym) - { - fputs_filtered ("in ", gdb_stdout); - fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout); - wrap_here (wrap_indent); - fputs_filtered (" at ", gdb_stdout); - } - fputs_filtered (b->source_file, gdb_stdout); - printf_filtered (":%d", b->line_number); - } - else - print_address_symbolic (b->address, gdb_stdout, demangle, " "); - break; - } + annotate_record (); + annotate_field (0); + printf_filtered ("%-3d ", b->number); + annotate_field (1); + if ((int) b->type > (sizeof (bptypes) / sizeof (bptypes[0]))) + error ("bptypes table does not describe type #%d.", (int) b->type); + if ((int) b->type != bptypes[(int) b->type].type) + error ("bptypes table does not describe type #%d?", (int) b->type); + printf_filtered ("%-14s ", bptypes[(int) b->type].description); + annotate_field (2); + printf_filtered ("%-4s ", bpdisps[(int) b->disposition]); + annotate_field (3); + printf_filtered ("%-3c ", bpenables[(int) b->enable]); + + strcpy (wrap_indent, " "); + if (addressprint) + strcat (wrap_indent, " "); + switch (b->type) + { + case bp_watchpoint: + case bp_hardware_watchpoint: + case bp_read_watchpoint: + case bp_access_watchpoint: + /* Field 4, the address, is omitted (which makes the columns + not line up too nicely with the headers, but the effect + is relatively readable). */ + annotate_field (5); + print_expression (b->exp, gdb_stdout); + break; - if (b->thread != -1) - printf_filtered (" thread %d", b->thread ); + case bp_catch_load: + case bp_catch_unload: + /* Field 4, the address, is omitted (which makes the columns + not line up too nicely with the headers, but the effect + is relatively readable). */ + annotate_field (5); + if (b->dll_pathname == NULL) + printf_filtered (" "); + else + printf_filtered ("library \"%s\" ", b->dll_pathname); + break; - printf_filtered ("\n"); + case bp_catch_fork: + case bp_catch_vfork: + /* Field 4, the address, is omitted (which makes the columns + not line up too nicely with the headers, but the effect + is relatively readable). */ + annotate_field (5); + if (b->forked_inferior_pid != 0) + printf_filtered ("process %d ", b->forked_inferior_pid); + break; - if (b->frame) - { - annotate_field (6); + case bp_catch_exec: + /* Field 4, the address, is omitted (which makes the columns + not line up too nicely with the headers, but the effect + is relatively readable). */ + annotate_field (5); + if (b->exec_pathname != NULL) + printf_filtered ("program \"%s\" ", b->exec_pathname); + break; + case bp_catch_catch: + /* Field 4, the address, is omitted (which makes the columns + not line up too nicely with the headers, but the effect + is relatively readable). */ + annotate_field (5); + printf_filtered ("exception catch "); + break; + case bp_catch_throw: + /* Field 4, the address, is omitted (which makes the columns + not line up too nicely with the headers, but the effect + is relatively readable). */ + annotate_field (5); + printf_filtered ("exception throw "); + break; - printf_filtered ("\tstop only in stack frame at "); - print_address_numeric (b->frame, 1, gdb_stdout); - printf_filtered ("\n"); - } + case bp_breakpoint: + case bp_hardware_breakpoint: + case bp_until: + case bp_finish: + case bp_longjmp: + case bp_longjmp_resume: + case bp_step_resume: + case bp_through_sigtramp: + case bp_watchpoint_scope: + case bp_call_dummy: + case bp_shlib_event: + if (addressprint) + { + annotate_field (4); + /* FIXME-32x64: need a print_address_numeric with + field width */ + printf_filtered + ("%s ", + local_hex_string_custom + ((unsigned long) b->address, "08l")); + } - if (b->cond) - { - annotate_field (7); + annotate_field (5); - printf_filtered ("\tstop only if "); - print_expression (b->cond, gdb_stdout); - printf_filtered ("\n"); - } + last_addr = b->address; + if (b->source_file) + { + sym = find_pc_sect_function (b->address, b->section); + if (sym) + { + fputs_filtered ("in ", gdb_stdout); + fputs_filtered (SYMBOL_SOURCE_NAME (sym), gdb_stdout); + wrap_here (wrap_indent); + fputs_filtered (" at ", gdb_stdout); + } + fputs_filtered (b->source_file, gdb_stdout); + printf_filtered (":%d", b->line_number); + } + else + print_address_symbolic (b->address, gdb_stdout, demangle, " "); + break; + } - if (b->thread != -1) - { - /* FIXME should make an annotation for this */ - printf_filtered ("\tstop only in thread %d\n", b->thread); - } + if (b->thread != -1) + printf_filtered (" thread %d", b->thread); - if (show_breakpoint_hit_counts && b->hit_count) - { - /* FIXME should make an annotation for this */ - if (ep_is_catchpoint (b)) - printf_filtered ("\tcatchpoint"); - else - printf_filtered ("\tbreakpoint"); - printf_filtered (" already hit %d time%s\n", - b->hit_count, (b->hit_count == 1 ? "" : "s")); - } + printf_filtered ("\n"); - if (b->ignore_count) - { - annotate_field (8); + if (b->frame) + { + annotate_field (6); - printf_filtered ("\tignore next %d hits\n", b->ignore_count); - } + printf_filtered ("\tstop only in stack frame at "); + print_address_numeric (b->frame, 1, gdb_stdout); + printf_filtered ("\n"); + } - if ((l = b->commands)) - { - annotate_field (9); + if (b->cond) + { + annotate_field (7); - while (l) - { - print_command_line (l, 4, gdb_stdout); - l = l->next; - } - } - } + printf_filtered ("\tstop only if "); + print_expression (b->cond, gdb_stdout); + printf_filtered ("\n"); + } + + if (b->thread != -1) + { + /* FIXME should make an annotation for this */ + printf_filtered ("\tstop only in thread %d\n", b->thread); + } + + if (show_breakpoint_hit_counts && b->hit_count) + { + /* FIXME should make an annotation for this */ + if (ep_is_catchpoint (b)) + printf_filtered ("\tcatchpoint"); + else + printf_filtered ("\tbreakpoint"); + printf_filtered (" already hit %d time%s\n", + b->hit_count, (b->hit_count == 1 ? "" : "s")); + } + + if (b->ignore_count) + { + annotate_field (8); + + printf_filtered ("\tignore next %d hits\n", b->ignore_count); + } + + if ((l = b->commands)) + { + annotate_field (9); + + while (l) + { + print_command_line (l, 4, gdb_stdout); + l = l->next; + } + } + } if (!found_a_breakpoint) { if (bnum == -1) - printf_filtered ("No breakpoints or watchpoints.\n"); + printf_filtered ("No breakpoints or watchpoints.\n"); else - printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum); + printf_filtered ("No breakpoint or watchpoint number %d.\n", bnum); } else /* Compare against (CORE_ADDR)-1 in case some compiler decides that a comparison of an unsigned with -1 is always false. */ - if (last_addr != (CORE_ADDR)-1) - set_next_address (last_addr); + if (last_addr != (CORE_ADDR) - 1) + set_next_address (last_addr); annotate_breakpoints_table_end (); } @@ -3023,25 +3048,25 @@ describe_other_breakpoints (pc, section) ALL_BREAKPOINTS (b) if (b->address == pc) - if (overlay_debugging == 0 || - b->section == section) - others++; + if (overlay_debugging == 0 || + b->section == section) + others++; if (others > 0) { printf_filtered ("Note: breakpoint%s ", (others > 1) ? "s" : ""); ALL_BREAKPOINTS (b) if (b->address == pc) - if (overlay_debugging == 0 || - b->section == section) - { - others--; - printf_filtered - ("%d%s%s ", - b->number, - ((b->enable == disabled || b->enable == shlib_disabled || b->enable == call_disabled) - ? " (disabled)" : ""), - (others > 1) ? "," : ((others == 1) ? " and" : "")); - } + if (overlay_debugging == 0 || + b->section == section) + { + others--; + printf_filtered + ("%d%s%s ", + b->number, + ((b->enable == disabled || b->enable == shlib_disabled || b->enable == call_disabled) + ? " (disabled)" : ""), + (others > 1) ? "," : ((others == 1) ? " and" : "")); + } printf_filtered ("also set at pc "); print_address_numeric (pc, 1, gdb_stdout); printf_filtered (".\n"); @@ -3085,10 +3110,10 @@ check_duplicates (address, section) && b->enable != call_disabled && b->address == address && (overlay_debugging == 0 || b->section == section)) - { - count++; - b->duplicate = count > 1; - } + { + count++; + b->duplicate = count > 1; + } } /* Low level routine to set a breakpoint. @@ -3160,12 +3185,12 @@ create_longjmp_breakpoint (func_name) struct symtab_and_line sal; struct breakpoint *b; - INIT_SAL (&sal); /* initialize to zeroes */ + INIT_SAL (&sal); /* initialize to zeroes */ if (func_name != NULL) { struct minimal_symbol *m; - m = lookup_minimal_symbol_text (func_name, NULL, (struct objfile *)NULL); + m = lookup_minimal_symbol_text (func_name, NULL, (struct objfile *) NULL); if (m) sal.pc = SYMBOL_VALUE_ADDRESS (m); else @@ -3173,48 +3198,49 @@ create_longjmp_breakpoint (func_name) } sal.section = find_pc_overlay (sal.pc); b = set_raw_breakpoint (sal); - if (!b) return; + if (!b) + return; b->type = func_name != NULL ? bp_longjmp : bp_longjmp_resume; b->disposition = donttouch; b->enable = disabled; b->silent = 1; if (func_name) - b->addr_string = strsave(func_name); + b->addr_string = strsave (func_name); b->number = internal_breakpoint_number--; } -#endif /* #ifdef GET_LONGJMP_TARGET */ +#endif /* #ifdef GET_LONGJMP_TARGET */ /* Call this routine when stepping and nexting to enable a breakpoint if we do a longjmp(). When we hit that breakpoint, call set_longjmp_resume_breakpoint() to figure out where we are going. */ void -enable_longjmp_breakpoint() +enable_longjmp_breakpoint () { register struct breakpoint *b; ALL_BREAKPOINTS (b) if (b->type == bp_longjmp) - { - b->enable = enabled; - check_duplicates (b->address, b->section); - } + { + b->enable = enabled; + check_duplicates (b->address, b->section); + } } void -disable_longjmp_breakpoint() +disable_longjmp_breakpoint () { register struct breakpoint *b; ALL_BREAKPOINTS (b) - if ( b->type == bp_longjmp + if (b->type == bp_longjmp || b->type == bp_longjmp_resume) - { - b->enable = disabled; - check_duplicates (b->address, b->section); - } + { + b->enable = disabled; + check_duplicates (b->address, b->section); + } } #ifdef SOLIB_ADD @@ -3225,7 +3251,7 @@ remove_solib_event_breakpoints () ALL_BREAKPOINTS_SAFE (b, temp) if (b->type == bp_shlib_event) - delete_breakpoint (b); + delete_breakpoint (b); } void @@ -3235,7 +3261,7 @@ create_solib_event_breakpoint (address) struct breakpoint *b; struct symtab_and_line sal; - INIT_SAL (&sal); /* initialize to zeroes */ + INIT_SAL (&sal); /* initialize to zeroes */ sal.pc = address; sal.section = find_pc_overlay (sal.pc); b = set_raw_breakpoint (sal); @@ -3248,34 +3274,34 @@ void disable_breakpoints_in_shlibs (silent) int silent; { - struct breakpoint * b; - int disabled_shlib_breaks = 0; + struct breakpoint *b; + int disabled_shlib_breaks = 0; /* See also: insert_breakpoints, under DISABLE_UNSETTABLE_BREAK. */ ALL_BREAKPOINTS (b) - { + { #if defined (PC_SOLIB) - if (((b->type == bp_breakpoint) || - (b->type == bp_hardware_breakpoint)) && - (b->enable != shlib_disabled) && - (b->enable != call_disabled) && - ! b->duplicate && - PC_SOLIB (b->address)) - { - b->enable = shlib_disabled; - if (!silent) - { - if (!disabled_shlib_breaks) - { - target_terminal_ours_for_output (); - printf_filtered ("Temporarily disabling shared library breakpoints:\n"); - } - disabled_shlib_breaks = 1; - printf_filtered ("%d ", b->number); - } - } + if (((b->type == bp_breakpoint) || + (b->type == bp_hardware_breakpoint)) && + (b->enable != shlib_disabled) && + (b->enable != call_disabled) && + !b->duplicate && + PC_SOLIB (b->address)) + { + b->enable = shlib_disabled; + if (!silent) + { + if (!disabled_shlib_breaks) + { + target_terminal_ours_for_output (); + printf_filtered ("Temporarily disabling shared library breakpoints:\n"); + } + disabled_shlib_breaks = 1; + printf_filtered ("%d ", b->number); + } + } #endif - } + } if (disabled_shlib_breaks && !silent) printf_filtered ("\n"); } @@ -3288,14 +3314,14 @@ re_enable_breakpoints_in_shlibs () ALL_BREAKPOINTS (b) if (b->enable == shlib_disabled) - { - char buf[1]; + { + char buf[1]; - /* Do not reenable the breakpoint if the shared library - is still not mapped in. */ - if (target_read_memory (b->address, buf, 1) == 0) - b->enable = enabled; - } + /* Do not reenable the breakpoint if the shared library + is still not mapped in. */ + if (target_read_memory (b->address, buf, 1) == 0) + b->enable = enabled; + } } #endif @@ -3308,21 +3334,21 @@ create_solib_load_unload_event_breakpoint (hookname, tempflag, dll_pathname, con char *cond_string; enum bptype bp_kind; { - struct breakpoint * b; + struct breakpoint *b; struct symtabs_and_lines sals; - struct symtab_and_line sal; - struct cleanup * old_chain; - struct cleanup * canonical_strings_chain = NULL; - int i; - char * addr_start = hookname; - char * addr_end = NULL; - char ** canonical = (char **) NULL; - int thread = -1; /* All threads. */ - + struct symtab_and_line sal; + struct cleanup *old_chain; + struct cleanup *canonical_strings_chain = NULL; + int i; + char *addr_start = hookname; + char *addr_end = NULL; + char **canonical = (char **) NULL; + int thread = -1; /* All threads. */ + /* Set a breakpoint on the specified hook. */ sals = decode_line_1 (&hookname, 1, (struct symtab *) NULL, 0, &canonical); addr_end = hookname; - + if (sals.nelts == 0) { warning ("Unable to set a breakpoint on dynamic linker callback."); @@ -3340,35 +3366,35 @@ create_solib_load_unload_event_breakpoint (hookname, tempflag, dll_pathname, con /* Make sure that all storage allocated in decode_line_1 gets freed in case the following errors out. */ old_chain = make_cleanup (free, sals.sals); - if (canonical != (char **)NULL) + if (canonical != (char **) NULL) { make_cleanup (free, canonical); canonical_strings_chain = make_cleanup (null_cleanup, 0); if (canonical[0] != NULL) - make_cleanup (free, canonical[0]); + make_cleanup (free, canonical[0]); } - + resolve_sal_pc (&sals.sals[0]); - + /* Remove the canonical strings from the cleanup, they are needed below. */ - if (canonical != (char **)NULL) + if (canonical != (char **) NULL) discard_cleanups (canonical_strings_chain); - + b = set_raw_breakpoint (sals.sals[0]); set_breakpoint_count (breakpoint_count + 1); b->number = breakpoint_count; b->cond = NULL; b->cond_string = (cond_string == NULL) ? NULL : savestring (cond_string, strlen (cond_string)); b->thread = thread; - - if (canonical != (char **)NULL && canonical[0] != NULL) + + if (canonical != (char **) NULL && canonical[0] != NULL) b->addr_string = canonical[0]; else if (addr_start) b->addr_string = savestring (addr_start, addr_end - addr_start); - + b->enable = enabled; b->disposition = tempflag ? del : donttouch; - + if (dll_pathname == NULL) b->dll_pathname = NULL; else @@ -3377,37 +3403,37 @@ create_solib_load_unload_event_breakpoint (hookname, tempflag, dll_pathname, con strcpy (b->dll_pathname, dll_pathname); } b->type = bp_kind; - + mention (b); do_cleanups (old_chain); } void create_solib_load_event_breakpoint (hookname, tempflag, dll_pathname, cond_string) - char * hookname; - int tempflag; - char * dll_pathname; - char * cond_string; + char *hookname; + int tempflag; + char *dll_pathname; + char *cond_string; { create_solib_load_unload_event_breakpoint (hookname, - tempflag, - dll_pathname, - cond_string, - bp_catch_load); + tempflag, + dll_pathname, + cond_string, + bp_catch_load); } void create_solib_unload_event_breakpoint (hookname, tempflag, dll_pathname, cond_string) - char * hookname; - int tempflag; - char * dll_pathname; - char * cond_string; + char *hookname; + int tempflag; + char *dll_pathname; + char *cond_string; { create_solib_load_unload_event_breakpoint (hookname, - tempflag, - dll_pathname, - cond_string, - bp_catch_unload); + tempflag, + dll_pathname, + cond_string, + bp_catch_unload); } static void @@ -3416,15 +3442,15 @@ create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_kind) char *cond_string; enum bptype bp_kind; { - struct symtab_and_line sal; - struct breakpoint * b; - int thread = -1; /* All threads. */ - - INIT_SAL(&sal); + struct symtab_and_line sal; + struct breakpoint *b; + int thread = -1; /* All threads. */ + + INIT_SAL (&sal); sal.pc = 0; sal.symtab = NULL; sal.line = 0; - + b = set_raw_breakpoint (sal); set_breakpoint_count (breakpoint_count + 1); b->number = breakpoint_count; @@ -3435,38 +3461,38 @@ create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_kind) b->enable = enabled; b->disposition = tempflag ? del : donttouch; b->forked_inferior_pid = 0; - + b->type = bp_kind; - + mention (b); } void create_fork_event_catchpoint (tempflag, cond_string) - int tempflag; - char * cond_string; + int tempflag; + char *cond_string; { create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_fork); } - + void create_vfork_event_catchpoint (tempflag, cond_string) - int tempflag; - char * cond_string; + int tempflag; + char *cond_string; { create_fork_vfork_event_catchpoint (tempflag, cond_string, bp_catch_vfork); } void create_exec_event_catchpoint (tempflag, cond_string) - int tempflag; - char * cond_string; + int tempflag; + char *cond_string; { - struct symtab_and_line sal; - struct breakpoint * b; - int thread = -1; /* All threads. */ + struct symtab_and_line sal; + struct breakpoint *b; + int thread = -1; /* All threads. */ - INIT_SAL(&sal); + INIT_SAL (&sal); sal.pc = 0; sal.symtab = NULL; sal.line = 0; @@ -3487,41 +3513,42 @@ create_exec_event_catchpoint (tempflag, cond_string) } static int -hw_breakpoint_used_count() +hw_breakpoint_used_count () { register struct breakpoint *b; int i = 0; ALL_BREAKPOINTS (b) - { - if (b->type == bp_hardware_breakpoint && b->enable == enabled) - i++; - } + { + if (b->type == bp_hardware_breakpoint && b->enable == enabled) + i++; + } return i; } static int -hw_watchpoint_used_count(type, other_type_used) - enum bptype type; - int *other_type_used; +hw_watchpoint_used_count (type, other_type_used) + enum bptype type; + int *other_type_used; { register struct breakpoint *b; int i = 0; *other_type_used = 0; ALL_BREAKPOINTS (b) - { - if (b->enable == enabled) - { - if (b->type == type) i++; - else if ((b->type == bp_hardware_watchpoint || - b->type == bp_read_watchpoint || - b->type == bp_access_watchpoint) - && b->enable == enabled) - *other_type_used = 1; - } - } + { + if (b->enable == enabled) + { + if (b->type == type) + i++; + else if ((b->type == bp_hardware_watchpoint || + b->type == bp_read_watchpoint || + b->type == bp_access_watchpoint) + && b->enable == enabled) + *other_type_used = 1; + } + } return i; } @@ -3532,7 +3559,7 @@ hw_watchpoint_used_count(type, other_type_used) deleted automatically... */ void -set_longjmp_resume_breakpoint(pc, frame) +set_longjmp_resume_breakpoint (pc, frame) CORE_ADDR pc; struct frame_info *frame; { @@ -3540,56 +3567,56 @@ set_longjmp_resume_breakpoint(pc, frame) ALL_BREAKPOINTS (b) if (b->type == bp_longjmp_resume) - { - b->address = pc; - b->enable = enabled; - if (frame != NULL) - b->frame = frame->frame; - else - b->frame = 0; - check_duplicates (b->address, b->section); - return; - } + { + b->address = pc; + b->enable = enabled; + if (frame != NULL) + b->frame = frame->frame; + else + b->frame = 0; + check_duplicates (b->address, b->section); + return; + } } void disable_watchpoints_before_interactive_call_start () { - struct breakpoint * b; + struct breakpoint *b; ALL_BREAKPOINTS (b) - { - if (((b->type == bp_watchpoint) - || (b->type == bp_hardware_watchpoint) - || (b->type == bp_read_watchpoint) - || (b->type == bp_access_watchpoint) - || ep_is_exception_catchpoint (b)) - && (b->enable == enabled)) - { - b->enable = call_disabled; - check_duplicates (b->address, b->section); - } - } + { + if (((b->type == bp_watchpoint) + || (b->type == bp_hardware_watchpoint) + || (b->type == bp_read_watchpoint) + || (b->type == bp_access_watchpoint) + || ep_is_exception_catchpoint (b)) + && (b->enable == enabled)) + { + b->enable = call_disabled; + check_duplicates (b->address, b->section); + } + } } void enable_watchpoints_after_interactive_call_stop () { - struct breakpoint * b; + struct breakpoint *b; ALL_BREAKPOINTS (b) - { - if (((b->type == bp_watchpoint) - || (b->type == bp_hardware_watchpoint) - || (b->type == bp_read_watchpoint) - || (b->type == bp_access_watchpoint) - || ep_is_exception_catchpoint (b)) - && (b->enable == call_disabled)) - { - b->enable = enabled; - check_duplicates (b->address, b->section); - } - } + { + if (((b->type == bp_watchpoint) + || (b->type == bp_hardware_watchpoint) + || (b->type == bp_read_watchpoint) + || (b->type == bp_access_watchpoint) + || ep_is_exception_catchpoint (b)) + && (b->enable == call_disabled)) + { + b->enable = enabled; + check_duplicates (b->address, b->section); + } + } } @@ -3618,8 +3645,8 @@ set_momentary_breakpoint (sal, frame, type) return b; } - + /* Tell the user we have just set a breakpoint B. */ static void @@ -3654,7 +3681,7 @@ mention (b) print_expression (b->exp, gdb_stdout); break; case bp_access_watchpoint: - printf_filtered ("Hardware access (read/write) watchpoint %d: ",b->number); + printf_filtered ("Hardware access (read/write) watchpoint %d: ", b->number); print_expression (b->exp, gdb_stdout); break; case bp_breakpoint: @@ -3668,25 +3695,25 @@ mention (b) case bp_catch_load: case bp_catch_unload: printf_filtered ("Catchpoint %d (%s %s)", - b->number, - (b->type == bp_catch_load) ? "load" : "unload", - (b->dll_pathname != NULL) ? b->dll_pathname : ""); + b->number, + (b->type == bp_catch_load) ? "load" : "unload", + (b->dll_pathname != NULL) ? b->dll_pathname : ""); break; case bp_catch_fork: case bp_catch_vfork: printf_filtered ("Catchpoint %d (%s)", - b->number, - (b->type == bp_catch_fork) ? "fork" : "vfork"); + b->number, + (b->type == bp_catch_fork) ? "fork" : "vfork"); break; case bp_catch_exec: printf_filtered ("Catchpoint %d (exec)", - b->number); + b->number); break; case bp_catch_catch: case bp_catch_throw: printf_filtered ("Catchpoint %d (%s)", - b->number, - (b->type == bp_catch_catch) ? "catch" : "throw"); + b->number, + (b->type == bp_catch_catch) ? "catch" : "throw"); break; case bp_until: @@ -3710,16 +3737,16 @@ mention (b) if (b->source_file) printf_filtered (": file %s, line %d.", b->source_file, b->line_number); - TUIDO(((TuiOpaqueFuncPtr)tui_vAllSetHasBreakAt, b, 1)); - TUIDO(((TuiOpaqueFuncPtr)tuiUpdateAllExecInfos)); + TUIDO (((TuiOpaqueFuncPtr) tui_vAllSetHasBreakAt, b, 1)); + TUIDO (((TuiOpaqueFuncPtr) tuiUpdateAllExecInfos)); } printf_filtered ("\n"); } - + /* Set a breakpoint according to ARG (function, linenum or *address) flag: first bit : 0 non-temporary, 1 temporary. - second bit : 0 normal breakpoint, 1 hardware breakpoint. */ + second bit : 0 normal breakpoint, 1 hardware breakpoint. */ static void break_command_1 (arg, flag, from_tty) @@ -3741,7 +3768,7 @@ break_command_1 (arg, flag, from_tty) char *addr_end = NULL; struct cleanup *old_chain; struct cleanup *canonical_strings_chain = NULL; - char **canonical = (char **)NULL; + char **canonical = (char **) NULL; int i; int thread; @@ -3751,21 +3778,21 @@ break_command_1 (arg, flag, from_tty) sals.sals = NULL; sals.nelts = 0; - INIT_SAL (&sal); /* initialize to zeroes */ + INIT_SAL (&sal); /* initialize to zeroes */ /* If no arg given, or if first arg is 'if ', use the default breakpoint. */ - if (!arg || (arg[0] == 'i' && arg[1] == 'f' + if (!arg || (arg[0] == 'i' && arg[1] == 'f' && (arg[2] == ' ' || arg[2] == '\t'))) { if (default_breakpoint_valid) { - sals.sals = (struct symtab_and_line *) + sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line)); sal.pc = default_breakpoint_address; sal.line = default_breakpoint_line; sal.symtab = default_breakpoint_symtab; - sal.section = find_pc_overlay (sal.pc); + sal.section = find_pc_overlay (sal.pc); sals.sals[0] = sal; sals.nelts = 1; } @@ -3777,27 +3804,27 @@ break_command_1 (arg, flag, from_tty) addr_start = arg; /* Force almost all breakpoints to be in terms of the - current_source_symtab (which is decode_line_1's default). This - should produce the results we want almost all of the time while - leaving default_breakpoint_* alone. */ + current_source_symtab (which is decode_line_1's default). This + should produce the results we want almost all of the time while + leaving default_breakpoint_* alone. */ if (default_breakpoint_valid && (!current_source_symtab || (arg && (*arg == '+' || *arg == '-')))) sals = decode_line_1 (&arg, 1, default_breakpoint_symtab, default_breakpoint_line, &canonical); else - sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, &canonical); + sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, &canonical); addr_end = arg; } - - if (! sals.nelts) + + if (!sals.nelts) return; /* Make sure that all storage allocated in decode_line_1 gets freed in case the following `for' loop errors out. */ old_chain = make_cleanup (free, sals.sals); - if (canonical != (char **)NULL) + if (canonical != (char **) NULL) { make_cleanup (free, canonical); canonical_strings_chain = make_cleanup (null_cleanup, 0); @@ -3832,11 +3859,11 @@ break_command_1 (arg, flag, from_tty) Give the target a chance to bless sals.sals[i].pc before we try to make a breakpoint for it. */ - if (PC_REQUIRES_RUN_BEFORE_USE(sals.sals[i].pc)) - { - error ("Cannot break on %s without a running program.", addr_start); - } - + if (PC_REQUIRES_RUN_BEFORE_USE (sals.sals[i].pc)) + { + error ("Cannot break on %s without a running program.", addr_start); + } + tok = arg; while (tok && *tok) @@ -3877,17 +3904,17 @@ break_command_1 (arg, flag, from_tty) { int i, target_resources_ok; - i = hw_breakpoint_used_count (); + i = hw_breakpoint_used_count (); target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT ( - bp_hardware_breakpoint, i + sals.nelts, 0); + bp_hardware_breakpoint, i + sals.nelts, 0); if (target_resources_ok == 0) error ("No hardware breakpoint support in the target."); else if (target_resources_ok < 0) - error ("Hardware breakpoints used exceeds limit."); + error ("Hardware breakpoints used exceeds limit."); } /* Remove the canonical strings from the cleanup, they are needed below. */ - if (canonical != (char **)NULL) + if (canonical != (char **) NULL) discard_cleanups (canonical_strings_chain); /* Now set all the breakpoints. */ @@ -3906,14 +3933,14 @@ break_command_1 (arg, flag, from_tty) b->thread = thread; /* If a canonical line spec is needed use that instead of the - command string. */ - if (canonical != (char **)NULL && canonical[i] != NULL) + command string. */ + if (canonical != (char **) NULL && canonical[i] != NULL) b->addr_string = canonical[i]; else if (addr_start) b->addr_string = savestring (addr_start, addr_end - addr_start); if (cond_start) b->cond_string = savestring (cond_start, cond_end - cond_start); - + b->enable = enabled; b->disposition = tempflag ? del : donttouch; mention (b); @@ -3982,12 +4009,12 @@ break_at_finish_at_depth_command_1 (arg, flag, from_tty) if (if_arg) { extra_args = arg; - extra_args_len = strlen (arg); + extra_args_len = strlen (arg); } if (selected_pc) { - if (find_pc_partial_function(selected_pc, (char **)NULL, &low, &high)) + if (find_pc_partial_function (selected_pc, (char **) NULL, &low, &high)) { addr_string = (char *) xmalloc (26 + extra_args_len); if (extra_args_len) @@ -4047,33 +4074,32 @@ break_at_finish_command_1 (arg, flag, from_tty) if (if_arg) { extra_args = arg; - extra_args_len = strlen (arg); + extra_args_len = strlen (arg); + } + else if (arg) + { + /* get the stuff after the function name or address */ + extra_args = strchr (arg, ' '); + if (extra_args) + { + extra_args++; + extra_args_len = strlen (extra_args); + } } - else - if (arg) - { - /* get the stuff after the function name or address */ - extra_args = strchr (arg, ' '); - if (extra_args) - { - extra_args++; - extra_args_len = strlen (extra_args); - } - } sals.sals = NULL; sals.nelts = 0; - beg_addr_string = addr_string; - sals = decode_line_1 (&addr_string, 1, (struct symtab *)NULL, 0, - (char ***)NULL); + beg_addr_string = addr_string; + sals = decode_line_1 (&addr_string, 1, (struct symtab *) NULL, 0, + (char ***) NULL); free (beg_addr_string); old_chain = make_cleanup (free, sals.sals); for (i = 0; (i < sals.nelts); i++) { sal = sals.sals[i]; - if (find_pc_partial_function (sal.pc, (char **)NULL, &low, &high)) + if (find_pc_partial_function (sal.pc, (char **) NULL, &low, &high)) { break_string = (char *) xmalloc (extra_args_len + 26); if (extra_args_len) @@ -4081,7 +4107,7 @@ break_at_finish_command_1 (arg, flag, from_tty) else sprintf (break_string, "*0x%x", high); break_command_1 (break_string, flag, from_tty); - free(break_string); + free (break_string); } else error ("No function contains the specified address"); @@ -4091,7 +4117,7 @@ break_at_finish_command_1 (arg, flag, from_tty) printf_filtered ("Multiple breakpoints were set.\n"); printf_filtered ("Use the \"delete\" command to delete unwanted breakpoints.\n"); } - do_cleanups(old_chain); + do_cleanups (old_chain); } @@ -4114,14 +4140,14 @@ resolve_sal_pc (sal) if (sal->section == 0 && sal->symtab != NULL) { struct blockvector *bv; - struct block *b; - struct symbol *sym; - int index; + struct block *b; + struct symbol *sym; + int index; - bv = blockvector_for_pc_sect (sal->pc, 0, &index, sal->symtab); + bv = blockvector_for_pc_sect (sal->pc, 0, &index, sal->symtab); if (bv != NULL) { - b = BLOCKVECTOR_BLOCK (bv, index); + b = BLOCKVECTOR_BLOCK (bv, index); sym = block_function (b); if (sym != NULL) { @@ -4131,11 +4157,11 @@ resolve_sal_pc (sal) else { /* It really is worthwhile to have the section, so we'll just - have to look harder. This case can be executed if we have - line numbers but no functions (as can happen in assembly - source). */ + have to look harder. This case can be executed if we have + line numbers but no functions (as can happen in assembly + source). */ - struct minimal_symbol *msym; + struct minimal_symbol *msym; msym = lookup_minimal_symbol_by_pc (sal->pc); if (msym) @@ -4218,7 +4244,7 @@ stopin_command (arg, from_tty) { int badInput = 0; - if (arg == (char *)NULL) + if (arg == (char *) NULL) badInput = 1; else if (*arg != '*') { @@ -4226,22 +4252,22 @@ stopin_command (arg, from_tty) int hasColon = 0; /* look for a ':'. If this is a line number specification, then say - it is bad, otherwise, it should be an address or function/method - name */ + it is bad, otherwise, it should be an address or function/method + name */ while (*argptr && !hasColon) - { - hasColon = (*argptr == ':'); - argptr++; - } + { + hasColon = (*argptr == ':'); + argptr++; + } if (hasColon) - badInput = (*argptr != ':'); /* Not a class::method */ + badInput = (*argptr != ':'); /* Not a class::method */ else - badInput = isdigit(*arg); /* a simple line number */ + badInput = isdigit (*arg); /* a simple line number */ } if (badInput) - printf_filtered("Usage: stop in \n"); + printf_filtered ("Usage: stop in \n"); else break_command_1 (arg, 0, from_tty); } @@ -4253,7 +4279,7 @@ stopat_command (arg, from_tty) { int badInput = 0; - if (arg == (char *)NULL || *arg == '*') /* no line number */ + if (arg == (char *) NULL || *arg == '*') /* no line number */ badInput = 1; else { @@ -4261,21 +4287,21 @@ stopat_command (arg, from_tty) int hasColon = 0; /* look for a ':'. If there is a '::' then get out, otherwise - it is probably a line number. */ + it is probably a line number. */ while (*argptr && !hasColon) - { - hasColon = (*argptr == ':'); - argptr++; - } + { + hasColon = (*argptr == ':'); + argptr++; + } if (hasColon) - badInput = (*argptr == ':'); /* we have class::method */ + badInput = (*argptr == ':'); /* we have class::method */ else - badInput = !isdigit(*arg); /* not a line number */ + badInput = !isdigit (*arg); /* not a line number */ } if (badInput) - printf_filtered("Usage: stop at \n"); + printf_filtered ("Usage: stop at \n"); else break_command_1 (arg, 0, from_tty); } @@ -4306,8 +4332,8 @@ watch_command_1 (arg, accessflag, from_tty) enum bptype bp_type; int mem_cnt = 0; - INIT_SAL (&sal); /* initialize to zeroes */ - + INIT_SAL (&sal); /* initialize to zeroes */ + /* Parse arguments. */ innermost_block = NULL; exp_start = arg; @@ -4336,27 +4362,31 @@ watch_command_1 (arg, accessflag, from_tty) cond_end = tok; } if (*tok) - error("Junk at end of command."); + error ("Junk at end of command."); - if (accessflag == 1) bp_type = bp_read_watchpoint; - else if (accessflag == 2) bp_type = bp_access_watchpoint; - else bp_type = bp_hardware_watchpoint; + if (accessflag == 1) + bp_type = bp_read_watchpoint; + else if (accessflag == 2) + bp_type = bp_access_watchpoint; + else + bp_type = bp_hardware_watchpoint; mem_cnt = can_use_hardware_watchpoint (val); if (mem_cnt == 0 && bp_type != bp_hardware_watchpoint) error ("Expression cannot be implemented with read/access watchpoint."); - if (mem_cnt != 0) { - i = hw_watchpoint_used_count (bp_type, &other_type_used); - target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT( - bp_type, i + mem_cnt, other_type_used); - if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint) - error ("Target does not have this type of hardware watchpoint support."); - if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint) - error ("Target resources have been allocated for other types of watchpoints."); - } + if (mem_cnt != 0) + { + i = hw_watchpoint_used_count (bp_type, &other_type_used); + target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT ( + bp_type, i + mem_cnt, other_type_used); + if (target_resources_ok == 0 && bp_type != bp_hardware_watchpoint) + error ("Target does not have this type of hardware watchpoint support."); + if (target_resources_ok < 0 && bp_type != bp_hardware_watchpoint) + error ("Target resources have been allocated for other types of watchpoints."); + } #if defined(HPUXHPPA) - /* On HP-UX if you set a h/w + /* On HP-UX if you set a h/w watchpoint before the "run" command, the inferior dies with a e.g., SIGILL once you start it. I initially believed this was due to a bad interaction between page protection traps and the initial @@ -4370,13 +4400,13 @@ watch_command_1 (arg, accessflag, from_tty) Until I figure out what's happening, I'm disallowing watches altogether before the "run" or "attach" command. We'll tell the user they must set watches after getting the program started. */ - if (! target_has_execution) + if (!target_has_execution) { warning ("can't do that without a running program; try \"break main\", \"run\" first"); return; } #endif /* HPUXHPPA */ - + /* Now set up the breakpoint. */ b = set_raw_breakpoint (sal); set_breakpoint_count (breakpoint_count + 1); @@ -4391,7 +4421,7 @@ watch_command_1 (arg, accessflag, from_tty) b->cond_string = savestring (cond_start, cond_end - cond_start); else b->cond_string = 0; - + frame = block_innermost_frame (exp_valid_block); if (frame) { @@ -4399,7 +4429,7 @@ watch_command_1 (arg, accessflag, from_tty) b->watchpoint_frame = frame->frame; } else - b->watchpoint_frame = (CORE_ADDR)0; + b->watchpoint_frame = (CORE_ADDR) 0; if (mem_cnt && target_resources_ok > 0) b->type = bp_type; @@ -4417,7 +4447,7 @@ watch_command_1 (arg, accessflag, from_tty) struct symtab_and_line scope_sal; INIT_SAL (&scope_sal); /* initialize to zeroes */ - scope_sal.pc = get_frame_pc (prev_frame); + scope_sal.pc = get_frame_pc (prev_frame); scope_sal.section = find_pc_overlay (scope_sal.pc); scope_breakpoint = set_raw_breakpoint (scope_sal); @@ -4461,20 +4491,20 @@ can_use_hardware_watchpoint (v) int found_memory_cnt = 0; /* Did the user specifically forbid us to use hardware watchpoints? */ - if (! can_use_hw_watchpoints) + if (!can_use_hw_watchpoints) return 0; - + /* Make sure all the intermediate values are in memory. Also make sure we found at least one memory expression. Guards against watch 0x12345, which is meaningless, but could cause errors if one tries to insert a hardware watchpoint for the constant expression. */ - for ( ; v; v = v->next) + for (; v; v = v->next) { if (v->lval == lval_memory) { if (TARGET_REGION_SIZE_OK_FOR_HW_WATCHPOINT (TYPE_LENGTH (VALUE_TYPE (v)))) found_memory_cnt++; - } + } else if (v->lval != not_lval && v->modifiable == 0) return 0; } @@ -4484,28 +4514,31 @@ can_use_hardware_watchpoint (v) return found_memory_cnt; } -static void watch_command (arg, from_tty) +static void +watch_command (arg, from_tty) char *arg; int from_tty; { watch_command_1 (arg, 0, from_tty); } -static void rwatch_command (arg, from_tty) +static void +rwatch_command (arg, from_tty) char *arg; int from_tty; { watch_command_1 (arg, 1, from_tty); } -static void awatch_command (arg, from_tty) +static void +awatch_command (arg, from_tty) char *arg; int from_tty; { watch_command_1 (arg, 2, from_tty); } - + /* Helper routines for the until_command routine in infcmd.c. Here because it uses the mechanisms of breakpoints. */ @@ -4540,26 +4573,26 @@ until_break_command (arg, from_tty) /* Set a breakpoint where the user wants it and at return from this function */ - + if (default_breakpoint_valid) sals = decode_line_1 (&arg, 1, default_breakpoint_symtab, - default_breakpoint_line, (char ***)NULL); + default_breakpoint_line, (char ***) NULL); else - sals = decode_line_1 (&arg, 1, (struct symtab *)NULL, 0, (char ***)NULL); - + sals = decode_line_1 (&arg, 1, (struct symtab *) NULL, 0, (char ***) NULL); + if (sals.nelts != 1) error ("Couldn't get information on specified line."); - + sal = sals.sals[0]; - free ((PTR)sals.sals); /* malloc'd, so freed */ - + free ((PTR) sals.sals); /* malloc'd, so freed */ + if (*arg) error ("Junk at end of arguments."); - + resolve_sal_pc (&sal); - + breakpoint = set_momentary_breakpoint (sal, selected_frame, bp_until); - + if (!async_p || !target_has_async) old_chain = make_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint); else @@ -4575,14 +4608,14 @@ until_break_command (arg, from_tty) if (async_p && target_has_async) { /* In this case we don't need args for the continuation, because - all it needs to do is do the cleanups in the - exec_cleanup_chain, which will be only those inserted by this - function. We can get away by using ALL_CLEANUPS. */ + all it needs to do is do the cleanups in the + exec_cleanup_chain, which will be only those inserted by this + function. We can get away by using ALL_CLEANUPS. */ add_continuation (until_break_command_continuation, NULL); } /* Keep within the current frame */ - + if (prev_frame) { sal = find_pc_line (prev_frame->pc, 0); @@ -4593,12 +4626,12 @@ until_break_command (arg, from_tty) else make_exec_cleanup ((make_cleanup_func) delete_breakpoint, breakpoint); } - + proceed (-1, TARGET_SIGNAL_DEFAULT, 0); /* Do the cleanups now, anly if we are not running asynchronously, of if we are, but the target is still synchronous. */ if (!async_p || !target_has_async) - do_cleanups(old_chain); + do_cleanups (old_chain); } #if 0 @@ -4643,7 +4676,7 @@ struct sal_chain static struct symtabs_and_lines map_catch_names (args, function) char *args; - int (*function)(); + int (*function) (); { register char *p = args; register char *p1; @@ -4681,7 +4714,7 @@ map_catch_names (args, function) if (function (p)) { struct sal_chain *next = (struct sal_chain *) - alloca (sizeof (struct sal_chain)); + alloca (sizeof (struct sal_chain)); next->next = sal_chain; next->sal = get_catch_sal (p); sal_chain = next; @@ -4693,7 +4726,8 @@ map_catch_names (args, function) win: #endif p = p1; - while (*p == ' ' || *p == '\t') p++; + while (*p == ' ' || *p == '\t') + p++; } } #endif @@ -4770,7 +4804,7 @@ get_catch_sals (this_level_only) if (SYMBOL_CLASS (sym) == LOC_LABEL) { struct sal_chain *next = (struct sal_chain *) - alloca (sizeof (struct sal_chain)); + alloca (sizeof (struct sal_chain)); next->next = sal_chain; next->sal = find_pc_line (SYMBOL_VALUE_ADDRESS (sym), 0); sal_chain = next; @@ -4786,8 +4820,8 @@ get_catch_sals (this_level_only) break; /* After handling the function's top-level block, stop. - Don't continue to its superblock, the block of - per-file symbols. */ + Don't continue to its superblock, the block of + per-file symbols. */ if (BLOCK_FUNCTION (block)) break; block = BLOCK_SUPERBLOCK (block); @@ -4816,12 +4850,12 @@ static void ep_skip_leading_whitespace (s) char **s; { - if ((s == NULL) || (*s == NULL)) - return; - while (isspace(**s)) - *s += 1; + if ((s == NULL) || (*s == NULL)) + return; + while (isspace (**s)) + *s += 1; } - + /* This function examines a string, and attempts to find a token that might be an event name in the leading characters. If a possible match is found, a pointer to the last character of @@ -4830,31 +4864,31 @@ static char * ep_find_event_name_end (arg) char *arg; { - char * s = arg; - char * event_name_end = NULL; - + char *s = arg; + char *event_name_end = NULL; + /* If we could depend upon the presense of strrpbrk, we'd use that... */ if (arg == NULL) return NULL; - + /* We break out of the loop when we find a token delimiter. - Basically, we're looking for alphanumerics and underscores; - anything else delimites the token. */ + Basically, we're looking for alphanumerics and underscores; + anything else delimites the token. */ while (*s != '\0') { - if (! isalnum(*s) && (*s != '_')) - break; + if (!isalnum (*s) && (*s != '_')) + break; event_name_end = s; s++; } - + return event_name_end; } - + /* This function attempts to parse an optional "if " clause from the arg string. If one is not found, it returns NULL. - + Else, it returns a pointer to the condition string. (It does not attempt to evaluate the string against a particular block.) And, it updates arg to point to the first character following the parsed @@ -4863,67 +4897,71 @@ static char * ep_parse_optional_if_clause (arg) char **arg; { - char * cond_string; - - if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace((*arg)[2])) + char *cond_string; + + if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace ((*arg)[2])) return NULL; - + /* Skip the "if" keyword. */ (*arg) += 2; - + /* Skip any extra leading whitespace, and record the start of the condition string. */ ep_skip_leading_whitespace (arg); cond_string = *arg; - + /* Assume that the condition occupies the remainder of the arg string. */ (*arg) += strlen (cond_string); - + return cond_string; } - + /* This function attempts to parse an optional filename from the arg string. If one is not found, it returns NULL. - + Else, it returns a pointer to the parsed filename. (This function makes no attempt to verify that a file of that name exists, or is accessible.) And, it updates arg to point to the first character following the parsed filename in the arg string. - + Note that clients needing to preserve the returned filename for future access should copy it to their own buffers. */ static char * ep_parse_optional_filename (arg) char **arg; { - static char filename [1024]; - char * arg_p = *arg; - int i; - char c; - + static char filename[1024]; + char *arg_p = *arg; + int i; + char c; + if ((*arg_p == '\0') || isspace (*arg_p)) return NULL; - - for (i=0; ; i++) + + for (i = 0;; i++) { c = *arg_p; if (isspace (c)) - c = '\0'; + c = '\0'; filename[i] = c; if (c == '\0') - break; + break; arg_p++; } *arg = arg_p; - + return filename; } - + /* Commands to deal with catching events, such as signals, exceptions, process start/exit, etc. */ - -typedef enum {catch_fork, catch_vfork} catch_fork_kind; - + +typedef enum +{ + catch_fork, catch_vfork +} +catch_fork_kind; + static void catch_fork_command_1 PARAMS ((catch_fork_kind fork_kind, char *arg, int tempflag, int from_tty)); static void @@ -4933,33 +4971,34 @@ catch_fork_command_1 (fork_kind, arg, tempflag, from_tty) int tempflag; int from_tty; { - char * cond_string = NULL; - + char *cond_string = NULL; + ep_skip_leading_whitespace (&arg); - + /* The allowed syntax is: - catch [v]fork - catch [v]fork if - + catch [v]fork + catch [v]fork if + First, check if there's an if clause. */ cond_string = ep_parse_optional_if_clause (&arg); - + if ((*arg != '\0') && !isspace (*arg)) error ("Junk at end of arguments."); - + /* If this target supports it, create a fork or vfork catchpoint and enable reporting of such events. */ - switch (fork_kind) { - case catch_fork : + switch (fork_kind) + { + case catch_fork: create_fork_event_catchpoint (tempflag, cond_string); break; - case catch_vfork : + case catch_vfork: create_vfork_event_catchpoint (tempflag, cond_string); break; - default : + default: error ("unsupported or unknown fork kind; cannot catch it"); break; - } + } } static void @@ -4968,13 +5007,13 @@ catch_exec_command_1 (arg, tempflag, from_tty) int tempflag; int from_tty; { - char * cond_string = NULL; + char *cond_string = NULL; ep_skip_leading_whitespace (&arg); /* The allowed syntax is: - catch exec - catch exec if + catch exec + catch exec if First, check if there's an if clause. */ cond_string = ep_parse_optional_if_clause (&arg); @@ -4986,34 +5025,34 @@ catch_exec_command_1 (arg, tempflag, from_tty) and enable reporting of such events. */ create_exec_event_catchpoint (tempflag, cond_string); } - + #if defined(SOLIB_ADD) static void catch_load_command_1 (arg, tempflag, from_tty) - char * arg; - int tempflag; - int from_tty; + char *arg; + int tempflag; + int from_tty; { - char * dll_pathname = NULL; - char * cond_string = NULL; - + char *dll_pathname = NULL; + char *cond_string = NULL; + ep_skip_leading_whitespace (&arg); - + /* The allowed syntax is: - catch load - catch load if - catch load - catch load if - + catch load + catch load if + catch load + catch load if + The user is not allowed to specify the after an if clause. - + We'll ignore the pathological case of a file named "if". - + First, check if there's an if clause. If so, then there cannot be a filename. */ cond_string = ep_parse_optional_if_clause (&arg); - + /* If there was an if clause, then there cannot be a filename. Else, there might be a filename and an if clause. */ if (cond_string == NULL) @@ -5022,42 +5061,42 @@ catch_load_command_1 (arg, tempflag, from_tty) ep_skip_leading_whitespace (&arg); cond_string = ep_parse_optional_if_clause (&arg); } - + if ((*arg != '\0') && !isspace (*arg)) error ("Junk at end of arguments."); - + /* Create a load breakpoint that only triggers when a load of the specified dll (or any dll, if no pathname was specified) occurs. */ SOLIB_CREATE_CATCH_LOAD_HOOK (inferior_pid, tempflag, dll_pathname, cond_string); } - + static void catch_unload_command_1 (arg, tempflag, from_tty) - char * arg; - int tempflag; - int from_tty; + char *arg; + int tempflag; + int from_tty; { - char * dll_pathname = NULL; - char * cond_string = NULL; - + char *dll_pathname = NULL; + char *cond_string = NULL; + ep_skip_leading_whitespace (&arg); - + /* The allowed syntax is: - catch unload - catch unload if - catch unload - catch unload if - + catch unload + catch unload if + catch unload + catch unload if + The user is not allowed to specify the after an if clause. - + We'll ignore the pathological case of a file named "if". - + First, check if there's an if clause. If so, then there cannot be a filename. */ cond_string = ep_parse_optional_if_clause (&arg); - + /* If there was an if clause, then there cannot be a filename. Else, there might be a filename and an if clause. */ if (cond_string == NULL) @@ -5066,10 +5105,10 @@ catch_unload_command_1 (arg, tempflag, from_tty) ep_skip_leading_whitespace (&arg); cond_string = ep_parse_optional_if_clause (&arg); } - + if ((*arg != '\0') && !isspace (*arg)) error ("Junk at end of arguments."); - + /* Create an unload breakpoint that only triggers when an unload of the specified dll (or any dll, if no pathname was specified) occurs. */ @@ -5080,7 +5119,7 @@ catch_unload_command_1 (arg, tempflag, from_tty) /* Commands to deal with catching exceptions. */ /* Set a breakpoint at the specified callback routine for an - exception event callback */ + exception event callback */ static void create_exception_catchpoint (tempflag, cond_string, ex_event, sal) @@ -5089,11 +5128,11 @@ create_exception_catchpoint (tempflag, cond_string, ex_event, sal) enum exception_event_kind ex_event; struct symtab_and_line *sal; { - struct breakpoint * b; - int i; - int thread = -1; /* All threads. */ + struct breakpoint *b; + int i; + int thread = -1; /* All threads. */ - if (!sal) /* no exception support? */ + if (!sal) /* no exception support? */ return; b = set_raw_breakpoint (*sal); @@ -5107,21 +5146,21 @@ create_exception_catchpoint (tempflag, cond_string, ex_event, sal) b->disposition = tempflag ? del : donttouch; switch (ex_event) { - case EX_EVENT_THROW: - b->type = bp_catch_throw; - break; - case EX_EVENT_CATCH: - b->type = bp_catch_catch; - break; - default: /* error condition */ - b->type = bp_none; - b->enable = disabled; - error ("Internal error -- invalid catchpoint kind"); + case EX_EVENT_THROW: + b->type = bp_catch_throw; + break; + case EX_EVENT_CATCH: + b->type = bp_catch_catch; + break; + default: /* error condition */ + b->type = bp_none; + b->enable = disabled; + error ("Internal error -- invalid catchpoint kind"); } mention (b); } -/* Deal with "catch catch" and "catch throw" commands */ +/* Deal with "catch catch" and "catch throw" commands */ static void catch_exception_command_1 (ex_event, arg, tempflag, from_tty) @@ -5130,11 +5169,11 @@ catch_exception_command_1 (ex_event, arg, tempflag, from_tty) int tempflag; int from_tty; { - char * cond_string = NULL; - struct symtab_and_line * sal = NULL; - + char *cond_string = NULL; + struct symtab_and_line *sal = NULL; + ep_skip_leading_whitespace (&arg); - + cond_string = ep_parse_optional_if_clause (&arg); if ((*arg != '\0') && !isspace (*arg)) @@ -5147,31 +5186,31 @@ catch_exception_command_1 (ex_event, arg, tempflag, from_tty) /* See if we can find a callback routine */ sal = target_enable_exception_callback (ex_event, 1); - if (sal) + if (sal) { /* We have callbacks from the runtime system for exceptions. - Set a breakpoint on the sal found, if no errors */ + Set a breakpoint on the sal found, if no errors */ if (sal != (struct symtab_and_line *) -1) - create_exception_catchpoint (tempflag, cond_string, ex_event, sal); + create_exception_catchpoint (tempflag, cond_string, ex_event, sal); else - return; /* something went wrong with setting up callbacks */ + return; /* something went wrong with setting up callbacks */ } - else + else { /* No callbacks from runtime system for exceptions. Try GNU C++ exception breakpoints using labels in debug info. */ if (ex_event == EX_EVENT_CATCH) - { - handle_gnu_4_16_catch_command (arg, tempflag, from_tty); - } + { + handle_gnu_4_16_catch_command (arg, tempflag, from_tty); + } else if (ex_event == EX_EVENT_THROW) - { - /* Set a breakpoint on __raise_exception () */ - - fprintf_filtered (gdb_stderr, "Unsupported with this platform/compiler combination.\n"); - fprintf_filtered (gdb_stderr, "Perhaps you can achieve the effect you want by setting\n"); - fprintf_filtered (gdb_stderr, "a breakpoint on __raise_exception().\n"); - } + { + /* Set a breakpoint on __raise_exception () */ + + fprintf_filtered (gdb_stderr, "Unsupported with this platform/compiler combination.\n"); + fprintf_filtered (gdb_stderr, "Perhaps you can achieve the effect you want by setting\n"); + fprintf_filtered (gdb_stderr, "a breakpoint on __raise_exception().\n"); + } } } @@ -5180,7 +5219,7 @@ catch_exception_command_1 (ex_event, arg, tempflag, from_tty) static int cover_target_enable_exception_callback (arg) - PTR arg; + PTR arg; { args_for_catchpoint_enable *args = arg; struct symtab_and_line *sal; @@ -5190,7 +5229,7 @@ cover_target_enable_exception_callback (arg) else if (sal == (struct symtab_and_line *) -1) return -1; else - return 1; /*is valid*/ + return 1; /*is valid */ } @@ -5203,7 +5242,7 @@ cover_target_enable_exception_callback (arg) Note: Only the "catch" flavour of GDB 4.16 is handled here. The "catch NAME" is now no longer allowed in catch_command_1(). Also, there was no code in GDB 4.16 for "catch throw". - + Called from catch_exception_command_1 () */ @@ -5223,12 +5262,12 @@ handle_gnu_4_16_catch_command (arg, tempflag, from_tty) char *save_arg; int i; - INIT_SAL (&sal); /* initialize to zeroes */ + INIT_SAL (&sal); /* initialize to zeroes */ /* If no arg given, or if first arg is 'if ', all active catch clauses are breakpointed. */ - if (!arg || (arg[0] == 'i' && arg[1] == 'f' + if (!arg || (arg[0] == 'i' && arg[1] == 'f' && (arg[2] == ' ' || arg[2] == '\t'))) { /* Grab all active catch clauses. */ @@ -5243,26 +5282,26 @@ handle_gnu_4_16_catch_command (arg, tempflag, from_tty) /* Not sure why this code has been disabled. I'm leaving it disabled. We can never come here now anyway since we don't allow the "catch NAME" syntax. - pai/1997-07-11 */ + pai/1997-07-11 */ /* This isn't used; I don't know what it was for. */ sals = map_catch_names (arg, catch_breakpoint); #endif } - if (! sals.nelts) + if (!sals.nelts) return; save_arg = arg; for (i = 0; i < sals.nelts; i++) { resolve_sal_pc (&sals.sals[i]); - + while (arg && *arg) { if (arg[0] == 'i' && arg[1] == 'f' && (arg[2] == ' ' || arg[2] == '\t')) - cond = parse_exp_1 ((arg += 2, &arg), + cond = parse_exp_1 ((arg += 2, &arg), block_for_pc (sals.sals[i].pc), 0); else error ("Junk at end of arguments."); @@ -5280,12 +5319,12 @@ handle_gnu_4_16_catch_command (arg, tempflag, from_tty) b = set_raw_breakpoint (sal); set_breakpoint_count (breakpoint_count + 1); b->number = breakpoint_count; - b->type = bp_breakpoint; /* Important -- this is an ordinary breakpoint. - For platforms with callback support for exceptions, - create_exception_catchpoint() will create special - bp types (bp_catch_catch and bp_catch_throw), and - there is code in insert_breakpoints() and elsewhere - that depends on that. */ + b->type = bp_breakpoint; /* Important -- this is an ordinary breakpoint. + For platforms with callback support for exceptions, + create_exception_catchpoint() will create special + bp types (bp_catch_catch and bp_catch_throw), and + there is code in insert_breakpoints() and elsewhere + that depends on that. */ b->cond = cond; b->enable = enabled; @@ -5299,7 +5338,7 @@ handle_gnu_4_16_catch_command (arg, tempflag, from_tty) printf_unfiltered ("Multiple breakpoints were set.\n"); printf_unfiltered ("Use the \"delete\" command to delete unwanted breakpoints.\n"); } - free ((PTR)sals.sals); + free ((PTR) sals.sals); } #if 0 @@ -5307,12 +5346,12 @@ handle_gnu_4_16_catch_command (arg, tempflag, from_tty) just to placate infrun */ static struct breakpoint * create_temp_exception_breakpoint (pc) - CORE_ADDR pc; + CORE_ADDR pc; { struct symtab_and_line sal; struct breakpoint *b; - INIT_SAL(&sal); + INIT_SAL (&sal); sal.pc = pc; sal.symtab = NULL; sal.line = 0; @@ -5332,27 +5371,27 @@ create_temp_exception_breakpoint (pc) static void catch_command_1 (arg, tempflag, from_tty) - char *arg; - int tempflag; - int from_tty; + char *arg; + int tempflag; + int from_tty; { - + /* The first argument may be an event name, such as "start" or "load". If so, then handle it as such. If it doesn't match an event name, then attempt to interpret it as an exception name. (This latter is the v4.16-and-earlier GDB meaning of the "catch" command.) - + First, try to find the bounds of what might be an event name. */ - char * arg1_start = arg; - char * arg1_end; - int arg1_length; - + char *arg1_start = arg; + char *arg1_end; + int arg1_length; + if (arg1_start == NULL) { - /* Old behaviour was to use pre-v-4.16 syntax */ + /* Old behaviour was to use pre-v-4.16 syntax */ /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */ /* return; */ - /* Now, this is not allowed */ + /* Now, this is not allowed */ error ("Catch requires an event name."); } @@ -5360,7 +5399,7 @@ catch_command_1 (arg, tempflag, from_tty) if (arg1_end == NULL) error ("catch requires an event"); arg1_length = arg1_end + 1 - arg1_start; - + /* Try to match what we found against known event names. */ if (strncmp (arg1_start, "signal", arg1_length) == 0) { @@ -5368,11 +5407,11 @@ catch_command_1 (arg, tempflag, from_tty) } else if (strncmp (arg1_start, "catch", arg1_length) == 0) { - catch_exception_command_1 (EX_EVENT_CATCH, arg1_end+1, tempflag, from_tty); + catch_exception_command_1 (EX_EVENT_CATCH, arg1_end + 1, tempflag, from_tty); } else if (strncmp (arg1_start, "throw", arg1_length) == 0) { - catch_exception_command_1 (EX_EVENT_THROW, arg1_end+1, tempflag, from_tty); + catch_exception_command_1 (EX_EVENT_THROW, arg1_end + 1, tempflag, from_tty); } else if (strncmp (arg1_start, "thread_start", arg1_length) == 0) { @@ -5397,7 +5436,7 @@ catch_command_1 (arg, tempflag, from_tty) else if (strncmp (arg1_start, "fork", arg1_length) == 0) { #if defined(CHILD_INSERT_FORK_CATCHPOINT) - catch_fork_command_1 (catch_fork, arg1_end+1, tempflag, from_tty); + catch_fork_command_1 (catch_fork, arg1_end + 1, tempflag, from_tty); #else error ("Catch of fork not yet implemented"); #endif @@ -5405,7 +5444,7 @@ catch_command_1 (arg, tempflag, from_tty) else if (strncmp (arg1_start, "vfork", arg1_length) == 0) { #if defined(CHILD_INSERT_VFORK_CATCHPOINT) - catch_fork_command_1 (catch_vfork, arg1_end+1, tempflag, from_tty); + catch_fork_command_1 (catch_vfork, arg1_end + 1, tempflag, from_tty); #else error ("Catch of vfork not yet implemented"); #endif @@ -5413,7 +5452,7 @@ catch_command_1 (arg, tempflag, from_tty) else if (strncmp (arg1_start, "exec", arg1_length) == 0) { #if defined(CHILD_INSERT_EXEC_CATCHPOINT) - catch_exec_command_1 (arg1_end+1, tempflag, from_tty); + catch_exec_command_1 (arg1_end + 1, tempflag, from_tty); #else error ("Catch of exec not yet implemented"); #endif @@ -5421,7 +5460,7 @@ catch_command_1 (arg, tempflag, from_tty) else if (strncmp (arg1_start, "load", arg1_length) == 0) { #if defined(SOLIB_ADD) - catch_load_command_1 (arg1_end+1, tempflag, from_tty); + catch_load_command_1 (arg1_end + 1, tempflag, from_tty); #else error ("Catch of load not implemented"); #endif @@ -5429,7 +5468,7 @@ catch_command_1 (arg, tempflag, from_tty) else if (strncmp (arg1_start, "unload", arg1_length) == 0) { #if defined(SOLIB_ADD) - catch_unload_command_1 (arg1_end+1, tempflag, from_tty); + catch_unload_command_1 (arg1_end + 1, tempflag, from_tty); #else error ("Catch of load not implemented"); #endif @@ -5438,15 +5477,15 @@ catch_command_1 (arg, tempflag, from_tty) { error ("Catch of stop not yet implemented"); } - + /* This doesn't appear to be an event name */ else { /* Pre-v.4.16 behaviour was to treat the argument - as the name of an exception */ + as the name of an exception */ /* catch_throw_command_1 (arg1_start, tempflag, from_tty); */ - /* Now this is not allowed */ + /* Now this is not allowed */ error ("Unknown event kind specified for catch"); } @@ -5532,9 +5571,9 @@ clear_command (arg, from_tty) } else { - sals.sals = (struct symtab_and_line *) + sals.sals = (struct symtab_and_line *) xmalloc (sizeof (struct symtab_and_line)); - INIT_SAL (&sal); /* initialize to zeroes */ + INIT_SAL (&sal); /* initialize to zeroes */ sal.line = default_breakpoint_line; sal.symtab = default_breakpoint_symtab; sal.pc = default_breakpoint_address; @@ -5558,37 +5597,37 @@ clear_command (arg, from_tty) for (i = 0; i < sals.nelts; i++) { /* If exact pc given, clear bpts at that pc. - If line given (pc == 0), clear all bpts on specified line. - If defaulting, clear all bpts on default line + If line given (pc == 0), clear all bpts on specified line. + If defaulting, clear all bpts on default line or at default pc. - - defaulting sal.pc != 0 tests to do - - 0 1 pc - 1 1 pc _and_ line - 0 0 line - 1 0 */ + + defaulting sal.pc != 0 tests to do + + 0 1 pc + 1 1 pc _and_ line + 0 0 line + 1 0 */ sal = sals.sals[i]; found = (struct breakpoint *) 0; while (breakpoint_chain - /* Why don't we check here that this is not - a watchpoint, etc., as we do below? - I can't make it fail, but don't know - what's stopping the failure: a watchpoint - of the same address as "sal.pc" should - wind up being deleted. */ - - && ( ((sal.pc && (breakpoint_chain->address == sal.pc)) && - (overlay_debugging == 0 || - breakpoint_chain->section == sal.section)) - || ((default_match || (0 == sal.pc)) - && breakpoint_chain->source_file != NULL - && sal.symtab != NULL - && STREQ (breakpoint_chain->source_file, sal.symtab->filename) - && breakpoint_chain->line_number == sal.line))) + /* Why don't we check here that this is not + a watchpoint, etc., as we do below? + I can't make it fail, but don't know + what's stopping the failure: a watchpoint + of the same address as "sal.pc" should + wind up being deleted. */ + + && (((sal.pc && (breakpoint_chain->address == sal.pc)) && + (overlay_debugging == 0 || + breakpoint_chain->section == sal.section)) + || ((default_match || (0 == sal.pc)) + && breakpoint_chain->source_file != NULL + && sal.symtab != NULL + && STREQ (breakpoint_chain->source_file, sal.symtab->filename) + && breakpoint_chain->line_number == sal.line))) { b1 = breakpoint_chain; @@ -5599,28 +5638,28 @@ clear_command (arg, from_tty) ALL_BREAKPOINTS (b) - while (b->next - && b->next->type != bp_none - && b->next->type != bp_watchpoint - && b->next->type != bp_hardware_watchpoint - && b->next->type != bp_read_watchpoint - && b->next->type != bp_access_watchpoint - && ( ((sal.pc && (b->next->address == sal.pc)) && - (overlay_debugging == 0 || - b->next->section == sal.section)) - || ((default_match || (0 == sal.pc)) - && b->next->source_file != NULL - && sal.symtab != NULL - && STREQ (b->next->source_file, sal.symtab->filename) - && b->next->line_number == sal.line))) + while (b->next + && b->next->type != bp_none + && b->next->type != bp_watchpoint + && b->next->type != bp_hardware_watchpoint + && b->next->type != bp_read_watchpoint + && b->next->type != bp_access_watchpoint + && (((sal.pc && (b->next->address == sal.pc)) && + (overlay_debugging == 0 || + b->next->section == sal.section)) + || ((default_match || (0 == sal.pc)) + && b->next->source_file != NULL + && sal.symtab != NULL + && STREQ (b->next->source_file, sal.symtab->filename) + && b->next->line_number == sal.line))) - { - b1 = b->next; - b->next = b1->next; - b1->next = found; - found = b1; - } + { + b1 = b->next; + b->next = b1->next; + b1->next = found; + found = b1; + } if (found == 0) { @@ -5630,19 +5669,23 @@ clear_command (arg, from_tty) error ("No breakpoint at this line."); } - if (found->next) from_tty = 1; /* Always report if deleted more than one */ - if (from_tty) printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : ""); + if (found->next) + from_tty = 1; /* Always report if deleted more than one */ + if (from_tty) + printf_unfiltered ("Deleted breakpoint%s ", found->next ? "s" : ""); breakpoints_changed (); while (found) { - if (from_tty) printf_unfiltered ("%d ", found->number); + if (from_tty) + printf_unfiltered ("%d ", found->number); b1 = found->next; delete_breakpoint (found); found = b1; } - if (from_tty) putchar_unfiltered ('\n'); + if (from_tty) + putchar_unfiltered ('\n'); } - free ((PTR)sals.sals); + free ((PTR) sals.sals); } /* Delete breakpoint in BS if they are `delete' breakpoints and @@ -5656,15 +5699,15 @@ breakpoint_auto_delete (bs) struct breakpoint *b, *temp; for (; bs; bs = bs->next) - if (bs->breakpoint_at && bs->breakpoint_at->disposition == del + if (bs->breakpoint_at && bs->breakpoint_at->disposition == del && bs->stop) delete_breakpoint (bs->breakpoint_at); ALL_BREAKPOINTS_SAFE (b, temp) - { - if (b->disposition == del_at_next_stop) - delete_breakpoint (b); - } + { + if (b->disposition == del_at_next_stop) + delete_breakpoint (b); + } } /* Delete a breakpoint and clean up all traces of it in the data structures. */ @@ -5701,7 +5744,7 @@ delete_breakpoint (bpt) if (bpt->inserted) remove_breakpoint (bpt, mark_uninserted); - + if (breakpoint_chain == bpt) breakpoint_chain = bpt->next; @@ -5710,14 +5753,14 @@ delete_breakpoint (bpt) isn't actually running. target_enable_exception_callback for a null target ops vector gives an undesirable error message, so we check here and avoid it. Since currently (1997-09-17) only HP-UX aCC's - exceptions are supported in this way, it's OK for now. FIXME */ + exceptions are supported in this way, it's OK for now. FIXME */ if (ep_is_exception_catchpoint (bpt) && target_has_execution) { static char message1[] = "Error in deleting catchpoint %d:\n"; static char message[sizeof (message1) + 30]; args_for_catchpoint_enable args; - sprintf (message, message1, bpt->number); /* Format possible error msg */ + sprintf (message, message1, bpt->number); /* Format possible error msg */ args.kind = bpt->type == bp_catch_catch ? EX_EVENT_CATCH : EX_EVENT_THROW; args.enable = 0; catch_errors (cover_target_enable_exception_callback, &args, @@ -5727,10 +5770,10 @@ delete_breakpoint (bpt) ALL_BREAKPOINTS (b) if (b->next == bpt) - { - b->next = bpt->next; - break; - } + { + b->next = bpt->next; + break; + } /* Before turning off the visuals for the bp, check to see that there are no other bps at the same address. */ @@ -5739,17 +5782,17 @@ delete_breakpoint (bpt) int clearIt; ALL_BREAKPOINTS (b) - { - clearIt = (b->address != bpt->address); - if (!clearIt) - break; - } + { + clearIt = (b->address != bpt->address); + if (!clearIt) + break; + } if (clearIt) - { - TUIDO(((TuiOpaqueFuncPtr)tui_vAllSetHasBreakAt, bpt, 0)); - TUIDO(((TuiOpaqueFuncPtr)tuiUpdateAllExecInfos)); - } + { + TUIDO (((TuiOpaqueFuncPtr) tui_vAllSetHasBreakAt, bpt, 0)); + TUIDO (((TuiOpaqueFuncPtr) tuiUpdateAllExecInfos)); + } } check_duplicates (bpt->address, bpt->section); @@ -5770,18 +5813,18 @@ delete_breakpoint (bpt) && b->enable != disabled && b->enable != shlib_disabled && b->enable != call_disabled) - { - int val; - val = target_insert_breakpoint (b->address, b->shadow_contents); - if (val != 0) - { - target_terminal_ours_for_output (); - fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number); - memory_error (val, b->address); /* which bombs us out */ - } - else - b->inserted = 1; - } + { + int val; + val = target_insert_breakpoint (b->address, b->shadow_contents); + if (val != 0) + { + target_terminal_ours_for_output (); + fprintf_unfiltered (gdb_stderr, "Cannot insert breakpoint %d:\n", b->number); + memory_error (val, b->address); /* which bombs us out */ + } + else + b->inserted = 1; + } } free_command_lines (&bpt->commands); @@ -5826,7 +5869,7 @@ delete_breakpoint (bpt) bp, we mark it as deleted before freeing its storage. */ bpt->type = bp_none; - free ((PTR)bpt); + free ((PTR) bpt); } void @@ -5841,27 +5884,27 @@ delete_command (arg, from_tty) int breaks_to_delete = 0; /* Delete all breakpoints if no argument. - Do not delete internal or call-dummy breakpoints, these - have to be deleted with an explicit breakpoint number argument. */ - ALL_BREAKPOINTS (b) - { - if (b->type != bp_call_dummy && - b->type != bp_shlib_event && - b->number >= 0) - breaks_to_delete = 1; - } + Do not delete internal or call-dummy breakpoints, these + have to be deleted with an explicit breakpoint number argument. */ + ALL_BREAKPOINTS (b) + { + if (b->type != bp_call_dummy && + b->type != bp_shlib_event && + b->number >= 0) + breaks_to_delete = 1; + } /* Ask user only if there are some breakpoints to delete. */ if (!from_tty || (breaks_to_delete && query ("Delete all breakpoints? "))) { - ALL_BREAKPOINTS_SAFE (b, temp) - { - if (b->type != bp_call_dummy && - b->type != bp_shlib_event && - b->number >= 0) - delete_breakpoint (b); - } + ALL_BREAKPOINTS_SAFE (b, temp) + { + if (b->type != bp_call_dummy && + b->type != bp_shlib_event && + b->number >= 0) + delete_breakpoint (b); + } } } else @@ -5876,7 +5919,7 @@ static int breakpoint_re_set_one (bint) PTR bint; { - struct breakpoint *b = (struct breakpoint *)bint; /* get past catch_errs */ + struct breakpoint *b = (struct breakpoint *) bint; /* get past catch_errs */ struct value *mark; int i; struct symtabs_and_lines sals; @@ -5899,14 +5942,14 @@ breakpoint_re_set_one (bint) return 0; } /* In case we have a problem, disable this breakpoint. We'll restore - its status if we succeed. */ + its status if we succeed. */ save_enable = b->enable; b->enable = disabled; set_language (b->language); input_radix = b->input_radix; s = b->addr_string; - sals = decode_line_1 (&s, 1, (struct symtab *)NULL, 0, (char ***)NULL); + sals = decode_line_1 (&s, 1, (struct symtab *) NULL, 0, (char ***) NULL); for (i = 0; i < sals.nelts; i++) { resolve_sal_pc (&sals.sals[i]); @@ -5917,23 +5960,23 @@ breakpoint_re_set_one (bint) { s = b->cond_string; if (b->cond) - free ((PTR)b->cond); + free ((PTR) b->cond); b->cond = parse_exp_1 (&s, block_for_pc (sals.sals[i].pc), 0); } - /* We need to re-set the breakpoint if the address changes...*/ + /* We need to re-set the breakpoint if the address changes... */ if (b->address != sals.sals[i].pc - /* ...or new and old breakpoints both have source files, and - the source file name or the line number changes... */ + /* ...or new and old breakpoints both have source files, and + the source file name or the line number changes... */ || (b->source_file != NULL && sals.sals[i].symtab != NULL && (!STREQ (b->source_file, sals.sals[i].symtab->filename) || b->line_number != sals.sals[i].line) - ) - /* ...or we switch between having a source file and not having - one. */ - || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL)) ) + /* ...or we switch between having a source file and not having + one. */ + || ((b->source_file == NULL) != (sals.sals[i].symtab == NULL)) + ) { if (b->source_file != NULL) free (b->source_file); @@ -5946,26 +5989,26 @@ breakpoint_re_set_one (bint) b->line_number = sals.sals[i].line; b->address = sals.sals[i].pc; - /* Used to check for duplicates here, but that can - cause trouble, as it doesn't check for disable - breakpoints. */ + /* Used to check for duplicates here, but that can + cause trouble, as it doesn't check for disable + breakpoints. */ mention (b); /* Might be better to do this just once per breakpoint_re_set, - rather than once for every breakpoint. */ + rather than once for every breakpoint. */ breakpoints_changed (); } b->section = sals.sals[i].section; b->enable = save_enable; /* Restore it, this worked. */ - /* Now that this is re-enabled, check_duplicates + /* Now that this is re-enabled, check_duplicates can be used. */ - check_duplicates (b->address, b->section); + check_duplicates (b->address, b->section); } - free ((PTR)sals.sals); + free ((PTR) sals.sals); break; case bp_watchpoint: @@ -5974,15 +6017,15 @@ breakpoint_re_set_one (bint) case bp_access_watchpoint: innermost_block = NULL; /* The issue arises of what context to evaluate this in. The same - one as when it was set, but what does that mean when symbols have - been re-read? We could save the filename and functionname, but - if the context is more local than that, the best we could do would - be something like how many levels deep and which index at that - particular level, but that's going to be less stable than filenames - or functionnames. */ + one as when it was set, but what does that mean when symbols have + been re-read? We could save the filename and functionname, but + if the context is more local than that, the best we could do would + be something like how many levels deep and which index at that + particular level, but that's going to be less stable than filenames + or functionnames. */ /* So for now, just use a global context. */ if (b->exp) - free ((PTR)b->exp); + free ((PTR) b->exp); b->exp = parse_expression (b->exp_string); b->exp_valid_block = innermost_block; mark = value_mark (); @@ -5997,42 +6040,42 @@ breakpoint_re_set_one (bint) { s = b->cond_string; if (b->cond) - free ((PTR)b->cond); - b->cond = parse_exp_1 (&s, (struct block *)0, 0); + free ((PTR) b->cond); + b->cond = parse_exp_1 (&s, (struct block *) 0, 0); } if (b->enable == enabled) mention (b); value_free_to_mark (mark); break; - case bp_catch_catch: - case bp_catch_throw: + case bp_catch_catch: + case bp_catch_throw: break; - /* We needn't really do anything to reset these, since the mask - that requests them is unaffected by e.g., new libraries being - loaded. */ + /* We needn't really do anything to reset these, since the mask + that requests them is unaffected by e.g., new libraries being + loaded. */ case bp_catch_fork: case bp_catch_vfork: case bp_catch_exec: break; - + default: printf_filtered ("Deleting unknown breakpoint type %d\n", b->type); /* fall through */ - /* Delete longjmp breakpoints, they will be reset later by - breakpoint_re_set. */ + /* Delete longjmp breakpoints, they will be reset later by + breakpoint_re_set. */ case bp_longjmp: case bp_longjmp_resume: delete_breakpoint (b); break; - /* This breakpoint is special, it's set up when the inferior - starts and we really don't want to touch it. */ + /* This breakpoint is special, it's set up when the inferior + starts and we really don't want to touch it. */ case bp_shlib_event: - /* Keep temporary breakpoints, which can be encountered when we step - over a dlopen call and SOLIB_ADD is resetting the breakpoints. - Otherwise these should have been blown away via the cleanup chain - or by breakpoint_init_inferior when we rerun the executable. */ + /* Keep temporary breakpoints, which can be encountered when we step + over a dlopen call and SOLIB_ADD is resetting the breakpoints. + Otherwise these should have been blown away via the cleanup chain + or by breakpoint_init_inferior when we rerun the executable. */ case bp_until: case bp_finish: case bp_watchpoint_scope: @@ -6052,15 +6095,15 @@ breakpoint_re_set () enum language save_language; int save_input_radix; static char message1[] = "Error in re-setting breakpoint %d:\n"; - char message[sizeof (message1) + 30 /* slop */]; - + char message[sizeof (message1) + 30 /* slop */ ]; + save_language = current_language->la_language; save_input_radix = input_radix; ALL_BREAKPOINTS_SAFE (b, temp) - { - sprintf (message, message1, b->number); /* Format possible error msg */ - catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL); - } + { + sprintf (message, message1, b->number); /* Format possible error msg */ + catch_errors (breakpoint_re_set_one, b, message, RETURN_MASK_ALL); + } set_language (save_language); input_radix = save_input_radix; @@ -6090,12 +6133,12 @@ breakpoint_re_set () - Else, reset it to the current thread for inferior_pid. */ void breakpoint_re_set_thread (b) - struct breakpoint * b; + struct breakpoint *b; { if (b->thread != -1) { if (in_thread_list (inferior_pid)) - b->thread = pid_to_thread_id (inferior_pid); + b->thread = pid_to_thread_id (inferior_pid); } } @@ -6110,22 +6153,22 @@ set_ignore_count (bptnum, count, from_tty) ALL_BREAKPOINTS (b) if (b->number == bptnum) - { - b->ignore_count = count; - if (!from_tty) - return; - else if (count == 0) - printf_filtered ("Will stop next time breakpoint %d is reached.", - bptnum); - else if (count == 1) - printf_filtered ("Will ignore next crossing of breakpoint %d.", - bptnum); - else - printf_filtered ("Will ignore next %d crossings of breakpoint %d.", - count, bptnum); - breakpoints_changed (); + { + b->ignore_count = count; + if (!from_tty) return; - } + else if (count == 0) + printf_filtered ("Will stop next time breakpoint %d is reached.", + bptnum); + else if (count == 1) + printf_filtered ("Will ignore next crossing of breakpoint %d.", + bptnum); + else + printf_filtered ("Will ignore next %d crossings of breakpoint %d.", + count, bptnum); + breakpoints_changed (); + return; + } error ("No breakpoint number %d.", bptnum); } @@ -6152,7 +6195,7 @@ ignore_command (args, from_tty) if (p == 0) error_no_arg ("a breakpoint number"); - + num = get_number (&p); if (*p == 0) @@ -6184,18 +6227,18 @@ map_breakpoint_numbers (args, function) while (*p) { p1 = p; - + num = get_number (&p1); ALL_BREAKPOINTS (b) if (b->number == num) - { - struct breakpoint *related_breakpoint = b->related_breakpoint; - function (b); - if (related_breakpoint) - function (related_breakpoint); - goto win; - } + { + struct breakpoint *related_breakpoint = b->related_breakpoint; + function (b); + if (related_breakpoint) + function (related_breakpoint); + goto win; + } printf_unfiltered ("No breakpoint number %d.\n", num); win: p = p1; @@ -6230,27 +6273,27 @@ disable_command (args, from_tty) if (args == 0) ALL_BREAKPOINTS (bpt) switch (bpt->type) - { - case bp_none: - warning ("attempted to disable apparently deleted breakpoint #%d?\n", bpt->number); - continue; - case bp_breakpoint: - case bp_catch_load: - case bp_catch_unload: - case bp_catch_fork: - case bp_catch_vfork: - case bp_catch_exec: - case bp_catch_catch: - case bp_catch_throw: - case bp_hardware_breakpoint: - case bp_watchpoint: - case bp_hardware_watchpoint: - case bp_read_watchpoint: - case bp_access_watchpoint: - disable_breakpoint (bpt); - default: - continue; - } + { + case bp_none: + warning ("attempted to disable apparently deleted breakpoint #%d?\n", bpt->number); + continue; + case bp_breakpoint: + case bp_catch_load: + case bp_catch_unload: + case bp_catch_fork: + case bp_catch_vfork: + case bp_catch_exec: + case bp_catch_catch: + case bp_catch_throw: + case bp_hardware_breakpoint: + case bp_watchpoint: + case bp_hardware_watchpoint: + case bp_read_watchpoint: + case bp_access_watchpoint: + disable_breakpoint (bpt); + default: + continue; + } else map_breakpoint_numbers (args, disable_breakpoint); } @@ -6268,13 +6311,13 @@ do_enable_breakpoint (bpt, disposition) if (bpt->type == bp_hardware_breakpoint) { int i; - i = hw_breakpoint_used_count(); - target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT( - bp_hardware_breakpoint, i+1, 0); + i = hw_breakpoint_used_count (); + target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT ( + bp_hardware_breakpoint, i + 1, 0); if (target_resources_ok == 0) - error ("No hardware breakpoint support in the target."); + error ("No hardware breakpoint support in the target."); else if (target_resources_ok < 0) - error ("Hardware breakpoints used exceeds limit."); + error ("Hardware breakpoints used exceeds limit."); } bpt->enable = enabled; @@ -6289,11 +6332,11 @@ do_enable_breakpoint (bpt, disposition) { struct frame_info *fr = - /* Ensure that we have the current frame. Else, this - next query may pessimistically be answered as, "No, - not within current scope". */ - get_current_frame (); - fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame); + /* Ensure that we have the current frame. Else, this + next query may pessimistically be answered as, "No, + not within current scope". */ + get_current_frame (); + fr = find_frame_addr_in_frame_chain (bpt->watchpoint_frame); if (fr == NULL) { printf_filtered ("\ @@ -6316,28 +6359,28 @@ is valid is not currently in scope.\n", bpt->number); value_fetch_lazy (bpt->val); if (bpt->type == bp_hardware_watchpoint || - bpt->type == bp_read_watchpoint || - bpt->type == bp_access_watchpoint) - { - int i = hw_watchpoint_used_count (bpt->type, &other_type_used); - int mem_cnt = can_use_hardware_watchpoint (bpt->val); - - /* Hack around 'unused var' error for some targets here */ - (void) mem_cnt, i; - target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT( - bpt->type, i + mem_cnt, other_type_used); - /* we can consider of type is bp_hardware_watchpoint, convert to - bp_watchpoint in the following condition */ - if (target_resources_ok < 0) - { - printf_filtered("\ + bpt->type == bp_read_watchpoint || + bpt->type == bp_access_watchpoint) + { + int i = hw_watchpoint_used_count (bpt->type, &other_type_used); + int mem_cnt = can_use_hardware_watchpoint (bpt->val); + + /* Hack around 'unused var' error for some targets here */ + (void) mem_cnt, i; + target_resources_ok = TARGET_CAN_USE_HARDWARE_WATCHPOINT ( + bpt->type, i + mem_cnt, other_type_used); + /* we can consider of type is bp_hardware_watchpoint, convert to + bp_watchpoint in the following condition */ + if (target_resources_ok < 0) + { + printf_filtered ("\ Cannot enable watchpoint %d because target watch resources\n\ have been allocated for other watchpoints.\n", bpt->number); - bpt->enable = disabled; - value_free_to_mark (mark); - return; - } - } + bpt->enable = disabled; + value_free_to_mark (mark); + return; + } + } if (save_selected_frame_level >= 0) select_and_print_frame (save_selected_frame, save_selected_frame_level); @@ -6368,27 +6411,27 @@ enable_command (args, from_tty) if (args == 0) ALL_BREAKPOINTS (bpt) switch (bpt->type) - { - case bp_none: - warning ("attempted to enable apparently deleted breakpoint #%d?\n", bpt->number); - continue; - case bp_breakpoint: - case bp_catch_load: - case bp_catch_unload: - case bp_catch_fork: - case bp_catch_vfork: - case bp_catch_exec: - case bp_catch_catch: - case bp_catch_throw: - case bp_hardware_breakpoint: - case bp_watchpoint: - case bp_hardware_watchpoint: - case bp_read_watchpoint: - case bp_access_watchpoint: - enable_breakpoint (bpt); - default: - continue; - } + { + case bp_none: + warning ("attempted to enable apparently deleted breakpoint #%d?\n", bpt->number); + continue; + case bp_breakpoint: + case bp_catch_load: + case bp_catch_unload: + case bp_catch_fork: + case bp_catch_vfork: + case bp_catch_exec: + case bp_catch_catch: + case bp_catch_throw: + case bp_hardware_breakpoint: + case bp_watchpoint: + case bp_hardware_watchpoint: + case bp_read_watchpoint: + case bp_access_watchpoint: + enable_breakpoint (bpt); + default: + continue; + } else map_breakpoint_numbers (args, enable_breakpoint); } @@ -6438,10 +6481,10 @@ decode_line_spec_1 (string, funfirstline) if (default_breakpoint_valid) sals = decode_line_1 (&string, funfirstline, default_breakpoint_symtab, default_breakpoint_line, - (char ***)NULL); + (char ***) NULL); else sals = decode_line_1 (&string, funfirstline, - (struct symtab *)NULL, 0, (char ***)NULL); + (struct symtab *) NULL, 0, (char ***) NULL); if (*string) error ("Junk at end of line specification: %s", string); return sals; @@ -6461,7 +6504,7 @@ _initialize_breakpoint () "Set ignore-count of breakpoint number N to COUNT.\n\ Usage is `ignore N COUNT'."); if (xdb_commands) - add_com_alias("bc", "ignore", class_breakpoint, 1); + add_com_alias ("bc", "ignore", class_breakpoint, 1); add_com ("commands", class_breakpoint, commands_command, "Set commands to be executed when a breakpoint is hit.\n\ @@ -6482,8 +6525,8 @@ expression to be evaluated whenever breakpoint N is reached. "); Like \"break\" except the breakpoint is only temporary,\n\ so it will be deleted when hit. Equivalent to \"break\" followed\n\ by using \"enable delete\" on the breakpoint number."); - add_com("txbreak", class_breakpoint, tbreak_at_finish_command, - "Set temporary breakpoint at procedure exit. Either there should\n\ + add_com ("txbreak", class_breakpoint, tbreak_at_finish_command, + "Set temporary breakpoint at procedure exit. Either there should\n\ be no argument or the argument must be a depth.\n"); add_com ("hbreak", class_breakpoint, hbreak_command, @@ -6504,8 +6547,8 @@ This is used to cancel the effect of the \"disable\" command.\n\ With a subcommand you can enable temporarily.", &enablelist, "enable ", 1, &cmdlist); if (xdb_commands) - add_com("ab", class_breakpoint, enable_command, - "Enable some breakpoints.\n\ + add_com ("ab", class_breakpoint, enable_command, + "Enable some breakpoints.\n\ Give breakpoint numbers (separated by spaces) as arguments.\n\ With no subcommand, breakpoints are enabled until you command otherwise.\n\ This is used to cancel the effect of the \"disable\" command.\n\ @@ -6514,11 +6557,11 @@ With a subcommand you can enable temporarily."); add_com_alias ("en", "enable", class_breakpoint, 1); add_abbrev_prefix_cmd ("breakpoints", class_breakpoint, enable_command, - "Enable some breakpoints.\n\ + "Enable some breakpoints.\n\ Give breakpoint numbers (separated by spaces) as arguments.\n\ This is used to cancel the effect of the \"disable\" command.\n\ May be abbreviated to simply \"enable\".\n", - &enablebreaklist, "enable breakpoints ", 1, &enablelist); + &enablebreaklist, "enable breakpoints ", 1, &enablelist); add_cmd ("once", no_class, enable_once_command, "Enable breakpoints for one hit. Give breakpoint numbers.\n\ @@ -6541,7 +6584,7 @@ If a breakpoint is hit while enabled in this fashion, it becomes disabled.", &enablelist); add_prefix_cmd ("disable", class_breakpoint, disable_command, - "Disable some breakpoints.\n\ + "Disable some breakpoints.\n\ Arguments are breakpoint numbers with spaces in between.\n\ To disable all breakpoints, give no argument.\n\ A disabled breakpoint is not forgotten, but has no effect until reenabled.", @@ -6549,8 +6592,8 @@ A disabled breakpoint is not forgotten, but has no effect until reenabled.", add_com_alias ("dis", "disable", class_breakpoint, 1); add_com_alias ("disa", "disable", class_breakpoint, 1); if (xdb_commands) - add_com("sb", class_breakpoint, disable_command, - "Disable some breakpoints.\n\ + add_com ("sb", class_breakpoint, disable_command, + "Disable some breakpoints.\n\ Arguments are breakpoint numbers with spaces in between.\n\ To disable all breakpoints, give no argument.\n\ A disabled breakpoint is not forgotten, but has no effect until reenabled."); @@ -6564,7 +6607,7 @@ This command may be abbreviated \"disable\".", &disablelist); add_prefix_cmd ("delete", class_breakpoint, delete_command, - "Delete some breakpoints or auto-display expressions.\n\ + "Delete some breakpoints or auto-display expressions.\n\ Arguments are breakpoint numbers with spaces in between.\n\ To delete all breakpoints, give no argument.\n\ \n\ @@ -6574,7 +6617,7 @@ The \"unset\" command is also an alias for \"delete\".", add_com_alias ("d", "delete", class_breakpoint, 1); if (xdb_commands) add_com ("db", class_breakpoint, delete_command, - "Delete some breakpoints.\n\ + "Delete some breakpoints.\n\ Arguments are breakpoint numbers with spaces in between.\n\ To delete all breakpoints, give no argument.\n"); @@ -6591,7 +6634,7 @@ Argument may be line number, function name, or \"*\" and an address.\n\ If line number is specified, all breakpoints in that line are cleared.\n\ If function is specified, breakpoints at beginning of function are cleared.\n\ If an address is specified, breakpoints at that address are cleared.\n\n", -"With no argument, clears all breakpoints in the line that the selected frame\n\ + "With no argument, clears all breakpoints in the line that the selected frame\n\ is executing in.\n\ \n\ See also the \"delete\" command which clears breakpoints by number.", NULL)); @@ -6602,7 +6645,7 @@ Argument may be line number, function name, or \"*\" and an address.\n\ If line number is specified, break at start of code for that line.\n\ If function is specified, break at start of code for that function.\n\ If an address is specified, break at that exact address.\n", -"With no arg, uses current execution address of selected stack frame.\n\ + "With no arg, uses current execution address of selected stack frame.\n\ This is useful for breaking on return to a stack frame.\n\ \n\ Multiple breakpoints at one place are permitted, and useful if conditional.\n\ @@ -6613,13 +6656,13 @@ Do \"help breakpoints\" for info on other commands dealing with breakpoints.", N add_com_alias ("bre", "break", class_run, 1); add_com_alias ("brea", "break", class_run, 1); - add_com("xbreak", class_breakpoint, break_at_finish_command, - concat("Set breakpoint at procedure exit. \n\ + add_com ("xbreak", class_breakpoint, break_at_finish_command, + concat ("Set breakpoint at procedure exit. \n\ Argument may be function name, or \"*\" and an address.\n\ If function is specified, break at end of code for that function.\n\ If an address is specified, break at the end of the function that contains \n\ that exact address.\n", -"With no arg, uses current execution address of selected stack frame.\n\ + "With no arg, uses current execution address of selected stack frame.\n\ This is useful for breaking on return to a stack frame.\n\ \n\ Multiple breakpoints at one place are permitted, and useful if conditional.\n\ @@ -6635,21 +6678,21 @@ Do \"help breakpoints\" for info on other commands dealing with breakpoints.", N add_com_alias ("ba", "break", class_breakpoint, 1); add_com_alias ("bu", "ubreak", class_breakpoint, 1); add_com ("bx", class_breakpoint, break_at_finish_at_depth_command, - "Set breakpoint at procedure exit. Either there should\n\ + "Set breakpoint at procedure exit. Either there should\n\ be no argument or the argument must be a depth.\n"); } if (dbx_commands) { - add_abbrev_prefix_cmd("stop", class_breakpoint, stop_command, - "Break in function/address or break at a line in the current file.", - &stoplist, "stop ", 1, &cmdlist); - add_cmd("in", class_breakpoint, stopin_command, - "Break in function or address.\n", &stoplist); - add_cmd("at", class_breakpoint, stopat_command, - "Break at a line in the current file.\n", &stoplist); - add_com("status", class_info, breakpoints_info, - concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\ + add_abbrev_prefix_cmd ("stop", class_breakpoint, stop_command, + "Break in function/address or break at a line in the current file.", + &stoplist, "stop ", 1, &cmdlist); + add_cmd ("in", class_breakpoint, stopin_command, + "Break in function or address.\n", &stoplist); + add_cmd ("at", class_breakpoint, stopat_command, + "Break at a line in the current file.\n", &stoplist); + add_com ("status", class_info, breakpoints_info, + concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\ The \"Type\" column indicates one of:\n\ \tbreakpoint - normal breakpoint\n\ \twatchpoint - watchpoint\n\ @@ -6657,7 +6700,7 @@ The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\ the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\ breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\ address and file/line number respectively.\n\n", -"Convenience variable \"$_\" and default examine address for \"x\"\n\ + "Convenience variable \"$_\" and default examine address for \"x\"\n\ are set to the address of the last breakpoint listed.\n\n\ Convenience variable \"$bpnum\" contains the number of the last\n\ breakpoint set.", NULL)); @@ -6672,14 +6715,14 @@ The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\ the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\ breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\ address and file/line number respectively.\n\n", -"Convenience variable \"$_\" and default examine address for \"x\"\n\ + "Convenience variable \"$_\" and default examine address for \"x\"\n\ are set to the address of the last breakpoint listed.\n\n\ Convenience variable \"$bpnum\" contains the number of the last\n\ breakpoint set.", NULL)); if (xdb_commands) - add_com("lb", class_breakpoint, breakpoints_info, - concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\ + add_com ("lb", class_breakpoint, breakpoints_info, + concat ("Status of user-settable breakpoints, or breakpoint number NUMBER.\n\ The \"Type\" column indicates one of:\n\ \tbreakpoint - normal breakpoint\n\ \twatchpoint - watchpoint\n\ @@ -6687,13 +6730,13 @@ The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\ the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\ breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\ address and file/line number respectively.\n\n", -"Convenience variable \"$_\" and default examine address for \"x\"\n\ + "Convenience variable \"$_\" and default examine address for \"x\"\n\ are set to the address of the last breakpoint listed.\n\n\ Convenience variable \"$bpnum\" contains the number of the last\n\ breakpoint set.", NULL)); add_cmd ("breakpoints", class_maintenance, maintenance_info_breakpoints, - concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\ + concat ("Status of all breakpoints, or breakpoint number NUMBER.\n\ The \"Type\" column indicates one of:\n\ \tbreakpoint - normal breakpoint\n\ \twatchpoint - watchpoint\n\ @@ -6701,18 +6744,18 @@ The \"Type\" column indicates one of:\n\ \tlongjmp resume - internal breakpoint at the target of longjmp()\n\ \tuntil - internal breakpoint used by the \"until\" command\n\ \tfinish - internal breakpoint used by the \"finish\" command\n", -"The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\ + "The \"Disp\" column contains one of \"keep\", \"del\", or \"dis\" to indicate\n\ the disposition of the breakpoint after it gets hit. \"dis\" means that the\n\ breakpoint will be disabled. The \"Address\" and \"What\" columns indicate the\n\ address and file/line number respectively.\n\n", -"Convenience variable \"$_\" and default examine address for \"x\"\n\ + "Convenience variable \"$_\" and default examine address for \"x\"\n\ are set to the address of the last breakpoint listed.\n\n\ Convenience variable \"$bpnum\" contains the number of the last\n\ breakpoint set.", NULL), &maintenanceinfolist); add_com ("catch", class_breakpoint, catch_command, - "Set catchpoints to catch events.\n\ + "Set catchpoints to catch events.\n\ Raised signals may be caught:\n\ \tcatch signal - all signals\n\ \tcatch signal - a particular signal\n\ @@ -6745,15 +6788,15 @@ C++ exceptions may be caught:\n\ Do \"help set follow-fork-mode\" for info on debugging your program\n\ after a fork or vfork is caught.\n\n\ Do \"help breakpoints\" for info on other commands dealing with breakpoints."); - + add_com ("tcatch", class_breakpoint, tcatch_command, - "Set temporary catchpoints to catch events.\n\ + "Set temporary catchpoints to catch events.\n\ Args like \"catch\" command.\n\ Like \"catch\" except the catchpoint is only temporary,\n\ so it will be deleted when hit. Equivalent to \"catch\" followed\n\ by using \"enable delete\" on the catchpoint number."); - -add_com ("watch", class_breakpoint, watch_command, + + add_com ("watch", class_breakpoint, watch_command, "Set a watchpoint for an expression.\n\ A watchpoint stops execution of your program whenever the value of\n\ @@ -6774,13 +6817,13 @@ an expression is either read or written."); c = add_set_cmd ("can-use-hw-watchpoints", class_support, var_zinteger, - (char *) &can_use_hw_watchpoints, - "Set debugger's willingness to use watchpoint hardware.\n\ + (char *) &can_use_hw_watchpoints, + "Set debugger's willingness to use watchpoint hardware.\n\ If zero, gdb will not use hardware for new watchpoints, even if\n\ such is available. (However, any hardware watchpoints that were\n\ created before setting this to nonzero, will continue to use watchpoint\n\ hardware.)", - &setlist); + &setlist); add_show_from_set (c, &showlist); can_use_hw_watchpoints = 1; diff --git a/gdb/breakpoint.h b/gdb/breakpoint.h index 8eec1f5..8061e86 100644 --- a/gdb/breakpoint.h +++ b/gdb/breakpoint.h @@ -1,21 +1,22 @@ /* Data structures associated with breakpoints in GDB. Copyright (C) 1992, 93, 94, 95, 96, 98, 1999 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #if !defined (BREAKPOINT_H) #define BREAKPOINT_H 1 @@ -34,33 +35,34 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ here. This includes: * single-step (for machines where we have to simulate single stepping) - (probably, though perhaps it is better for it to look as much as - possible like a single-step to wait_for_inferior). */ - -enum bptype { - bp_none = 0, /* Eventpoint has been deleted. */ - bp_breakpoint, /* Normal breakpoint */ - bp_hardware_breakpoint, /* Hardware assisted breakpoint */ - bp_until, /* used by until command */ - bp_finish, /* used by finish command */ - bp_watchpoint, /* Watchpoint */ - bp_hardware_watchpoint, /* Hardware assisted watchpoint */ - bp_read_watchpoint, /* read watchpoint, (hardware assisted) */ - bp_access_watchpoint, /* access watchpoint, (hardware assisted) */ - bp_longjmp, /* secret breakpoint to find longjmp() */ - bp_longjmp_resume, /* secret breakpoint to escape longjmp() */ - - /* Used by wait_for_inferior for stepping over subroutine calls, for - stepping over signal handlers, and for skipping prologues. */ - bp_step_resume, - - /* Used by wait_for_inferior for stepping over signal handlers. */ - bp_through_sigtramp, - - /* Used to detect when a watchpoint expression has gone out of - scope. These breakpoints are usually not visible to the user. - - This breakpoint has some interesting properties: + (probably, though perhaps it is better for it to look as much as + possible like a single-step to wait_for_inferior). */ + +enum bptype + { + bp_none = 0, /* Eventpoint has been deleted. */ + bp_breakpoint, /* Normal breakpoint */ + bp_hardware_breakpoint, /* Hardware assisted breakpoint */ + bp_until, /* used by until command */ + bp_finish, /* used by finish command */ + bp_watchpoint, /* Watchpoint */ + bp_hardware_watchpoint, /* Hardware assisted watchpoint */ + bp_read_watchpoint, /* read watchpoint, (hardware assisted) */ + bp_access_watchpoint, /* access watchpoint, (hardware assisted) */ + bp_longjmp, /* secret breakpoint to find longjmp() */ + bp_longjmp_resume, /* secret breakpoint to escape longjmp() */ + + /* Used by wait_for_inferior for stepping over subroutine calls, for + stepping over signal handlers, and for skipping prologues. */ + bp_step_resume, + + /* Used by wait_for_inferior for stepping over signal handlers. */ + bp_through_sigtramp, + + /* Used to detect when a watchpoint expression has gone out of + scope. These breakpoints are usually not visible to the user. + + This breakpoint has some interesting properties: 1) There's always a 1:1 mapping between watchpoints on local variables and watchpoint_scope breakpoints. @@ -69,78 +71,80 @@ enum bptype { associated with when hit. 3) It can never be disabled. */ - bp_watchpoint_scope, - - /* The breakpoint at the end of a call dummy. */ - /* FIXME: What if the function we are calling longjmp()s out of the - call, or the user gets out with the "return" command? We currently - have no way of cleaning up the breakpoint in these (obscure) situations. - (Probably can solve this by noticing longjmp, "return", etc., it's - similar to noticing when a watchpoint on a local variable goes out - of scope (with hardware support for watchpoints)). */ - bp_call_dummy, - - /* Some dynamic linkers (HP, maybe Solaris) can arrange for special - code in the inferior to run when significant events occur in the - dynamic linker (for example a library is loaded or unloaded). - - By placing a breakpoint in this magic code GDB will get control - when these significant events occur. GDB can then re-examine - the dynamic linker's data structures to discover any newly loaded - dynamic libraries. */ - bp_shlib_event, - - /* These breakpoints are used to implement the "catch load" command - on platforms whose dynamic linkers support such functionality. */ - bp_catch_load, - - /* These breakpoints are used to implement the "catch unload" command - on platforms whose dynamic linkers support such functionality. */ - bp_catch_unload, - - /* These are not really breakpoints, but are catchpoints that - implement the "catch fork", "catch vfork" and "catch exec" commands - on platforms whose kernel support such functionality. (I.e., - kernels which can raise an event when a fork or exec occurs, as - opposed to the debugger setting breakpoints on functions named - "fork" or "exec".) */ - bp_catch_fork, - bp_catch_vfork, - bp_catch_exec, - - /* These are catchpoints to implement "catch catch" and "catch throw" - commands for C++ exception handling. */ - bp_catch_catch, - bp_catch_throw - - -}; + bp_watchpoint_scope, + + /* The breakpoint at the end of a call dummy. */ + /* FIXME: What if the function we are calling longjmp()s out of the + call, or the user gets out with the "return" command? We currently + have no way of cleaning up the breakpoint in these (obscure) situations. + (Probably can solve this by noticing longjmp, "return", etc., it's + similar to noticing when a watchpoint on a local variable goes out + of scope (with hardware support for watchpoints)). */ + bp_call_dummy, + + /* Some dynamic linkers (HP, maybe Solaris) can arrange for special + code in the inferior to run when significant events occur in the + dynamic linker (for example a library is loaded or unloaded). + + By placing a breakpoint in this magic code GDB will get control + when these significant events occur. GDB can then re-examine + the dynamic linker's data structures to discover any newly loaded + dynamic libraries. */ + bp_shlib_event, + + /* These breakpoints are used to implement the "catch load" command + on platforms whose dynamic linkers support such functionality. */ + bp_catch_load, + + /* These breakpoints are used to implement the "catch unload" command + on platforms whose dynamic linkers support such functionality. */ + bp_catch_unload, + + /* These are not really breakpoints, but are catchpoints that + implement the "catch fork", "catch vfork" and "catch exec" commands + on platforms whose kernel support such functionality. (I.e., + kernels which can raise an event when a fork or exec occurs, as + opposed to the debugger setting breakpoints on functions named + "fork" or "exec".) */ + bp_catch_fork, + bp_catch_vfork, + bp_catch_exec, + + /* These are catchpoints to implement "catch catch" and "catch throw" + commands for C++ exception handling. */ + bp_catch_catch, + bp_catch_throw + + + }; /* States of enablement of breakpoint. */ -enum enable { - disabled, /* The eventpoint is inactive, and cannot trigger. */ - enabled, /* The eventpoint is active, and can trigger. */ - shlib_disabled, /* The eventpoint's address is within an unloaded solib. - The eventpoint will be automatically enabled & reset - when that solib is loaded. */ - call_disabled /* The eventpoint has been disabled while a call into - the inferior is "in flight", because some eventpoints - interfere with the implementation of a call on some - targets. The eventpoint will be automatically enabled - & reset when the call "lands" (either completes, or - stops at another eventpoint). */ -}; +enum enable + { + disabled, /* The eventpoint is inactive, and cannot trigger. */ + enabled, /* The eventpoint is active, and can trigger. */ + shlib_disabled, /* The eventpoint's address is within an unloaded solib. + The eventpoint will be automatically enabled & reset + when that solib is loaded. */ + call_disabled /* The eventpoint has been disabled while a call into + the inferior is "in flight", because some eventpoints + interfere with the implementation of a call on some + targets. The eventpoint will be automatically enabled + & reset when the call "lands" (either completes, or + stops at another eventpoint). */ + }; /* Disposition of breakpoint. Ie: what to do after hitting it. */ -enum bpdisp { - del, /* Delete it */ - del_at_next_stop, /* Delete at next stop, whether hit or not */ - disable, /* Disable it */ - donttouch /* Leave it alone */ -}; +enum bpdisp + { + del, /* Delete it */ + del_at_next_stop, /* Delete at next stop, whether hit or not */ + disable, /* Disable it */ + donttouch /* Leave it alone */ + }; /* Note that the ->silent field is not currently used by any commands (though the code is in there if it was to be, and set_raw_breakpoint @@ -151,118 +155,118 @@ enum bpdisp { /* This is for a breakpoint or a watchpoint. */ struct breakpoint -{ - struct breakpoint *next; - /* Type of breakpoint. */ - enum bptype type; - /* Zero means disabled; remember the info but don't break here. */ - enum enable enable; - /* What to do with this breakpoint after we hit it. */ - enum bpdisp disposition; - /* Number assigned to distinguish breakpoints. */ - int number; - - /* Address to break at, or NULL if not a breakpoint. */ - CORE_ADDR address; - - /* Line number of this address. Only matters if address is - non-NULL. */ - - int line_number; - - /* Source file name of this address. Only matters if address is - non-NULL. */ - - char *source_file; - - /* Non-zero means a silent breakpoint (don't print frame info - if we stop here). */ - unsigned char silent; - /* Number of stops at this breakpoint that should - be continued automatically before really stopping. */ - int ignore_count; - /* "Real" contents of byte where breakpoint has been inserted. - Valid only when breakpoints are in the program. Under the complete - control of the target insert_breakpoint and remove_breakpoint routines. - No other code should assume anything about the value(s) here. */ - char shadow_contents[BREAKPOINT_MAX]; - /* Nonzero if this breakpoint is now inserted. Only matters if address - is non-NULL. */ - char inserted; - /* Nonzero if this is not the first breakpoint in the list - for the given address. Only matters if address is non-NULL. */ - char duplicate; - /* Chain of command lines to execute when this breakpoint is hit. */ - struct command_line *commands; - /* Stack depth (address of frame). If nonzero, break only if fp - equals this. */ - CORE_ADDR frame; - /* Conditional. Break only if this expression's value is nonzero. */ - struct expression *cond; - - /* String we used to set the breakpoint (malloc'd). Only matters if - address is non-NULL. */ - char *addr_string; - /* Language we used to set the breakpoint. */ - enum language language; - /* Input radix we used to set the breakpoint. */ - int input_radix; - /* String form of the breakpoint condition (malloc'd), or NULL if there - is no condition. */ - char *cond_string; - /* String form of exp (malloc'd), or NULL if none. */ - char *exp_string; - - /* The expression we are watching, or NULL if not a watchpoint. */ - struct expression *exp; - /* The largest block within which it is valid, or NULL if it is - valid anywhere (e.g. consists just of global symbols). */ - struct block *exp_valid_block; - /* Value of the watchpoint the last time we checked it. */ - value_ptr val; - - /* Holds the value chain for a hardware watchpoint expression. */ - value_ptr val_chain; - - /* Holds the address of the related watchpoint_scope breakpoint - when using watchpoints on local variables (might the concept - of a related breakpoint be useful elsewhere, if not just call - it the watchpoint_scope breakpoint or something like that. FIXME). */ - struct breakpoint *related_breakpoint; - - /* Holds the frame address which identifies the frame this watchpoint - should be evaluated in, or NULL if the watchpoint should be evaluated - on the outermost frame. */ - CORE_ADDR watchpoint_frame; - - /* Thread number for thread-specific breakpoint, or -1 if don't care */ - int thread; - - /* Count of the number of times this breakpoint was taken, dumped - with the info, but not used for anything else. Useful for - seeing how many times you hit a break prior to the program - aborting, so you can back up to just before the abort. */ - int hit_count; - - /* Filename of a dynamically-linked library (dll), used for bp_catch_load - and bp_catch_unload (malloc'd), or NULL if any library is significant. */ - char * dll_pathname; - - /* Filename of a dll whose state change (e.g., load or unload) - triggered this catchpoint. This field is only vaid immediately - after this catchpoint has triggered. */ - char * triggered_dll_pathname; - - /* Process id of a child process whose forking triggered this catchpoint. - This field is only vaid immediately after this catchpoint has triggered. */ - int forked_inferior_pid; - - /* Filename of a program whose exec triggered this catchpoint. This - field is only vaid immediately after this catchpoint has triggered. */ - char * exec_pathname; - - asection *section; -}; + { + struct breakpoint *next; + /* Type of breakpoint. */ + enum bptype type; + /* Zero means disabled; remember the info but don't break here. */ + enum enable enable; + /* What to do with this breakpoint after we hit it. */ + enum bpdisp disposition; + /* Number assigned to distinguish breakpoints. */ + int number; + + /* Address to break at, or NULL if not a breakpoint. */ + CORE_ADDR address; + + /* Line number of this address. Only matters if address is + non-NULL. */ + + int line_number; + + /* Source file name of this address. Only matters if address is + non-NULL. */ + + char *source_file; + + /* Non-zero means a silent breakpoint (don't print frame info + if we stop here). */ + unsigned char silent; + /* Number of stops at this breakpoint that should + be continued automatically before really stopping. */ + int ignore_count; + /* "Real" contents of byte where breakpoint has been inserted. + Valid only when breakpoints are in the program. Under the complete + control of the target insert_breakpoint and remove_breakpoint routines. + No other code should assume anything about the value(s) here. */ + char shadow_contents[BREAKPOINT_MAX]; + /* Nonzero if this breakpoint is now inserted. Only matters if address + is non-NULL. */ + char inserted; + /* Nonzero if this is not the first breakpoint in the list + for the given address. Only matters if address is non-NULL. */ + char duplicate; + /* Chain of command lines to execute when this breakpoint is hit. */ + struct command_line *commands; + /* Stack depth (address of frame). If nonzero, break only if fp + equals this. */ + CORE_ADDR frame; + /* Conditional. Break only if this expression's value is nonzero. */ + struct expression *cond; + + /* String we used to set the breakpoint (malloc'd). Only matters if + address is non-NULL. */ + char *addr_string; + /* Language we used to set the breakpoint. */ + enum language language; + /* Input radix we used to set the breakpoint. */ + int input_radix; + /* String form of the breakpoint condition (malloc'd), or NULL if there + is no condition. */ + char *cond_string; + /* String form of exp (malloc'd), or NULL if none. */ + char *exp_string; + + /* The expression we are watching, or NULL if not a watchpoint. */ + struct expression *exp; + /* The largest block within which it is valid, or NULL if it is + valid anywhere (e.g. consists just of global symbols). */ + struct block *exp_valid_block; + /* Value of the watchpoint the last time we checked it. */ + value_ptr val; + + /* Holds the value chain for a hardware watchpoint expression. */ + value_ptr val_chain; + + /* Holds the address of the related watchpoint_scope breakpoint + when using watchpoints on local variables (might the concept + of a related breakpoint be useful elsewhere, if not just call + it the watchpoint_scope breakpoint or something like that. FIXME). */ + struct breakpoint *related_breakpoint; + + /* Holds the frame address which identifies the frame this watchpoint + should be evaluated in, or NULL if the watchpoint should be evaluated + on the outermost frame. */ + CORE_ADDR watchpoint_frame; + + /* Thread number for thread-specific breakpoint, or -1 if don't care */ + int thread; + + /* Count of the number of times this breakpoint was taken, dumped + with the info, but not used for anything else. Useful for + seeing how many times you hit a break prior to the program + aborting, so you can back up to just before the abort. */ + int hit_count; + + /* Filename of a dynamically-linked library (dll), used for bp_catch_load + and bp_catch_unload (malloc'd), or NULL if any library is significant. */ + char *dll_pathname; + + /* Filename of a dll whose state change (e.g., load or unload) + triggered this catchpoint. This field is only vaid immediately + after this catchpoint has triggered. */ + char *triggered_dll_pathname; + + /* Process id of a child process whose forking triggered this catchpoint. + This field is only vaid immediately after this catchpoint has triggered. */ + int forked_inferior_pid; + + /* Filename of a program whose exec triggered this catchpoint. This + field is only vaid immediately after this catchpoint has triggered. */ + char *exec_pathname; + + asection *section; + }; /* The following stuff is an abstract data type "bpstat" ("breakpoint status"). This provides the ability to determine whether we have stopped at a @@ -284,71 +288,73 @@ extern bpstat bpstat_stop_status PARAMS ((CORE_ADDR *, int)); /* This bpstat_what stuff tells wait_for_inferior what to do with a breakpoint (a challenging task). */ -enum bpstat_what_main_action { - /* Perform various other tests; that is, this bpstat does not - say to perform any action (e.g. failed watchpoint and nothing - else). */ - BPSTAT_WHAT_KEEP_CHECKING, - - /* Rather than distinguish between noisy and silent stops here, it - might be cleaner to have bpstat_print make that decision (also - taking into account stop_print_frame and source_only). But the - implications are a bit scary (interaction with auto-displays, etc.), - so I won't try it. */ - - /* Stop silently. */ - BPSTAT_WHAT_STOP_SILENT, - - /* Stop and print. */ - BPSTAT_WHAT_STOP_NOISY, - - /* Remove breakpoints, single step once, then put them back in and - go back to what we were doing. It's possible that this should be - removed from the main_action and put into a separate field, to more - cleanly handle BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE. */ - BPSTAT_WHAT_SINGLE, - - /* Set longjmp_resume breakpoint, remove all other breakpoints, - and continue. The "remove all other breakpoints" part is required - if we are also stepping over another breakpoint as well as doing - the longjmp handling. */ - BPSTAT_WHAT_SET_LONGJMP_RESUME, - - /* Clear longjmp_resume breakpoint, then handle as - BPSTAT_WHAT_KEEP_CHECKING. */ - BPSTAT_WHAT_CLEAR_LONGJMP_RESUME, - - /* Clear longjmp_resume breakpoint, then handle as BPSTAT_WHAT_SINGLE. */ - BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE, - - /* Clear step resume breakpoint, and keep checking. */ - BPSTAT_WHAT_STEP_RESUME, - - /* Clear through_sigtramp breakpoint, muck with trap_expected, and keep - checking. */ - BPSTAT_WHAT_THROUGH_SIGTRAMP, - - /* Check the dynamic linker's data structures for new libraries, then - keep checking. */ - BPSTAT_WHAT_CHECK_SHLIBS, - - /* Check the dynamic linker's data structures for new libraries, then - resume out of the dynamic linker's callback, stop and print. */ - BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK, - - /* This is just used to keep track of how many enums there are. */ - BPSTAT_WHAT_LAST -}; - -struct bpstat_what { - enum bpstat_what_main_action main_action; - - /* Did we hit a call dummy breakpoint? This only goes with a main_action - of BPSTAT_WHAT_STOP_SILENT or BPSTAT_WHAT_STOP_NOISY (the concept of - continuing from a call dummy without popping the frame is not a - useful one). */ - int call_dummy; -}; +enum bpstat_what_main_action + { + /* Perform various other tests; that is, this bpstat does not + say to perform any action (e.g. failed watchpoint and nothing + else). */ + BPSTAT_WHAT_KEEP_CHECKING, + + /* Rather than distinguish between noisy and silent stops here, it + might be cleaner to have bpstat_print make that decision (also + taking into account stop_print_frame and source_only). But the + implications are a bit scary (interaction with auto-displays, etc.), + so I won't try it. */ + + /* Stop silently. */ + BPSTAT_WHAT_STOP_SILENT, + + /* Stop and print. */ + BPSTAT_WHAT_STOP_NOISY, + + /* Remove breakpoints, single step once, then put them back in and + go back to what we were doing. It's possible that this should be + removed from the main_action and put into a separate field, to more + cleanly handle BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE. */ + BPSTAT_WHAT_SINGLE, + + /* Set longjmp_resume breakpoint, remove all other breakpoints, + and continue. The "remove all other breakpoints" part is required + if we are also stepping over another breakpoint as well as doing + the longjmp handling. */ + BPSTAT_WHAT_SET_LONGJMP_RESUME, + + /* Clear longjmp_resume breakpoint, then handle as + BPSTAT_WHAT_KEEP_CHECKING. */ + BPSTAT_WHAT_CLEAR_LONGJMP_RESUME, + + /* Clear longjmp_resume breakpoint, then handle as BPSTAT_WHAT_SINGLE. */ + BPSTAT_WHAT_CLEAR_LONGJMP_RESUME_SINGLE, + + /* Clear step resume breakpoint, and keep checking. */ + BPSTAT_WHAT_STEP_RESUME, + + /* Clear through_sigtramp breakpoint, muck with trap_expected, and keep + checking. */ + BPSTAT_WHAT_THROUGH_SIGTRAMP, + + /* Check the dynamic linker's data structures for new libraries, then + keep checking. */ + BPSTAT_WHAT_CHECK_SHLIBS, + + /* Check the dynamic linker's data structures for new libraries, then + resume out of the dynamic linker's callback, stop and print. */ + BPSTAT_WHAT_CHECK_SHLIBS_RESUME_FROM_HOOK, + + /* This is just used to keep track of how many enums there are. */ + BPSTAT_WHAT_LAST + }; + +struct bpstat_what + { + enum bpstat_what_main_action main_action; + + /* Did we hit a call dummy breakpoint? This only goes with a main_action + of BPSTAT_WHAT_STOP_SILENT or BPSTAT_WHAT_STOP_NOISY (the concept of + continuing from a call dummy without popping the frame is not a + useful one). */ + int call_dummy; + }; /* Tell what to do about this bpstat. */ struct bpstat_what bpstat_what PARAMS ((bpstat)); @@ -364,9 +370,9 @@ bpstat bpstat_find_breakpoint PARAMS ((bpstat, struct breakpoint *)); step_resume breakpoint. See wait_for_inferior's use of this function. - */ + */ extern struct breakpoint * -bpstat_find_step_resume_breakpoint PARAMS ((bpstat)); + bpstat_find_step_resume_breakpoint PARAMS ((bpstat)); /* Nonzero if a signal that we got in wait() was due to circumstances explained by the BS. */ @@ -405,45 +411,45 @@ extern void bpstat_clear_actions PARAMS ((bpstat)); /* Given a bpstat that records zero or more triggered eventpoints, this function returns another bpstat which contains only the catchpoints on that first list, if any. - */ + */ extern void bpstat_get_triggered_catchpoints PARAMS ((bpstat, bpstat *)); - + /* Implementation: */ struct bpstats -{ - /* Linked list because there can be two breakpoints at the - same place, and a bpstat reflects the fact that both have been hit. */ - bpstat next; - /* Breakpoint that we are at. */ - struct breakpoint *breakpoint_at; - /* Commands left to be done. */ - struct command_line *commands; - /* Old value associated with a watchpoint. */ - value_ptr old_val; - - /* Nonzero if this breakpoint tells us to print the frame. */ - char print; - - /* Nonzero if this breakpoint tells us to stop. */ - char stop; - - /* Function called by bpstat_print to print stuff associated with - this element of the bpstat chain. Returns 0 or 1 just like - bpstat_print, or -1 if it can't deal with it. */ - int (*print_it) PARAMS((bpstat bs)); -}; + { + /* Linked list because there can be two breakpoints at the + same place, and a bpstat reflects the fact that both have been hit. */ + bpstat next; + /* Breakpoint that we are at. */ + struct breakpoint *breakpoint_at; + /* Commands left to be done. */ + struct command_line *commands; + /* Old value associated with a watchpoint. */ + value_ptr old_val; + + /* Nonzero if this breakpoint tells us to print the frame. */ + char print; + + /* Nonzero if this breakpoint tells us to stop. */ + char stop; + + /* Function called by bpstat_print to print stuff associated with + this element of the bpstat chain. Returns 0 or 1 just like + bpstat_print, or -1 if it can't deal with it. */ + int (*print_it) PARAMS ((bpstat bs)); + }; enum inf_context -{ - inf_starting, - inf_running, - inf_exited -}; - + { + inf_starting, + inf_running, + inf_exited + }; + /* Prototypes for breakpoint-related functions. */ -#ifdef __STDC__ /* Forward declarations for prototypes */ +#ifdef __STDC__ /* Forward declarations for prototypes */ struct frame_info; #endif @@ -500,16 +506,16 @@ extern int reattach_breakpoints PARAMS ((int)); This function causes the following: - - All eventpoints are marked "not inserted". - - All eventpoints with a symbolic address are reset such that - the symbolic address must be reevaluated before the eventpoints - can be reinserted. - - The solib breakpoints are explicitly removed from the breakpoint - list. - - A step-resume breakpoint, if any, is explicitly removed from the - breakpoint list. - - All eventpoints without a symbolic address are removed from the - breakpoint list. */ + - All eventpoints are marked "not inserted". + - All eventpoints with a symbolic address are reset such that + the symbolic address must be reevaluated before the eventpoints + can be reinserted. + - The solib breakpoints are explicitly removed from the breakpoint + list. + - A step-resume breakpoint, if any, is explicitly removed from the + breakpoint list. + - All eventpoints without a symbolic address are removed from the + breakpoint list. */ extern void update_breakpoints_after_exec PARAMS ((void)); /* This function can be used to physically remove hardware breakpoints @@ -518,11 +524,11 @@ extern void update_breakpoints_after_exec PARAMS ((void)); those targets which support following the processes of a fork() or vfork() system call, when one of the resulting two processes is to be detached and allowed to run free. - + It is an error to use this function on the process whose id is inferior_pid. */ extern int detach_breakpoints PARAMS ((int)); - + extern void enable_longjmp_breakpoint PARAMS ((void)); extern void disable_longjmp_breakpoint PARAMS ((void)); @@ -556,7 +562,7 @@ disable_watchpoints_before_interactive_call_start PARAMS ((void)); extern void enable_watchpoints_after_interactive_call_stop PARAMS ((void)); - + extern void clear_breakpoint_hit_counts PARAMS ((void)); /* The following are for displays, which aren't really breakpoints, but @@ -583,23 +589,23 @@ extern void disable_breakpoints_in_shlibs PARAMS ((int silent)); extern void re_enable_breakpoints_in_shlibs PARAMS ((void)); extern void create_solib_load_event_breakpoint PARAMS ((char *, int, char *, char *)); - + extern void create_solib_unload_event_breakpoint PARAMS ((char *, int, char *, char *)); - + extern void create_fork_event_catchpoint PARAMS ((int, char *)); - + extern void create_vfork_event_catchpoint PARAMS ((int, char *)); extern void create_exec_event_catchpoint PARAMS ((int, char *)); - + /* This function returns TRUE if ep is a catchpoint. */ extern int ep_is_catchpoint PARAMS ((struct breakpoint *)); - + /* This function returns TRUE if ep is a catchpoint of a shared library (aka dynamically-linked library) event, such as a library load or unload. */ extern int ep_is_shlib_catchpoint PARAMS ((struct breakpoint *)); - + extern struct breakpoint *set_breakpoint_sal PARAMS ((struct symtab_and_line)); #endif /* !defined (BREAKPOINT_H) */ diff --git a/gdb/buildsym.c b/gdb/buildsym.c index 24b64be..860f4aa 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -1,21 +1,22 @@ /* Support routines for building symbol tables in GDB's internal format. Copyright 1986-1999 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ /* This module provides subroutines used for creating and adding to the symbol table. These routines are called from various symbol- @@ -35,7 +36,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "gdb_string.h" /* Ask buildsym.h to define the vars it normally declares `extern'. */ -#define EXTERN /**/ +#define EXTERN +/**/ #include "buildsym.h" /* Our own declarations */ #undef EXTERN @@ -220,7 +222,7 @@ finish_block (struct symbol *symbol, struct pending **listhead, } block = (struct block *) obstack_alloc (&objfile->symbol_obstack, - (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *)))); + (sizeof (struct block) + ((i - 1) * sizeof (struct symbol *)))); /* Copy the symbols into the block. */ @@ -382,7 +384,7 @@ finish_block (struct symbol *symbol, struct pending **listhead, else { complain (&innerblock_anon_complaint, BLOCK_START (pblock->block), - BLOCK_END (pblock->block), BLOCK_START (block), + BLOCK_END (pblock->block), BLOCK_START (block), BLOCK_END (block)); } if (BLOCK_START (pblock->block) < BLOCK_START (block)) @@ -569,7 +571,7 @@ start_subfile (char *name, char *dirname) program. But to demangle we need to set the language to C++. We can distinguish cfront code by the fact that it has #line directives which specify a file name ending in .C. - + So if the filename of this subfile ends in .C, then change the language of any pending subfiles from C to C++. We also accept any other C++ suffixes accepted by deduce_language_from_filename @@ -695,7 +697,7 @@ record_line (register struct subfile *subfile, int line, CORE_ADDR pc) subfile->line_vector_length = INITIAL_LINE_VECTOR_LENGTH; subfile->line_vector = (struct linetable *) xmalloc (sizeof (struct linetable) - + subfile->line_vector_length * sizeof (struct linetable_entry)); + + subfile->line_vector_length * sizeof (struct linetable_entry)); subfile->line_vector->nitems = 0; have_line_numbers = 1; } @@ -855,7 +857,7 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section) /* Cleanup any undefined types that have been left hanging around (this needs to be done before the finish_blocks so that file_symbols is still good). - + Both cleanup_undefined_types and finish_global_stabs are stabs specific, but harmless for other symbol readers, since on gdb startup or when finished reading stabs, the state is set so these @@ -921,7 +923,7 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section) if (objfile->flags & OBJF_REORDERED) qsort (subfile->line_vector->item, subfile->line_vector->nitems, - sizeof (struct linetable_entry), compare_line_numbers); + sizeof (struct linetable_entry), compare_line_numbers); } /* Now, allocate a symbol table. */ @@ -968,8 +970,8 @@ end_symtab (CORE_ADDR end_addr, struct objfile *objfile, int section) if (subfile->debugformat != NULL) { symtab->debugformat = obsavestring (subfile->debugformat, - strlen (subfile->debugformat), - &objfile->symbol_obstack); + strlen (subfile->debugformat), + &objfile->symbol_obstack); } /* All symtabs for the main file and the subfiles share a @@ -1025,7 +1027,7 @@ push_context (int desc, CORE_ADDR valu) context_stack_size *= 2; context_stack = (struct context_stack *) xrealloc ((char *) context_stack, - (context_stack_size * sizeof (struct context_stack))); + (context_stack_size * sizeof (struct context_stack))); } new = &context_stack[context_stack_depth++]; diff --git a/gdb/buildsym.h b/gdb/buildsym.h index e3a34c9..f16ffc5 100644 --- a/gdb/buildsym.h +++ b/gdb/buildsym.h @@ -1,21 +1,22 @@ /* Build symbol tables in GDB's internal format. Copyright 1986-1993, 1996-1999 Free Software Foundation, Inc. -This file is part of GDB. - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #if !defined (BUILDSYM_H) #define BUILDSYM_H 1 diff --git a/gdb/c-lang.c b/gdb/c-lang.c index efed49d..308f8d4 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -1,21 +1,22 @@ /* C language support routines for GDB, the GNU debugger. Copyright 1992, 1993, 1994 Free Software Foundation, Inc. -This file is part of GDB. + This file is part of GDB. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ #include "defs.h" #include "symtab.h" @@ -26,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "c-lang.h" extern void _initialize_c_language PARAMS ((void)); -static void c_emit_char PARAMS ((int c, GDB_FILE *stream, int quoter)); +static void c_emit_char PARAMS ((int c, GDB_FILE * stream, int quoter)); /* Print the character C on STREAM as part of the contents of a literal string whose delimiter is QUOTER. Note that that format for printing @@ -117,7 +118,7 @@ c_printstr (stream, string, length, width, force_ellipses) style. */ if (!force_ellipses && length > 0 - && extract_unsigned_integer (string + (length - 1) * width, width) == '\0') + && extract_unsigned_integer (string + (length - 1) * width, width) == '\0') length--; if (length == 0) @@ -129,7 +130,7 @@ c_printstr (stream, string, length, width, force_ellipses) for (i = 0; i < length && things_printed < print_max; ++i) { /* Position of the character we are examining - to see whether it is repeated. */ + to see whether it is repeated. */ unsigned int rep1; /* Number of repetitions we have detected so far. */ unsigned int reps; @@ -149,7 +150,7 @@ c_printstr (stream, string, length, width, force_ellipses) reps = 1; while (rep1 < length && extract_unsigned_integer (string + rep1 * width, width) - == current_char) + == current_char) { ++rep1; ++reps; @@ -231,191 +232,192 @@ c_create_fundamental_type (objfile, typeid) switch (typeid) { - default: - /* FIXME: For now, if we are asked to produce a type not in this - language, create the equivalent of a C integer type with the - name "". When all the dust settles from the type - reconstruction work, this should probably become an error. */ - type = init_type (TYPE_CODE_INT, - TARGET_INT_BIT / TARGET_CHAR_BIT, - 0, "", objfile); - warning ("internal error: no C/C++ fundamental type %d", typeid); - break; - case FT_VOID: - type = init_type (TYPE_CODE_VOID, - TARGET_CHAR_BIT / TARGET_CHAR_BIT, - 0, "void", objfile); - break; - case FT_BOOLEAN: - type = init_type (TYPE_CODE_BOOL, - TARGET_CHAR_BIT / TARGET_CHAR_BIT, - 0, "bool", objfile); - - break; - case FT_CHAR: - type = init_type (TYPE_CODE_INT, - TARGET_CHAR_BIT / TARGET_CHAR_BIT, - 0, "char", objfile); - TYPE_FLAGS (type) |= TYPE_FLAG_NOSIGN; - break; - case FT_SIGNED_CHAR: - type = init_type (TYPE_CODE_INT, - TARGET_CHAR_BIT / TARGET_CHAR_BIT, - 0, "signed char", objfile); - break; - case FT_UNSIGNED_CHAR: - type = init_type (TYPE_CODE_INT, - TARGET_CHAR_BIT / TARGET_CHAR_BIT, - TYPE_FLAG_UNSIGNED, "unsigned char", objfile); - break; - case FT_SHORT: - type = init_type (TYPE_CODE_INT, - TARGET_SHORT_BIT / TARGET_CHAR_BIT, - 0, "short", objfile); - break; - case FT_SIGNED_SHORT: - type = init_type (TYPE_CODE_INT, - TARGET_SHORT_BIT / TARGET_CHAR_BIT, - 0, "short", objfile); /* FIXME-fnf */ - break; - case FT_UNSIGNED_SHORT: - type = init_type (TYPE_CODE_INT, - TARGET_SHORT_BIT / TARGET_CHAR_BIT, - TYPE_FLAG_UNSIGNED, "unsigned short", objfile); - break; - case FT_INTEGER: - type = init_type (TYPE_CODE_INT, - TARGET_INT_BIT / TARGET_CHAR_BIT, - 0, "int", objfile); - break; - case FT_SIGNED_INTEGER: - type = init_type (TYPE_CODE_INT, - TARGET_INT_BIT / TARGET_CHAR_BIT, - 0, "int", objfile); /* FIXME -fnf */ - break; - case FT_UNSIGNED_INTEGER: - type = init_type (TYPE_CODE_INT, - TARGET_INT_BIT / TARGET_CHAR_BIT, - TYPE_FLAG_UNSIGNED, "unsigned int", objfile); - break; - case FT_LONG: - type = init_type (TYPE_CODE_INT, - TARGET_LONG_BIT / TARGET_CHAR_BIT, - 0, "long", objfile); - break; - case FT_SIGNED_LONG: - type = init_type (TYPE_CODE_INT, - TARGET_LONG_BIT / TARGET_CHAR_BIT, - 0, "long", objfile); /* FIXME -fnf */ - break; - case FT_UNSIGNED_LONG: - type = init_type (TYPE_CODE_INT, - TARGET_LONG_BIT / TARGET_CHAR_BIT, - TYPE_FLAG_UNSIGNED, "unsigned long", objfile); - break; - case FT_LONG_LONG: - type = init_type (TYPE_CODE_INT, - TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, - 0, "long long", objfile); - break; - case FT_SIGNED_LONG_LONG: - type = init_type (TYPE_CODE_INT, - TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, - 0, "signed long long", objfile); - break; - case FT_UNSIGNED_LONG_LONG: - type = init_type (TYPE_CODE_INT, - TARGET_LONG_LONG_BIT / TARGET_CHAR_BIT, - TYPE_FLAG_UNSIGNED, "unsigned long long", objfile); - break; - case FT_FLOAT: - type = init_type (TYPE_CODE_FLT, - TARGET_FLOAT_BIT / TARGET_CHAR_BIT, - 0, "float", objfile); - break; - case FT_DBL_PREC_FLOAT: - type = init_type (TYPE_CODE_FLT, - TARGET_DOUBLE_BIT / TARGET_CHAR_BIT, - 0, "double", objfile); - break; - case FT_EXT_PREC_FLOAT: - type = init_type (TYPE_CODE_FLT, - TARGET_LONG_DOUBLE_BIT / TARGET_CHAR_BIT, - 0, "long double", objfile); - break; - case FT_TEMPLATE_ARG: - type = init_type (TYPE_CODE_TEMPLATE_ARG, - 0, - 0, "