Author Topic: Debugger: Determine is a source line has executable code  (Read 21840 times)

dzzie

  • Guest
Debugger: Determine is a source line has executable code
« on: June 10, 2014, 08:33:32 AM »
Hi,

I am working on the debugger GUI now. Most things are working nicely

if i set a breakpoint or Run2Line on an empty source line or variable declaration
the debugger will never stop because execution never touches this line.

I need to figure out a function such as the following:

Code: [Select]
isValidExecutableLine(int lineNo)

pDO->cSourceLines is just an array of all lines. I can put something together by
manually parsing the pDO->SourceLines[j].line but it wont be as robust as the syntax
parser.

Would conclusive information of this kind be available somewhere?

screenshot attached for the curious

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Debugger: Determine is a source line has executable code
« Reply #1 on: June 10, 2014, 08:55:31 AM »
Hi Dave,

Will you be dealing with array variables as well with the debugger? Both DBG and SDBG doesn't.  :'(

I'll ping Peter and see if he can offer some direction on your issue.

John
« Last Edit: June 10, 2014, 12:38:42 PM by support »

dzzie

  • Guest
Re: Debugger: Determine is a source line has executable code
« Reply #2 on: June 10, 2014, 10:21:35 AM »
for an array, I was thinking if they double click the variable name, it could pop up a another form which lists all of its elements
I havent looked into how to walk an array yet

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Debugger: Determine is a source line has executable code
« Reply #3 on: June 10, 2014, 11:01:59 AM »
Quote
I havent looked into how to walk an array yet

 :)

A good look at scriba is about the only example you will have. On a positive note, under the covers an indexed based array looks no different than an associative array or a combination of both.

Quote
it could pop up a another form which lists all of its elements

Maybe popping a window showing the elements and their L/UBOUND ranges first then allow them to select an element's index to traverse showing the data it contains. If you get that working, I would like to chat about REF mappings.  ;)
 
« Last Edit: June 10, 2014, 01:45:31 PM by support »

dzzie

  • Guest
Re: Debugger: Determine is a source line has executable code
« Reply #4 on: June 11, 2014, 05:23:57 AM »
ok got the array walking working with flat and multidimensional arrays. dumping will work to any level deep. Method I used was double click on lower variable list to look up top level array object elements by name. they are dumped to separate window. If any of those elements are arrays, then you double click on those and it will look up the array element by pointer to dump its contents.

couple useful code snips

Code: [Select]
void __stdcall dbg_EnumAryVarsByPointer(pDebuggerObject pDO, VARIABLE v)
{
#pragma EXPORT
VARIABLE v2=NULL;
int low, high, i;
unsigned long sz;
    char cBuffer[2050];
    char buf[1025];

if(v==NULL) return;
if(TYPE(v) != VTYPE_ARRAY) return;

low = ARRAYLOW(v);
high = ARRAYHIGH(v);

for(i = low; i <= high; i++){
v2 = v->Value.aValue[i-low]; //even if lbound(v) = 3 first element is at .aValue[0]
if(v2 != NULL){
sz = 1024;
SPrintVariable(pDO, v2, buf, &sz);
sprintf(cBuffer,"Array-Variable:%d:%d:%s", i, TYPE(v2), buf);
vbStdOut(cb_debugger, cBuffer, strlen(cBuffer));
}
}
}


void __stdcall dbg_EnumCallStack(pDebuggerObject pDO)
{
#pragma EXPORT

  pDebugCallStack_t p;
  pDebugCallStack_t np;
  pUserFunction_t   uf;
  char buf[1024];
  long i;

  if( pDO == NULL )return;

  sprintf(buf, "Call-Stack:%d:%s", LineNumberForNode(pDO,pDO->lPC), "CurrentLine");
  vbStdOut(cb_debugger,buf,strlen(buf));

  if( pDO->StackListPointer == NULL )return;
 
  p = pDO->StackListPointer;
  if(p->pUF && p->pUF->pszFunctionName ){
  sprintf(buf, "Call-Stack:%d:%s", LineNumberForNode(pDO,p->Node), p->pUF->pszFunctionName);
  }else{
  sprintf(buf, "Call-Stack:%d:Unknown", LineNumberForNode(pDO,p->Node) );
  }
  vbStdOut(cb_debugger,buf,strlen(buf));
 
  for(i=0; i < pDO->CallStackDepth; i++){
    if(p->up == NULL) return;
p = p->up;
if(p->pUF && p->pUF->pszFunctionName ){
  sprintf(buf, "Call-Stack:%d:%s", LineNumberForNode(pDO,p->Node) , p->pUF->pszFunctionName);
}else{
sprintf(buf, "Call-Stack:%d:Unknown", LineNumberForNode(pDO,p->Node));
}
vbStdOut(cb_debugger,buf,strlen(buf));
  }


  return;
}


Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: Debugger: Determine is a source line has executable code
« Reply #5 on: June 11, 2014, 08:32:55 AM »
Thanks for the SB array code! That will come in handy with ext. modules I write. Your debugger is coming along nicely and at an amazingly fast pace.

Great job!