www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.debugger - [ddbg] "Access violation" and "Invalid val type" with dictionaries

reply Ary Manzana <ary esperanto.org.ar> writes:
Hi Jascha,

Take the following code:

---
module main;

import std.stdio;

class Point {
	
	int x;
	int y;
	
	this(int x, int y) {
		this.x = x;
		this.y = y;
	}
	
	public override char[] toString() {
		return "(" ~ std.string.toString(x) ~ ", " ~ std.string.toString(y) ~ ")";
	}
	
}

void main() {
	Point[int] dictionary;
	dictionary[1] = new Point(1, 10);
	dictionary[2] = new Point(2, 20);
	dictionary[3] = new Point(3, 30);
	
	writefln("%s", dictionary[1]);
}
---

If you run it, you'll see (1, 10) as the output. However, if you set a 
breakpoint in the writefln line and you try to access dictionary[1]:

->= dictionary[1]
Access Violation
->= dictionary[cast(int)1]
Access Violation

Further:

->= dictionary
invalid val type PC4main5Point

Is this a bug in ddbg?

Regards,
Ary
Jun 26 2007
parent reply Jascha Wetzel <firstname mainia.de> writes:
it's missing support for class types in associative arrays, and a 
missing warning message about that ;)
the next release will fix it.

Ary Manzana wrote:
 Hi Jascha,
 
 Take the following code:
 
 ---
 module main;
 
 import std.stdio;
 
 class Point {
     
     int x;
     int y;
     
     this(int x, int y) {
         this.x = x;
         this.y = y;
     }
     
     public override char[] toString() {
         return "(" ~ std.string.toString(x) ~ ", " ~ 
 std.string.toString(y) ~ ")";
     }
     
 }
 
 void main() {
     Point[int] dictionary;
     dictionary[1] = new Point(1, 10);
     dictionary[2] = new Point(2, 20);
     dictionary[3] = new Point(3, 30);
     
     writefln("%s", dictionary[1]);
 }
 ---
 
 If you run it, you'll see (1, 10) as the output. However, if you set a 
 breakpoint in the writefln line and you try to access dictionary[1]:
 
 ->= dictionary[1]
 Access Violation
 ->= dictionary[cast(int)1]
 Access Violation
 
 Further:
 
 ->= dictionary
 invalid val type PC4main5Point
 
 Is this a bug in ddbg?
 
 Regards,
 Ary

Jun 28 2007
parent reply Ary Manzana <ary esperanto.org.ar> writes:
Thanks!

Just a curiosity: why "= dictionary.length" gives me the length in 
hexadecimal?

Another one: if the length of an array or a dictionary is big enough (> 
100) then I'd like to group by 100 the contents (like in JDT). So I'll 
request the length of the array, and work on that. However, currently 
ddbg only allows me to show around 30 entries, the last one being shown 
as "$". That means I'll have to group by 30 or less. Can this number be 
configured somehow?

Jascha Wetzel escribió:
 it's missing support for class types in associative arrays, and a 
 missing warning message about that ;)
 the next release will fix it.
 
 Ary Manzana wrote:
 Hi Jascha,

 Take the following code:

 ---
 module main;

 import std.stdio;

 class Point {
         int x;
     int y;
         this(int x, int y) {
         this.x = x;
         this.y = y;
     }
         public override char[] toString() {
         return "(" ~ std.string.toString(x) ~ ", " ~ 
 std.string.toString(y) ~ ")";
     }
     }

 void main() {
     Point[int] dictionary;
     dictionary[1] = new Point(1, 10);
     dictionary[2] = new Point(2, 20);
     dictionary[3] = new Point(3, 30);
         writefln("%s", dictionary[1]);


 ---

 If you run it, you'll see (1, 10) as the output. However, if you set a 
 breakpoint in the writefln line and you try to access dictionary[1]:

 ->= dictionary[1]
 Access Violation
 ->= dictionary[cast(int)1]
 Access Violation

 Further:

 ->= dictionary
 invalid val type PC4main5Point

 Is this a bug in ddbg?

 Regards,
 Ary


Jun 28 2007
parent Jascha Wetzel <firstname mainia.de> writes:
Ary Manzana wrote:
 Just a curiosity: why "= dictionary.length" gives me the length in 
 hexadecimal?

the length is a uint and uints, voids and pointers are printed in hex at the moment.
 Another one: if the length of an array or a dictionary is big enough (> 
 100) then I'd like to group by 100 the contents (like in JDT). So I'll 
 request the length of the array, and work on that. However, currently 
 ddbg only allows me to show around 30 entries, the last one being shown 
 as "$". That means I'll have to group by 30 or less. Can this number be 
 configured somehow?

it'll be in the next release.
Jun 30 2007