Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* faster printing of QStrings
@ 2007-03-22 12:30 Markus.Grunwald
  2007-03-22 12:42 ` Daniel Jacobowitz
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Markus.Grunwald @ 2007-03-22 12:30 UTC (permalink / raw)
  To: gdb

Hello,

we are developing Qt applications. kdevelops debugger offers a watch where 
it can display QStrings. I am more the commandline user and have found a 
nice function that prints QStrings with gdb:

define pqs
    set $i=0
    set $unicode=$arg0.d->unicode

    printf "Getting QString...\n"
    while $i < $arg0.d->len
        set $c=$unicode[$i++].ucs
        if $c < 32 
          printf "\\0%o", $c
        else
          if $c <= 127
            printf "%c", $c
          else 
            printf "\\0%o", $c
          end 
        end
    end
    echo \n
end

(gdb) pqs oszPrinterLine
Getting QString...
kopierer akzeptiert Anfragen seit Mo 19 Feb 2007 13:27:28 CET

Works fine - except that it takes ages (25s) ! Kdevelop displays the 
QStrings in an instant. Now I wonder if there is a faster way of getting 
this information in gdb - and maybe even to "display oszPrinterLine" which 
makes sense only if printing is fast... ?

Mit freundlichen Grüßen

Markus Grunwald
Softwareentwicklung

PRÜFTECHNIK Condition Monitoring GmbH
Oskar-Messter-Straße 19-21
85737 Ismaning
www.pruftechnik.com
Tel: +49 (0)89 99616177
Fax: +49 (0)89 99616200

PRÜFTECHNIK Condition Monitoring GmbH
Sitz Ismaning / HRB 145655 München 
Geschäftsführer: Johann Lösl, Roland Schühle

Ein Unternehmen der PRÜFTECHNIK-Gruppe


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: faster printing of QStrings
  2007-03-22 12:30 faster printing of QStrings Markus.Grunwald
@ 2007-03-22 12:42 ` Daniel Jacobowitz
  2007-03-23 13:08   ` Eli Zaretskii
  2007-03-22 13:50 ` Ramana Radhakrishnan
  2007-03-23 13:10 ` Eli Zaretskii
  2 siblings, 1 reply; 8+ messages in thread
From: Daniel Jacobowitz @ 2007-03-22 12:42 UTC (permalink / raw)
  To: Markus.Grunwald; +Cc: gdb

On Thu, Mar 22, 2007 at 01:28:18PM +0100, Markus.Grunwald@pruftechnik.com wrote:
> Hello,
> 
> we are developing Qt applications. kdevelops debugger offers a watch where 
> it can display QStrings. I am more the commandline user and have found a 
> nice function that prints QStrings with gdb:

Thanks for posting this - I'm sure it will be useful to someone, and
it's also a good test case for GDB performance :-)

> Works fine - except that it takes ages (25s) ! Kdevelop displays the 
> QStrings in an instant. Now I wonder if there is a faster way of getting 
> this information in gdb - and maybe even to "display oszPrinterLine" which 
> makes sense only if printing is fast... ?

I couldn't think of anything.  It's probably the array access and a
pile of symbol lookups that are slowing it down; when I can find time
(no promises, but this was already on top of my todo list) I will try
to speed it up.

The only way you could use it with display today is by defining a
hook-stop macro.  I would like to offer something better involving
integrated Python, but it probably won't happen until next year.

-- 
Daniel Jacobowitz
CodeSourcery


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: faster printing of QStrings
  2007-03-22 12:30 faster printing of QStrings Markus.Grunwald
  2007-03-22 12:42 ` Daniel Jacobowitz
@ 2007-03-22 13:50 ` Ramana Radhakrishnan
  2007-03-22 15:03   ` Markus.Grunwald
  2007-03-23 13:10 ` Eli Zaretskii
  2 siblings, 1 reply; 8+ messages in thread
From: Ramana Radhakrishnan @ 2007-03-22 13:50 UTC (permalink / raw)
  To: Markus.Grunwald; +Cc: gdb

On Thu, 2007-03-22 at 13:28 +0100, Markus.Grunwald@pruftechnik.com
wrote:
> Hello,
> 
> we are developing Qt applications. kdevelops debugger offers a watch where 
> it can display QStrings. I am more the commandline user and have found a 
> nice function that prints QStrings with gdb:

> 
> define pqs
>     set $i=0
>     set $unicode=$arg0.d->unicode
> 
>     printf "Getting QString...\n"
>     while $i < $arg0.d->len
>         set $c=$unicode[$i++].ucs
>         if $c < 32 
>           printf "\\0%o", $c
>         else
>           if $c <= 127
>             printf "%c", $c
>           else 
>             printf "\\0%o", $c
>           end 
>         end
>     end
>     echo \n
> end
> 
> (gdb) pqs oszPrinterLine
> Getting QString...
> kopierer akzeptiert Anfragen seit Mo 19 Feb 2007 13:27:28 CET
> 
> Works fine - except that it takes ages (25s) ! Kdevelop displays the 
> QStrings in an instant. Now I wonder if there is a faster way of getting 
> this information in gdb - and maybe even to "display oszPrinterLine" which 
> makes sense only if printing is fast... ?

Might it go a bit faster if you used a convenience variable for len
too :) ? 

set $len = $arg0.d->len

while $i < $len 

Getting the actual length is loop invariant. I am no expert in the gdb
scripting areas ... 

cheers
Ramana 

> 
> Mit freundlichen Grüßen
> 
> Markus Grunwald
> Softwareentwicklung
> 
> PRÜFTECHNIK Condition Monitoring GmbH
> Oskar-Messter-Straße 19-21
> 85737 Ismaning
> www.pruftechnik.com
> Tel: +49 (0)89 99616177
> Fax: +49 (0)89 99616200
> 
> PRÜFTECHNIK Condition Monitoring GmbH
> Sitz Ismaning / HRB 145655 München 
> Geschäftsführer: Johann Lösl, Roland Schühle
> 
> Ein Unternehmen der PRÜFTECHNIK-Gruppe

-- 
cheers
Ramana

Ramana Radhakrishnan
IDE & Tools Group
Celunite Inc (www.celunite.com)



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: faster printing of QStrings
  2007-03-22 13:50 ` Ramana Radhakrishnan
@ 2007-03-22 15:03   ` Markus.Grunwald
  0 siblings, 0 replies; 8+ messages in thread
From: Markus.Grunwald @ 2007-03-22 15:03 UTC (permalink / raw)
  To: gdb

Hello,

> Might it go a bit faster if you used a convenience variable for len
> too :) ? 
> 
> set $len = $arg0.d->len
> 
> while $i < $len 

Thanks for the idea, but it didn't help...

cu
Markus


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: faster printing of QStrings
  2007-03-22 12:42 ` Daniel Jacobowitz
@ 2007-03-23 13:08   ` Eli Zaretskii
  0 siblings, 0 replies; 8+ messages in thread
From: Eli Zaretskii @ 2007-03-23 13:08 UTC (permalink / raw)
  To: Daniel Jacobowitz; +Cc: Markus.Grunwald, gdb

> Date: Thu, 22 Mar 2007 08:39:06 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: gdb@sourceware.org
> 
> The only way you could use it with display today is by defining a
> hook-stop macro.  I would like to offer something better involving
> integrated Python, but it probably won't happen until next year.

What about adding to the debuggee a function that prints a Qstring,
and calling that from GDB?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: faster printing of QStrings
  2007-03-22 12:30 faster printing of QStrings Markus.Grunwald
  2007-03-22 12:42 ` Daniel Jacobowitz
  2007-03-22 13:50 ` Ramana Radhakrishnan
@ 2007-03-23 13:10 ` Eli Zaretskii
  2007-03-23 14:00   ` Markus.Grunwald
  2 siblings, 1 reply; 8+ messages in thread
From: Eli Zaretskii @ 2007-03-23 13:10 UTC (permalink / raw)
  To: Markus.Grunwald; +Cc: gdb

> From: Markus.Grunwald@pruftechnik.com
> Date: Thu, 22 Mar 2007 13:28:18 +0100
> 
> we are developing Qt applications. kdevelops debugger offers a watch where 
> it can display QStrings. I am more the commandline user and have found a 
> nice function that prints QStrings with gdb:
> 
> define pqs
>     set $i=0
>     set $unicode=$arg0.d->unicode
> 
>     printf "Getting QString...\n"
>     while $i < $arg0.d->len
>         set $c=$unicode[$i++].ucs
>         if $c < 32 
>           printf "\\0%o", $c
>         else
>           if $c <= 127
>             printf "%c", $c
>           else 
>             printf "\\0%o", $c
>           end 
>         end
>     end
>     echo \n
> end

Thanks for posting this, but it only prints the ASCII characters, the
rest is displayed as octal escapes.  Wouldn't it be better to send
UTF-8 encoding to the terminal?  Then the non-ASCII characters will
also be displayed in a human-readable form.

> Works fine - except that it takes ages (25s) !

For Qstring's of what length?


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: faster printing of QStrings
  2007-03-23 13:10 ` Eli Zaretskii
@ 2007-03-23 14:00   ` Markus.Grunwald
  0 siblings, 0 replies; 8+ messages in thread
From: Markus.Grunwald @ 2007-03-23 14:00 UTC (permalink / raw)
  To: gdb

Hello,

> Thanks for posting this, but it only prints the ASCII characters, the
> rest is displayed as octal escapes.  Wouldn't it be better to send
> UTF-8 encoding to the terminal?  Then the non-ASCII characters will
> also be displayed in a human-readable form.

Hmm, never had non-ascii nor non-latin15 characters, so it didn't bother 
me... But since I don't have an UTF-8 environment here ( well, maybe 
sometimes... ), displaying non-ascii characters directly wouldn't help me.
 
> > Works fine - except that it takes ages (25s) !
> 
> For Qstring's of what length?

For the string that I have posted (61 chars) :
kopierer akzeptiert Anfragen seit Mo 19 Feb 2007 13:27:28 CET

cu
Markus


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: faster printing of QStrings
@ 2007-03-22 15:19 Markus.Grunwald
  0 siblings, 0 replies; 8+ messages in thread
From: Markus.Grunwald @ 2007-03-22 15:19 UTC (permalink / raw)
  To: gdb

Hello,

> Thanks for posting this - I'm sure it will be useful to someone, and
> it's also a good test case for GDB performance :-)

:) 
 
> I couldn't think of anything.  It's probably the array access and a
> pile of symbol lookups that are slowing it down; when I can find time
> (no promises, but this was already on top of my todo list) I will try
> to speed it up.

Perhaps a look into the kdevelop code could help - they do it somehow ...


> The only way you could use it with display today is by defining a
> hook-stop macro.

I'll have a look how this works.

Thanks !

Markus


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2007-03-23 14:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-22 12:30 faster printing of QStrings Markus.Grunwald
2007-03-22 12:42 ` Daniel Jacobowitz
2007-03-23 13:08   ` Eli Zaretskii
2007-03-22 13:50 ` Ramana Radhakrishnan
2007-03-22 15:03   ` Markus.Grunwald
2007-03-23 13:10 ` Eli Zaretskii
2007-03-23 14:00   ` Markus.Grunwald
2007-03-22 15:19 Markus.Grunwald

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox