[svn:parrot] r36680 - in trunk: . compilers/imcc compilers/pirc/src docs docs/pdds/draft examples/c ext/Parrot-Embed/lib/Parrot include/parrot src src/packfile src/pmc t/src tools/dev
rurban at svn.parrot.org
rurban at svn.parrot.org
Fri Feb 13 18:07:21 UTC 2009
Author: rurban
Date: Fri Feb 13 18:07:17 2009
New Revision: 36680
URL: https://trac.parrot.org/parrot/changeset/36680
Log:
TT #266
- Rename Parrot_readbc,loadbc to Parrot_pbc_read,load.
- Add a third debug argument to Parrot_pbc_read
- Encapsulate TRACE_PACKFILE macros
- Add Deprecation
Modified:
trunk/DEPRECATED.pod
trunk/NEWS
trunk/compilers/imcc/main.c
trunk/compilers/pirc/src/bcgen.c
trunk/docs/embed.pod
trunk/docs/pdds/draft/pdd10_embedding.pod
trunk/examples/c/test_main.c
trunk/ext/Parrot-Embed/lib/Parrot/Embed.xs
trunk/include/parrot/embed.h
trunk/include/parrot/packfile.h
trunk/src/embed.c
trunk/src/exec_start.c
trunk/src/packfile.c
trunk/src/packfile/pf_items.c
trunk/src/parrot_debugger.c
trunk/src/pbc_disassemble.c
trunk/src/pbc_dump.c
trunk/src/pbc_info.c
trunk/src/pbc_merge.c
trunk/src/pmc/packfile.pmc
trunk/t/src/extend.t
trunk/tools/dev/pbc_to_exe.pir
Modified: trunk/DEPRECATED.pod
==============================================================================
--- trunk/DEPRECATED.pod Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/DEPRECATED.pod Fri Feb 13 18:07:17 2009 (r36680)
@@ -150,6 +150,11 @@
namespace entry by default. Use the C<:nsentry> flag to cause this
to happen. See RT #60586 and RT #53302.
+=item Parrot_readbc, Parrot_loadbc. [post 0.8.1]
+
+They have been renamed to C<Parrot_pbc_read>, C<Parrot_pbc_load>.
+C<Parrot_pbc_read> has one third int argument. See TT #266.
+
=back
=head1 Compiler tools
Modified: trunk/NEWS
==============================================================================
--- trunk/NEWS Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/NEWS Fri Feb 13 18:07:17 2009 (r36680)
@@ -10,6 +10,8 @@
- build instructions can be found at http://tinyurl.com/rakudo
- Cleanup
+ removed Zcode implementation
+- Deprecations
+ + Parrot_readbc, Parrot_loadbc renamed to Parrot_pbc_read, Parrot_pbc_load.
- Tools
+ pbc_disassemble options added
+ pbc_dump renamed from pdump
Modified: trunk/compilers/imcc/main.c
==============================================================================
--- trunk/compilers/imcc/main.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/compilers/imcc/main.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -990,7 +990,7 @@
opt_desc, opt_level);
pf = PackFile_new(interp, 0);
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
IMCC_push_parser_state(interp);
IMCC_INFO(interp)->state->file = sourcefile;
@@ -1094,11 +1094,11 @@
/* If the input file is Parrot bytecode, then we simply read it
into a packfile, which Parrot then loads */
if (STATE_LOAD_PBC(interp)) {
- PackFile * const pf = Parrot_readbc(interp, sourcefile);
+ PackFile * const pf = Parrot_pbc_read(interp, sourcefile, 0);
if (!pf)
IMCC_fatal_standalone(interp, 1, "main: Packfile loading failed\n");
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
}
else
compile_to_bytecode(interp, sourcefile, output_file);
@@ -1116,10 +1116,10 @@
PackFile *pf;
IMCC_info(interp, 1, "Loading %s\n", output_file);
- pf = Parrot_readbc(interp, output_file);
+ pf = Parrot_pbc_read(interp, output_file, 0);
if (!pf)
IMCC_fatal_standalone(interp, 1, "Packfile loading failed\n");
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
SET_STATE_LOAD_PBC(interp);
}
}
Modified: trunk/compilers/pirc/src/bcgen.c
==============================================================================
--- trunk/compilers/pirc/src/bcgen.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/compilers/pirc/src/bcgen.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -380,7 +380,7 @@
/* Create a new packfile and load it into the parrot interpreter */
bc->packfile = PackFile_new(interp, 0);
- Parrot_loadbc(interp, bc->packfile);
+ Parrot_pbc_load(interp, bc->packfile);
/* store a pointer to the parrot interpreter, which saves passing around
* the interp as an extra argument.
Modified: trunk/docs/embed.pod
==============================================================================
--- trunk/docs/embed.pod Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/docs/embed.pod Fri Feb 13 18:07:17 2009 (r36680)
@@ -20,8 +20,8 @@
return 1;
}
- pf = Parrot_readbc(interp, "foo.pbc");
- Parrot_loadbc(interp, pf);
+ pf = Parrot_pbc_read(interp, "foo.pbc", 0);
+ Parrot_pbc_load(interp, pf);
Parrot_runcode(interp, argc, argv);
Parrot_destroy(interp);
@@ -242,12 +242,12 @@
=over 4
-=item C<Parrot_PackFile Parrot_readbc(PARROT_INTERP, const char *path)>
+=item C<Parrot_PackFile Parrot_pbc_read(PARROT_INTERP, const char *path, const int debug)>
Reads Parrot bytecode or PIR from the file referenced by C<path>. Returns
-a packfile structure for use by C<Parrot_loadbc()>.
+a packfile structure for use by C<Parrot_pbc_load()>. C<debug> should be 0.
-=item C<void Parrot_loadbc(PARROT_INTERP, Parrot_PackFile pf)>
+=item C<void Parrot_pbc_load(PARROT_INTERP, Parrot_PackFile pf)>
Loads a packfile into the interpreter. After this operation the interpreter
is ready to run the bytecode in the packfile.
Modified: trunk/docs/pdds/draft/pdd10_embedding.pod
==============================================================================
--- trunk/docs/pdds/draft/pdd10_embedding.pod Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/docs/pdds/draft/pdd10_embedding.pod Fri Feb 13 18:07:17 2009 (r36680)
@@ -208,7 +208,7 @@
I<Note: I suppose NULL would work as well; it might be more C-like. Continue
considering.>
-I<Note also: the current C<Parrot_readbc()> and C<Parrot_loadbc()> exposes the
+I<Note also: the current C<Parrot_pbc_read()> and C<Parrot_pbc_load()> exposes the
details of packfiles to the external API and uses two operations to perform a
single logical operation.>
Modified: trunk/examples/c/test_main.c
==============================================================================
--- trunk/examples/c/test_main.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/examples/c/test_main.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -80,13 +80,13 @@
filename = parseflags(interp, &argc, &argv);
- pf = Parrot_readbc(interp, filename);
+ pf = Parrot_pbc_read(interp, filename, 0);
if (!pf) {
return 1;
}
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
Parrot_runcode(interp, argc, argv);
Parrot_destroy(interp);
Modified: trunk/ext/Parrot-Embed/lib/Parrot/Embed.xs
==============================================================================
--- trunk/ext/Parrot-Embed/lib/Parrot/Embed.xs Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/ext/Parrot-Embed/lib/Parrot/Embed.xs Fri Feb 13 18:07:17 2009 (r36680)
@@ -84,7 +84,7 @@
interp = Parrot_new( (Parrot_Interp)parent );
pf = PackFile_new( interp, 0 );
- Parrot_loadbc( interp, pf );
+ Parrot_pbc_load( interp, pf );
/* Can't use RETVAL/OUTPUT here because typemap loses class variable */
ST(0) = sv_newmortal();
@@ -100,13 +100,13 @@
Parrot_PackFile pf;
CODE:
real_interp = interp->interp;
- pf = Parrot_readbc( real_interp, filename );
+ pf = Parrot_pbc_read( real_interp, filename, 0 );
if (!pf)
Perl_croak( aTHX_
"File '%s' not found in $parrot_interpreter->load_file()", filename );
- Parrot_loadbc( real_interp, pf );
+ Parrot_pbc_load( real_interp, pf );
RETVAL = 1;
OUTPUT:
RETVAL
Modified: trunk/include/parrot/embed.h
==============================================================================
--- trunk/include/parrot/embed.h Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/include/parrot/embed.h Fri Feb 13 18:07:17 2009 (r36680)
@@ -49,9 +49,9 @@
PARROT_EXPORT void Parrot_setwarnings(Parrot_Interp, Parrot_warnclass);
-PARROT_EXPORT Parrot_PackFile Parrot_readbc(Parrot_Interp, const char *);
+PARROT_EXPORT Parrot_PackFile Parrot_pbc_read(Parrot_Interp, const char *, const int);
-PARROT_EXPORT void Parrot_loadbc(Parrot_Interp, Parrot_PackFile);
+PARROT_EXPORT void Parrot_pbc_load(Parrot_Interp, Parrot_PackFile);
PARROT_EXPORT void Parrot_setup_argv(Parrot_Interp, int argc, const char **argv);
@@ -78,6 +78,12 @@
int Parrot_revision(void);
+/* Deprecated */
+
+/* with 0.9.1 TT #266 */
+#define Parrot_readbc(i, c) Parrot_pbc_read((i), (c), 0)
+#define Parrot_loadbc(i, pf) Parrot_pbc_load((i), (pf))
+
#endif /* PARROT_EMBED_H_GUARD */
/*
Modified: trunk/include/parrot/packfile.h
==============================================================================
--- trunk/include/parrot/packfile.h Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/include/parrot/packfile.h Fri Feb 13 18:07:17 2009 (r36680)
@@ -24,6 +24,26 @@
#define CONSTANT_SEGMENT_NAME "CONSTANT"
#define BYTE_CODE_SEGMENT_NAME "BYTECODE"
+#define FLOATTYPE_8 0
+#define FLOATTYPE_8_NAME "IEEE-754 8 byte double"
+#define FLOATTYPE_12 1
+#define FLOATTYPE_12_NAME "x86 little endian 12 byte long double"
+#define FLOATTYPE_MAX 1
+
+#define TRACE_PACKFILE 2
+#if TRACE_PACKFILE
+void Parrot_trace_eprintf(ARGIN(const char *s), ...);
+# define TRACE_PRINTF(args) if (pf->options) Parrot_trace_eprintf args
+# if TRACE_PACKFILE == 2
+# define TRACE_PRINTF_VAL(args) if (pf->options & 2) Parrot_trace_eprintf args
+# else
+# define TRACE_PRINTF_VAL(args)
+# endif
+#else
+# define TRACE_PRINTF(args)
+# define TRACE_PRINTF_VAL(args)
+#endif
+
/*
** Structure Definitions:
*/
@@ -971,6 +991,7 @@
__attribute__nonnull__(2);
PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
opcode_t PF_fetch_opcode(
ARGIN_NULLOK(const PackFile *pf),
ARGMOD(const opcode_t **stream))
@@ -1097,6 +1118,13 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*rb);
+void fetch_buf_be_32(
+ ARGOUT(unsigned char *rb),
+ ARGIN(const unsigned char *b))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ FUNC_MODIFIES(*rb);
+
void fetch_buf_be_4(
ARGOUT(unsigned char *rb),
ARGIN(const unsigned char *b))
@@ -1125,6 +1153,13 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*rb);
+void fetch_buf_le_32(
+ ARGOUT(unsigned char *rb),
+ ARGIN(const unsigned char *b))
+ __attribute__nonnull__(1)
+ __attribute__nonnull__(2)
+ FUNC_MODIFIES(*rb);
+
void fetch_buf_le_4(
ARGOUT(unsigned char *rb),
ARGIN(const unsigned char *b))
@@ -1161,6 +1196,9 @@
#define ASSERT_ARGS_fetch_buf_be_16 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(rb) \
|| PARROT_ASSERT_ARG(b)
+#define ASSERT_ARGS_fetch_buf_be_32 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(rb) \
+ || PARROT_ASSERT_ARG(b)
#define ASSERT_ARGS_fetch_buf_be_4 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(rb) \
|| PARROT_ASSERT_ARG(b)
@@ -1173,6 +1211,9 @@
#define ASSERT_ARGS_fetch_buf_le_16 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(rb) \
|| PARROT_ASSERT_ARG(b)
+#define ASSERT_ARGS_fetch_buf_le_32 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
+ PARROT_ASSERT_ARG(rb) \
+ || PARROT_ASSERT_ARG(b)
#define ASSERT_ARGS_fetch_buf_le_4 __attribute__unused__ int _ASSERT_ARGS_CHECK = \
PARROT_ASSERT_ARG(rb) \
|| PARROT_ASSERT_ARG(b)
Modified: trunk/src/embed.c
==============================================================================
--- trunk/src/embed.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/embed.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -374,7 +374,7 @@
/*
-=item C<PackFile * Parrot_readbc>
+=item C<PackFile * Parrot_pbc_read>
Read in a bytecode, unpack it into a C<PackFile> structure, and do fixups.
@@ -385,7 +385,7 @@
PARROT_EXPORT
PARROT_CAN_RETURN_NULL
PackFile *
-Parrot_readbc(PARROT_INTERP, ARGIN_NULLOK(const char *fullname))
+Parrot_pbc_read(PARROT_INTERP, ARGIN_NULLOK(const char *fullname), const int debug)
{
FILE *io = NULL;
INTVAL is_mapped = 0;
@@ -528,6 +528,9 @@
pf = PackFile_new(interp, is_mapped);
+ /* Make the cmdline option available to the unpackers */
+ pf->options = debug;
+
if (!PackFile_unpack(interp, pf, (opcode_t *)program_code,
(size_t)program_size)) {
Parrot_io_eprintf(interp, "Parrot VM: Can't unpack packfile %s.\n",
@@ -556,9 +559,9 @@
/*
-=item C<void Parrot_loadbc>
+=item C<void Parrot_pbc_load>
-Loads the C<PackFile> returned by C<Parrot_readbc()>.
+Loads the C<PackFile> returned by C<Parrot_pbc_read()>.
=cut
@@ -566,7 +569,7 @@
PARROT_EXPORT
void
-Parrot_loadbc(PARROT_INTERP, NOTNULL(PackFile *pf))
+Parrot_pbc_load(PARROT_INTERP, NOTNULL(PackFile *pf))
{
if (pf == NULL) {
Parrot_io_eprintf(interp, "Invalid packfile\n");
@@ -1237,7 +1240,7 @@
pf->cur_cs->base.data = program_code;
pf->cur_cs->base.size = 2;
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
run_native = func;
Modified: trunk/src/exec_start.c
==============================================================================
--- trunk/src/exec_start.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/exec_start.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -81,7 +81,7 @@
printf("Can't unpack.\n");
return 1;
}
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
PackFile_fixup_subs(interp, PBC_PBC, NULL);
/* opcode_map has the offset of each opcode in the compiled code
Modified: trunk/src/packfile.c
==============================================================================
--- trunk/src/packfile.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/packfile.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -451,13 +451,20 @@
extern int Parrot_exec_run;
#endif
-#define TRACE_PACKFILE 0
-
/* TODO: This is broken on 64/32 transformations. See TT #254 */
#define ROUND_16(val) (((val) & 0xf) ? 16 - ((val) & 0xf) : 0)
#define ALIGN_16(st, cursor) \
(cursor) += ROUND_16((const char *)(cursor) - (const char *)(st))/sizeof (opcode_t)
+#if TRACE_PACKFILE
+void Parrot_trace_eprintf(ARGIN(const char *s), ...) {
+ va_list args;
+ va_start(args, s);
+ vfprintf(stderr, s, args);
+ va_end(args);
+}
+#endif
+
/*
=item C<void PackFile_destroy>
@@ -839,11 +846,12 @@
opcode_t i;
PackFile_FixupTable * const ft = self->fixups;
PackFile_ConstTable * const ct = self->const_table;
-
#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PackFile: do_sub_pragmas (action=%d)\n", action);
+ PackFile * const pf = self->base.pf;
#endif
+ TRACE_PRINTF(("PackFile: do_sub_pragmas (action=%d)\n", action));
+
for (i = 0; i < ft->fixup_count; i++) {
switch (ft->fixups[i]->type) {
case enum_fixup_sub:
@@ -911,6 +919,9 @@
const opcode_t *cursor;
int header_read_length;
opcode_t padding;
+#if TRACE_PACKFILE
+ PackFile * const pf = self;
+#endif
self->src = packed;
self->size = packed_size;
@@ -947,23 +958,21 @@
return 0;
}
- if (header->floattype != 0 && header->floattype != 1) {
+ if (header->floattype > FLOATTYPE_MAX) {
Parrot_io_eprintf(NULL, "PackFile_unpack: Invalid floattype %d\n",
header->floattype);
return 0;
}
/* Describe what was read for debugging. */
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PackFile_unpack: Wordsize %d.\n", header->wordsize);
- Parrot_io_eprintf(NULL, "PackFile_unpack: Floattype %d (%s).\n",
- header->floattype,
- header->floattype ?
+ TRACE_PRINTF(("PackFile_unpack: Wordsize %d.\n", header->wordsize));
+ TRACE_PRINTF(("PackFile_unpack: Floattype %d (%s).\n",
+ header->floattype,
+ header->floattype ?
"x86 little endian 12 byte long double" :
- "IEEE-754 8 byte double");
- Parrot_io_eprintf(NULL, "PackFile_unpack: Byteorder %d (%sendian).\n",
- header->byteorder, header->byteorder ? "big " : "little-");
-#endif
+ "IEEE-754 8 byte double"));
+ TRACE_PRINTF(("PackFile_unpack: Byteorder %d (%sendian).\n",
+ header->byteorder, header->byteorder ? "big " : "little-"));
/* Check the UUID type is valid and, if needed, read a UUID. */
if (header->uuid_type == 0) {
@@ -1007,18 +1016,14 @@
}
/* Padding. */
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PackFile_unpack: 3 words padding.\n");
-#endif
+ TRACE_PRINTF(("PackFile_unpack: 3 words padding.\n"));
padding = PF_fetch_opcode(self, &cursor);
padding = PF_fetch_opcode(self, &cursor);
padding = PF_fetch_opcode(self, &cursor);
UNUSED(padding);
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PackFile_unpack: Directory read, offset %d.\n",
- (INTVAL)cursor - (INTVAL)packed);
-#endif
+ TRACE_PRINTF(("PackFile_unpack: Directory read, offset %d.\n",
+ (INTVAL)cursor - (INTVAL)packed));
self->directory.base.file_offset = (INTVAL)cursor - (INTVAL)self->src;
@@ -1040,9 +1045,7 @@
}
#endif
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PackFile_unpack: Unpack done.\n");
-#endif
+ TRACE_PRINTF(("PackFile_unpack: Unpack done.\n"));
return cursor - packed;
}
@@ -1221,8 +1224,13 @@
header->bc_minor = PARROT_PBC_MINOR;
#if NUMVAL_SIZE == 8
header->floattype = 0;
-#else /* if XXX */
+#else
+# if (NUMVAL_SIZE == 12) && PARROT_BIGENDIAN
header->floattype = 1;
+# else
+ exit_fatal(1, "PackFile_set_header: Unsupported floattype NUMVAL_SIZE=%d,"
+ " PARROT_BIGENDIAN=%d\n", NUMVAL_SIZE, PARROT_BIGENDIAN);
+# endif
#endif
}
@@ -1285,6 +1293,7 @@
PackFile * const pf = mem_allocate_zeroed_typed(PackFile);
pf->header = mem_allocate_zeroed_typed(PackFile_Header);
pf->is_mmap_ped = is_mapped;
+ pf->options = 0;
/* fill header with system specific data */
PackFile_set_header(pf->header);
@@ -1375,15 +1384,16 @@
{
ASSERT_ARGS(default_unpack)
DECL_CONST_CAST_OF(opcode_t);
+#if TRACE_PACKFILE
+ PackFile * const pf = self->pf;
+#endif
self->op_count = PF_fetch_opcode(self->pf, &cursor);
self->itype = PF_fetch_opcode(self->pf, &cursor);
self->id = PF_fetch_opcode(self->pf, &cursor);
self->size = PF_fetch_opcode(self->pf, &cursor);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "default_unpack: op_count=%d, itype=%d, id=%d, size=%d.\n",
- self->op_count, self->itype, self->id, self->size);
-#endif
+ TRACE_PRINTF_VAL(("default_unpack: op_count=%d, itype=%d, id=%d, size=%d.\n",
+ self->op_count, self->itype, self->id, self->size));
if (self->size == 0)
return cursor;
@@ -1415,10 +1425,8 @@
int i;
for (i = 0; i < (int)self->size; i++) {
self->data[i] = PF_fetch_opcode(self->pf, &cursor);
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "default_unpack: transformed op[#%d]/%d %u\n",
- i, self->size, self->data[i]);
-#endif
+ TRACE_PRINTF(("default_unpack: transformed op[#%d]/%d %u\n",
+ i, self->size, self->data[i]));
}
}
@@ -1788,6 +1796,9 @@
{
ASSERT_ARGS(PackFile_Segment_unpack)
PackFile_Segment_unpack_func_t f = self->pf->PackFuncs[self->type].unpack;
+#if TRACE_PACKFILE
+ PackFile * const pf = self->pf;
+#endif
cursor = default_unpack(self, cursor);
@@ -1795,21 +1806,22 @@
return NULL;
if (f) {
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PackFile_Segment_unpack: special\n");
-#endif
+ TRACE_PRINTF(("PackFile_Segment_unpack: special\n"));
+
cursor = (f)(interp, self, cursor);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, " PackFile_Segment_unpack: cursor=0x%x\n", cursor);
-#endif
+ TRACE_PRINTF_VAL((" PackFile_Segment_unpack: offset=0x%x\n",
+ pf->src - cursor));
+
if (!cursor)
return NULL;
}
+ TRACE_PRINTF_VAL(("pre-ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n",
+ pf->src - cursor, pf->src, cursor));
+ /* FIXME on 64bit reading 32bit */
ALIGN_16(self->pf->src, cursor);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, " ALIGN_16: src=0x%x cursor=0x%x\n", self->pf->src, cursor);
-#endif
+ TRACE_PRINTF_VAL(("ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n",
+ pf->src - cursor, pf->src, cursor));
return cursor;
}
@@ -1923,9 +1935,7 @@
size_t i;
dir->num_segments = PF_fetch_opcode(pf, &cursor);
-#if TRACE_PACKFILE
- Parrot_io_eprintf(interp, "directory_unpack: %ld num_segments\n", dir->num_segments);
-#endif
+ TRACE_PRINTF(("directory_unpack: %ld num_segments\n", dir->num_segments));
mem_realloc_n_typed(dir->segments, dir->num_segments, PackFile_Segment *);
for (i = 0; i < dir->num_segments; i++) {
@@ -1938,28 +1948,19 @@
if (type >= PF_MAX_SEG)
type = PF_UNKNOWN_SEG;
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "Segment type %d.\n", type);
-#endif
+ TRACE_PRINTF_VAL(("Segment type %d.\n", type));
/* get name */
name = PF_fetch_cstring(pf, &cursor);
-
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "Segment name \"%s\".\n", name);
-#endif
+ TRACE_PRINTF_VAL(("Segment name \"%s\".\n", name));
/* create it */
seg = PackFile_Segment_new_seg(interp, dir, type, name, 0);
mem_sys_free(name);
seg->file_offset = PF_fetch_opcode(pf, &cursor);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "Segment file_offset %ld.\n", seg->file_offset);
-#endif
+ TRACE_PRINTF_VAL(("Segment file_offset %ld.\n", seg->file_offset));
seg->op_count = PF_fetch_opcode(pf, &cursor);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "Segment op_count %ld.\n", seg->op_count);
-#endif
+ TRACE_PRINTF_VAL(("Segment op_count %ld.\n", seg->op_count));
if (pf->need_wordsize) {
#if OPCODE_T_SIZE == 8
@@ -1975,10 +1976,9 @@
pf->header->wordsize);
return 0;
}
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "Segment offset: new pos 0x%x (src=0x%x cursor=0x%x).\n",
- pos - pf->src, pf->src, cursor);
-#endif
+ TRACE_PRINTF_VAL(("Segment offset: new pos 0x%x (src=0x%x cursor=0x%x).\n",
+ pos - pf->src, pf->src, cursor));
+
}
else
pos = pf->src + seg->file_offset;
@@ -2007,14 +2007,12 @@
seg->dir = dir;
}
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "pre-ALIGN_16: cursor=0x%x\n", cursor);
+ TRACE_PRINTF_VAL(("pre-ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n",
+ pf->src - cursor, pf->src, cursor));
/* FIXME on 64bit reading 32bit */
-#endif
ALIGN_16(pf->src, cursor);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "ALIGN_16: src=0x%x cursor=0x%x\n", pf->src, cursor);
-#endif
+ TRACE_PRINTF_VAL(("ALIGN_16: offset=0x%x src=0x%x cursor=0x%x\n",
+ pf->src - cursor, pf->src, cursor));
/* and now unpack contents of dir */
for (i = 0; cursor && i < dir->num_segments; i++) {
@@ -2027,9 +2025,7 @@
size_t delta = 0;
cursor = csave;
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "PackFile_Segment_unpack [%d] tmp len=%d.\n", i, tmp);
-#endif
+ TRACE_PRINTF_VAL(("PackFile_Segment_unpack [%d] tmp len=%d.\n", i, tmp));
pos = PackFile_Segment_unpack(interp, dir->segments[i], cursor);
if (!pos) {
@@ -2037,10 +2033,9 @@
dir->segments[i]->name);
return 0;
}
-#if TRACE_PACKFILE == 2
- else
- Parrot_io_eprintf(NULL, "PackFile_Segment_unpack ok. pos=0x%x\n", pos);
-#endif
+ else {
+ TRACE_PRINTF_VAL((NULL, "PackFile_Segment_unpack ok. pos=0x%x\n", pos));
+ }
/* BUG: on 64bit reading 32bit lurking here! */
if (pf->need_wordsize) {
@@ -2054,10 +2049,8 @@
}
else
delta = pos - cursor;
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, " delta=%d pos=0x%x cursor=0x%x\n",
- delta, pos, cursor);
-#endif
+ TRACE_PRINTF_VAL((" delta=%d pos=0x%x cursor=0x%x\n",
+ delta, pos, cursor));
if ((size_t)delta != tmp || dir->segments[i]->op_count != tmp)
fprintf(stderr, "PackFile_unpack segment '%s' directory length %d "
@@ -3246,10 +3239,7 @@
pf = self->base.pf;
self->fixup_count = PF_fetch_opcode(pf, &cursor);
-#if TRACE_PACKFILE
- Parrot_io_eprintf(interp,
- "PackFile_FixupTable_unpack(): %ld entries\n", self->fixup_count);
-#endif
+ TRACE_PRINTF(("PackFile_FixupTable_unpack(): %ld entries\n", self->fixup_count));
if (self->fixup_count) {
self->fixups = (PackFile_FixupEntry **)mem_sys_allocate_zeroed(
@@ -3274,11 +3264,8 @@
case enum_fixup_sub:
entry->name = PF_fetch_cstring(pf, &cursor);
entry->offset = PF_fetch_opcode(pf, &cursor);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(interp,
- "PackFile_FixupTable_unpack(): type %d, name %s, offset %ld\n",
- entry->type, entry->name, entry->offset);
-#endif
+ TRACE_PRINTF_VAL(("PackFile_FixupTable_unpack(): type %d, name %s, offset %ld\n",
+ entry->type, entry->name, entry->offset));
break;
case enum_fixup_none:
break;
@@ -3497,11 +3484,8 @@
self->const_count = PF_fetch_opcode(pf, &cursor);
-#if TRACE_PACKFILE
- Parrot_io_eprintf(interp,
- "PackFile_ConstTable_unpack: Unpacking %ld constants\n",
- self->const_count);
-#endif
+ TRACE_PRINTF(("PackFile_ConstTable_unpack: Unpacking %ld constants\n",
+ self->const_count));
if (self->const_count == 0) {
return cursor;
@@ -3519,11 +3503,8 @@
}
for (i = 0; i < self->const_count; i++) {
-#if TRACE_PACKFILE
- Parrot_io_eprintf(interp,
- "PackFile_ConstTable_unpack(): Unpacking constant %ld/%ld\n",
- i, self->const_count);
-#endif
+ TRACE_PRINTF(("PackFile_ConstTable_unpack(): Unpacking constant %ld/%ld\n",
+ i, self->const_count));
#if EXEC_CAPABLE
if (Parrot_exec_run)
@@ -3719,10 +3700,8 @@
PackFile * const pf = constt->base.pf;
const opcode_t type = PF_fetch_opcode(pf, &cursor);
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PackFile_Constant_unpack(): Type is %ld ('%c')...\n",
- type, (char)type);
-#endif
+ TRACE_PRINTF(("PackFile_Constant_unpack(): Type is %ld ('%c')...\n",
+ type, (char)type));
switch (type) {
case PFC_NUMBER:
@@ -4056,24 +4035,21 @@
INTVAL i, str_len;
PackFile_ByteCode *code;
char *code_name;
+#if TRACE_PACKFILE
+ PackFile * const pf = seg->pf;
+#endif
/* Unpack keys. */
self->num_keys = PF_fetch_opcode(seg->pf, &cursor);
-#if TRACE_PACKFILE
- Parrot_io_eprintf(interp,
- "PackFile_Annotations_unpack: Unpacking %ld keys\n",
- self->num_keys);
-#endif
+ TRACE_PRINTF(("PackFile_Annotations_unpack: Unpacking %ld keys\n",
+ self->num_keys));
self->keys = mem_allocate_n_typed(self->num_keys, PackFile_Annotations_Key *);
for (i = 0; i < self->num_keys; i++) {
self->keys[i] = mem_allocate_typed(PackFile_Annotations_Key);
self->keys[i]->name = PF_fetch_opcode(seg->pf, &cursor);
self->keys[i]->type = PF_fetch_opcode(seg->pf, &cursor);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(interp,
- "PackFile_Annotations_unpack: key[%d]/%d name=%s type=%d\n",
- i, self->num_keys, self->keys[i]->name, self->keys[i]->type);
-#endif
+ TRACE_PRINTF_VAL(("PackFile_Annotations_unpack: key[%d]/%d name=%s type=%d\n",
+ i, self->num_keys, self->keys[i]->name, self->keys[i]->type));
}
/* Unpack groups. */
@@ -4083,11 +4059,8 @@
self->groups[i] = mem_allocate_typed(PackFile_Annotations_Group);
self->groups[i]->bytecode_offset = PF_fetch_opcode(seg->pf, &cursor);
self->groups[i]->entries_offset = PF_fetch_opcode(seg->pf, &cursor);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(interp,
- "PackFile_Annotations_unpack: group[%d]/%d bytecode_offset=%d entries_offset=%d\n",
- i, self->num_groups, self->groups[i]->bytecode_offset, self->groups[i]->entries_offset);
-#endif
+ TRACE_PRINTF_VAL(("PackFile_Annotations_unpack: group[%d]/%d bytecode_offset=%d entries_offset=%d\n",
+ i, self->num_groups, self->groups[i]->bytecode_offset, self->groups[i]->entries_offset));
}
/* Unpack entries. */
@@ -4447,7 +4420,7 @@
PackFile_append_pbc(PARROT_INTERP, ARGIN_NULLOK(const char *filename))
{
ASSERT_ARGS(PackFile_append_pbc)
- PackFile * const pf = Parrot_readbc(interp, filename);
+ PackFile * const pf = Parrot_pbc_read(interp, filename, 0);
if (!pf)
return NULL;
@@ -4564,6 +4537,9 @@
=head1 HISTORY
+Parrot_readbc and Parrot_loadbc renamed. Trace macros and 64-bit fixes
+by Reini Urban 2009.
+
Rework by Melvin; new bytecode format, make bytecode portable. (Do
endian conversion and wordsize transforms on the fly.)
Modified: trunk/src/packfile/pf_items.c
==============================================================================
--- trunk/src/packfile/pf_items.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/packfile/pf_items.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -60,24 +60,31 @@
__attribute__nonnull__(2)
FUNC_MODIFIES(*dest);
+PARROT_WARN_UNUSED_RESULT
static opcode_t fetch_op_be_4(ARGIN(const unsigned char *b))
__attribute__nonnull__(1);
+PARROT_WARN_UNUSED_RESULT
static opcode_t fetch_op_be_8(ARGIN(const unsigned char *b))
__attribute__nonnull__(1);
+PARROT_WARN_UNUSED_RESULT
static opcode_t fetch_op_le_4(ARGIN(const unsigned char *b))
__attribute__nonnull__(1);
+PARROT_WARN_UNUSED_RESULT
static opcode_t fetch_op_le_8(ARGIN(const unsigned char *b))
__attribute__nonnull__(1);
+PARROT_WARN_UNUSED_RESULT
static opcode_t fetch_op_mixed_be(ARGIN(const unsigned char *b))
__attribute__nonnull__(1);
+PARROT_WARN_UNUSED_RESULT
static opcode_t fetch_op_mixed_le(ARGIN(const unsigned char *b))
__attribute__nonnull__(1);
+PARROT_WARN_UNUSED_RESULT
static opcode_t fetch_op_test(ARGIN(const unsigned char *b))
__attribute__nonnull__(1);
@@ -107,7 +114,9 @@
/* Don't modify between HEADERIZER BEGIN / HEADERIZER END. Your changes will be lost. */
/* HEADERIZER END: static */
-#define TRACE_PACKFILE 0
+#if TRACE_PACKFILE
+void Parrot_trace_eprintf(ARGIN(const char *s), ...);
+#endif
/*
* round val up to whole size, return result in bytes
@@ -236,6 +245,7 @@
*/
+PARROT_WARN_UNUSED_RESULT
static opcode_t
fetch_op_test(ARGIN(const unsigned char *b))
{
@@ -262,6 +272,7 @@
*/
+PARROT_WARN_UNUSED_RESULT
static opcode_t
fetch_op_mixed_le(ARGIN(const unsigned char *b))
{
@@ -298,6 +309,7 @@
*/
+PARROT_WARN_UNUSED_RESULT
static opcode_t
fetch_op_mixed_be(ARGIN(const unsigned char *b))
{
@@ -332,6 +344,7 @@
*/
+PARROT_WARN_UNUSED_RESULT
static opcode_t
fetch_op_be_4(ARGIN(const unsigned char *b))
{
@@ -366,6 +379,7 @@
*/
+PARROT_WARN_UNUSED_RESULT
static opcode_t
fetch_op_be_8(ARGIN(const unsigned char *b))
{
@@ -396,6 +410,7 @@
*/
+PARROT_WARN_UNUSED_RESULT
static opcode_t
fetch_op_le_4(ARGIN(const unsigned char *b))
{
@@ -430,6 +445,7 @@
*/
+PARROT_WARN_UNUSED_RESULT
static opcode_t
fetch_op_le_8(ARGIN(const unsigned char *b))
{
@@ -461,6 +477,7 @@
*/
PARROT_WARN_UNUSED_RESULT
+PARROT_CANNOT_RETURN_NULL
opcode_t
PF_fetch_opcode(ARGIN_NULLOK(const PackFile *pf), ARGMOD(const opcode_t **stream))
{
@@ -470,9 +487,7 @@
return *(*stream)++;
o = (pf->fetch_op)(*((const unsigned char **)stream));
*((const unsigned char **) (stream)) += pf->header->wordsize;
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, " PF_fetch_opcode: 0x%lx (%ld)\n", o, o);
-#endif
+ TRACE_PRINTF_VAL((" PF_fetch_opcode: 0x%lx (%ld)\n", o, o));
return o;
}
@@ -606,36 +621,32 @@
FLOATVAL f;
double d;
if (!pf || !pf->fetch_nv) {
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PF_fetch_number: Native [%d bytes]\n",
- sizeof (FLOATVAL));
-#endif
+ TRACE_PRINTF(("PF_fetch_number: Native [%d bytes]\n",
+ sizeof (FLOATVAL)));
memcpy(&f, (const char*)*stream, sizeof (FLOATVAL));
+ TRACE_PRINTF_VAL(("PF_fetch_number: %f\n", f));
(*stream) += (sizeof (FLOATVAL) + sizeof (opcode_t) - 1)/
sizeof (opcode_t);
return f;
}
f = (FLOATVAL) 0;
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PF_fetch_number: Byteordering..\n");
-#endif
- /* Here is where the size transforms get messy.
- Floattype 0 = IEEE-754 8 byte double
- Floattype 1 = x86 little endian 12 byte long double
- */
- if (NUMVAL_SIZE == 8 && pf->header->floattype) {
+ TRACE_PRINTF(("PF_fetch_number: Byteordering..\n"));
+ /* 12->8 has a messy cast. */
+ if (NUMVAL_SIZE == 8 && pf->header->floattype == FLOATTYPE_12) {
(pf->fetch_nv)((unsigned char *)&d, (const unsigned char *) *stream);
f = d;
+ TRACE_PRINTF_VAL(("PF_fetch_number: cast %f\n", f));
}
else {
(pf->fetch_nv)((unsigned char *)&f, (const unsigned char *) *stream);
+ TRACE_PRINTF_VAL(("PF_fetch_number: %f\n", f));
}
- if (pf->header->floattype) {
- *((const unsigned char **) (stream)) += 12;
- }
- else {
+ if (pf->header->floattype == FLOATTYPE_8) {
*((const unsigned char **) (stream)) += 8;
}
+ else if (pf->header->floattype == FLOATTYPE_12) {
+ *((const unsigned char **) (stream)) += 12;
+ }
return f;
}
@@ -718,21 +729,19 @@
/* These may need to be separate */
size = (size_t)PF_fetch_opcode(pf, cursor);
-
-#if TRACE_PACKFILE
- Parrot_io_eprintf(NULL, "PF_fetch_string(): flags are 0x%04x...\n", flags);
- Parrot_io_eprintf(NULL, "PF_fetch_string(): charset_nr is %ld...\n",
- charset_nr);
- Parrot_io_eprintf(NULL, "PF_fetch_string(): size is %ld...\n", size);
-#endif
+ TRACE_PRINTF(("PF_fetch_string(): flags are 0x%04x...\n", flags));
+ TRACE_PRINTF(("PF_fetch_string(): charset_nr is %ld...\n",
+ charset_nr));
+ TRACE_PRINTF(("PF_fetch_string(): size is %ld...\n", size));
charset_name = Parrot_charset_c_name(interp, charset_nr);
s = string_make(interp, (const char *)*cursor, size, charset_name, flags);
-#if TRACE_PACKFILE == 3
- Parrot_io_eprintf(NULL, "PF_fetch_string(): string is: ");
- Parrot_io_putps(interp, Parrot_io_STDERR(interp), s);
- Parrot_io_eprintf(NULL, "\n");
+#if TRACE_PACKFILE == 2
+ if (pf->options & 3) {
+ /* print only printable characters */
+ Parrot_io_eprintf(NULL, "PF_fetch_string(): string is '%s'\n", s->strstart);
+ }
#endif
/* s = string_make(interp, *cursor, size,
@@ -740,9 +749,7 @@
flags); */
size = ROUND_UP_B(size, wordsize);
-#if TRACE_PACKFILE == 2
- Parrot_io_eprintf(NULL, "PF_fetch_string(): round size up to %ld.\n", size);
-#endif
+ TRACE_PRINTF(("PF_fetch_string(): round size up to %ld.\n", size));
*((const unsigned char **) (cursor)) += size;
return s;
}
@@ -766,7 +773,7 @@
opcode_t padded_size = s->bufused;
char *charcursor;
-#if TRACE_PACKFILE == 2
+#if TRACE_PACKFILE == 3
Parrot_io_eprintf(NULL, "PF_store_string(): size is %ld...\n", s->bufused);
#endif
Modified: trunk/src/parrot_debugger.c
==============================================================================
--- trunk/src/parrot_debugger.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/parrot_debugger.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -179,19 +179,19 @@
ext = strrchr(filename, '.');
if (ext && STREQ(ext, ".pbc")) {
- Parrot_PackFile pf = Parrot_readbc(interp, filename);
+ Parrot_PackFile pf = Parrot_pbc_read(interp, filename, 0);
if (!pf)
return 1;
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
PackFile_fixup_subs(interp, PBC_MAIN, NULL);
}
else {
Parrot_PackFile pf = PackFile_new(interp, 0);
int pasm_file = 0;
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
IMCC_push_parser_state(interp);
IMCC_INFO(interp)->state->file = filename;
Modified: trunk/src/pbc_disassemble.c
==============================================================================
--- trunk/src/pbc_disassemble.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/pbc_disassemble.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -8,7 +8,7 @@
=head1 SYNOPSIS
- pbc_disassemble [-bh?] [-o outfile] [file.pbc]
+ pbc_disassemble [-bdh?] [-o outfile] [file.pbc]
=head1 DESCRIPTION
@@ -52,6 +52,9 @@
printf("pbc_disassemble -o converted.pasm file.pbc\n\n");
printf(" -b\t\t ... bare .pasm without header and left column\n");
printf(" -h\t\t ... dump Constant-table header only\n");
+#if TRACE_PACKFILE
+ printf(" -d\t\t ... debug\n");
+#endif
printf(" -o filename\t ... output to filename\n");
exit(EXIT_SUCCESS);
}
@@ -60,6 +63,7 @@
{ 'h', 'h', OPTION_optional_FLAG, { "--header-only" } },
{ '?', '?', OPTION_optional_FLAG, { "--help" } },
{ 'b', 'b', OPTION_optional_FLAG, { "--bare" } },
+ { 'd', 'd', OPTION_optional_FLAG, { "--debug" } },
{ 'o', 'o', OPTION_required_FLAG, { "--output" } }
};
@@ -81,6 +85,7 @@
Parrot_Interp interp;
const char *outfile = NULL;
int option = 0;
+ int debug = 0;
struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT;
int status;
@@ -102,6 +107,9 @@
case 'o':
outfile = opt.opt_arg;
break;
+ case 'd':
+ debug = 1;
+ break;
case '?':
default:
help();
@@ -114,14 +122,14 @@
argc -= opt.opt_index;
argv += opt.opt_index;
- pf = Parrot_readbc(interp, argc ? *argv : "-");
+ pf = Parrot_pbc_read(interp, argc ? *argv : "-", debug);
if (!pf) {
printf("Can't read PBC\n");
return 1;
}
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
do_dis(interp, outfile, option);
@@ -160,7 +168,7 @@
actually run the disassembler to normal C comments (Wed, 16 Nov 2005).
Reini Urban: Renamed from disassemble to pbc_disassemble (2008-07-03).
- Add options: help, -h, -o, bare (2009-01-29)
+ Add options: help, -h, -o, --debug, --bare (2009-01-29)
=cut
Modified: trunk/src/pbc_dump.c
==============================================================================
--- trunk/src/pbc_dump.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/pbc_dump.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -32,6 +32,11 @@
Terse output.
+=item C<-e> C--debug>
+
+Display detailed packfile reader debugging information if
+F<include/parrot/packfile.h> enables TRACE_PACKFILE
+
=item C<-o converted.pbc>
Repacks a PBC file into the platform's native binary format for better
@@ -180,6 +185,9 @@
printf("\t-d ... disassemble bytecode segments\n");
printf("\t-h ... dump header only\n");
printf("\t-t ... terse output\n");
+#if TRACE_PACKFILE
+ printf("\t--debug debug output\n");
+#endif
printf("\n\t-o converted.pbc repacks a PBC file into "
"the platform's native\n");
printf("\t binary format for better efficiency on reading "
@@ -192,6 +200,7 @@
{ '?', '?', OPTION_optional_FLAG, { "--help" } },
{ 't', 't', OPTION_optional_FLAG, { "--terse" } },
{ 'd', 'd', OPTION_optional_FLAG, { "--disassemble" } },
+ { 'e', 'e', OPTION_optional_FLAG, { "--debug" } },
{ 'o', 'o', OPTION_required_FLAG, { "--output" } }
};
@@ -215,6 +224,7 @@
int disas = 0;
int convert = 0;
int header = 0;
+ int debug = 0;
const char *file = NULL;
struct longopt_opt_info opt = LONGOPT_OPT_INFO_INIT;
int status;
@@ -237,6 +247,9 @@
case 'd':
disas = 1;
break;
+ case 'e':
+ debug = 1;
+ break;
case 'o':
file = opt.opt_arg;
convert = 1;
@@ -254,13 +267,13 @@
argv += opt.opt_index;
- pf = Parrot_readbc(interp, *argv);
+ pf = Parrot_pbc_read(interp, *argv, debug);
if (!pf) {
printf("Can't read PBC\n");
return 1;
}
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
if (convert) {
size_t size;
opcode_t *pack;
Modified: trunk/src/pbc_info.c
==============================================================================
--- trunk/src/pbc_info.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/pbc_info.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -70,7 +70,7 @@
interp = Parrot_new(NULL);
- pf = Parrot_readbc(interp, argv[1]);
+ pf = Parrot_pbc_read(interp, argv[1], 0);
/*
* add some more segments
Modified: trunk/src/pbc_merge.c
==============================================================================
--- trunk/src/pbc_merge.c Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/pbc_merge.c Fri Feb 13 18:07:17 2009 (r36680)
@@ -228,7 +228,7 @@
=item C<static PackFile* pbc_merge_loadpbc>
This function loads a PBC file and unpacks it. We can't
-use Parrot_readbc because that is specified to also
+use Parrot_pbc_read because that is specified to also
fixup the segments, which we don't want.
=cut
@@ -270,7 +270,7 @@
Parrot_exit(interp, 1);
}
- /* Read in program. Nabbed from Parrot_readpbc. */
+ /* Read in program. Nabbed from Parrot_pbc_read. */
chunk_size = program_size > 0 ? program_size : 1024;
program_code = (char *)mem_sys_allocate(chunk_size);
wanted = program_size;
Modified: trunk/src/pmc/packfile.pmc
==============================================================================
--- trunk/src/pmc/packfile.pmc Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/src/pmc/packfile.pmc Fri Feb 13 18:07:17 2009 (r36680)
@@ -82,7 +82,7 @@
=cut
-Implementation note: taken from the bottom end of Parrot_readbc().
+Implementation note: taken from the bottom end of Parrot_pbc_read().
*/
VTABLE void set_string_native(STRING *str) {
PackFile *pf = PMC_data_typed(SELF, PackFile *);
Modified: trunk/t/src/extend.t
==============================================================================
--- trunk/t/src/extend.t Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/t/src/extend.t Fri Feb 13 18:07:17 2009 (r36680)
@@ -440,11 +440,11 @@
static opcode_t*
the_test(PARROT_INTERP, opcode_t *cur_op, opcode_t *start)
{
- PackFile *pf = Parrot_readbc(interp, "$temp_pbc");
+ PackFile *pf = Parrot_pbc_read(interp, "$temp_pbc", 0);
STRING *name = Parrot_str_new_constant(interp, "_sub1");
PMC *sub, *arg;
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
sub = Parrot_find_global_cur(interp, name);
Parrot_call_sub(interp, sub, "v");
Parrot_eprintf(interp, "back\\n");
@@ -514,12 +514,12 @@
static opcode_t*
the_test(PARROT_INTERP, opcode_t *cur_op, opcode_t *start)
{
- PackFile *pf = Parrot_readbc(interp, "$temp_pbc");
+ PackFile *pf = Parrot_pbc_read(interp, "$temp_pbc", 0);
STRING *name = Parrot_str_new_constant(interp, "_sub1");
PMC *sub;
Parrot_runloop jump_point;
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
sub = Parrot_find_global_cur(interp, name);
if (setjmp(jump_point.resume)) {
@@ -602,14 +602,14 @@
return 1;
}
- packfile = Parrot_readbc( interp, "$temp_pbc" );
+ packfile = Parrot_pbc_read( interp, "$temp_pbc", 0 );
if (!packfile) {
printf( "Boo\\n" );
return 1;
}
- Parrot_loadbc( interp, packfile );
+ Parrot_pbc_load( interp, packfile );
Parrot_runcode( interp, 1, code );
Parrot_destroy( interp );
@@ -684,8 +684,8 @@
return 1;
}
- pf = Parrot_readbc( interp, "$temp_pbc" );
- Parrot_loadbc( interp, pf );
+ pf = Parrot_pbc_read( interp, "$temp_pbc", 0 );
+ Parrot_pbc_load( interp, pf );
sub = Parrot_find_global_cur( interp, Parrot_str_new_constant( interp, "add" ) );
result = Parrot_call_sub( interp, sub, "III", 100, 200 );
Modified: trunk/tools/dev/pbc_to_exe.pir
==============================================================================
--- trunk/tools/dev/pbc_to_exe.pir Fri Feb 13 16:21:18 2009 (r36679)
+++ trunk/tools/dev/pbc_to_exe.pir Fri Feb 13 18:07:17 2009 (r36680)
@@ -69,7 +69,7 @@
do_sub_pragmas(interp, pf->cur_cs, PBC_PBC, NULL);
- Parrot_loadbc(interp, pf);
+ Parrot_pbc_load(interp, pf);
PackFile_fixup_subs(interp, PBC_MAIN, NULL);
Parrot_runcode(interp, argc, argv);
More information about the parrot-commits
mailing list