Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

visualization "jumps" between different heap memory types when multiple types of pointers point to same block #3

Open
pgbovine opened this issue Feb 12, 2020 · 0 comments
Labels

Comments

@pgbovine
Copy link

Two things can be done:

  • track the type of the first pointer that refers to a block of memory and use that to consistently refer to that memory block so that it doesn't "jump"
  • [stretch goal] in addition to the above, let the user choose what type to display it as

See example here for explanation in top comments:

http://pythontutor.com/visualize.html#code=//%20annoying%20thing%3A%20when%20the%20tracer%20enters%20foo,%20'element'%20is%0A//%20a%20'void*',%20so%20the%20heap%20memory%20it%20points%20to%20is%20printed%20as%0A//%20a%20series%20of%20raw%20bytes,%20thus%20losing%20its%20original%20type%20information,%0A//%20which%20causes%20the%20visualization%20to%20abruptly%20%22jump%22%20between%20the%20original%0A//%20type%20%28e.g.,%20int,%20char%29%20and%20the%20void*%20pointed-to%20block%20of%20raw%20bytes.%0A//%0A//%20IDEALLY%20we'd%20let%20the%20user%20choose%20whether%20to%20view%20*element%20as%0A//%20raw%20bytes%20or%20as%20int,%20char,%20etc.%3B%20but%20the%20easiest%20thing%20for%20now%0A//%20is%20to%20track%20what%20type%20it%20was%20ORIGINALLY%20at%20the%20start%20of%20the%20trace%0A//%20and%20simply%20to%20keep%20that%20type%20consistent%20as%20the%20user%20steps%20to%20latter%0A//%20execution%20steps%20so%20that%20the%20visualization%20never%20abruptly%20%22jumps%22%0Avoid%20foo%28void*%20element%29%20%7B%0A%20%20return%3B%0A%7D%0A%0Aint%20main%28%29%20%7B%0A%20%20int*%20x%20%3D%20malloc%28sizeof%28int%29%29%3B%0A%20%20char*%20y%20%3D%20malloc%28sizeof%28char%29%29%3B%0A%20%20*x%20%3D%2042%3B%0A%20%20*y%20%3D%20'c'%3B%0A%20%20foo%28x%29%3B%0A%20%20foo%28y%29%3B%0A%20%20return%200%3B%0A%7D&cumulative=false&curInstr=0&heapPrimitives=nevernest&mode=display&origin=opt-frontend.js&py=c&rawInputLstJSON=%5B%5D&textReferences=false

@pythontutor-dev pythontutor-dev transferred this issue from another repository Jun 28, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants