aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/lib/java/io/DataInputStream.class
blob: 6730b4a924133eaa31103e7230e3573f516d93df (plain)
ofshex dumpascii
0000 ca fe ba be 00 00 00 31 00 bb 07 00 02 01 00 17 6a 61 76 61 2f 69 6f 2f 44 61 74 61 49 6e 70 75 .......1........java/io/DataInpu
0020 74 53 74 72 65 61 6d 07 00 04 01 00 19 6a 61 76 61 2f 69 6f 2f 46 69 6c 74 65 72 49 6e 70 75 74 tStream......java/io/FilterInput
0040 53 74 72 65 61 6d 07 00 06 01 00 11 6a 61 76 61 2f 69 6f 2f 44 61 74 61 49 6e 70 75 74 01 00 03 Stream......java/io/DataInput...
0060 62 75 66 01 00 02 5b 42 01 00 06 3c 69 6e 69 74 3e 01 00 18 28 4c 6a 61 76 61 2f 69 6f 2f 49 6e buf...[B...<init>...(Ljava/io/In
0080 70 75 74 53 74 72 65 61 6d 3b 29 56 01 00 04 43 6f 64 65 0a 00 03 00 0d 0c 00 09 00 0a 09 00 01 putStream;)V...Code.............
00a0 00 0f 0c 00 07 00 08 01 00 0f 4c 69 6e 65 4e 75 6d 62 65 72 54 61 62 6c 65 01 00 12 4c 6f 63 61 ..........LineNumberTable...Loca
00c0 6c 56 61 72 69 61 62 6c 65 54 61 62 6c 65 01 00 04 74 68 69 73 01 00 19 4c 6a 61 76 61 2f 69 6f lVariableTable...this...Ljava/io
00e0 2f 44 61 74 61 49 6e 70 75 74 53 74 72 65 61 6d 3b 01 00 02 69 6e 01 00 15 4c 6a 61 76 61 2f 69 /DataInputStream;...in...Ljava/i
0100 6f 2f 49 6e 70 75 74 53 74 72 65 61 6d 3b 01 00 04 72 65 61 64 01 00 05 28 5b 42 29 49 01 00 0a o/InputStream;...read...([B)I...
0120 45 78 63 65 70 74 69 6f 6e 73 07 00 1a 01 00 13 6a 61 76 61 2f 69 6f 2f 49 4f 45 78 63 65 70 74 Exceptions......java/io/IOExcept
0140 69 6f 6e 09 00 01 00 1c 0c 00 14 00 15 0a 00 1e 00 20 07 00 1f 01 00 13 6a 61 76 61 2f 69 6f 2f ion.....................java/io/
0160 49 6e 70 75 74 53 74 72 65 61 6d 0c 00 16 00 21 01 00 07 28 5b 42 49 49 29 49 01 00 01 62 01 00 InputStream....!...([BII)I...b..
0180 03 6f 66 66 01 00 01 49 01 00 03 6c 65 6e 01 00 0b 72 65 61 64 42 6f 6f 6c 65 61 6e 01 00 03 28 .off...I...len...readBoolean...(
01a0 29 5a 0a 00 1e 00 29 0c 00 16 00 2a 01 00 03 28 29 49 0a 00 01 00 2c 0c 00 2d 00 2e 01 00 10 63 )Z....)....*...()I....,..-.....c
01c0 6f 6e 76 65 72 74 54 6f 42 6f 6f 6c 65 61 6e 01 00 04 28 49 29 5a 01 00 08 72 65 61 64 42 79 74 onvertToBoolean...(I)Z...readByt
01e0 65 01 00 03 28 29 42 0a 00 01 00 32 0c 00 33 00 34 01 00 0d 63 6f 6e 76 65 72 74 54 6f 42 79 74 e...()B....2..3.4...convertToByt
0200 65 01 00 04 28 49 29 42 01 00 08 72 65 61 64 43 68 61 72 01 00 03 28 29 43 0a 00 01 00 38 0c 00 e...(I)B...readChar...()C....8..
0220 39 00 3a 01 00 09 72 65 61 64 46 75 6c 6c 79 01 00 07 28 5b 42 49 49 29 56 0a 00 01 00 3c 0c 00 9.:...readFully...([BII)V....<..
0240 3d 00 3e 01 00 0d 63 6f 6e 76 65 72 74 54 6f 43 68 61 72 01 00 05 28 5b 42 29 43 01 00 0a 72 65 =.>...convertToChar...([B)C...re
0260 61 64 44 6f 75 62 6c 65 01 00 03 28 29 44 0a 00 01 00 42 0c 00 43 00 44 01 00 08 72 65 61 64 4c adDouble...()D....B..C.D...readL
0280 6f 6e 67 01 00 03 28 29 4a 0a 00 46 00 48 07 00 47 01 00 10 6a 61 76 61 2f 6c 61 6e 67 2f 44 6f ong...()J..F.H..G...java/lang/Do
02a0 75 62 6c 65 0c 00 49 00 4a 01 00 10 6c 6f 6e 67 42 69 74 73 54 6f 44 6f 75 62 6c 65 01 00 04 28 uble..I.J...longBitsToDouble...(
02c0 4a 29 44 01 00 09 72 65 61 64 46 6c 6f 61 74 01 00 03 28 29 46 0a 00 01 00 4e 0c 00 4f 00 2a 01 J)D...readFloat...()F....N..O.*.
02e0 00 07 72 65 61 64 49 6e 74 0a 00 51 00 53 07 00 52 01 00 0f 6a 61 76 61 2f 6c 61 6e 67 2f 46 6c ..readInt..Q.S..R...java/lang/Fl
0300 6f 61 74 0c 00 54 00 55 01 00 0e 69 6e 74 42 69 74 73 54 6f 46 6c 6f 61 74 01 00 04 28 49 29 46 oat..T.U...intBitsToFloat...(I)F
0320 01 00 05 28 5b 42 29 56 07 00 58 01 00 23 6a 61 76 61 2f 6c 61 6e 67 2f 49 6e 64 65 78 4f 75 74 ...([B)V..X..#java/lang/IndexOut
0340 4f 66 42 6f 75 6e 64 73 45 78 63 65 70 74 69 6f 6e 07 00 5a 01 00 17 6a 61 76 61 2f 6c 61 6e 67 OfBoundsException..Z...java/lang
0360 2f 53 74 72 69 6e 67 42 75 69 6c 64 65 72 08 00 5c 01 00 11 4e 65 67 61 74 69 76 65 20 6c 65 6e /StringBuilder..\...Negative.len
0380 67 74 68 3a 20 0a 00 59 00 5e 0c 00 09 00 5f 01 00 15 28 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 gth:...Y.^...._...(Ljava/lang/St
03a0 72 69 6e 67 3b 29 56 0a 00 59 00 61 0c 00 62 00 63 01 00 06 61 70 70 65 6e 64 01 00 1c 28 49 29 ring;)V..Y.a..b.c...append...(I)
03c0 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 42 75 69 6c 64 65 72 3b 0a 00 59 00 65 0c 00 Ljava/lang/StringBuilder;..Y.e..
03e0 66 00 67 01 00 08 74 6f 53 74 72 69 6e 67 01 00 14 28 29 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 f.g...toString...()Ljava/lang/St
0400 72 69 6e 67 3b 0a 00 57 00 5e 07 00 6a 01 00 14 6a 61 76 61 2f 69 6f 2f 45 4f 46 45 78 63 65 70 ring;..W.^..j...java/io/EOFExcep
0420 74 69 6f 6e 0a 00 69 00 6c 0c 00 09 00 6d 01 00 03 28 29 56 01 00 06 6f 66 66 73 65 74 01 00 07 tion..i.l....m...()V...offset...
0440 6e 75 6d 72 65 61 64 0a 00 01 00 71 0c 00 72 00 17 01 00 0c 63 6f 6e 76 65 72 74 54 6f 49 6e 74 numread....q..r.....convertToInt
0460 01 00 08 72 65 61 64 4c 69 6e 65 01 00 0a 44 65 70 72 65 63 61 74 65 64 07 00 76 01 00 16 6a 61 ...readLine...Deprecated..v...ja
0480 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 42 75 66 66 65 72 0a 00 75 00 6c 0a 00 75 00 79 0c 00 va/lang/StringBuffer..u.l..u.y..
04a0 7a 00 2a 01 00 06 6c 65 6e 67 74 68 0a 00 75 00 65 07 00 7d 01 00 1b 6a 61 76 61 2f 69 6f 2f 50 z.*...length..u.e..}...java/io/P
04c0 75 73 68 62 61 63 6b 49 6e 70 75 74 53 74 72 65 61 6d 0a 00 7c 00 0d 0a 00 7c 00 80 0c 00 81 00 ushbackInputStream..|....|......
04e0 82 01 00 06 75 6e 72 65 61 64 01 00 04 28 49 29 56 0a 00 75 00 84 0c 00 62 00 85 01 00 1b 28 43 ....unread...(I)V..u....b.....(C
0500 29 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 42 75 66 66 65 72 3b 08 00 87 01 00 00 01 )Ljava/lang/StringBuffer;.......
0520 00 04 73 74 72 62 01 00 18 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 42 75 66 66 65 72 ..strb...Ljava/lang/StringBuffer
0540 3b 01 00 01 63 01 00 06 6e 65 78 74 5f 63 0a 00 01 00 8d 0c 00 8e 00 8f 01 00 0d 63 6f 6e 76 65 ;...c...next_c.............conve
0560 72 74 54 6f 4c 6f 6e 67 01 00 05 28 5b 42 29 4a 01 00 09 72 65 61 64 53 68 6f 72 74 01 00 03 28 rtToLong...([B)J...readShort...(
0580 29 53 0a 00 01 00 93 0c 00 94 00 95 01 00 0e 63 6f 6e 76 65 72 74 54 6f 53 68 6f 72 74 01 00 05 )S.............convertToShort...
05a0 28 5b 42 29 53 01 00 10 72 65 61 64 55 6e 73 69 67 6e 65 64 42 79 74 65 0a 00 01 00 98 0c 00 99 ([B)S...readUnsignedByte........
05c0 00 9a 01 00 15 63 6f 6e 76 65 72 74 54 6f 55 6e 73 69 67 6e 65 64 42 79 74 65 01 00 04 28 49 29 .....convertToUnsignedByte...(I)
05e0 49 01 00 11 72 65 61 64 55 6e 73 69 67 6e 65 64 53 68 6f 72 74 0a 00 01 00 9d 0c 00 9e 00 17 01 I...readUnsignedShort...........
0600 00 16 63 6f 6e 76 65 72 74 54 6f 55 6e 73 69 67 6e 65 64 53 68 6f 72 74 01 00 07 72 65 61 64 55 ..convertToUnsignedShort...readU
0620 54 46 0a 00 01 00 a1 0c 00 9f 00 a2 01 00 27 28 4c 6a 61 76 61 2f 69 6f 2f 44 61 74 61 49 6e 70 TF............'(Ljava/io/DataInp
0640 75 74 3b 29 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 3b 0b 00 05 00 a4 0c 00 9b 00 2a ut;)Ljava/lang/String;.........*
0660 0b 00 05 00 38 0a 00 01 00 a7 0c 00 a8 00 a9 01 00 0e 63 6f 6e 76 65 72 74 46 72 6f 6d 55 54 46 ....8.............convertFromUTF
0680 01 00 16 28 5b 42 29 4c 6a 61 76 61 2f 6c 61 6e 67 2f 53 74 72 69 6e 67 3b 01 00 13 4c 6a 61 76 ...([B)Ljava/lang/String;...Ljav
06a0 61 2f 69 6f 2f 44 61 74 61 49 6e 70 75 74 3b 01 00 06 55 54 46 6c 65 6e 01 00 09 73 6b 69 70 42 a/io/DataInput;...UTFlen...skipB
06c0 79 74 65 73 0a 00 1e 00 ae 0c 00 af 00 b0 01 00 04 73 6b 69 70 01 00 04 28 4a 29 4a 01 00 01 6e ytes.............skip...(J)J...n
06e0 01 00 01 69 07 00 b4 01 00 1e 6a 61 76 61 2f 69 6f 2f 55 54 46 44 61 74 61 46 6f 72 6d 61 74 45 ...i......java/io/UTFDataFormatE
0700 78 63 65 70 74 69 6f 6e 0a 00 75 00 b6 0c 00 09 00 82 0a 00 b3 00 6c 01 00 06 73 74 72 62 75 66 xception..u...........l...strbuf
0720 01 00 0a 53 6f 75 72 63 65 46 69 6c 65 01 00 14 44 61 74 61 49 6e 70 75 74 53 74 72 65 61 6d 2e ...SourceFile...DataInputStream.
0740 6a 61 76 61 00 21 00 01 00 03 00 01 00 05 00 01 00 00 00 07 00 08 00 00 00 1c 00 01 00 09 00 0a java.!..........................
0760 00 01 00 0b 00 00 00 4a 00 02 00 02 00 00 00 0e 2a 2b b7 00 0c 2a 10 08 bc 08 b5 00 0e b1 00 00 .......J........*+...*..........
0780 00 02 00 10 00 00 00 0e 00 03 00 00 00 46 00 05 00 3c 00 0d 00 47 00 11 00 00 00 16 00 02 00 00 .............F...<...G..........
07a0 00 0e 00 12 00 13 00 00 00 00 00 0e 00 14 00 15 00 01 00 11 00 16 00 17 00 02 00 18 00 00 00 04 ................................
07c0 00 01 00 19 00 0b 00 00 00 40 00 04 00 02 00 00 00 0c 2a b4 00 1b 2b 03 2b be b6 00 1d ac 00 00 .........@........*...+.+.......
07e0 00 02 00 10 00 00 00 06 00 01 00 00 00 58 00 11 00 00 00 16 00 02 00 00 00 0c 00 12 00 13 00 00 .............X..................
0800 00 00 00 0c 00 22 00 08 00 01 00 11 00 16 00 21 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 .....".........!................
0820 00 53 00 04 00 04 00 00 00 0b 2a b4 00 1b 2b 1c 1d b6 00 1d ac 00 00 00 02 00 10 00 00 00 06 00 .S........*...+.................
0840 01 00 00 00 6d 00 11 00 00 00 2a 00 04 00 00 00 0b 00 12 00 13 00 00 00 00 00 0b 00 22 00 08 00 ....m.....*................."...
0860 01 00 00 00 0b 00 23 00 24 00 02 00 00 00 0b 00 25 00 24 00 03 00 11 00 26 00 27 00 02 00 18 00 ......#.$.......%.$.....&.'.....
0880 00 00 04 00 01 00 19 00 0b 00 00 00 35 00 01 00 01 00 00 00 0b 2a b4 00 1b b6 00 28 b8 00 2b ac ............5........*.....(..+.
08a0 00 00 00 02 00 10 00 00 00 06 00 01 00 00 00 84 00 11 00 00 00 0c 00 01 00 00 00 0b 00 12 00 13 ................................
08c0 00 00 00 11 00 2f 00 30 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 35 00 01 00 01 00 00 ...../.0.................5......
08e0 00 0b 2a b4 00 1b b6 00 28 b8 00 31 ac 00 00 00 02 00 10 00 00 00 06 00 01 00 00 00 98 00 11 00 ..*.....(..1....................
0900 00 00 0c 00 01 00 00 00 0b 00 12 00 13 00 00 00 11 00 35 00 36 00 02 00 18 00 00 00 04 00 01 00 ..................5.6...........
0920 19 00 0b 00 00 00 40 00 04 00 01 00 00 00 12 2a 2a b4 00 0e 03 05 b6 00 37 2a b4 00 0e b8 00 3b ......@........**.......7*.....;
0940 ac 00 00 00 02 00 10 00 00 00 0a 00 02 00 00 00 b6 00 0a 00 b7 00 11 00 00 00 0c 00 01 00 00 00 ................................
0960 12 00 12 00 13 00 00 00 11 00 3f 00 40 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 32 00 ..........?.@.................2.
0980 02 00 01 00 00 00 08 2a b6 00 41 b8 00 45 af 00 00 00 02 00 10 00 00 00 06 00 01 00 00 00 d1 00 .......*..A..E..................
09a0 11 00 00 00 0c 00 01 00 00 00 08 00 12 00 13 00 00 00 11 00 4b 00 4c 00 02 00 18 00 00 00 04 00 ....................K.L.........
09c0 01 00 19 00 0b 00 00 00 32 00 01 00 01 00 00 00 08 2a b6 00 4d b8 00 50 ae 00 00 00 02 00 10 00 ........2........*..M..P........
09e0 00 00 06 00 01 00 00 00 ea 00 11 00 00 00 0c 00 01 00 00 00 08 00 12 00 13 00 00 00 11 00 39 00 ..............................9.
0a00 56 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 41 00 04 00 02 00 00 00 09 2a 2b 03 2b be V.................A........*+.+.
0a20 b6 00 37 b1 00 00 00 02 00 10 00 00 00 0a 00 02 00 00 00 fd 00 08 00 fe 00 11 00 00 00 16 00 02 ..7.............................
0a40 00 00 00 09 00 12 00 13 00 00 00 00 00 09 00 22 00 08 00 01 00 11 00 39 00 3a 00 02 00 18 00 00 ...............".......9.:......
0a60 00 04 00 01 00 19 00 0b 00 00 00 b6 00 05 00 05 00 00 00 44 1d 9c 00 3e bb 00 57 59 bb 00 59 59 ...................D...>..WY..YY
0a80 12 5b b7 00 5d 1d b6 00 60 b6 00 64 b7 00 68 bf 2a b4 00 1b 2b 1c 1d b6 00 1d 36 04 15 04 9c 00 .[..]...`..d..h.*...+.....6.....
0aa0 0b bb 00 69 59 b7 00 6b bf 1d 15 04 64 3e 1c 15 04 60 3d 1d 9d ff dc b1 00 00 00 02 00 10 00 00 ...iY..k....d>...`=.............
0ac0 00 26 00 09 00 00 01 15 00 04 01 16 00 1c 01 1b 00 28 01 1c 00 2d 01 1d 00 35 01 1e 00 3a 01 1f .&...............(...-...5...:..
0ae0 00 3f 01 18 00 43 01 21 00 11 00 00 00 34 00 05 00 00 00 44 00 12 00 13 00 00 00 00 00 44 00 07 .?...C.!.....4.....D.........D..
0b00 00 08 00 01 00 00 00 44 00 6e 00 24 00 02 00 00 00 44 00 25 00 24 00 03 00 28 00 17 00 6f 00 24 .......D.n.$.....D.%.$...(...o.$
0b20 00 04 00 11 00 4f 00 2a 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 40 00 04 00 01 00 00 .....O.*.................@......
0b40 00 12 2a 2a b4 00 0e 03 07 b6 00 37 2a b4 00 0e b8 00 70 ac 00 00 00 02 00 10 00 00 00 0a 00 02 ..**.......7*.....p.............
0b60 00 00 01 40 00 0a 01 41 00 11 00 00 00 0c 00 01 00 00 00 12 00 12 00 13 00 00 00 11 00 73 00 67 ...@...A.....................s.g
0b80 00 03 00 18 00 00 00 04 00 01 00 19 00 74 00 00 00 00 00 0b 00 00 01 0d 00 04 00 04 00 00 00 89 .............t..................
0ba0 bb 00 75 59 b7 00 77 4c 2a b4 00 1b b6 00 28 3d 1c 02 a0 00 13 2b b6 00 78 9e 00 0a 2b b6 00 7b ..uY..wL*.....(=.....+..x...+..{
0bc0 a7 00 04 01 b0 1c 10 0d a0 00 3d 2a b4 00 1b b6 00 28 3e 1d 10 0a 9f 00 42 1d 02 9f 00 3d 2a b4 ..........=*.....(>.....B....=*.
0be0 00 1b c1 00 7c 9a 00 12 2a bb 00 7c 59 2a b4 00 1b b7 00 7e b5 00 1b 2a b4 00 1b c0 00 7c 1d b6 ....|...*..|Y*.....~...*.....|..
0c00 00 7f a7 00 16 1c 10 0a a0 00 06 a7 00 0d 2b 1c 92 b6 00 83 57 a7 ff 93 2b b6 00 78 9e 00 0a 2b ..............+.....W...+..x...+
0c20 b6 00 7b a7 00 05 12 86 b0 00 00 00 02 00 10 00 00 00 42 00 10 00 00 01 60 00 08 01 64 00 10 01 ..{...............B.....`...d...
0c40 65 00 15 01 66 00 25 01 67 00 2b 01 69 00 33 01 6a 00 3e 01 6c 00 48 01 6d 00 57 01 6e 00 62 01 e...f.%.g.+.i.3.j.>.l.H.m.W.n.b.
0c60 70 00 65 01 72 00 6b 01 73 00 6e 01 74 00 75 01 62 00 78 01 77 00 11 00 00 00 2a 00 04 00 00 00 p.e.r.k.s.n.t.u.b.x.w.....*.....
0c80 89 00 12 00 13 00 00 00 08 00 81 00 88 00 89 00 01 00 10 00 65 00 8a 00 24 00 02 00 33 00 32 00 ....................e...$...3.2.
0ca0 8b 00 24 00 03 00 11 00 43 00 44 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 41 00 04 00 ..$.....C.D.................A...
0cc0 01 00 00 00 13 2a 2a b4 00 0e 03 10 08 b6 00 37 2a b4 00 0e b8 00 8c ad 00 00 00 02 00 10 00 00 .....**........7*...............
0ce0 00 0a 00 02 00 00 01 9b 00 0b 01 9c 00 11 00 00 00 0c 00 01 00 00 00 13 00 12 00 13 00 00 00 11 ................................
0d00 00 90 00 91 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 40 00 04 00 01 00 00 00 12 2a 2a .....................@........**
0d20 b4 00 0e 03 05 b6 00 37 2a b4 00 0e b8 00 92 ac 00 00 00 02 00 10 00 00 00 0a 00 02 00 00 01 bc .......7*.......................
0d40 00 0a 01 bd 00 11 00 00 00 0c 00 01 00 00 00 12 00 12 00 13 00 00 00 11 00 96 00 2a 00 02 00 18 ...........................*....
0d60 00 00 00 04 00 01 00 19 00 0b 00 00 00 35 00 01 00 01 00 00 00 0b 2a b4 00 1b b6 00 28 b8 00 97 .............5........*.....(...
0d80 ac 00 00 00 02 00 10 00 00 00 06 00 01 00 00 01 d2 00 11 00 00 00 0c 00 01 00 00 00 0b 00 12 00 ................................
0da0 13 00 00 00 11 00 9b 00 2a 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 40 00 04 00 01 00 ........*.................@.....
0dc0 00 00 12 2a 2a b4 00 0e 03 05 b6 00 37 2a b4 00 0e b8 00 9c ac 00 00 00 02 00 10 00 00 00 0a 00 ...**.......7*..................
0de0 02 00 00 01 f2 00 0a 01 f3 00 11 00 00 00 0c 00 01 00 00 00 12 00 12 00 13 00 00 00 11 00 9f 00 ................................
0e00 67 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 2f 00 01 00 01 00 00 00 05 2a b8 00 a0 b0 g................./........*....
0e20 00 00 00 02 00 10 00 00 00 06 00 01 00 00 02 3f 00 11 00 00 00 0c 00 01 00 00 00 05 00 12 00 13 ...............?................
0e40 00 00 00 19 00 9f 00 a2 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 63 00 04 00 03 00 00 .........................c......
0e60 00 19 2a b9 00 a3 01 00 3c 1b bc 08 4d 2a 2c 03 1b b9 00 a5 04 00 2c b8 00 a6 b0 00 00 00 02 00 ..*.....<...M*,.......,.........
0e80 10 00 00 00 12 00 04 00 00 02 50 00 07 02 51 00 0b 02 57 00 14 02 59 00 11 00 00 00 20 00 03 00 ..........P...Q...W...Y.........
0ea0 00 00 19 00 14 00 aa 00 00 00 07 00 12 00 ab 00 24 00 01 00 0b 00 0e 00 07 00 08 00 02 00 11 00 ................$...............
0ec0 ac 00 9a 00 02 00 18 00 00 00 04 00 01 00 19 00 0b 00 00 00 60 00 03 00 02 00 00 00 14 1b 9d 00 ....................`...........
0ee0 05 03 ac 2a b4 00 1b 1b 85 b6 00 ad 88 ac 57 1b ac 00 01 00 06 00 10 00 11 00 69 00 02 00 10 00 ...*..........W...........i.....
0f00 00 00 16 00 05 00 00 02 6e 00 04 02 6f 00 06 02 72 00 11 02 74 00 12 02 78 00 11 00 00 00 16 00 ........n...o...r...t...x.......
0f20 02 00 00 00 14 00 12 00 13 00 00 00 00 00 14 00 b1 00 24 00 01 00 08 00 2d 00 2e 00 02 00 18 00 ..................$.....-.......
0f40 00 00 04 00 01 00 69 00 0b 00 00 00 46 00 02 00 01 00 00 00 14 1a 9c 00 0b bb 00 69 59 b7 00 6b ......i.....F..............iY..k
0f60 bf 1a 99 00 05 04 ac 03 ac 00 00 00 02 00 10 00 00 00 0e 00 03 00 00 02 7d 00 04 02 7e 00 0c 02 ........................}...~...
0f80 80 00 11 00 00 00 0c 00 01 00 00 00 14 00 22 00 24 00 00 00 08 00 33 00 34 00 02 00 18 00 00 00 ..............".$.....3.4.......
0fa0 04 00 01 00 69 00 0b 00 00 00 41 00 02 00 01 00 00 00 0f 1a 9c 00 0b bb 00 69 59 b7 00 6b bf 1a ....i.....A..............iY..k..
0fc0 91 ac 00 00 00 02 00 10 00 00 00 0e 00 03 00 00 02 85 00 04 02 86 00 0c 02 88 00 11 00 00 00 0c ................................
0fe0 00 01 00 00 00 0f 00 b2 00 24 00 00 00 08 00 99 00 9a 00 02 00 18 00 00 00 04 00 01 00 69 00 0b .........$...................i..
1000 00 00 00 44 00 02 00 01 00 00 00 12 1a 9c 00 0b bb 00 69 59 b7 00 6b bf 1a 11 00 ff 7e ac 00 00 ...D..............iY..k.....~...
1020 00 02 00 10 00 00 00 0e 00 03 00 00 02 8d 00 04 02 8e 00 0c 02 90 00 11 00 00 00 0c 00 01 00 00 ................................
1040 00 12 00 b2 00 24 00 00 00 08 00 3d 00 3e 00 01 00 0b 00 00 00 42 00 03 00 01 00 00 00 10 2a 03 .....$.....=.>.......B........*.
1060 33 10 08 78 2a 04 33 11 00 ff 7e 80 92 ac 00 00 00 02 00 10 00 00 00 0e 00 03 00 00 02 95 00 06 3..x*.3...~.....................
1080 02 96 00 0d 02 95 00 11 00 00 00 0c 00 01 00 00 00 10 00 07 00 08 00 00 00 08 00 94 00 95 00 01 ................................
10a0 00 0b 00 00 00 42 00 03 00 01 00 00 00 10 2a 03 33 10 08 78 2a 04 33 11 00 ff 7e 80 93 ac 00 00 .....B........*.3..x*.3...~.....
10c0 00 02 00 10 00 00 00 0e 00 03 00 00 02 9b 00 06 02 9c 00 0d 02 9b 00 11 00 00 00 0c 00 01 00 00 ................................
10e0 00 10 00 07 00 08 00 00 00 08 00 9e 00 17 00 01 00 0b 00 00 00 45 00 03 00 01 00 00 00 13 2a 03 .....................E........*.
1100 33 11 00 ff 7e 10 08 78 2a 04 33 11 00 ff 7e 80 ac 00 00 00 02 00 10 00 00 00 0e 00 03 00 00 02 3...~..x*.3...~.................
1120 a1 00 0a 02 a2 00 11 02 a1 00 11 00 00 00 0c 00 01 00 00 00 13 00 07 00 08 00 00 00 08 00 72 00 ..............................r.
1140 17 00 01 00 0b 00 00 00 6b 00 03 00 01 00 00 00 29 2a 03 33 11 00 ff 7e 10 18 78 2a 04 33 11 00 ........k.......)*.3...~..x*.3..
1160 ff 7e 10 10 78 80 2a 05 33 11 00 ff 7e 10 08 78 80 2a 06 33 11 00 ff 7e 80 ac 00 00 00 02 00 10 .~..x.*.3...~..x.*.3...~........
1180 00 00 00 1e 00 07 00 00 02 a7 00 0a 02 a8 00 14 02 a7 00 15 02 a9 00 1f 02 a7 00 20 02 aa 00 27 ...............................'
11a0 02 a7 00 11 00 00 00 0c 00 01 00 00 00 29 00 07 00 08 00 00 00 08 00 8e 00 8f 00 01 00 0b 00 00 .............)..................
11c0 00 c1 00 05 00 01 00 00 00 5f 2a 03 33 11 00 ff 7e 85 10 38 79 2a 04 33 11 00 ff 7e 85 10 30 79 ........._*.3...~..8y*.3...~..0y
11e0 81 2a 05 33 11 00 ff 7e 85 10 28 79 81 2a 06 33 11 00 ff 7e 85 10 20 79 81 2a 07 33 11 00 ff 7e .*.3...~..(y.*.3...~...y.*.3...~
1200 85 10 18 79 81 2a 08 33 11 00 ff 7e 85 10 10 79 81 2a 10 06 33 11 00 ff 7e 85 10 08 79 81 2a 10 ...y.*.3...~...y.*..3...~...y.*.
1220 07 33 11 00 ff 7e 85 81 ad 00 00 00 02 00 10 00 00 00 3e 00 0f 00 00 02 af 00 0b 02 b0 00 16 02 .3...~............>.............
1240 af 00 17 02 b1 00 22 02 af 00 23 02 b2 00 2e 02 af 00 2f 02 b3 00 3a 02 af 00 3b 02 b4 00 46 02 ......"...#......./...:...;...F.
1260 af 00 47 02 b5 00 53 02 af 00 54 02 b6 00 5d 02 af 00 11 00 00 00 0c 00 01 00 00 00 5f 00 07 00 ..G...S...T...]............._...
1280 08 00 00 00 08 00 a8 00 a9 00 02 00 18 00 00 00 06 00 02 00 69 00 b3 00 0b 00 00 01 8b 00 04 00 ....................i...........
12a0 03 00 00 00 f5 bb 00 75 59 2a be 05 6c 05 60 b7 00 b5 4c 03 3d a7 00 da 2a 1c 33 11 00 80 7e 9a .......uY*..l.`...L.=...*.3...~.
12c0 00 16 2b 2a 1c 84 02 01 33 11 00 ff 7e 92 b6 00 83 57 a7 00 bd 2a 1c 33 11 00 e0 7e 11 00 c0 a0 ..+*....3...~....W...*.3...~....
12e0 00 41 1c 04 60 2a be a2 00 12 2a 1c 04 60 33 11 00 c0 7e 11 00 80 9f 00 0b bb 00 b3 59 b7 00 b7 .A..`*....*..`3...~.........Y...
1300 bf 2b 2a 1c 84 02 01 33 10 1f 7e 10 06 78 2a 1c 84 02 01 33 10 3f 7e 80 92 b6 00 83 57 a7 00 72 .+*....3..~..x*....3.?~.....W..r
1320 2a 1c 33 11 00 f0 7e 11 00 e0 a0 00 5d 1c 05 60 2a be a2 00 21 2a 1c 04 60 33 11 00 c0 7e 11 00 *.3...~.....]..`*...!*..`3...~..
1340 80 a0 00 12 2a 1c 05 60 33 11 00 c0 7e 11 00 80 9f 00 0b bb 00 b3 59 b7 00 b7 bf 2b 2a 1c 84 02 ....*..`3...~.........Y....+*...
1360 01 33 10 0f 7e 10 0c 78 2a 1c 84 02 01 33 10 3f 7e 10 06 78 80 2a 1c 84 02 01 33 10 3f 7e 80 92 .3..~..x*....3.?~..x.*....3.?~..
1380 b6 00 83 57 a7 00 0b bb 00 b3 59 b7 00 b7 bf 1c 2a be a1 ff 26 2b b6 00 7b b0 00 00 00 02 00 10 ...W......Y.....*...&+..{.......
13a0 00 00 00 5e 00 17 00 00 02 c2 00 0e 02 c4 00 13 02 c6 00 1d 02 c7 00 30 02 c8 00 3d 02 ca 00 45 ...^...................0...=...E
13c0 02 cb 00 54 02 cc 00 5c 02 ce 00 69 02 cf 00 74 02 ce 00 7b 02 d1 00 88 02 d3 00 90 02 d4 00 9f ...T...\...i...t...{............
13e0 02 d5 00 ae 02 d6 00 b6 02 d8 00 c3 02 d9 00 d0 02 da 00 db 02 d8 00 e2 02 dd 00 ea 02 c4 00 f0 ................................
1400 02 e1 00 11 00 00 00 20 00 03 00 00 00 f5 00 07 00 08 00 00 00 0e 00 e7 00 b8 00 89 00 01 00 10 ................................
1420 00 e0 00 b2 00 24 00 02 00 01 00 b9 00 00 00 02 00 ba .....$............
69 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
/* Target-dependent code for GNU/Linux running on the Fujitsu FR-V,
   for GDB.

   Copyright (C) 2004-2016 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 3 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, see <http://www.gnu.org/licenses/>.  */

#include "defs.h"
#include "gdbcore.h"
#include "target.h"
#include "frame.h"
#include "osabi.h"
#include "regcache.h"
#include "elf-bfd.h"
#include "elf/frv.h"
#include "frv-tdep.h"
#include "trad-frame.h"
#include "frame-unwind.h"
#include "regset.h"
#include "linux-tdep.h"

/* Define the size (in bytes) of an FR-V instruction.  */
static const int frv_instr_size = 4;

enum {
  NORMAL_SIGTRAMP = 1,
  RT_SIGTRAMP = 2
};

static int
frv_linux_pc_in_sigtramp (struct gdbarch *gdbarch, CORE_ADDR pc,
			  const char *name)
{
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  gdb_byte buf[frv_instr_size];
  LONGEST instr;
  int retval = 0;

  if (target_read_memory (pc, buf, sizeof buf) != 0)
    return 0;

  instr = extract_unsigned_integer (buf, sizeof buf, byte_order);

  if (instr == 0x8efc0077)	/* setlos #__NR_sigreturn, gr7 */
    retval = NORMAL_SIGTRAMP;
  else if (instr == 0x8efc00ad)	/* setlos #__NR_rt_sigreturn, gr7 */
    retval = RT_SIGTRAMP;
  else
    return 0;

  if (target_read_memory (pc + frv_instr_size, buf, sizeof buf) != 0)
    return 0;
  instr = extract_unsigned_integer (buf, sizeof buf, byte_order);
  if (instr != 0xc0700000)	/* tira	gr0, 0 */
    return 0;

  /* If we get this far, we'll return a non-zero value, either
     NORMAL_SIGTRAMP (1) or RT_SIGTRAMP (2).  */
  return retval;
}

/* Given NEXT_FRAME, the "callee" frame of the sigtramp frame that we
   wish to decode, and REGNO, one of the frv register numbers defined
   in frv-tdep.h, return the address of the saved register (corresponding
   to REGNO) in the sigtramp frame.  Return -1 if the register is not
   found in the sigtramp frame.  The magic numbers in the code below
   were computed by examining the following kernel structs:

   From arch/frv/kernel/signal.c:

      struct sigframe
      {
	      void (*pretcode)(void);
	      int sig;
	      struct sigcontext sc;
	      unsigned long extramask[_NSIG_WORDS-1];
	      uint32_t retcode[2];
      };

      struct rt_sigframe
      {
	      void (*pretcode)(void);
	      int sig;
	      struct siginfo *pinfo;
	      void *puc;
	      struct siginfo info;
	      struct ucontext uc;
	      uint32_t retcode[2];
      };

   From include/asm-frv/ucontext.h:

      struct ucontext {
	      unsigned long		uc_flags;
	      struct ucontext		*uc_link;
	      stack_t			uc_stack;
	      struct sigcontext	uc_mcontext;
	      sigset_t		uc_sigmask;
      };

   From include/asm-frv/signal.h:

      typedef struct sigaltstack {
	      void *ss_sp;
	      int ss_flags;
	      size_t ss_size;
      } stack_t;

   From include/asm-frv/sigcontext.h:

      struct sigcontext {
	      struct user_context	sc_context;
	      unsigned long		sc_oldmask;
      } __attribute__((aligned(8)));

   From include/asm-frv/registers.h:
      struct user_int_regs
      {
	      unsigned long		psr;
	      unsigned long		isr;
	      unsigned long		ccr;
	      unsigned long		cccr;
	      unsigned long		lr;
	      unsigned long		lcr;
	      unsigned long		pc;
	      unsigned long		__status;
	      unsigned long		syscallno;
	      unsigned long		orig_gr8;
	      unsigned long		gner[2];
	      unsigned long long	iacc[1];

	      union {
		      unsigned long	tbr;
		      unsigned long	gr[64];
	      };
      };

      struct user_fpmedia_regs
      {
	      unsigned long	fr[64];
	      unsigned long	fner[2];
	      unsigned long	msr[2];
	      unsigned long	acc[8];
	      unsigned char	accg[8];
	      unsigned long	fsr[1];
      };

      struct user_context
      {
	      struct user_int_regs		i;
	      struct user_fpmedia_regs	f;

	      void *extension;
      } __attribute__((aligned(8)));  */

static LONGEST
frv_linux_sigcontext_reg_addr (struct frame_info *this_frame, int regno,
                               CORE_ADDR *sc_addr_cache_ptr)
{
  struct gdbarch *gdbarch = get_frame_arch (this_frame);
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  CORE_ADDR sc_addr;

  if (sc_addr_cache_ptr && *sc_addr_cache_ptr)
    {
      sc_addr = *sc_addr_cache_ptr;
    }
  else
    {
      CORE_ADDR pc, sp;
      gdb_byte buf[4];
      int tramp_type;

      pc = get_frame_pc (this_frame);
      tramp_type = frv_linux_pc_in_sigtramp (gdbarch, pc, 0);

      get_frame_register (this_frame, sp_regnum, buf);
      sp = extract_unsigned_integer (buf, sizeof buf, byte_order);

      if (tramp_type == NORMAL_SIGTRAMP)
	{
	  /* For a normal sigtramp frame, the sigcontext struct starts
	     at SP + 8.  */
	  sc_addr = sp + 8;
	}
      else if (tramp_type == RT_SIGTRAMP)
	{
	  /* For a realtime sigtramp frame, SP + 12 contains a pointer
 	     to a ucontext struct.  The ucontext struct contains a
 	     sigcontext struct starting 24 bytes in.  (The offset of
 	     uc_mcontext within struct ucontext is derived as follows: 
 	     stack_t is a 12-byte struct and struct sigcontext is
 	     8-byte aligned.  This gives an offset of 8 + 12 + 4 (for
 	     padding) = 24.)  */
	  if (target_read_memory (sp + 12, buf, sizeof buf) != 0)
	    {
	      warning (_("Can't read realtime sigtramp frame."));
	      return 0;
	    }
	  sc_addr = extract_unsigned_integer (buf, sizeof buf, byte_order);
 	  sc_addr += 24;
	}
      else
	internal_error (__FILE__, __LINE__, _("not a signal trampoline"));

      if (sc_addr_cache_ptr)
	*sc_addr_cache_ptr = sc_addr;
    }

  switch (regno)
    {
    case psr_regnum :
      return sc_addr + 0;
    /* sc_addr + 4 has "isr", the Integer Status Register.  */
    case ccr_regnum :
      return sc_addr + 8;
    case cccr_regnum :
      return sc_addr + 12;
    case lr_regnum :
      return sc_addr + 16;
    case lcr_regnum :
      return sc_addr + 20;
    case pc_regnum :
      return sc_addr + 24;
    /* sc_addr + 28 is __status, the exception status.
       sc_addr + 32 is syscallno, the syscall number or -1.
       sc_addr + 36 is orig_gr8, the original syscall arg #1.
       sc_addr + 40 is gner[0].
       sc_addr + 44 is gner[1].  */
    case iacc0h_regnum :
      return sc_addr + 48;
    case iacc0l_regnum :
      return sc_addr + 52;
    default : 
      if (first_gpr_regnum <= regno && regno <= last_gpr_regnum)
	return sc_addr + 56 + 4 * (regno - first_gpr_regnum);
      else if (first_fpr_regnum <= regno && regno <= last_fpr_regnum)
	return sc_addr + 312 + 4 * (regno - first_fpr_regnum);
      else
	return -1;  /* not saved.  */
    }
}

/* Signal trampolines.  */

static struct trad_frame_cache *
frv_linux_sigtramp_frame_cache (struct frame_info *this_frame,
				void **this_cache)
{
  struct gdbarch *gdbarch = get_frame_arch (this_frame);
  enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
  struct trad_frame_cache *cache;
  CORE_ADDR addr;
  gdb_byte buf[4];
  int regnum;
  CORE_ADDR sc_addr_cache_val = 0;
  struct frame_id this_id;

  if (*this_cache)
    return (struct trad_frame_cache *) *this_cache;

  cache = trad_frame_cache_zalloc (this_frame);

  /* FIXME: cagney/2004-05-01: This is is long standing broken code.
     The frame ID's code address should be the start-address of the
     signal trampoline and not the current PC within that
     trampoline.  */
  get_frame_register (this_frame, sp_regnum, buf);
  addr = extract_unsigned_integer (buf, sizeof buf, byte_order);
  this_id = frame_id_build (addr, get_frame_pc (this_frame));
  trad_frame_set_id (cache, this_id);

  for (regnum = 0; regnum < frv_num_regs; regnum++)
    {
      LONGEST reg_addr = frv_linux_sigcontext_reg_addr (this_frame, regnum,
							&sc_addr_cache_val);
      if (reg_addr != -1)
	trad_frame_set_reg_addr (cache, regnum, reg_addr);
    }

  *this_cache = cache;
  return cache;
}

static void
frv_linux_sigtramp_frame_this_id (struct frame_info *this_frame,
				  void **this_cache,
				  struct frame_id *this_id)
{
  struct trad_frame_cache *cache
    = frv_linux_sigtramp_frame_cache (this_frame, this_cache);
  trad_frame_get_id (cache, this_id);
}

static struct value *
frv_linux_sigtramp_frame_prev_register (struct frame_info *this_frame,
					void **this_cache, int regnum)
{
  /* Make sure we've initialized the cache.  */
  struct trad_frame_cache *cache
    = frv_linux_sigtramp_frame_cache (this_frame, this_cache);
  return trad_frame_get_register (cache, this_frame, regnum);
}

static int
frv_linux_sigtramp_frame_sniffer (const struct frame_unwind *self,
				  struct frame_info *this_frame,
				  void **this_cache)
{
  struct gdbarch *gdbarch = get_frame_arch (this_frame);
  CORE_ADDR pc = get_frame_pc (this_frame);
  const char *name;

  find_pc_partial_function (pc, &name, NULL, NULL);
  if (frv_linux_pc_in_sigtramp (gdbarch, pc, name))
    return 1;

  return 0;
}

static const struct frame_unwind frv_linux_sigtramp_frame_unwind =
{
  SIGTRAMP_FRAME,
  default_frame_unwind_stop_reason,
  frv_linux_sigtramp_frame_this_id,
  frv_linux_sigtramp_frame_prev_register,
  NULL,
  frv_linux_sigtramp_frame_sniffer
};

/* The FRV kernel defines ELF_NGREG as 46.  We add 2 in order to include
   the loadmap addresses in the register set.  (See below for more info.)  */
#define FRV_ELF_NGREG (46 + 2)
typedef unsigned char frv_elf_greg_t[4];
typedef struct { frv_elf_greg_t reg[FRV_ELF_NGREG]; } frv_elf_gregset_t;

typedef unsigned char frv_elf_fpreg_t[4];
typedef struct
{
  frv_elf_fpreg_t fr[64];
  frv_elf_fpreg_t fner[2];
  frv_elf_fpreg_t msr[2];
  frv_elf_fpreg_t acc[8];
  unsigned char accg[8];
  frv_elf_fpreg_t fsr[1];
} frv_elf_fpregset_t;

/* Register maps.  */

static const struct regcache_map_entry frv_linux_gregmap[] =
  {
    { 1, psr_regnum, 4 },
    { 1, REGCACHE_MAP_SKIP, 4 }, /* isr */
    { 1, ccr_regnum, 4 },
    { 1, cccr_regnum, 4 },
    { 1, lr_regnum, 4 },
    { 1, lcr_regnum, 4 },
    { 1, pc_regnum, 4 },
    { 1, REGCACHE_MAP_SKIP, 4 }, /* __status */
    { 1, REGCACHE_MAP_SKIP, 4 }, /* syscallno */
    { 1, REGCACHE_MAP_SKIP, 4 }, /* orig_gr8 */
    { 1, gner0_regnum, 4 },
    { 1, gner1_regnum, 4 },
    { 1, REGCACHE_MAP_SKIP, 8 }, /* iacc0 */
    { 1, tbr_regnum, 4 },
    { 31, first_gpr_regnum + 1, 4 }, /* gr1 ... gr31 */

    /* Technically, the loadmap addresses are not part of `pr_reg' as
       found in the elf_prstatus struct.  The fields which communicate
       the loadmap address appear (by design) immediately after
       `pr_reg' though, and the BFD function elf32_frv_grok_prstatus()
       has been implemented to include these fields in the register
       section that it extracts from the core file.  So, for our
       purposes, they may be viewed as registers.  */

    { 1, fdpic_loadmap_exec_regnum, 4 },
    { 1, fdpic_loadmap_interp_regnum, 4 },
    { 0 }
  };

static const struct regcache_map_entry frv_linux_fpregmap[] =
  {
    { 64, first_fpr_regnum, 4 }, /* fr0 ... fr63 */
    { 1, fner0_regnum, 4 },
    { 1, fner1_regnum, 4 },
    { 1, msr0_regnum, 4 },
    { 1, msr1_regnum, 4 },
    { 8, acc0_regnum, 4 },	/* acc0 ... acc7 */
    { 1, accg0123_regnum, 4 },
    { 1, accg4567_regnum, 4 },
    { 1, fsr0_regnum, 4 },
    { 0 }
  };

/* Unpack an frv_elf_gregset_t into GDB's register cache.  */

static void 
frv_linux_supply_gregset (const struct regset *regset,
                          struct regcache *regcache,
			  int regnum, const void *gregs, size_t len)
{
  int regi;
  char zerobuf[MAX_REGISTER_SIZE];

  memset (zerobuf, 0, MAX_REGISTER_SIZE);

  /* gr0 always contains 0.  Also, the kernel passes the TBR value in
     this slot.  */
  regcache_raw_supply (regcache, first_gpr_regnum, zerobuf);

  /* Fill gr32, ..., gr63 with zeros. */
  for (regi = first_gpr_regnum + 32; regi <= last_gpr_regnum; regi++)
    regcache_raw_supply (regcache, regi, zerobuf);

  regcache_supply_regset (regset, regcache, regnum, gregs, len);
}

/* FRV Linux kernel register sets.  */

static const struct regset frv_linux_gregset =
{
  frv_linux_gregmap,
  frv_linux_supply_gregset, regcache_collect_regset
};

static const struct regset frv_linux_fpregset =
{
  frv_linux_fpregmap,
  regcache_supply_regset, regcache_collect_regset
};

static void
frv_linux_iterate_over_regset_sections (struct gdbarch *gdbarch,
					iterate_over_regset_sections_cb *cb,
					void *cb_data,
					const struct regcache *regcache)
{
  cb (".reg", sizeof (frv_elf_gregset_t), &frv_linux_gregset,
      NULL, cb_data);
  cb (".reg2", sizeof (frv_elf_fpregset_t), &frv_linux_fpregset,
      NULL, cb_data);
}


static void
frv_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
{
  linux_init_abi (info, gdbarch);

  /* Set the sigtramp frame sniffer.  */
  frame_unwind_append_unwinder (gdbarch, &frv_linux_sigtramp_frame_unwind); 

  set_gdbarch_iterate_over_regset_sections
    (gdbarch, frv_linux_iterate_over_regset_sections);
}

static enum gdb_osabi
frv_linux_elf_osabi_sniffer (bfd *abfd)
{
  int elf_flags;

  elf_flags = elf_elfheader (abfd)->e_flags;

  /* Assume GNU/Linux if using the FDPIC ABI.  If/when another OS shows
     up that uses this ABI, we'll need to start using .note sections
     or some such.  */
  if (elf_flags & EF_FRV_FDPIC)
    return GDB_OSABI_LINUX;
  else
    return GDB_OSABI_UNKNOWN;
}

/* Provide a prototype to silence -Wmissing-prototypes.  */
void _initialize_frv_linux_tdep (void);

void
_initialize_frv_linux_tdep (void)
{
  gdbarch_register_osabi (bfd_arch_frv, 0, GDB_OSABI_LINUX,
			  frv_linux_init_abi);
  gdbarch_register_osabi_sniffer (bfd_arch_frv,
				  bfd_target_elf_flavour,
				  frv_linux_elf_osabi_sniffer);
}