This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: DPrintf feedback


> -----Original Message-----
> From: Tom Tromey [mailto:tromey@redhat.com] 
> Sent: Friday, February 22, 2013 2:32 PM
> To: Marc Khouzam
> Cc: 'Yao Qi'; 'gdb-patches@sourceware.org'; 'Pedro Alves'; 
> 'Joel Brobecker'; 'Stan Shebs'
> Subject: Re: DPrintf feedback
> 
> >>>>> "Marc" == Marc Khouzam <marc.khouzam@ericsson.com> writes:
> 
> Marc> Such an approach may also help fix the "continue" problem
> Marc> that Yao is trying to address.  I seem to recall that 
> Hui had posted 
> Marc> patches to add some kind of 'printf' tracepoint 
> command.  Maybe that 
> Marc> would be something that can help?
> 
> I thought this was subsumed by "set dprintf-style agent"?

I haven't followed the details, so I can't be sure.
"set dprintf-style agent" makes the dprintf breakpoint 
command be "agent-printf <string>".
I didn't expect that to be something that could be re-used
by a tracepoint command.  But that makes me realize the 
bigger limitation of using tracepoints; tracepoints are
only supported with gdbserver.  I thought a tracepoint
doing the printf would be nice for each case, not just
with gdbserver.  I guess there's a lot more work
needed to first support tracepoints in GDB alone, and
then use them for dprintf.  I missed that detail.

I wonder if you guys feel tracepoints would be a nicer
way to handle dprintf?

> Marc> Other issues I ran across are below.  I wasn't sure 
> opening PRs was
> Marc> the way to do since those issues may disappear if the current 
> Marc> implementation is amended:
> 
> I think it is best to file PRs.  If a patch fixes them all, 
> then that is
> fine.  But if not, then this the only way to avoid losing track.

Will do.

> Marc> - Pagination is triggered for dprintf in CLI mode, at least when
> Marc> using dprintf-style 'gdb'.
> 
> Maybe we need a new "gdb-unfiltered" setting?  Or we could disable
> pagination entirely here, but that maybe leads to other issues.
> 
> Marc> - In Eclipse, the dprintf-style that makes sense is either 
> Marc>   'call' or 'agent'.
> 
> I was surprised to hear this.  Could you say why?

On Linux, Eclipse uses the -inferior-tty-set command to tell GDB
to send the inferior's output to a different console.  So we have
a gdb console and an inferior console.  If we want dprintf to look 
like a real printf, its output needs to be shown in the inferior
console, so it requires GDB to send it to the same tty.  That is
not what "dprintf-style gdb" does, as it sends it to the gdb console.

> Marc> - Output buffering is not behaving as a real printf.  For 
> Marc>   example, if my program does
> Marc>      printf("hello");
> Marc>      printf("friend\n");
> Marc> and I put a dprintf " my " on the second line, 
> Marc> I would expect to see
> Marc>    "hello my friend"
> Marc> but instead I see
> Marc>    " my hellofriend"
> Marc> which shows that the dprintf string does not go to the same 
> Marc> buffer as the real printfs, and is flushed earlier.
> Marc> This also happens with the dprintf-style "agent"
> 
> Which other setting does this happen with?
> I would expect it to work with "call" but not with "gdb".
>
> You could hack around this by disabling buffering for stdout.
> I'm not totally sure it is a bug for it to work the current way by
> default.

I hadn't tried it with "call" because my machine is an Ubuntu,
so the "call" setting does not work.  I managed to get my hands
on a Suse machine and tried it; you are right, "call" prints
things nicely.  I guess the problem is only that "agent" style
does not do that properly.  I'll specify this important point
in the PR.

Thanks for the quick answer.

Marc



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]