cvsuser     02/11/16 07:12:19

  Modified:    .        MANIFEST embed.c jit.c
               config/gen/makefiles root.in
  Added:       .        jit_debug.c
  Log:
  JIT debug via gdb
  
  Revision  Changes    Path
  1.252     +1 -0      parrot/MANIFEST
  
  Index: MANIFEST
  ===================================================================
  RCS file: /cvs/public/parrot/MANIFEST,v
  retrieving revision 1.251
  retrieving revision 1.252
  diff -u -w -r1.251 -r1.252
  --- MANIFEST  15 Nov 2002 05:49:06 -0000      1.251
  +++ MANIFEST  16 Nov 2002 15:12:17 -0000      1.252
  @@ -1262,6 +1262,7 @@
   jit/sun4/core.jit
   jit/sun4/jit_emit.h
   jit2h.pl
  +jit_debug.c
   key.c
   languages/BASIC/README.BASIC
   languages/BASIC/alpha.pasm
  
  
  
  1.50      +3 -1      parrot/embed.c
  
  Index: embed.c
  ===================================================================
  RCS file: /cvs/public/parrot/embed.c,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -w -r1.49 -r1.50
  --- embed.c   8 Nov 2002 05:18:39 -0000       1.49
  +++ embed.c   16 Nov 2002 15:12:17 -0000      1.50
  @@ -1,7 +1,7 @@
   /* embed.c
    *  Copyright: (When this is determined...it will go here)
    *  CVS Info
  - *     $Id: embed.c,v 1.49 2002/11/08 05:18:39 josh Exp $
  + *     $Id: embed.c,v 1.50 2002/11/16 15:12:17 leo Exp $
    *  Overview:
    *     The Parrot embedding interface.
    *  Data Structure and Algorithms:
  @@ -128,6 +128,8 @@
   
   #endif  /* HAS_HEADER_SYSMMAN */
   
  +        interpreter->current_file = string_make(interpreter, filename,
  +                strlen(filename), NULL, 0, NULL);
       }
   
       /* if we've opened a file (or stdin) with PIO, read it in */
  
  
  
  1.40      +12 -1     parrot/jit.c
  
  Index: jit.c
  ===================================================================
  RCS file: /cvs/public/parrot/jit.c,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -w -r1.39 -r1.40
  --- jit.c     16 Nov 2002 10:35:58 -0000      1.39
  +++ jit.c     16 Nov 2002 15:12:17 -0000      1.40
  @@ -1,7 +1,7 @@
   /*
    * jit.c
    *
  - * $Id: jit.c,v 1.39 2002/11/16 10:35:58 leo Exp $
  + * $Id: jit.c,v 1.40 2002/11/16 15:12:17 leo Exp $
    */
   
   #include <parrot/parrot.h>
  @@ -9,6 +9,10 @@
   #define JIT_EMIT 0
   #include "parrot/jit_emit.h"
   
  +#ifdef __GNUC__
  +void Parrot_jit_debug(struct Parrot_Interp* interpreter);
  +#endif
  +
   /*
    * optimize_jit()
    */
  @@ -584,6 +588,13 @@
   #ifdef PPC
       ppc_sync_cache(jit_info.arena.start, jit_info.native_ptr);
   #endif
  +
  +    /* assume gdb is available */
  +#ifdef __GNUC__
  +    if (Interp_flags_TEST(interpreter, PARROT_DEBUG_FLAG))
  +        Parrot_jit_debug(interpreter);
  +#endif
  +
       return (jit_f)D2FPTR(jit_info.arena.start);
   }
   
  
  
  
  1.1                  parrot/jit_debug.c
  
  Index: jit_debug.c
  ===================================================================
  /*
   * jit_debug.c
   *
   * $Id: jit_debug.c,v 1.1 2002/11/16 15:12:17 leo Exp $
   *
   * write stabs file for jit code
   * when debugging jit code with gdb, do:
   *
   * add-symbol-file <file.o> 0
   *
   */
  
  #include <parrot/parrot.h>
  #include "parrot/jit.h"
  
  #ifdef __GNUC__
  void Parrot_jit_debug(struct Parrot_Interp* interpreter);
  
  static void
  Parrot_jit_debug_stabs(struct Parrot_Interp *interpreter)
  {
      Parrot_jit_info_t *jit_info = interpreter->jit_info;
      STRING *file = interpreter->current_file;
      STRING *pasmfile, *stabsfile, *ofile, *cmd;
      FILE *stabs;
      size_t i;
      int line;
  
      /* chop pbc */
      file = string_chopn(file, 3);
      pasmfile = string_copy(interpreter, file);
      pasmfile = string_append(interpreter, pasmfile,
              string_make(interpreter, "pasm", 4, 0, 0, 0),
              0);
      stabsfile = string_copy(interpreter, file);
      stabsfile = string_append(interpreter, stabsfile,
              string_make(interpreter, "stabs.s", 7, 0, 0, 0),
              0);
      ofile = string_copy(interpreter, file);
      ofile = string_append(interpreter, ofile,
              string_make(interpreter, "o", 4, 0, 0, 0),
              0);
      stabsfile = string_copy(interpreter, file);
      stabsfile = string_append(interpreter, stabsfile,
              string_make(interpreter, "stabs.s", 7, 0, 0, 0),
              0);
      stabs = fopen(string_to_cstring(interpreter,stabsfile), "w");
      if (stabs == NULL)
          return;
  
      /* filename info */
      fprintf(stabs, ".stabs \"%s\",100,0,0,0\n",
              string_to_cstring(interpreter, pasmfile));
      /* jit_func start addr */
      fprintf(stabs, ".stabs \"jit_func:F(0,1)\",36,0,1,%p\n",
              jit_info->arena.start);
      /* we don't have line numbers yet, emit dummys, assuming there are
       * no comments and spaces in source for testing
       */
  
      /* jit_begin */
      fprintf(stabs, ".stabn 68,0,1,0\n");
      line = 1;
      for (i = 0; i < jit_info->arena.map_size; i++) {
          if (jit_info->arena.op_map[i].ptr) {
              fprintf(stabs, ".stabn 68,0,%d,%d\n", line,
                      (char *)jit_info->arena.op_map[i].ptr -
                      (char *)jit_info->arena.start);
              line++;
          }
      }
      fprintf(stabs, ".stabs \"\",36,0,1,%p\n",
              (char *)jit_info->arena.start+ jit_info->arena.size);
      fclose(stabs);
      /* run the stabs file through C<as> generating file.o */
      cmd = Parrot_sprintf_c(interpreter, "as %Ss -o %Ss", stabsfile, ofile);
      system(string_to_cstring(interpreter, cmd));
  }
  
  void
  Parrot_jit_debug(struct Parrot_Interp* interpreter)
  {
  
      Parrot_jit_debug_stabs(interpreter);
  }
  
  
  #endif
  
  /*
   * Local variables:
   * c-indentation-style: bsd
   * c-basic-offset: 4
   * indent-tabs-mode: nil
   * End:
   *
   * vim: expandtab shiftwidth=4:
  */
  
  
  
  1.55      +4 -2      parrot/config/gen/makefiles/root.in
  
  Index: root.in
  ===================================================================
  RCS file: /cvs/public/parrot/config/gen/makefiles/root.in,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -w -r1.54 -r1.55
  --- root.in   8 Nov 2002 05:18:41 -0000       1.54
  +++ root.in   16 Nov 2002 15:12:19 -0000      1.55
  @@ -100,7 +100,7 @@
        register$(O) core_ops$(O) core_ops_prederef$(O) memory$(O) \
        packfile$(O) stacks$(O) string$(O) sub$(O) encoding$(O) \
        chartype$(O) runops_cores$(O) trace$(O) pmc$(O) key$(O) hash$(O) \
  -     core_pmcs$(O) platform$(O) ${jit_o} \
  +     core_pmcs$(O) platform$(O) ${jit_o} jit_debug$(O) \
        ${gc_o} rx$(O) rxstacks$(O) intlist$(O) list$(O) \
        embed$(O) warnings$(O)  ${cg_o} \
        packout$(O) byteorder$(O) debug$(O) smallobject$(O) \
  @@ -342,6 +342,8 @@
   
   jit$(O) : $(GENERAL_H_FILES) ${jit_h} $(INC)/jit_emit.h
   
  +jit_debug$(O) : $(GENERAL_H_FILES) ${jit_h}
  +
   jit_cpu$(O): $(GENERAL_H_FILES) ${jit_h} $(INC)/jit_emit.h
   
   key$(O) : $(GENERAL_H_FILES)
  
  
  


Reply via email to