Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* Plotting from GDB
@ 2008-01-31 17:32 Florian Lorenzen
  2008-01-31 22:07 ` Daniel Jacobowitz
  2008-02-05  9:52 ` Michael Snyder
  0 siblings, 2 replies; 3+ messages in thread
From: Florian Lorenzen @ 2008-01-31 17:32 UTC (permalink / raw)
  To: gdb-patches


[-- Attachment #1.1: Type: text/plain, Size: 460 bytes --]

Hello,

I spent a lot of time debugging numerical codes. Very often, it is
useful to plot a certain quantity instead of staring on numbers. To
help with this, I wrote some small user defined commands to create a
plot with gnuplot during the debugging session. Perhaps, you want to
include it in your distribution, I attach you the file. (I know, DDD
has this functionality, but perhaps CLI or Emacs users might be
interested in this.)

Best regards,

Florian


[-- Attachment #1.2: plot1d.gdb --]
[-- Type: text/plain, Size: 1395 bytes --]

# plot1d.gdb
#
# Copyright (C) 2008 Florian Lorenzen
#
# Plot an expression that expands to {x1, x2, ..., xN}, i. e.
# N numbers using gnuplot.
#
# This file is for the GNU debugger 6.x.
#
# It writes temporary files named __plot1d.dump, __plot1d.dat, __plot1d.gp, so
# you should not have files of the same name in the working directory.
#
# It requires sed, awk, and gnuplot available in the $PATH.

# plot1d_opt_range <expr> <opt> <range>
#
# Plot the points of <expr> passing <opt> as plot options using
# <range> in the set yrange command.
define plot1d_opt_range
  shell rm -f __plot1d.dump __plot1d.dat __plot1d.gp
  set logging file __plot1d.dump
  set logging on
  output $arg0
  set logging off
  shell awk '{printf("%s", $0)}' < __plot1d.dump | \
    sed 's/^{\(.*\)}$/\1/;s/, */\n/g' > __plot1d.dat
  shell echo "set yrange $arg2; plot '__plot1d.dat' $arg1 title '$arg0'; \
    pause -1 \"Press enter to continue\"" > __plot1d.gp
  shell gnuplot __plot1d.gp
  shell rm -f __plot1d.dump __plot1d.dat __plot1d.gp
end

# plot1d <expr>
#
# Just plot the points of <expr>.
define plot1d
  plot1d_opt_range $arg0 "" "[*:*]"
end

# plot1d_opt <expr> <opt>
#
# Plot the points of <expr> passing <opt> to the
# plot command after the datafile. So, one can pass
# "with lines" here.
define plot1d_opt
  plot1d_opt_range $arg0 $arg1 "[*:*]"
end


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2008-02-05  9:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-31 17:32 Plotting from GDB Florian Lorenzen
2008-01-31 22:07 ` Daniel Jacobowitz
2008-02-05  9:52 ` Michael Snyder

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