changeset 10:6f0fb88d1463 src

Added some debug info, to hopefully help in tracking bugs in libdvdnav.
author jcdutton
date Tue, 09 Apr 2002 15:19:07 +0000
parents 058a95695876
children 1f479a99339c
files decoder.c decoder.h highlight.c vm.c vmcmd.c vmcmd.h
diffstat 6 files changed, 62 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/decoder.c	Sun Apr 07 19:35:54 2002 +0000
+++ b/decoder.c	Tue Apr 09 15:19:07 2002 +0000
@@ -51,7 +51,7 @@
 /* Get count bits of command from byte and bit position. */
 static uint32_t bits(int byte, int bit, int count) {
   uint32_t val = 0;
-  int bit_mask;
+  uint8_t bit_mask;
   
   while(count--) {
     if(bit > 7) {
@@ -350,9 +350,10 @@
       data2 = bits(5, 4, 4);
       if(bits(5, 0, 1)) {
 	fprintf(stderr, "Detected SetGPRMMD Counter!! This is unsupported.\n");
-	assert(0);
+	state->GPRM_mode[data2] = 1;
       } else {
-	;
+	fprintf(stderr, "Detected ResetGPRMMD Counter!! This is unsupported.\n");
+	state->GPRM_mode[data2] = 0;
       }
       if(cond) {
 	state->GPRM[data2] = data;
@@ -540,34 +541,33 @@
 
 #ifdef TRACE
   /*  DEBUG */
+  fprintf(stderr, "libdvdnav: Registers before transaction\n");
+  vmPrint_registers( registers );
   if(1) {
     int i;
-    fprintf(stderr, "   #   ");
-    for(i = 0; i < 24; i++)
-    fprintf(stderr, " %2d |", i);
-    fprintf(stderr, "\nSRPMS: ");
-    for(i = 0; i < 24; i++)
-      fprintf(stderr, "%04x|", state->SPRM[i]);
-    fprintf(stderr, "\nGRPMS: ");
-    for(i = 0; i < 16; i++)
-      fprintf(stderr, "%04x|", state->GPRM[i]);
-    fprintf(stderr, "\n");
-  }
-  if(1) {
-    int i;
+    fprintf(stderr, "libdvdnav: Full list of commands to execute\n");
     for(i = 0; i < num_commands; i++)
       vmPrint_CMD(i, &commands[i]);
     fprintf(stderr, "--------------------------------------------\n");
   } /*  end DEBUG */
+  if (1) {
+    fprintf(stderr, "libdvdnav: Single stepping commands\n");
+  }
 #endif
   
   while(i < num_commands && total < 100000) {
     int line;
     
-    if(0) vmPrint_CMD(i, &commands[i]);
+#ifdef TRACE
+    if(1) vmPrint_CMD(i, &commands[i]);
+#endif
     line = eval_command(&commands[i].bytes[0], return_values);
     
     if (line < 0) { /*  Link command */
+#ifdef TRACE
+      fprintf(stderr, "libdvdnav: Registers after transaction\n");
+      vmPrint_registers( registers );
+#endif
       fprintf(stderr, "eval: Doing Link/Jump/Call\n"); 
       return 1;
     }
@@ -581,6 +581,10 @@
   }
   
   memset(return_values, 0, sizeof(link_t));
+#ifdef TRACE
+  fprintf(stderr, "libdvdnav: Registers after transaction\n");
+  vmPrint_registers( registers );
+#endif
   return 0;
 }
 
@@ -705,3 +709,20 @@
     break;
   }
  }
+
+void vmPrint_registers( registers_t *registers ) {
+  int i;
+  fprintf(stderr, "   #   ");
+  for(i = 0; i < 24; i++)
+    fprintf(stderr, " %2d |", i);
+  fprintf(stderr, "\nSRPMS: ");
+  for(i = 0; i < 24; i++)
+    fprintf(stderr, "%04x|", registers->SPRM[i]);
+  fprintf(stderr, "\nGRPMS: ");
+  for(i = 0; i < 16; i++)
+    fprintf(stderr, "%04x|", registers->GPRM[i]);
+  fprintf(stderr, "\nGmode: ");
+  for(i = 0; i < 16; i++)
+    fprintf(stderr, "%04x|", registers->GPRM_mode[i]);
+  fprintf(stderr, "\n");
+}
--- a/decoder.h	Sun Apr 07 19:35:54 2002 +0000
+++ b/decoder.h	Tue Apr 09 15:19:07 2002 +0000
@@ -85,13 +85,13 @@
 typedef struct {
   uint16_t SPRM[24];
   uint16_t GPRM[16];
-  /* Need to have some thing to indicate normal/counter mode for every GPRM */
-  /* int GPRM_mode[16]; */
+  uint8_t  GPRM_mode[16];  /* Need to have some thing to indicate normal/counter mode for every GPRM */
 } registers_t;
 
 int vmEval_CMD(vm_cmd_t commands[], int num_commands, 
 	       registers_t *registers, link_t *return_values);
 
 void vmPrint_LINK(link_t value);
+void vmPrint_registers( registers_t *registers );
 
 #endif /* DECODER_H_INCLUDED */
--- a/highlight.c	Sun Apr 07 19:35:54 2002 +0000
+++ b/highlight.c	Tue Apr 09 15:19:07 2002 +0000
@@ -163,7 +163,7 @@
 
   /* Finally, make the VM execute the appropriate code and
    * scedule a jump */
-
+  fprintf(stderr, "libdvdnav: Evaluating Button Activation commands.\n");
   if(vm_eval_cmd(self->vm, &(button_ptr->cmd)) == 1) {
     /* Cammand caused a jump */
     dvdnav_do_post_jump(self);
--- a/vm.c	Sun Apr 07 19:35:54 2002 +0000
+++ b/vm.c	Tue Apr 09 15:19:07 2002 +0000
@@ -46,10 +46,10 @@
 static void saveRSMinfo(vm_t *vm,int cellN, int blockN);
 static int set_PGN(vm_t *vm);
 static link_t play_PGC(vm_t *vm);
+static link_t play_PGC_post(vm_t *vm);
 static link_t play_PG(vm_t *vm);
 static link_t play_Cell(vm_t *vm);
 static link_t play_Cell_post(vm_t *vm);
-static link_t play_PGC_post(vm_t *vm);
 static link_t process_command(vm_t *vm,link_t link_values);
 
 static void ifoOpenNewVTSI(vm_t *vm,dvd_reader_t *dvd, int vtsN);
@@ -165,6 +165,7 @@
   /*  Setup State */
   memset((vm->state).registers.SPRM, 0, sizeof(uint16_t)*24);
   memset((vm->state).registers.GPRM, 0, sizeof((vm->state).registers.GPRM));
+  memset((vm->state).registers.GPRM_mode, 0, sizeof((vm->state).registers.GPRM_mode));
   (vm->state).registers.SPRM[0] = ('e'<<8)|'n'; /*  Player Menu Languange code */
   (vm->state).AST_REG = 15; /*  15 why? */
   (vm->state).SPST_REG = 62; /*  62 why? */
@@ -957,6 +958,7 @@
     link_t link_next_pgc = {LinkNextPGC, 0, 0, 0};
     fprintf(stderr, "** Fell of the end of the pgc, continuing in NextPGC\n");
     assert((vm->state).pgc->next_pgc_nr != 0);
+    /* Should end up in the STOP_DOMAIN if next_pgc is 0. */
     return link_next_pgc;
   }
 }
@@ -983,12 +985,13 @@
       /* BUTTON number:data1 */
       if(link_values.data1 != 0)
 	(vm->state).HL_BTNN_REG = link_values.data1 << 10;
-      fprintf(stderr, "libdvdnav in trouble...LinkNoLink - CRASHING!!!\n");
+      fprintf(stderr, "libdvdnav: FIXME: in trouble...LinkNoLink - CRASHING!!!\n");
       assert(0);
       
     case LinkTopC:
-      /* Link to Top?? Cell */
+      /* Link to Top?? Cell. What is TopC */
       /* BUTTON number:data1 */
+      fprintf(stderr, "libdvdnav: FIXME: LinkTopC. What is LinkTopC?\n");
       if(link_values.data1 != 0)
 	(vm->state).HL_BTNN_REG = link_values.data1 << 10;
       link_values = play_Cell(vm);
@@ -998,7 +1001,7 @@
       /* BUTTON number:data1 */
       if(link_values.data1 != 0)
 	(vm->state).HL_BTNN_REG = link_values.data1 << 10;
-      (vm->state).cellN += 1; /* FIXME: What if cellN becomes > nr_of_cells? */
+      (vm->state).cellN += 1; /* if cellN becomes > nr_of_cells? it is handled in play_Cell() */
       link_values = play_Cell(vm);
       break;
     case LinkPrevC:
@@ -1006,13 +1009,14 @@
       /* BUTTON number:data1 */
       if(link_values.data1 != 0)
 	(vm->state).HL_BTNN_REG = link_values.data1 << 10;
-      (vm->state).cellN -= 1; /*  FIXME: What if cellN becomes < 1? */
+      (vm->state).cellN -= 1; /*  If cellN becomes < 1? it is handled in play_Cell() */
       link_values = play_Cell(vm);
       break;
       
     case LinkTopPG:
       /* Link to Top Program */
       /* BUTTON number:data1 */
+      fprintf(stderr, "libdvdnav: FIXME: LinkTopPG. What is LinkTopPG?\n");
       if(link_values.data1 != 0)
 	(vm->state).HL_BTNN_REG = link_values.data1 << 10;
       /*  Does pgN always contain the current value? */
@@ -1041,6 +1045,7 @@
     case LinkTopPGC:
       /* Link to Top Program Chain */
       /* BUTTON number:data1 */
+      fprintf(stderr, "libdvdnav: FIXME: LinkTopPGC. What is LinkTopPGC?\n");
       if(link_values.data1 != 0)
 	(vm->state).HL_BTNN_REG = link_values.data1 << 10;
       link_values = play_PGC(vm);
@@ -1078,6 +1083,7 @@
     case LinkTailPGC:
       /* Link to Tail??? Program Chain */
       /* BUTTON number:data1 */
+      fprintf(stderr, "libdvdnav: FIXME: LinkTailPGC. What is LinkTailPGC?\n");
       if(link_values.data1 != 0)
 	(vm->state).HL_BTNN_REG = link_values.data1 << 10;
       link_values = play_PGC_post(vm);
@@ -1159,7 +1165,7 @@
       break;
       
     case Exit:
-      fprintf(stderr, "libdvdnav in trouble...Link Exit - CRASHING!!!\n");
+      fprintf(stderr, "libdvdnav: FIXME:in trouble...Link Exit - CRASHING!!!\n");
       assert(0); /*  What should we do here?? */
       
     case JumpTT:
@@ -1177,7 +1183,7 @@
       /* Only allowed from the VTS Menu Domain(VTSM) */
       /* or the Video Title Set Domain(VTS) */
       assert((vm->state).domain == VTSM_DOMAIN || (vm->state).domain == VTS_DOMAIN); /* ?? */
-      /* FIXME: Should be able to use get_VTS_PTT here */
+      fprintf(stderr, "libdvdnav: FIXME: Should be able to use get_VTS_PTT here.\n"); 
       if(get_VTS_TT(vm,(vm->state).vtsN, link_values.data1) == -1)
 	assert(0);
       link_values = play_PGC(vm);
@@ -1549,6 +1555,9 @@
 
 /*
  * $Log$
+ * Revision 1.6  2002/04/09 15:19:07  jcdutton
+ * Added some debug info, to hopefully help in tracking bugs in libdvdnav.
+ *
  * Revision 1.5  2002/04/07 19:35:54  jcdutton
  * Added some comments into the code.
  *
--- a/vmcmd.c	Sun Apr 07 19:35:54 2002 +0000
+++ b/vmcmd.c	Tue Apr 09 15:19:07 2002 +0000
@@ -146,9 +146,9 @@
 
 static void print_system_reg(uint16_t reg) {
   if(reg < sizeof(system_reg_abbr_table) / sizeof(char *))
-    fprintf(stderr, system_reg_table[reg]);
+    fprintf(stderr, "%s (SRPM:%d)", system_reg_table[reg], reg);
   else
-    fprintf(stderr, " WARNING: Unknown system register ");
+    fprintf(stderr, " WARNING: Unknown system register ( reg=%d ) ", reg);
 }
 
 static void print_reg(uint8_t reg) {
@@ -518,3 +518,5 @@
   vmPrint_mnemonic(command);
   fprintf(stderr, "\n");
 }
+
+
--- a/vmcmd.h	Sun Apr 07 19:35:54 2002 +0000
+++ b/vmcmd.h	Tue Apr 09 15:19:07 2002 +0000
@@ -28,6 +28,7 @@
 #include "config.h"
 #include <inttypes.h>
 #include <dvdread/ifo_types.h> /*  Only for vm_cmd_t  */
+#include "decoder.h"
 
 void vmPrint_mnemonic(vm_cmd_t *command);
 void vmPrint_CMD(int row, vm_cmd_t *command);