75 #ifdef HAVE_DYNAMIC_LOADING
78 PrintS(
"is not a Singular procedure\n");
83 if (given_lineno >0) lineno=given_lineno;
84 else lineno=
p->data.s.body_lineno;
86 if (given_lineno== -1)
90 Print(
"breakpoints in %s deleted(%#x)\n",
p->procname,
i &255);
97 PrintS(
"too many breakpoints set, max is 7\n");
103 p->trace_flag|=(1<<
i);
104 Print(
"breakpoint %d, at line %d in %s\n",
i,lineno,
p->procname);
111 char * filename =
omStrDup(
"/tmp/sdXXXXXX");
112 int f=mkstemp(filename);
115 Print(
"cannot open %s\n",filename);
121 Print(
"cannot edit type %d\n",
pi->language);
126 const char *editor=
getenv(
"EDITOR");
133 if (
pi->data.s.body==
NULL)
136 if (
pi->data.s.body==
NULL)
138 PrintS(
"cannot get the procedure body\n");
146 ssize_t
res=write(
f,
pi->data.s.body,strlen(
pi->data.s.body));
150 PrintS(
"cannot write the procedure body\n");
163 if (strchr(editor,
' ')==
NULL)
165 execlp(editor,editor,filename,
NULL);
166 Print(
"cannot exec %s\n",editor);
170 size_t len=strlen(editor)+strlen(filename)+2;
172 snprintf(
p,len,
"%s %s",editor,filename);
176 Print(
"cannot call `%s`\n",editor);
186 FILE*
fp=fopen(filename,
"r");
189 Print(
"cannot read from %s\n",filename);
198 pi->data.s.body=(
char *)
omAlloc((
int)len+1);
200 pi->data.s.body[len]=
'\0';
221 char *
p=(
char *)currLine+len-1;
222 while ((*
p<=
' ') && (
p!=currLine))
226 if (
p==currLine)
return;
230 fwrite(currLine,1,len,stdout);
231 Print(
"<<\nbreakpoint %d (press ? for list of commands)\n",bp);
245 "b - print backtrace of calling stack\n"
246 "B <proc> [<line>] - define breakpoint\n"
248 "d - delete current breakpoint\n"
249 "D - show all breakpoints\n"
250 "e - edit the current procedure (current call will be aborted)\n"
251 "h,? - display this help screen\n"
252 "n - execute current line, break at next line\n"
253 "p <var> - display type and value of the variable <var>\n"
254 "q <flags> - quit debugger, set debugger flags(0,1,2)\n"
255 " 0: stop debug, 1:continue, 2: throw an error, return to toplevel\n"
256 "Q - quit Singular\n");
261 Print(
"breakpoint %d at line %d in %s\n",
268 Print(
"delete break point %d\n",bp);
282 extern void listall(
int showproc);
307 memset(&tmp,0,
sizeof(tmp));
321 Print(
"procedure `%s` ",
p);
Class used for (list of) interpreter objects.
void Print(leftv store=NULL, int spaces=0)
Called by type_cmd (e.g. "r;") or as default in jPRINT.
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)
char *(* fe_fgets_stdin)(const char *pr, char *s, int size)
const char * Tok2Cmdname(int tok)
idhdl ggetid(const char *n)
char * iiGetLibProcBuffer(procinfo *pi, int part)
void PrintS(const char *s)
BOOLEAN sdb_set_breakpoint(const char *pp, int given_lineno)
void sdb_edit(procinfo *pi)
void sdb(Voice *currentVoice, const char *currLine, int len)
static char * sdb_find_arg(char *p)
int sdb_checkline(char f)
STATIC_VAR char sdb_lastcmd