Plotting from GDB

Florian Lorenzen
2008-01-31T17:11:58Z

[-- 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 --]