[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: DDD graph display of two dimensional arrays?
From: |
Peter Toft |
Subject: |
Re: DDD graph display of two dimensional arrays? |
Date: |
Wed, 18 Jul 2007 22:41:30 +0200 (CEST) |
On Wed, 18 Jul 2007, Peter Toft wrote:
> Hi there
>
> Focus of this mail is DDD on 1D and 2D arrays.
>
> I have pasted a small C-code program at
> http://pastebin.com/f63009dd8
> (download from http://pastebin.com/pastebin.php?dl=f63009dd8)
> which I like your opinion on.
>
> I compile it with "gcc -g"
> Throw a breakpoint on line 59 and run under DDD.
>
> * I can see the contents of the "a"-vector in DDD by
> (gdb) graph display *a @ 3
> Very cool!
>
> * I can see the matrix (2D array) contents of the "c"
> matrix by
> (gdb) graph display c
> Elegant - very cool!
>
> * However how can I use DDD to see the contents of "b"
> similar to the contents of "c"?
> The best I can do is
> (gdb) graph display b
> (gdb) graph display (*b[0] @ 3) dependent on 3
> (gdb) graph display (*b[1] @ 3) dependent on 3
> ** if 3 is the "b" graph display **
> Obviously I would like to do the display in one command rather
> than three, and I think I will manually have to supply
> the length of the vectors, but it seems that I cannot do a
> compound DDD-operation like
> (gdb) graph display **b @3 @2
> Am I overlooking something or is it simply a limitation of DDD?
>
> My humble thank you to all of you DDD hackers - very very nice program
> you have made!!
Note that I also later today understood that to a large degree it boils
down to GDB -> http://sourceware.org/ml/gdb/2007-07/msg00140.html
But I want the feature in ddd :)
If I add a gdb-macro (to ~/.gdbinit)
define matprint2
set $i = 0
print
printf "{{"
while $i< $arg1
set $j = 0
printf "%d",$arg0[$i][$j++]
while $j< $arg2
printf ", %d",$arg0[$i][$j++]
end
printf "}"
set $i = 1+$i
if $i < $arg1
printf ", {"
end
end
printf "}\n"
end
then I can get my matrix values very similar to "b" access - kinda cool :)
(gdb) matprint c 2 3
{{2, -2, 22}, {12, -12, 212}}
however can the same macro is some way be augmented to also
couple to the wanted DDD commands
(gdb) graph display **b @3 @2
or perhaps (the not-yet existing command)
(gdb) graph displaymatrix b @3 @2
>
> BTW; sorry if this ends as a double-post. I send a mail 8 hours ago
> which did not make it to the list, and it does not appear in the archive
> http://lists.gnu.org/archive/html/ddd/2007-07/ (does not exist)
Hrrm round-trip of >20 hrs...
Best
--
Peter Toft, Ph.D. address@hidden http://petertoft.dk
Følg min Linux-blog på http://www.version2.dk/blogs/petertoft