Changeset 3105b0 in git


Ignore:
Timestamp:
Aug 20, 1999, 6:06:49 PM (25 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
99a286c05af3b60f04f2443ada520b679a44e7a3
Parents:
eb4fa6810e4f32cc808925d5dc987963d1c02d5b
Message:
*hannes: more sdb modi


git-svn-id: file:///usr/local/Singular/svn/trunk@3526 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Singular/extra.cc

    reb4fa6 r3105b0  
    22*  Computer Algebra System SINGULAR      *
    33*****************************************/
    4 /* $Id: extra.cc,v 1.102 1999-08-17 09:25:45 Singular Exp $ */
     4/* $Id: extra.cc,v 1.103 1999-08-20 16:06:49 Singular Exp $ */
    55/*
    66* ABSTRACT: general interface to internals of Singular ("system" command)
     
    4949#include "syz.h"
    5050#include "sdb.h"
    51 #include "version.h"
    5251
    5352// Define to enable many more system commands
     
    954953    if (strcmp(sys_cmd, "breakpoint") == 0)
    955954    {
    956       if ((h!=NULL) && (h->Typ()==PROC_CMD))
    957       {
    958         procinfov p=(procinfov)h->Data();
    959         if (p->language!=LANG_SINGULAR)
    960         {
    961           WerrorS("set breakpoints only in Singular procedures");
    962           return TRUE;
    963         }
    964         int lineno=p->data.s.body_lineno;
     955      if (h==NULL)
     956      {
     957       sdb_show_bp();
     958       return FALSE;
     959      }
     960      else if (h->Typ()==PROC_CMD)
     961      {
     962        int lineno=0;
    965963        if ((h->next!=NULL) && (h->next->Typ()==INT_CMD))
    966964        {
    967965          lineno=(int)h->next->Data();
    968966        }
    969         int i;
    970         if (lineno== -1)
    971         {
    972           i=p->trace_flag;
    973           p->trace_flag &=1;
    974           Print("breakpoints in %s deleted(%#x)\n",p->procname,i &255);
    975           return FALSE;
    976         }
    977         i=0;
    978         while((i<7) && (sdb_lines[i]!=-1)) i++;
    979         if (sdb_lines[i]!= -1)
    980         {
    981           PrintS("too many breakpoints set, max is 7\n");
    982           return FALSE;
    983         }
    984         else
    985         {
    986           sdb_lines[i]=lineno;
    987           sdb_files[i]=p->libname;
    988           i++;
    989           Print("breakpoint %d, at line %d in %s\n",i,lineno,p->procname);
    990           p->trace_flag|=(1<<i);
    991         }
    992       }
    993       else
    994       {
    995         WerrorS("system(\"breakpoint\",`proc`,`int`) expected");
     967        return sdb_set_breakpoint(h->Name(),lineno);
     968      }
     969      else
     970      {
     971        WerrorS("system(\"breakpoint\",`proc`[,`int`]) expected");
    996972        return TRUE;
    997973      }
    998       return FALSE;
    999974    }
    1000975    else
  • Singular/sdb.cc

    reb4fa6 r3105b0  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: sdb.cc,v 1.9 1999-06-10 15:14:03 Singular Exp $ */
     4/* $Id: sdb.cc,v 1.10 1999-08-20 16:06:48 Singular Exp $ */
    55/*
    66* ABSTRACT: Singular debugger
     
    1717#include "sdb.h"
    1818
     19// We use 8 breakpoints - corresponding to a bit in a char variable in procinfo
     20// bit 1..7 force a breakpoint, if lineno==sdb_lines[i-1],
     21//                         (for displaying only: file sdb_files[i-1])
     22// bit 0 force a breakpoint in every line (used for 'n')
     23
    1924int sdb_lines[]={-1,-1,-1,-1,-1,-1,-1,-1};
    2025char * sdb_files[6];
     
    3338  }
    3439  return 0;
     40}
     41
     42static char *sdb_find_arg(char *p)
     43{
     44  p++;
     45  while (*p==' ') p++;
     46  char *pp=p;
     47  while (*pp>' ') pp++;
     48  *pp='\0';
     49  return p;
     50}
     51
     52void sdb_show_bp()
     53{
     54  for(int i=0; i<7;i++)
     55    if (sdb_lines[i]!= -1)
     56      Print("Breakpoint %d: %s::%d\n",i+1,sdb_files[i],sdb_lines[i]);
     57}
     58
     59BOOLEAN sdb_set_breakpoint(const char *pp, int given_lineno)
     60{
     61  idhdl h=ggetid(pp,TRUE);
     62  if ((h==NULL)||(IDTYP(h)!=PROC_CMD))
     63  {
     64    PrintS(" not found\n");
     65    return TRUE;
     66  }
     67  else
     68  {
     69    procinfov p=(procinfov)IDDATA(h);
     70    #ifdef HAVE_DYNAMIC_LOADING
     71    if (p->language!=LANG_SINGULAR)
     72    {
     73      PrintS("is not a Singular procedure\n");
     74      return TRUE;
     75    }
     76    #endif
     77    int lineno;
     78    if (given_lineno >0) lineno=given_lineno;
     79    else                 lineno=p->data.s.body_lineno;
     80    int i;
     81    if (given_lineno== -1)
     82    {
     83      i=p->trace_flag;
     84      p->trace_flag &=1;
     85      Print("breakpoints in %s deleted(%#x)\n",p->procname,i &255);
     86      return FALSE;
     87    }
     88    i=0;
     89    while((i<7) && (sdb_lines[i]!=-1)) i++;
     90    if (sdb_lines[i]!= -1)
     91    {
     92      PrintS("too many breakpoints set, max is 7\n");
     93      return TRUE;
     94    }
     95    sdb_lines[i]=lineno;
     96    sdb_files[i]=p->libname;
     97    i++;
     98    p->trace_flag|=(1<<i);
     99    Print("breakpoint %d, at line %d in %s\n",i,lineno,p->procname);
     100    return FALSE;
     101  }
    35102}
    36103
     
    122189  unlink(filename);
    123190  FreeL(filename);
    124 }
    125 
    126 static char *sdb_find_arg(char *p)
    127 {
    128   p++;
    129   while (*p==' ') p++;
    130   char *pp=p;
    131   while (*pp>' ') pp++;
    132   *pp='\0';
    133   return p;
    134191}
    135192
     
    172229          PrintS(
    173230          "b - print backtrace of calling stack\n"
     231          "B <proc> [<line>] - define breakpoint\n"
    174232          "c - continue\n"
    175233          "d - delete current breakpoint\n"
     234          "D - show all preakpoints\n"
    176235          "e - edit the current procedure (current call will be aborted)\n"
    177236          "h,? - display this help screen\n"
     
    199258          break;
    200259        }
     260        case 'D':
     261          sdb_show_bp();
     262          break;
    201263        case 'n':
    202264          currentVoice->pi->trace_flag|= 1;
     
    211273        {
    212274          p=sdb_find_arg(p);
    213           Print("request `%s`",p);
     275          Print("variable `%s`",p);
    214276          idhdl h=ggetid(p,TRUE);
    215277          if (h==NULL)
    216             PrintS("NULL\n");
     278            PrintS(" not found\n");
    217279          else
    218280          {
     
    229291          VoiceBackTrack();
    230292          break;
     293        case 'B':
     294        {
     295          p=sdb_find_arg(p);
     296          Print("procedure `%s` ",p);
     297          sdb_set_breakpoint(p);
     298          break;
     299        }
    231300        case 'q':
    232301        {
  • Singular/sdb.h

    reb4fa6 r3105b0  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: sdb.h,v 1.4 1999-05-06 16:53:25 Singular Exp $ */
     6/* $Id: sdb.h,v 1.5 1999-08-20 16:06:49 Singular Exp $ */
    77/*
    88* ABSTRACT: Singular debugger
     
    1717
    1818void sdb_edit(procinfo *pi);
     19void sdb_show_bp();
     20BOOLEAN sdb_set_breakpoint(const char *p, int lineno=0);
    1921void sdb(Voice * currentVoice, const char * currLine, int len);
    2022#endif
Note: See TracChangeset for help on using the changeset viewer.