Oops! Retract last change. Didn't mean to pollute things with energize just
[deliverable/binutils-gdb.git] / gdb / energize.c
index 33ee5a883d111bbc12a432dc738dba22eac5b361..eee9a17436e90badd48fa8039d825c0352f64790 100644 (file)
@@ -69,7 +69,8 @@ extern int pgrp_inferior;
 
 extern char *source_path;
 
-char **pprompt;                        /* Pointer to pointer to prompt */
+/* The name of the executable file */
+static char *exec_file;
 
 /* Tell energize_command_line_input() where to get its text from */
 static int doing_breakcommands_message = 0;
@@ -219,7 +220,7 @@ full_filename(symtab)
 }
 
 /* Tell the energize kernel how high the stack is so that frame numbers (which
-   are relative to the current stack height make sense.
+   are relative to the current stack height) make sense.
 
    Calculate the number of frames on the stack, and the number of subroutine
    invocations that haven't changed since the last call to this routine.  The
@@ -304,18 +305,52 @@ send_stack_info()
   stack_info_valid = 1;
 }
 
+/* Tell the Energize server about the file and line # that corresponds to pc,
+   and which stack frame level that pc corresponds to. */
+
+static void
+send_location(pc, frame_level)
+     CORE_ADDR pc;
+     int frame_level;
+{
+  char *funcname, *filename;
+  struct symtab_and_line sal;
+  struct symbol *symbol;
+
+  sal = find_pc_line(pc, 0);
+  symbol = find_pc_function(pc);
+
+  funcname = symbol ? symbol->name : "";
+  filename = full_filename(sal.symtab);
+
+  send_stack_info();
+
+  CVWriteStackFrameInfo(conn,
+                       instance_id,
+                       sal.line,
+                       CFileLinePos,
+                       frame_level,
+                       funcname,
+                       filename,
+                       ""      /* XXX ? transcript */
+                       );
+  if (filename)
+    free(filename);
+}
+
 /* Tell the kernel where we are in the program, and what the stack looks like.
    */
 
 static void
 send_status()
-{
-  static int linecount = 48;
-  struct symtab_and_line sal;
+{ 
+  char *funcname;
   struct symbol *symbol;
-  char *funcname, *filename;
   static int sent_prog_inst = 0;
 
+  symbol = find_pc_function(stop_pc);
+  funcname = symbol ? symbol->name : "";
+
   if (!has_run)
     return;
 
@@ -328,12 +363,6 @@ send_status()
       return;
     }
 
-  sal = find_pc_line(stop_pc, 0);
-  symbol = find_pc_function(stop_pc);
-
-  funcname = symbol ? symbol->name : "";
-  filename = full_filename(sal.symtab);
-
   if (!sent_prog_inst)
     {
       sent_prog_inst = 1;
@@ -346,17 +375,8 @@ send_status()
                                 );
     }
 
-  send_stack_info();
-
-  CVWriteStackFrameInfo(conn,
-                       instance_id,
-                       sal.line,
-                       CFileLinePos,
-                       0,      /* XXX - frame # */
-                       funcname,
-                       filename,
-                       ""      /* XXX ? transcript */
-                       );
+  send_location(stop_pc,
+               selected_frame_level); /* Had better be 0! */
 
   CVWriteProgramStoppedInfo(conn,
                            instance_id,
@@ -366,8 +386,6 @@ send_status()
                            ""  /* XXX ? transcript */
                            );
 
-  if (filename)
-    free(filename);
 }
 
 /* Call this to output annotated function names.  Names will be demangled if
@@ -390,7 +408,10 @@ energize_annotate_function(funcname, arg_mode, level)
       demangled_name = cplus_demangle(funcname, arg_mode);
 
       if (demangled_name)
-       funcname = demangled_name;
+       {
+         funcname = demangled_name;
+         printf_filtered("'");
+       }
     }
 
   send_stack_info();
@@ -403,7 +424,10 @@ energize_annotate_function(funcname, arg_mode, level)
                            funcname);
 
   if (demangled_name)
-    free(demangled_name);
+    {
+      free(demangled_name);
+      printf_filtered("'");
+    }
 }
 
 /* Call this just prior to printing out the name & value of a variable.  This
@@ -789,6 +813,7 @@ energize_ignore_breakpoint(b)
 \f
 /* Open up a pty and its associated tty.  Return the fd of the tty. */
 
+#ifndef NCR486
 static void
 getpty()
 {
@@ -809,7 +834,11 @@ getpty()
        continue;
       sprintf(dev, "/dev/tty%c%x", n/16 + 'p', n%16);
       ttyfd = open(dev, O_RDWR);
-      if (ttyfd < 0) {close(ptyfd); continue;}
+      if (ttyfd < 0)
+       {
+         close(ptyfd);
+         continue;
+       }
 
       /* Setup pty for non-blocking I/O.  Also make it give us a SIGIO when
         there's data available.  */
@@ -829,6 +858,75 @@ getpty()
 
   error ("getpty: can't get a pty\n");
 }
+#endif
+/* Alternate getpty for NCRs */
+
+#ifdef NCR486 /* LTL */
+#define MAX_PTM_TRY 16
+#define MAX_GRANTPT_TRY 4
+static void
+getpty()
+{
+  char *slavename;
+  extern char *ptsname();
+  int j, i;
+  int n, mfd, sfd;
+  struct termios termios;
+
+  /* Number of pseudo-terms is tuneable(16 - 255). System default is 16. */
+  for (i = 0; i < MAX_PTM_TRY; i++)
+    {
+      mfd = open("/dev/ptmx", O_RDWR); /* get the master */
+
+      if (mfd < 0)
+       continue;
+
+      if (grantpt(mfd) < 0)    /* get a slave */
+       for (j = 0; j < MAX_GRANTPT_TRY; j++)
+         if (grantpt(mfd) == 0 )
+           {
+             close(mfd);
+             continue;
+           }
+
+      if (unlockpt(mfd) < 0)
+       {                       /* unlock the slave so he can be opened */
+         close(mfd);
+         continue;
+       }
+
+      slavename = ptsname(mfd); /* get the slave device name */
+      if (!slavename)
+       {
+         close(mfd);
+         continue;
+       }
+
+      sfd = open(slavename, O_RDWR);
+
+      if (sfd < 0)
+       {
+         close(mfd);
+         continue;
+       }
+
+      /* setup mty for non-blocking I/O.  Also make it give us a SIGIO
+        when there's data availabe. */
+      n = fcntl(mfd, F_GETFL, 0);
+      fcntl(mfd, F_SETFL, n | O_NDELAY | O_SYNC);
+      fcntl(mfd, F_SETOWN,getpid());
+  
+      tcgetattr(sfd, &termios);
+      termios.c_oflag &= ~OPOST;       /* no post-processing */
+      tcsetattr(sfd, TCSANOW, &termios);
+
+      inferior_pty=mfd;
+      inferior_tty=sfd;
+      return;
+    }
+  error ("getpty: can't get a pts\n");
+} 
+#endif
 \f
 /* Examine a protocol packet from the driver. */
 
@@ -1149,18 +1247,25 @@ kernel_dispatch(queue)
          }
          break;
        case DynamicLoadRType:
-         switch (req->dynamicLoad.request->action)
-           {
-           case CDynamicLoadUpdateSymtab:
-             printf_filtered("CDynamicLoadUpdateSymtab, filename=%s\n",
-                             req->dynamicLoad.filenames.text);
-             break;
-           default:
-             printf_filtered("DynamicLoadRType: unknown action=%d, filename=%s\n",
-                             req->dynamicLoad.request->action,
-                             req->dynamicLoad.filenames.text);
-             break;
-           }
+         {
+           char *filename;
+
+           filename = req->dynamicLoad.filenames.byteLen ?
+             req->dynamicLoad.filenames.text : exec_file;
+
+           switch (req->dynamicLoad.request->action)
+             {
+             case CDynamicLoadUpdateSymtab:
+               execute_command_1(1, queue, "exec-file %s", filename);
+               execute_command_1(1, queue, "symbol-file %s", filename);
+               break;
+             default:
+               printf_filtered("DynamicLoadRType: unknown action=%d, filename=%s\n",
+                               req->dynamicLoad.request->action,
+                               req->dynamicLoad.filenames.text);
+               break;
+             }
+         }
          break;
        default:
          fprintf(stderr, "Unknown Debugger request type = %d\n",
@@ -1309,6 +1414,8 @@ energize_initialize(energize_id, execarg)
 
   if (!execarg) execarg = "";
 
+  exec_file = strdup(execarg); /* Save for later */
+
   printf("\ngdb-debugger pid=%d\n", getpid()); /* XXX - debugging only */
   
   /* First establish the connection with the kernel. */
@@ -1322,6 +1429,9 @@ energize_initialize(energize_id, execarg)
   /* Setup for I/O interrupts when appropriate. */
 
   n = fcntl(kerfd, F_GETFL, 0);
+#ifdef NCR486...
+  O_SYNC
+#endif
   fcntl(kerfd, F_SETFL, n|FASYNC);
   fcntl(kerfd, F_SETOWN, getpid());
 
@@ -1422,6 +1532,11 @@ energize_call_command(cmdblk, arg, from_tty)
   else
     (*cmdblk->function.cfunc)(arg, from_tty);
 
+  if (strcmp(cmdblk->name, "up") == 0
+      || strcmp(cmdblk->name, "down") == 0
+      || strcmp(cmdblk->name, "frame") == 0)
+    send_location(get_frame_info(selected_frame)->pc,
+                 selected_frame_level);
   print_prompt();
 }
 
This page took 0.026204 seconds and 4 git commands to generate.