bug-ddd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

ddd && perl: bug-fix graph display of blessed references (objects)


From: Peter Ernst
Subject: ddd && perl: bug-fix graph display of blessed references (objects)
Date: Wed, 5 Jun 2002 17:36:12 +0200 (MET DST)

Problem description:

   DDD 3.3.1 with Perl: when using the graphical display on reference
                        variables, de-referencing works nicely through
                        e.g. a double-mouse click (by means of code in
                        ddd/deref.C). However, if the references is
                        blessed (i.e. it is a object reference),
                        de-referencing does NOT work.

   Example: graph display $SeqInfoObj

            p $SeqInfoObj
            W3H::Parser::Seqinfo=HASH(0x4d3738)

            i.e. $SeqInfoObj is a blessed reference

            double-click on the graph does NOT dereference, because
            the code in ddd/deref.C tries to get the "type" of the
            reference (in this case HASH) by parsing the output of
            " p $SeqInfoObj ", and considers the first identifier as
            "type". In this case the type is "W3H" which is wrong.

            Interestingly, the regular expression to parse the output
            of " p $SeqInfoObj " (rxperlref line 359 in ddd/rxscan.L)
            already knows about the "more complicated" syntax. I.e. it
            is not necessary to fix something here.

Fix description:

            Correct is is to take the first identifier after a
            "=". This works for blessed and un-blessed references
            (un-blessed references don't have a "=" character in the
            output of " p $simple_ref "). I.e. the bug is fixed by
            changing line 72 in ddd/deref.C
  from:
            ref = val.through(rxidentifier);
  to:
            ref = val.at(rxidentifier, val.index("=") + 1);

on a blessed reference, val.index("=") + 1 points to the first
character after the "=" sign,
on a un-blessed reference, val.index("=") + 1 points to character 0.

The fix is working as you can see from the history file below:
$SeqInfoObj              is a blessed hash-reference

$SeqInfoObj->{'entries'} is an un-blessed array-reference

$SeqInfoObj->{'entries'}->[0]   aka
${$SeqInfoObj->{'entries'}}[0]
                         is an un-blessed hash-reference


from ~/.ddd/history :

------------- begin snip -------------------

exec "perl -d w3h.debugtask dnasweep -infile=ensembl_cdna:enst00000000442"
cont
c 218
graph display $SeqInfoObj
graph display %$SeqInfoObj dependent on 1
graph display @{$SeqInfoObj->{'entries'}} dependent on 2
graph display %{${$SeqInfoObj->{'entries'}}[0]} dependent on 3

------------- end snip -------------------


here's the patch:

------------- begin patch -------------------
*** deref.C.orig        Wed Sep 29 10:27:38 1999
--- deref.C     Wed Jun  5 17:19:03 2002
***************
*** 69,75 ****

        string val = gdbValue(expr, print_command);
        if (val.matches(rxperlref))
!           ref = val.through(rxidentifier);
      }

  #if 0
--- 69,75 ----

        string val = gdbValue(expr, print_command);
        if (val.matches(rxperlref))
!           ref = val.at(rxidentifier, val.index("=") + 1);
      }

  #if 0
------------- end patch -------------------


in case you're interested ~/.ddd/log :

------------- begin snip -------------------

GNU DDD 3.3.1 (sparc-sun-solaris2.7)
Copyright (C) 1995-1999 Technische Universit<E4>t Braunschweig, Germany.
Copyright (C) 1999-2001 Universit<E4>t Passau, Germany.

Compiled with GCC 2.95.2 19991024 (release), libstdc++ 2.8.0
Requires X11R6, Xt11R6, Motif 2.1 (Motif Version 2.1.0)
Includes Athena Panner, DDD core
Built 2002-06-05 by Peter Ernst <unknown>.
$  /home/dok427/fox/ddd-3.3.1/ddd/ddd --perl w3h.debugtask

------------- end snip -------------------


Kind regards,

     Peter Ernst

P.S: DDD is really a very nice program. Congratulations for it!

-- 
=======================================================================
 Peter Ernst
 Department of Molecular Biophysics - H0200
 Deutsches Krebsforschungszentrum (German Cancer Research Center) DKFZ
 Im Neuenheimer Feld 280
 69120 Heidelberg, Germany                     phone: +49-6221-42-2330
 http://genome.dkfz-heidelberg.de/               fax: +49-6221-42-2333
=======================================================================




reply via email to

[Prev in Thread] Current Thread [Next in Thread]