commit bb03ff5870aeaa6cf0b64015b9d7bf4ef7585b02 Author: Egeyar Bagcioglu Date: Fri Apr 2 21:42:12 2021 +0200 Introduce the builtins io_get_bias and io_set_bias 2021-04-03 Egeyar Bagcioglu * doc/poke.texi: Adjust the output of ".info ios". * libpoke/libpoke.c (pk_ios_get_bias): New. * libpoke/libpoke.h (pk_ios_get_bias): Likewise. * libpoke/pkl-ast.h: Define PKL_AST_BUILTIN_IOGETB and PKL_AST_BUILTIN_IOSETB. * libpoke/pkl-gen.c (PKL_PHASE_BEGIN_HANDLER): Add the cases PKL_AST_BUILTIN_IOGETB and PKL_AST_BUILTIN_IOSETB. * libpoke/pkl-lex.l: Add "__PKL_BUILTIN_IOGETB__" and "__PKL_BUILTIN_IOSETB__". * libpoke/pkl-rt.pk: Declare io_get_bias and io_set_bias. * libpoke/pkl-tab.y: Add BUILTIN_IOGETB and BUILTIN_IOSETB. * libpoke/pvm.jitter (iogetb): If bias is 8-bit aligned, report it in bytes, else in bits. (iosetb): Swap the positions of bias and ios. * poke/pk-cmd-ios.c (print_info_ios): Print the bias. (pk_cmd_info_ios): Likewise. * testsuite/Makefile.am: Add the new test files. * testsuite/poke.cmd/file-bias-1.pk: New * testsuite/poke.cmd/file-bias-2.pk: New. * testsuite/poke.cmd/file-mode.pk: Adjust ".info ios". * testsuite/poke.cmd/file-relative.pk: Likewise. * testsuite/poke.pkl/io_get_bias-1.pk: New. * testsuite/poke.pkl/io_get_bias-2.pk: New. * testsuite/poke.pkl/io_set_bias-1.pk: New. * testsuite/poke.pkl/io_set_bias-2.pk: New. * testsuite/poke.pkl/io_set_bias-3.pk: New. * testsuite/poke.pkl/io_set_bias-4.pk: New. * testsuite/poke.pkl/io_set_bias-5.pk: New. * testsuite/poke.pkl/io_set_bias-6.pk: New. * testsuite/poke.pkl/io_set_bias-7.pk: New. diff --git a/ChangeLog b/ChangeLog index 85a41434..8fa03f29 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,36 @@ +2021-04-03 Egeyar Bagcioglu + + * doc/poke.texi: Adjust the output of ".info ios". + * libpoke/libpoke.c (pk_ios_get_bias): New. + * libpoke/libpoke.h (pk_ios_get_bias): Likewise. + * libpoke/pkl-ast.h: Define PKL_AST_BUILTIN_IOGETB and + PKL_AST_BUILTIN_IOSETB. + * libpoke/pkl-gen.c (PKL_PHASE_BEGIN_HANDLER): Add the cases + PKL_AST_BUILTIN_IOGETB and PKL_AST_BUILTIN_IOSETB. + * libpoke/pkl-lex.l: Add "__PKL_BUILTIN_IOGETB__" and + "__PKL_BUILTIN_IOSETB__". + * libpoke/pkl-rt.pk: Declare io_get_bias and io_set_bias. + * libpoke/pkl-tab.y: Add BUILTIN_IOGETB and BUILTIN_IOSETB. + * libpoke/pvm.jitter (iogetb): If bias is 8-bit aligned, report it in + bytes, else in bits. + (iosetb): Swap the positions of bias and ios. + * poke/pk-cmd-ios.c (print_info_ios): Print the bias. + (pk_cmd_info_ios): Likewise. + * testsuite/Makefile.am: Add the new test files. + * testsuite/poke.cmd/file-bias-1.pk: New + * testsuite/poke.cmd/file-bias-2.pk: New. + * testsuite/poke.cmd/file-mode.pk: Adjust ".info ios". + * testsuite/poke.cmd/file-relative.pk: Likewise. + * testsuite/poke.pkl/io_get_bias-1.pk: New. + * testsuite/poke.pkl/io_get_bias-2.pk: New. + * testsuite/poke.pkl/io_set_bias-1.pk: New. + * testsuite/poke.pkl/io_set_bias-2.pk: New. + * testsuite/poke.pkl/io_set_bias-3.pk: New. + * testsuite/poke.pkl/io_set_bias-4.pk: New. + * testsuite/poke.pkl/io_set_bias-5.pk: New. + * testsuite/poke.pkl/io_set_bias-6.pk: New. + * testsuite/poke.pkl/io_set_bias-7.pk: New. + 2021-04-03 Luca Saiu * etc/hacking.org: Documentation. diff --git a/doc/poke.texi b/doc/poke.texi index f86c0cda..93dbe2a1 100644 --- a/doc/poke.texi +++ b/doc/poke.texi @@ -993,8 +993,8 @@ about: @example (poke) .info ios - Id Type Mode Size Name -* #0 FILE rw 0x00000398#B ./foo.o + Id Type Mode Bias Size Name +* #0 FILE rw 0x00000000#B 0x00000398#B ./foo.o @end example The command @command{.info ios} gives us information about all the IO @@ -1018,9 +1018,9 @@ clearly, let's open another file: (poke) .file bar.o The current IOS is now `./bar.o'. (poke) .info ios - Id Type Mode Size Name -* #1 FILE rw 0x00000398#B ./bar.o - #0 FILE rw 0x00000398#B ./foo.o + Id Type Mode Bias Size Name +* #1 FILE rw 0x00000000#B 0x00000398#B ./bar.o + #0 FILE rw 0x00000000#B 0x00000398#B ./foo.o @end example Ah, there we have both @file{foo.o} and @file{bar.o}. Now the current @@ -1034,9 +1034,9 @@ an IO space tag as an argument: (poke) .ios #0 The current IOS is now `./foo.o'. (poke) .info ios - Id Type Mode Size Name - #1 FILE rw 0x00000398#B ./bar.o -* #0 FILE rw 0x00000398#B ./foo.o + Id Type Mode Bias Size Name + #1 FILE rw 0x00000000#B 0x00000398#B ./bar.o +* #0 FILE rw 0x00000000#B 0x00000398#B ./foo.o @end example @noindent @@ -1046,8 +1046,8 @@ We are back to @file{foo.o}. Since we are not really interested in @example (poke) .close #1 (poke) .info ios - Id Type Mode Size Name -* #0 FILE rw 0x00000398#B ./foo.o + Id Type Mode Bias Size Name +* #0 FILE rw 0x00000000#B 0x00000398#B ./foo.o @end example @noindent @@ -2493,8 +2493,8 @@ that opened a file as an IO space? (poke) .file foo.o The current IOS is now `./foo.o'. (poke) .info ios - Id Type Mode Size Name -* #0 FILE rw 0x000004c8#B ./foo.o + Id Type Mode Bias Size Name +* #0 FILE rw 0x00000000#B 0x000004c8#B ./foo.o @end example @noindent @@ -2505,9 +2505,9 @@ Memory buffers can be created using a similar dot-command, (poke) .mem foo The current IOS is now `*foo*'. (poke) .info ios - Id Type Mode Size Name -* #1 MEMORY 0x00001000#B *foo* - #0 FILE rw 0x000004c8#B ./foo.o + Id Type Mode Bias Size Name +* #1 MEMORY 0x00000000#B 0x00001000#B *foo* + #0 FILE rw 0x00000000#B 0x000004c8#B ./foo.o @end example Note how the name of the buffer is built by prepending and appending @@ -2630,9 +2630,9 @@ we can continue our work tomorrow. This is how we would do that: @example (poke) .info ios - Id Type Mode Size Name -* #1 MEMORY 0x00001000#B *scratch* - #0 FILE rw 0x000f4241#B ./foo.o + Id Type Mode Bias Size Name +* #1 MEMORY 0x00000000#B 0x00001000#B *scratch* + #0 FILE rw 0x00000000#B 0x000f4241#B ./foo.o (poke) save :from 0#B :size iosize (1) :file "scratch.dat" @end example @@ -3673,9 +3673,9 @@ $ poke p.sbm (poke) .mem scratch The current IOS is now `*scratch*'. (poke) .info ios - Id Type Mode Size Name -* #1 MEMORY 0x00001000#B *scratch* - #0 FILE rw 0x0000006e#B ./p.sbm + Id Type Mode Bias Size Name +* #1 MEMORY 0x00000000#B 0x00001000#B *scratch* + #0 FILE rw 0x00000000#B 0x0000006e#B ./p.sbm (poke) copy :from_ios 0 :from 0#B :to 0#B :size iosize (0) (poke) dump 76543210 0011 2233 4455 6677 8899 aabb ccdd eeff 0123456789ABCDEF @@ -6077,8 +6077,8 @@ Thats it, @code{ehdr} is mapped at offset zero byte in the IO space @example (poke) .info ios - Id Type Mode Size Name -* #0 FILE rw 0x000004c8#B ./foo.o + Id Type Mode Bias Size Name +* #0 FILE rw 0x00000000#B 0x000004c8#B ./foo.o @end example Now that we have the ELF header, we may use it to get access to the @@ -6149,9 +6149,9 @@ ELF file: @code{bar.o}. We would start by opening the file: @example (poke) .file bar.o (poke) .info ios - Id Type Mode Size Name -* #1 FILE rw 0x000004c8#B ./bar.o - #0 FILE rw 0x000004c8#B ./foo.o + Id Type Mode Bias Size Name +* #1 FILE rw 0x00000000#B 0x000004c8#B ./bar.o + #0 FILE rw 0x00000000#B 0x000004c8#B ./foo.o @end example Now that @code{bar.o} is the current IO space, we can map its header. @@ -8185,9 +8185,9 @@ Display a list of open files. @example (poke) .info ios -Id Type Mode Size Name - #1 FILE r 0x0000df78#B foo.o -* #0 FILE rw 0x00000022#B foo.bson + Id Type Mode Bias Size Name + #1 FILE r 0x00000000#B 0x0000df78#B foo.o +* #0 FILE rw 0x00000000#B 0x00000022#B foo.bson @end example @cindex IO space @@ -8201,9 +8201,9 @@ switch to it as the new current IO space: (poke) .ios #1 The current file is now `foo.o'. (poke) .info ios - Id Type Mode Size Name -* #1 FILE r 0x0000df78#B foo.o - #0 FILE rw 0x00000022#B foo.bson + Id Type Mode Bias Size Name +* #1 FILE r 0x00000000#B 0x0000df78#B foo.o + #0 FILE rw 0x00000000#B 0x00000022#B foo.bson @end example @item .info variables diff --git a/libpoke/libpoke.c b/libpoke/libpoke.c index 5ca5b1dd..db1dafdf 100644 --- a/libpoke/libpoke.c +++ b/libpoke/libpoke.c @@ -524,6 +524,12 @@ pk_ios_size (pk_ios io) return ios_size ((ios) io); } +uint64_t +pk_ios_get_bias (pk_ios io) +{ + return ios_get_bias ((ios) io); +} + struct ios_map_fn_payload { pk_ios_map_fn cb; diff --git a/libpoke/libpoke.h b/libpoke/libpoke.h index 2e70bc12..a786735d 100644 --- a/libpoke/libpoke.h +++ b/libpoke/libpoke.h @@ -314,6 +314,10 @@ char *pk_ios_get_dev_if_name (pk_ios ios) LIBPOKE_API; uint64_t pk_ios_size (pk_ios ios) LIBPOKE_API; +/* Return the bias of the given IO space, in bits. */ + +uint64_t pk_ios_get_bias (pk_ios ios) LIBPOKE_API; + /* Return the flags which are active in a given IOS. */ #define PK_IOS_F_READ 1 diff --git a/libpoke/pkl-ast.h b/libpoke/pkl-ast.h index d4af5d73..443acecc 100644 --- a/libpoke/pkl-ast.h +++ b/libpoke/pkl-ast.h @@ -1435,6 +1435,8 @@ pkl_ast_node pkl_ast_make_incrdecr (pkl_ast ast, #define PKL_AST_BUILTIN_TERM_END_HYPERLINK 22 #define PKL_AST_BUILTIN_IOFLAGS 23 #define PKL_AST_BUILTIN_SLEEP 24 +#define PKL_AST_BUILTIN_IOGETB 25 +#define PKL_AST_BUILTIN_IOSETB 26 struct pkl_ast_comp_stmt { diff --git a/libpoke/pkl-gen.c b/libpoke/pkl-gen.c index 14e62fa5..99391896 100644 --- a/libpoke/pkl-gen.c +++ b/libpoke/pkl-gen.c @@ -664,6 +664,18 @@ PKL_PHASE_BEGIN_HANDLER (pkl_gen_ps_comp_stmt) pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NIP); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_RETURN); break; + case PKL_AST_BUILTIN_IOGETB: + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHVAR, 0, 0); + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_IOGETB); + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NIP); + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_RETURN); + break; + case PKL_AST_BUILTIN_IOSETB: + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHVAR, 0, 0); + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHVAR, 0, 1); + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_IOSETB); + pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_NIP); + break; case PKL_AST_BUILTIN_FORGET: pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHVAR, 0, 0); pkl_asm_insn (PKL_GEN_ASM, PKL_INSN_PUSHVAR, 0, 1); diff --git a/libpoke/pkl-lex.l b/libpoke/pkl-lex.l index b87237eb..a12f546a 100644 --- a/libpoke/pkl-lex.l +++ b/libpoke/pkl-lex.l @@ -245,6 +245,10 @@ S :: if (yyextra->bootstrapped) REJECT; return BUILTIN_IOSIZE; } "__PKL_BUILTIN_IOFLAGS__" { if (yyextra->bootstrapped) REJECT; return BUILTIN_IOFLAGS; } +"__PKL_BUILTIN_IOGETB__" { + if (yyextra->bootstrapped) REJECT; return BUILTIN_IOGETB; } +"__PKL_BUILTIN_IOSETB__" { + if (yyextra->bootstrapped) REJECT; return BUILTIN_IOSETB; } "__PKL_BUILTIN_GETENV__" { if (yyextra->bootstrapped) REJECT; return BUILTIN_GETENV; } "__PKL_BUILTIN_FORGET__" { diff --git a/libpoke/pkl-rt.pk b/libpoke/pkl-rt.pk index 406f6150..d169b689 100644 --- a/libpoke/pkl-rt.pk +++ b/libpoke/pkl-rt.pk @@ -27,6 +27,8 @@ fun open = (string handler, uint<64> flags = 0) int<32>: __PKL_BUILTIN_OPEN__; fun close = (int<32> ios) void: __PKL_BUILTIN_CLOSE__; fun iosize = (int<32> ios = get_ios) offset,8>: __PKL_BUILTIN_IOSIZE__; fun ioflags = (int<32> ios = get_ios) uint<64>: __PKL_BUILTIN_IOFLAGS__; +fun io_get_bias = (int<32> ios = get_ios) offset,1>: __PKL_BUILTIN_IOGETB__; +fun io_set_bias = (offset,1> bias = 0#1, int<32> ios = get_ios) void: __PKL_BUILTIN_IOSETB__; fun getenv = (string name) string: __PKL_BUILTIN_GETENV__; fun flush = (int<32> ios, offset,1> offset) void: __PKL_BUILTIN_FORGET__; fun get_time = int<64>[2]: __PKL_BUILTIN_GET_TIME__; diff --git a/libpoke/pkl-tab.y b/libpoke/pkl-tab.y index 67cf13f6..b51dbdfb 100644 --- a/libpoke/pkl-tab.y +++ b/libpoke/pkl-tab.y @@ -418,7 +418,8 @@ token UNION _("keyword `union'") %token LAMBDA _("keyword `lambda'") %token BUILTIN_RAND BUILTIN_GET_ENDIAN BUILTIN_SET_ENDIAN %token BUILTIN_GET_IOS BUILTIN_SET_IOS BUILTIN_OPEN BUILTIN_CLOSE -%token BUILTIN_IOSIZE BUILTIN_IOFLAGS BUILTIN_GETENV BUILTIN_FORGET BUILTIN_GET_TIME +%token BUILTIN_IOSIZE BUILTIN_IOFLAGS BUILTIN_IOGETB BUILTIN_IOSETB +%token BUILTIN_GETENV BUILTIN_FORGET BUILTIN_GET_TIME %token BUILTIN_STRACE BUILTIN_TERM_RGB_TO_COLOR BUILTIN_SLEEP %token BUILTIN_TERM_GET_COLOR BUILTIN_TERM_SET_COLOR %token BUILTIN_TERM_GET_BGCOLOR BUILTIN_TERM_SET_BGCOLOR @@ -2039,6 +2040,8 @@ builtin: | BUILTIN_CLOSE { $$ = PKL_AST_BUILTIN_CLOSE; } | BUILTIN_IOSIZE { $$ = PKL_AST_BUILTIN_IOSIZE; } | BUILTIN_IOFLAGS { $$ = PKL_AST_BUILTIN_IOFLAGS; } + | BUILTIN_IOGETB { $$ = PKL_AST_BUILTIN_IOGETB; } + | BUILTIN_IOSETB { $$ = PKL_AST_BUILTIN_IOSETB; } | BUILTIN_GETENV { $$ = PKL_AST_BUILTIN_GETENV; } | BUILTIN_FORGET { $$ = PKL_AST_BUILTIN_FORGET; } | BUILTIN_GET_TIME { $$ = PKL_AST_BUILTIN_GET_TIME; } diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter index de12d1ab..51ce7de4 100644 --- a/libpoke/pvm.jitter +++ b/libpoke/pvm.jitter @@ -1564,8 +1564,13 @@ instruction iogetb () if (io == NULL) PVM_RAISE_DFL (PVM_E_NO_IOS); - JITTER_PUSH_STACK (pvm_make_offset (PVM_MAKE_ULONG (ios_get_bias (io), 64), - PVM_MAKE_ULONG (1, 64))); + uint64_t bias = ios_get_bias (io); + if (bias % 8 == 0) + JITTER_PUSH_STACK (pvm_make_offset (PVM_MAKE_ULONG (bias/8, 64), + PVM_MAKE_ULONG (8, 64))); + else + JITTER_PUSH_STACK (pvm_make_offset (PVM_MAKE_ULONG (bias, 64), + PVM_MAKE_ULONG (1, 64))); end end @@ -1579,15 +1584,15 @@ end # The bias is specified as an offset. If the given IO space doesn't # exist, the exception PVM_E_NO_IOS is raised. # -# Stack: ( INT OFF -- INT ) +# Stack: ( OFF INT -- OFF ) # Exceptions: PVM_E_NO_IOS instruction iosetb () branching # because of PVM_RAISE_DIRECT # XXX make non-relocatable: see raise code - pvm_val bias = JITTER_TOP_STACK(); - ios io = ios_search_by_id (PVM_VAL_INT (JITTER_UNDER_TOP_STACK ())); + pvm_val bias = JITTER_UNDER_TOP_STACK(); + ios io = ios_search_by_id (PVM_VAL_INT (JITTER_TOP_STACK ())); JITTER_DROP_STACK (); diff --git a/poke/pk-cmd-ios.c b/poke/pk-cmd-ios.c index 42eda0ba..06483ac2 100644 --- a/poke/pk-cmd-ios.c +++ b/poke/pk-cmd-ios.c @@ -281,10 +281,21 @@ print_info_ios (pk_ios io, void *data) mode[2] = '\0'; pk_table_column (table, mode); + /* Bias. */ + { + char *string; + uint64_t bias = pk_ios_get_bias (io); + if (bias % 8 == 0) + asprintf (&string, "0x%08jx#B", bias / 8); + else + asprintf (&string, "0x%08jx#b", bias); + pk_table_column_cl (table, string, "offset"); + free (string); + } + /* Size. */ { char *size; - asprintf (&size, "0x%08jx#B", pk_ios_size (io)); pk_table_column_cl (table, size, "offset"); free (size); @@ -316,11 +327,12 @@ pk_cmd_info_ios (int argc, struct pk_cmd_arg argv[], uint64_t uflags) assert (argc == 0); - table = pk_table_new (5); + table = pk_table_new (6); pk_table_row_cl (table, "table-header"); pk_table_column (table, " Id"); pk_table_column (table, "Type"); pk_table_column (table, "Mode"); + pk_table_column (table, "Bias"); pk_table_column (table, "Size"); pk_table_column (table, "Name"); diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index b9b8de63..50fb7d07 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -74,6 +74,8 @@ EXTRA_DIST = \ poke.cmd/dump-11.pk \ poke.cmd/dump-12.pk \ poke.cmd/extract-1.pk \ + poke.cmd/file-bias-1.pk \ + poke.cmd/file-bias-2.pk \ poke.cmd/file-mode.pk \ poke.cmd/file-relative.pk \ poke.cmd/ios-1.pk \ @@ -1141,6 +1143,15 @@ EXTRA_DIST = \ poke.pkl/integers-7.pk \ poke.pkl/integers-diag-1.pk \ poke.pkl/integers-diag-2.pk \ + poke.pkl/io_get_bias-1.pk \ + poke.pkl/io_get_bias-2.pk \ + poke.pkl/io_set_bias-1.pk \ + poke.pkl/io_set_bias-2.pk \ + poke.pkl/io_set_bias-3.pk \ + poke.pkl/io_set_bias-4.pk \ + poke.pkl/io_set_bias-5.pk \ + poke.pkl/io_set_bias-6.pk \ + poke.pkl/io_set_bias-7.pk\ poke.pkl/ior-integers-1.pk \ poke.pkl/ior-integers-2.pk \ poke.pkl/ior-int-struct-1.pk \ diff --git a/testsuite/poke.cmd/file-bias-1.pk b/testsuite/poke.cmd/file-bias-1.pk new file mode 100644 index 00000000..8c458cd1 --- /dev/null +++ b/testsuite/poke.cmd/file-bias-1.pk @@ -0,0 +1,8 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80} foo.data } */ + +/* { dg-command { .file foo.data } } */ +/* { dg-command { io_set_bias (0x13#b) } } */ +/* { dg-command { .info ios } } */ +/* { dg-output " Id +Type +Mode +Bias +Size +Name" } */ +/* { dg-output "\n\\* #0 +FILE +rw +0x00000013#b +0x00000008#B +./foo.data" } */ diff --git a/testsuite/poke.cmd/file-bias-2.pk b/testsuite/poke.cmd/file-bias-2.pk new file mode 100644 index 00000000..f9f3e9ab --- /dev/null +++ b/testsuite/poke.cmd/file-bias-2.pk @@ -0,0 +1,8 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x10 0x20 0x30 0x40 0x50 0x60 0x70 0x80} foo.data } */ + +/* { dg-command { .file foo.data } } */ +/* { dg-command { io_set_bias (0x13#B) } } */ +/* { dg-command { .info ios } } */ +/* { dg-output " Id +Type +Mode +Bias +Size +Name" } */ +/* { dg-output "\n\\* #0 +FILE +rw +0x00000013#B +0x00000008#B +./foo.data" } */ diff --git a/testsuite/poke.cmd/file-mode.pk b/testsuite/poke.cmd/file-mode.pk index 6f7aa4ab..8e825eba 100644 --- a/testsuite/poke.cmd/file-mode.pk +++ b/testsuite/poke.cmd/file-mode.pk @@ -3,6 +3,6 @@ /* { dg-command { .file /etc/passwd } } */ /* { dg-command { .file /dev/null } } */ /* { dg-command { .info ios } } */ -/* { dg-output " Id +Type +Mode +Size +Name" } */ -/* { dg-output {\n. #1 +FILE +rw +0x00000000#B +/dev/null} } */ -/* { dg-output {\n #0 +FILE +r[w ] +0x[0-9a-f]*#B +/etc/passwd} } */ +/* { dg-output " Id +Type +Mode +Bias +Size +Name" } */ +/* { dg-output {\n. #1 +FILE +rw +0x00000000#B +0x00000000#B +/dev/null} } */ +/* { dg-output {\n #0 +FILE +r[w ] +0x00000000#B +0x[0-9a-f]*#B +/etc/passwd} } */ diff --git a/testsuite/poke.cmd/file-relative.pk b/testsuite/poke.cmd/file-relative.pk index 44d5b197..403a030b 100644 --- a/testsuite/poke.cmd/file-relative.pk +++ b/testsuite/poke.cmd/file-relative.pk @@ -3,5 +3,5 @@ /* { dg-command { .file a#b } } */ /* { dg-command { .info ios } } */ -/* { dg-output " Id +Type +Mode +Size +Name" } */ -/* { dg-output "\n\\* #0 +FILE +rw +0x00000008#B +./a#b" } */ +/* { dg-output " Id +Type +Mode +Bias +Size +Name" } */ +/* { dg-output "\n\\* #0 +FILE +rw +0x00000000#B +0x00000008#B +./a#b" } */ diff --git a/testsuite/poke.pkl/io_get_bias-1.pk b/testsuite/poke.pkl/io_get_bias-1.pk new file mode 100644 index 00000000..6862b1f0 --- /dev/null +++ b/testsuite/poke.pkl/io_get_bias-1.pk @@ -0,0 +1,7 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} foo.data } */ + +/* { dg-command { .set obase 10 } } */ +/* { dg-command { var foo = open ("foo.data") } } */ +/* { dg-command { io_get_bias } } */ +/* { dg-output "0UL#B" } */ diff --git a/testsuite/poke.pkl/io_get_bias-2.pk b/testsuite/poke.pkl/io_get_bias-2.pk new file mode 100644 index 00000000..8770dc50 --- /dev/null +++ b/testsuite/poke.pkl/io_get_bias-2.pk @@ -0,0 +1,7 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} foo.data } */ + +/* { dg-command { .set obase 10 } } */ +/* { dg-command { var foo = open ("foo.data") } } */ +/* { dg-command { io_get_bias (foo) } } */ +/* { dg-output "0UL#B" } */ diff --git a/testsuite/poke.pkl/io_set_bias-1.pk b/testsuite/poke.pkl/io_set_bias-1.pk new file mode 100644 index 00000000..2a258d14 --- /dev/null +++ b/testsuite/poke.pkl/io_set_bias-1.pk @@ -0,0 +1,8 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} foo.data } */ + +/* { dg-command { .set obase 10 } } */ +/* { dg-command { var foo = open ("foo.data") } } */ +/* { dg-command { io_set_bias (13#b) } } */ +/* { dg-command { io_get_bias } } */ +/* { dg-output "13UL#b" } */ diff --git a/testsuite/poke.pkl/io_set_bias-2.pk b/testsuite/poke.pkl/io_set_bias-2.pk new file mode 100644 index 00000000..428efc71 --- /dev/null +++ b/testsuite/poke.pkl/io_set_bias-2.pk @@ -0,0 +1,8 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} foo.data } */ + +/* { dg-command { .set obase 10 } } */ +/* { dg-command { var foo = open ("foo.data") } } */ +/* { dg-command { io_set_bias (13#B) } } */ +/* { dg-command { io_get_bias } } */ +/* { dg-output "13UL#B" } */ diff --git a/testsuite/poke.pkl/io_set_bias-3.pk b/testsuite/poke.pkl/io_set_bias-3.pk new file mode 100644 index 00000000..2ba7ec3a --- /dev/null +++ b/testsuite/poke.pkl/io_set_bias-3.pk @@ -0,0 +1,9 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} foo.data } */ + +/* { dg-command { .set obase 10 } } */ +/* { dg-command { var foo = open ("foo.data") } } */ +/* { dg-command { io_set_bias (13#B) } } */ +/* { dg-command { io_set_bias } } */ +/* { dg-command { io_get_bias } } */ +/* { dg-output "0UL#B" } */ diff --git a/testsuite/poke.pkl/io_set_bias-4.pk b/testsuite/poke.pkl/io_set_bias-4.pk new file mode 100644 index 00000000..36680e7f --- /dev/null +++ b/testsuite/poke.pkl/io_set_bias-4.pk @@ -0,0 +1,15 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} foo.data } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} bar.data } */ + +/* { dg-command { .set obase 10 } } */ +/* { dg-command { var foo = open ("foo.data") } } */ +/* { dg-command { var bar = open ("bar.data") } } */ +/* { dg-command { io_set_bias (42#b, bar) } } */ +/* { dg-command { io_get_bias (foo)} } */ +/* { dg-output "0UL#B" } */ +/* { dg-command { io_set_bias (5#B, foo) } } */ +/* { dg-command { io_get_bias (foo) } } */ +/* { dg-output "\n5UL#B" } */ +/* { dg-command { io_get_bias (bar) } } */ +/* { dg-output "\n42UL#b" } */ diff --git a/testsuite/poke.pkl/io_set_bias-5.pk b/testsuite/poke.pkl/io_set_bias-5.pk new file mode 100644 index 00000000..78c09e65 --- /dev/null +++ b/testsuite/poke.pkl/io_set_bias-5.pk @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} foo.data } */ + +/* { dg-command { .set obase 16 } } */ +/* { dg-command { .set endian big } } */ +/* { dg-command { var foo = open ("foo.data") } } */ +/* { dg-command { io_set_bias (4#b) } } */ +/* { dg-command { io_get_bias (foo)} } */ +/* { dg-output "4UL#b" } */ +/* { dg-command { byte @ 0x0#B } } */ +/* { dg-output "\n0x16UB" } */ diff --git a/testsuite/poke.pkl/io_set_bias-6.pk b/testsuite/poke.pkl/io_set_bias-6.pk new file mode 100644 index 00000000..51d24076 --- /dev/null +++ b/testsuite/poke.pkl/io_set_bias-6.pk @@ -0,0 +1,11 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} foo.data } */ + +/* { dg-command { .set obase 16 } } */ +/* { dg-command { .set endian big } } */ +/* { dg-command { var foo = open ("foo.data") } } */ +/* { dg-command { io_set_bias (9#b) } } */ +/* { dg-command { io_get_bias (foo)} } */ +/* { dg-output "9UL#b" } */ +/* { dg-command { byte @ 0x0#B } } */ +/* { dg-output "\n0xc4UB" } */ diff --git a/testsuite/poke.pkl/io_set_bias-7.pk b/testsuite/poke.pkl/io_set_bias-7.pk new file mode 100644 index 00000000..f9581e87 --- /dev/null +++ b/testsuite/poke.pkl/io_set_bias-7.pk @@ -0,0 +1,13 @@ +/* { dg-do run } */ +/* { dg-data {c*} {0x61 0x62 0x63 0x64 0x65} foo.data } */ + +/* { dg-command { .set obase 16 } } */ +/* { dg-command { .set endian big } } */ +/* { dg-command { var foo = open ("foo.data") } } */ +/* { dg-command { io_set_bias (9#b) } } */ +/* { dg-command { io_get_bias (foo)} } */ +/* { dg-output "9UL#b" } */ +/* { dg-command { byte @ 0x7#b = 0xff } } */ +/* { dg-command { io_set_bias } } */ +/* { dg-command { byte @ 0x2#B } } */ +/* { dg-output "\n0xffUB" } */