Giter Club home page Giter Club logo

Comments (3)

zeroflag avatar zeroflag commented on May 28, 2024

Hi,

This is not what traceback is meant for. Traceback is used internally to give a return stacktrace upon an unhandled exception. Although I think it should work that way too (but there is an abort at the end of traceback that makes it less useful in your scenario).

For example:

(stack) exception: EXC
(stack) : w1 EXC throw ;
(stack) : w2 w1 ;
(stack) : w3 w2 ;
(stack) : w4 w3 ;
(stack) : w5 w4 ;
(stack)
(stack) w5

Exeption: EXC rdepth: 9
  at unhandled (140296)
  at throw (140488)
  at w1 (148484)
  at w2 (148508)
  at w3 (148528)
  at w4 (148548)

w5 is not visible in the trace for some reason, this is probably a bug that need to be investigated.

If I add some nested calls to your example it works but has the same problem.

(stack) exception: EXC
(stack)
(stack) : w1 EXC traceback ;
(stack) : w2 w1 ;
(stack) : w3 w2 ;
(stack) : w4 w3 ;
(stack) : w5 w4 ;
(stack)
(stack) w5

Exeption: EXC rdepth: 7
  at w1 (148484)
  at w2 (148508)
  at w3 (148528)
  at w4 (148548)

The reason for not working this with only one call might be the same that causes that the last call is not visible in the nested case. I'll take a look at the problem more deeply sometime later.

from punyforth.

zeroflag avatar zeroflag commented on May 28, 2024

The problem is that w5 is called from the outer interpreter by an execute primitive that doesn't pushes down any return address to the rstack. I'll think about how to fix this.

from punyforth.

zeroflag avatar zeroflag commented on May 28, 2024

I modified the traceback word a bit. Now it gives the following output for this code

exception: E
: a 10 0 do i 5 = if E throw then loop ;
: b a ;
: c b ;
: d c ;
: e d ;
e
Exeption: E rdepth: 10
  at throw (1073648592)
  at a (1073653432)
  at ??? (5)
  at ??? (10)
  at b (1073653500)
  at c (1073653520)
  at d (1073653540)
  at e (1073653560)

This is the correct trace. As you can see now, the call ('e') is presented in the stack trace. (the number 5 and 10 are the loop variables).

Without nested calls:

exception: EXC : test-trace EXC throw ; test-trace
Exeption: EXC rdepth: 4
  at throw (1073648592)
  at test-trace (1073653388)

The usage of the traceback word might be revised in the future because currently it's not that useful from a user perspective.

from punyforth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.