Back to home page

LXR

 
 

    


Warning, /bsps/mips/shared/gdbstub/README.md is written in an unsupported language. File is not indexed.

0001 GDB stub
0002 ========
0003 
0004 Debugged this stub against the MongooseV bsp.  Relies on putting break
0005 instructions on breakpoints and step targets- normal stuff, and does not
0006 employ hardware breakpoint support at this time.  As written, a single
0007 breakpoint in a loop will not be reasserted unless the user steps or has
0008 a 2nd one, since breakpoints are only reset when the gdb stub is
0009 re-entered.  A useful enhancement would be to fix the break instruction
0010 management so the stub could invisibly put a 2nd break after the 1st
0011 "official" one so it can silently reset breakpoints.  Shouldn't be too
0012 hard, mostly a matter of working it out.
0013 
0014 This was tested only against an R3000 MIPS.  It should work OK on a
0015 R4000.  Needs to be tested at some point.
0016 
0017 This stub supports threads as implemented by gdb 5 and doesn't have any
0018 bugs I'm aware of.
0019 
0020 Greg Menke
0021 3/5/2002
0022 
0023 The contents of this directory are based upon the "r46kstub.tar.gz" package
0024 released to the net by
0025 
0026         C. M. Heard
0027         VVNET, Inc.                           phone:  +1 408 247 9376
0028         4040 Moorpark Ave. Suite 206          fax:    +1 408 244 3651
0029         San Jose, CA 95117 USA                e-mail: heard@vvnet.com
0030 
0031 This package was released in the September 1996 time frame for use
0032 with gdb 4.16 and an IDT R4600 Orion.   The stub was modified to support
0033 R3000 class CPUs and to work within the mips-rtems exeception processing
0034 framework.
0035 
0036 The file memlimits.h could end up being target board dependent.  If
0037 this is the case, copy it to your BSP directory and modify as necessary.
0038 
0039 
0040 Original README 
0041 ---------------
0042 
0043 The r46kstub directory and its compressed archive (r46kstub.tar.gz) contain
0044 the 9/29/96 source code snapshot for a ROM-resident gdb-4.16 debug agent
0045 (aka stub) for the IDT R4600 Orion processor.  It is based on the stub for
0046 the Hitachi SH processor written by Ben Lee and Steve Chamberlain and
0047 supplied with the gdb-4.16 distribution;  that stub in turn was "originally
0048 based on an m68k software stub written by Glenn Engel at HP, but has changed
0049 quite a bit".  The modifications for the R4600 were contributed by C. M.
0050 Heard of VVNET, Inc. and were based in part on the Algorithmics R4000 version
0051 of Phil Bunce's PMON program.
0052 
0053 The distribution consists of the following files:
0054 
0055 ```
0056 -rw-r--r--   1    1178 Sep 29 16:34 ChangeLog
0057 -rw-r--r--   1     748 Jul 26 01:18 Makefile
0058 -rw-r--r--   1    6652 Sep 29 16:34 README
0059 -rw-r--r--   1    1829 May 21 02:02 gdb_if.h
0060 -rw-r--r--   1    3745 Sep 29 14:03 ioaddr.h
0061 -rw-r--r--   1    2906 Sep 29 14:39 limits.h
0062 -rw-r--r--   1    6552 May 23 00:17 mips_opcode.h
0063 -rw-r--r--   1   14017 May 21 02:04 r4600.h
0064 -rw-r--r--   1   23874 Jul 21 20:31 r46kstub.c
0065 -rw-r--r--   1    1064 Jul  3 12:35 r46kstub.ld
0066 -rw-r--r--   1   13299 Sep 29 16:24 stubinit.S
0067 ```
0068 
0069 With the exception of mips_opcode.h, which is a slightly modified version
0070 of a header file contributed by Ralph Campbell to 4.4 BSD and is therefore
0071 copyrighted by the UC Regents, all of the source files have been dedicated
0072 by their authors to the public domain.  Use them as you wish, but do so
0073 at your own risk!  The authors accept _no_ responsibility for any errors.
0074 
0075 The debug agent contained herein is at this writing in active use at VVNET
0076 supporting initial hardware debug and board bring-up of an OC-12 ATM probe
0077 board.  It uses polled I/O on a 16C450 UART.  We had originally intended to
0078 add support for interrupts to allow gdb to break in on a running program,
0079 but we have found that this is not really necessary since the reset button
0080 will accomplish the same purpose (thanks to the MIPS feature of saving the
0081 program counter in the ErrorEPC register when a reset exception occurs).
0082 
0083 Be aware that this stub handles ALL interrupts and exceptions except for
0084 reset (or NMI) in the same way -- by passing control to the debug command
0085 loop.  It of course uses the ROM exception vectors to do so.  In order to
0086 support code that actally needs to use interrupts we use use a more elaborate
0087 stub that is linked with the downloaded program.  It hooks the RAM exception
0088 vectors and clears the BEV status bit to gain control.  The ROM-based stub
0089 is still used in this case for initial program loading.
0090 
0091 In order to port this stub to a different platform you will at a minimum
0092 need to customize the macros in limits.h (which define the limits of readable,
0093 writeable, and steppable address space) and the I/O addresses in ioaddr.h
0094 (which define the 16C450 MMIO addresses).  If you use something other than
0095 a 16C450 UART you will probably also need to modify the portions of stubinit.S
0096 which deal with the serial port.  I've tried to be careful to respect all the
0097 architecturally-defined hazards as described in Appendix F of Kane and
0098 Heinrich, MIPS RISC Architecture, in order to minimize the work in porting
0099 to 4000-series processors other than the R4600, but no guarantees are offered.
0100 Support is presently restricted to big-endian addressing, and I've not even
0101 considered what changes would be needed for little-endian support.
0102 
0103 When this stub is built with gcc-2.7.2 and binutils-2.6 you will see a few
0104 warning messages from the single-step support routine where a cast is used
0105 to sign-extend a pointer (the next instruction address) into a long long
0106 (the PC image).  Those warnings are expected;  I've checked the generated
0107 code and it is doing what I had intended.  But you should not see any other
0108 warnings or errors.  Here is a log of the build:
0109 
0110 ```shell
0111 mips64orion-idt-elf-gcc -g -Wa,-ahld -Wall -membedded-data \
0112         -O3 -c r46kstub.c >r46kstub.L
0113 r46kstub.c: In function `doSStep':
0114 r46kstub.c:537: warning: cast to pointer from integer of different size
0115 r46kstub.c:539: warning: cast to pointer from integer of different size
0116 r46kstub.c:547: warning: cast to pointer from integer of different size
0117 r46kstub.c:561: warning: cast to pointer from integer of different size
0118 r46kstub.c:563: warning: cast to pointer from integer of different size
0119 r46kstub.c:572: warning: cast to pointer from integer of different size
0120 r46kstub.c:574: warning: cast to pointer from integer of different size
0121 r46kstub.c:582: warning: cast to pointer from integer of different size
0122 r46kstub.c:589: warning: cast to pointer from integer of different size
0123 r46kstub.c:591: warning: cast to pointer from integer of different size
0124 r46kstub.c:597: warning: cast to pointer from integer of different size
0125 r46kstub.c:599: warning: cast to pointer from integer of different size
0126 r46kstub.c:605: warning: cast to pointer from integer of different size
0127 r46kstub.c:607: warning: cast to pointer from integer of different size
0128 r46kstub.c:613: warning: cast to pointer from integer of different size
0129 r46kstub.c:615: warning: cast to pointer from integer of different size
0130 r46kstub.c:624: warning: cast to pointer from integer of different size
0131 r46kstub.c:628: warning: cast to pointer from integer of different size
0132 r46kstub.c:635: warning: cast to pointer from integer of different size
0133 r46kstub.c:637: warning: cast to pointer from integer of different size
0134 mips64orion-idt-elf-gcc -g -Wa,-ahld -Wall -membedded-data \
0135         -O3 -c stubinit.S >stubinit.L
0136 mips64orion-idt-elf-ld -t -s -T r46kstub.ld -Map r46kstub.map -o r46kstub.out
0137 mips64orion-idt-elf-ld: mode elf32bmip
0138 stubinit.o
0139 r46kstub.o
0140 mips64orion-idt-elf-objcopy -S -R .bss -R .data -R .reginfo \
0141                                 -O srec r46kstub.out r46kstub.hex
0142 ```
0143 
0144 Limitations: stubinit.S deliberately forces the PC (which is a 64-bit
0145 register) to contain a legitimate sign-extended 32-bit value.  This was
0146 done to cope with a bug in gdb-4.16, which does _not_ properly sign-extend
0147 the initial PC when it loads a program.  This means that you cannot use
0148 the "set" command to load an unmapped sixty-four bit virtual address into
0149 the PC, as you can for all other registers.
0150 
0151 Please send bug reports, comments, or suggestions for improvement to: