1. Meta Information for Debugging

Is there anything I can call on from Euphoria code to give me the name of the history of called procedures/functions?

So, for example, in a debug_print() function, I could look at the list and see what procedure/function called the debug_print() function? Obviously, this would be meta-data known by the interpreter/executable, and would be very convenient for debugging.

If we don't have this, I will add $50 to the bounty to incorporate it into Euphoria code. smile

If there's another/better way to track this (during end-user run-time, NOT during debugging), I would love to hear about it.

new topic     » topic index » view message » categorize

2. Re: Meta Information for Debugging

euphoric said...

Is there anything I can call on from Euphoria code to give me the name of the history of called procedures/functions?

have you tried

 --debugger=simple_debug.e 
or 
 --debugger=simple_debug.dll 
using 
/Eu41/demo/simple_debug.e 
or 
built as a dll/so 

demo & doc needs more comment. debugger is probably one of the lesser known options.

a combination bounty/poll page might inspire someone to write another example demo.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Meta Information for Debugging

Looks like some useful and complicated stuff! I'll check this out. Thank you!

new topic     » goto parent     » topic index » view message » categorize

4. Re: Meta Information for Debugging

ne1uno said...

have you tried

In particular something like this (this is eu 4.1):

without inline 
include euphoria/debug/debug.e 
include std/console.e 
 
procedure debug_print() 
	display( call_stack() ) 
end procedure 
 
procedure foo() 
	debug_print() 
end procedure 
 
procedure bar() 
	foo() 
	debug_print() 
end procedure 
 
debug_print() 
foo() 
bar() 

Matt

new topic     » goto parent     » topic index » view message » categorize

5. Re: Meta Information for Debugging

Is there line counting problem in here somewhere? Perhaps an off-by-one error? Or maybe I'm misunderstanding how call_stack() reports its line numbers?

/* 1 */ 
/* 2 */ without inline 
/* 3 */ include euphoria/debug/debug.e 
/* 4 */ include std/console.e 
/* 5 */  
/* 6 */ sequence cs = call_stack() 
/* 7 */ display( cs[2..$] ) 
/* 8 */ 

{ 
  "<TopLevel>", 
  "C:\\Temp\\debug.ex", 
  5 <-- call_stack() was called from line 6 
} 

/*  1 */  
/*  2 */ without inline 
/*  3 */ include euphoria/debug/debug.e 
/*  4 */ include std/console.e 
/*  5 */  
/*  6 */ procedure debug_print()  
/*  7 */     sequence cs = call_stack() 
/*  8 */     display( cs[2..$] ) 
/*  9 */ end procedure  
/* 10 */  
/* 11 */ debug_print() 
/* 12 */  

{ 
  { 
    "debug_print", 
    "C:\\Temp\\debug.ex", 
    6 <-- call_stack() was called from line 7 
  }, 
  { 
    "<TopLevel>", 
    "C:\\Temp\\debug.ex", 
    10 <-- debug_print() was called from line 11 
  } 
} 

-Greg

new topic     » goto parent     » topic index » view message » categorize

6. Re: Meta Information for Debugging

Wow! Thanks, Matt! That call_stack() function looks to be exactly what I need!

new topic     » goto parent     » topic index » view message » categorize

7. Re: Meta Information for Debugging

Matt, your program works fine for me. However, when I add my own function, the program doesn't run and there's no error output. Can you see if this fails for you too? You literally just need to add that debug_printx() function and the program stops working. I'm running Euphoria 4.1 on this PC, Windows 8.

I've drilled down to what seems to be causing the crash, and it looks like the appending of the variable bc. This code runs, but if you uncomment the lines with bc being appended, it suddenly doesn't run for me, whether or not breadCrumb is 1.

Must be an obscure bug, right? Or something so obvious that I'm missing it.

new topic     » goto parent     » topic index » view message » categorize

8. Re: Meta Information for Debugging

euphoric said...

Matt, your program works fine for me. However, when I add my own function, the program doesn't run and there's no error output. Can you see if this fails for you too? You literally just need to add that debug_printx() function and the program stops working. I'm running Euphoria 4.1 on this PC, Windows 8.

I've drilled down to what seems to be causing the crash, and it looks like the appending of the variable bc. This code runs, but if you uncomment the lines with bc being appended, it suddenly doesn't run for me, whether or not breadCrumb is 1.

Must be an obscure bug, right? Or something so obvious that I'm missing it.

It seems to work for me. I even added a call to debug_printx().

Matt

new topic     » goto parent     » topic index » view message » categorize

9. Re: Meta Information for Debugging

ghaberek said...

Is there line counting problem in here somewhere? Perhaps an off-by-one error? Or maybe I'm misunderstanding how call_stack() reports its line numbers?

Could very easily be an off by one error. It's been a long time since I've looked at this code.

Matt

new topic     » goto parent     » topic index » view message » categorize

10. Re: Meta Information for Debugging

OK, thanks, Matt. I'll test on a few other PCs.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu