Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

debugger truncates strings #15393

Closed
DartBot opened this issue Dec 1, 2013 · 9 comments
Closed

debugger truncates strings #15393

DartBot opened this issue Dec 1, 2013 · 9 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.

Comments

@DartBot
Copy link

DartBot commented Dec 1, 2013

This issue was originally filed by ovang...@gmail.com


What steps will reproduce the problem?

  1. Create a class with a reasonably long return value from the toString() method
  2. Insert a breakpoint in the editor at some point where an instance of the object is in scope
  3. Inspect the instance in the debugger.

What is the expected output? What do you see instead?
Expected: The full dprint of the object
{Intersection (edge1:0)&(edge2:0)=(0.0, 0.0, NaN), Intersection (edge1:5)&(edge2:5)=(40.0, 40.0, NaN), Intersection (edge1:0)&(edge2:9)=(0.0, 0.0, NaN), Intersection (edge1:1)&(edge3:0)=(20.0, 5.0, NaN), Intersection (edge1:2)&(edge3:0)=(20.0, 5.0, Na
<more intersections follow this>
Observed:
A truncated dprint:
{Intersection (edge1:0)&(edge2:0)=(0.0, 0.0, NaN), Intersection (edge1:5)&(edge2:5)=(40.0, 40.0, NaN), Intersection (edge1:0)&(edge2:9)=(0.0, 0.0, NaN), Intersection (edge1:1)&(edge3:0)=(20.0, 5.0, NaN), Intersection (edge1:2)&(edge3:0)=(20.0, 5.0, N...

Please provide any additional information below.

Due to the length of the output, this information is difficult to inspect manually, but it could be copied out into a separate window and formatted. It can't, however be copied out and pasted if the string is truncated. In some cases (eg. Lists) the instance can be drilled into to find the data you're looking for. In others (eg. Hashsets) there are too many levels to look for each item, and the tree collapses and you have to drill down every time the object you'd like to inspect goes out of scope, (eg. the object was created in a loop).

The only option is to insert a print statement and use the output of that to obtain the information, which might
a) not actually be the information you're looking for
b) Require you to restart the debugger to load the new code (with prints) and proceed back to where you left off.

This is obviously intentional functionality, but I'd like to know why the debugger is allowed to throw away potentially useful debugging information.

@kasperl
Copy link

kasperl commented Dec 4, 2013

Added Area-VM, Triaged labels.

@iposva-google
Copy link
Contributor

Matthias, is the VM debugger interface truncating the strings?


cc @devoncarew.
cc @jacob314.
Set owner to @mhausner.
Added Accepted label.

@DartBot
Copy link
Author

DartBot commented Dec 4, 2013

This comment was originally written by @mhausner


Yes it is truncating strings and lists and maps, generally any long textual representation of an a dart value. I added this when complaints came in that the debugger crashed when there were large objects in stack traces, e.g. a list with 1M entries. See issue #8024.

The debugger/user can inspect large objects in pieces. If you have a better idea how to prevent problems like the one outlined in issue #8024, let me know.

@DartBot
Copy link
Author

DartBot commented Dec 4, 2013

This comment was originally written by @mhausner


By the way, this truncation happens in the textual representation of an object that the debugger sends along. The textual value is created using the object's toString() method. There is another bug open that requests the debugger not to call toString on objects unless the user specifically requests it. If I do remove these implicit toString() calls, I can remove the truncation as well. It will then be entirely in the user's control whether they request a textual representation that takes up lots of memory.

@DartBot
Copy link
Author

DartBot commented Dec 5, 2013

This comment was originally written by ovangl...@gmail.com


Why does toString need to be called when you first create the textual representation? Surely that work could be deferred until absolutely necessary. 99% of the time the representation will never be viewed, so you avoid the work of constructing the string completely.

I mean, there is very little instance information displayed in a stack trace, so why would you need to be generating anything?

(commenting with no experience in how debuggers work, so feel free to ignore)

@DartBot
Copy link
Author

DartBot commented Dec 5, 2013

This comment was originally written by ovangle...@gmail.com


That sounded kind of stupid, but I meant why can't you pass back an abstract representation who's textual value is computed lazily?

@DartBot
Copy link
Author

DartBot commented Dec 5, 2013

This comment was originally written by @mhausner


That can certainly be done. We tried to minimize the number of calls the debugger front-end has to make over the wire. If the debug target is remote, the latency might be an issue if the debugger has to make dozens or hundreds of calls. The solution could be: call toString on basic values like numbers and strings (and truncate the latter if necessary), delay the call to toString for others.

@DartBot
Copy link
Author

DartBot commented Dec 5, 2013

This comment was originally written by @zoechi


Maybe you could add a [...] button/link to truncated values where a click invokes a call that returns the value as whole? - just brainstorming, don't ask for an pull request ;-)

@DartBot DartBot added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. labels Dec 5, 2013
@rmacnak-google
Copy link
Contributor

Legacy debugging protocol removed in 6249c2b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

5 participants