| 1 |
# File: gdb_macros_for_itpp |
| 2 |
# Brief: This file defines some gdb macros for printing out it++ types |
| 3 |
# Author: Vasek (files contributed in feature request 1913404) and Erik G. Larsson |
| 4 |
# |
| 5 |
# To use it, add this line to ~/.gdbinit: |
| 6 |
# source gdb_macros_for_itpp |
| 7 |
# |
| 8 |
# gdb macros defined in this file: |
| 9 |
# |
| 10 |
# dv: display vec |
| 11 |
# dm: display mat |
| 12 |
# div: display integer (ivec or svec) vector |
| 13 |
# dim: display integer (ivec or svec) matrix |
| 14 |
# dcv: display cvec |
| 15 |
# dcm: display cmat |
| 16 |
# dbv: display bvec |
| 17 |
# dbm: display bmat |
| 18 |
# |
| 19 |
# ------------------------------------------------------------------------- |
| 20 |
# |
| 21 |
# Copyright (C) 1995-2010 (see AUTHORS file for a list of contributors) |
| 22 |
# |
| 23 |
# This file is part of IT++ - a C++ library of mathematical, signal |
| 24 |
# processing, speech processing, and communications classes and functions. |
| 25 |
# |
| 26 |
# IT++ is free software: you can redistribute it and/or modify it under the |
| 27 |
# terms of the GNU General Public License as published by the Free Software |
| 28 |
# Foundation, either version 3 of the License, or (at your option) any |
| 29 |
# later version. |
| 30 |
# |
| 31 |
# IT++ is distributed in the hope that it will be useful, but WITHOUT ANY |
| 32 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 33 |
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 34 |
# details. |
| 35 |
# |
| 36 |
# You should have received a copy of the GNU General Public License along |
| 37 |
# with IT++. If not, see <http://www.gnu.org/licenses/>. |
| 38 |
# |
| 39 |
# ------------------------------------------------------------------------- |
| 40 |
|
| 41 |
|
| 42 |
define div |
| 43 |
printf "Vector of length %i:\n", $arg0.datasize |
| 44 |
output $arg0.data[0]@($arg0.datasize) |
| 45 |
printf "\n" |
| 46 |
end |
| 47 |
|
| 48 |
document div |
| 49 |
Display it++ integer (ivec or svec) vector |
| 50 |
end |
| 51 |
|
| 52 |
define dim |
| 53 |
set $i=0 |
| 54 |
|
| 55 |
set $M = $arg0 |
| 56 |
set $rs = $M.no_rows |
| 57 |
set $col = $M.no_cols |
| 58 |
|
| 59 |
printf "Matrix of dimension %ix%i:\n", $rs, $col |
| 60 |
|
| 61 |
while $i < $rs |
| 62 |
set $j=0 |
| 63 |
printf "[" |
| 64 |
while $j< $col |
| 65 |
output $M.data[$j*$rs+$i] |
| 66 |
printf " " |
| 67 |
set $j++ |
| 68 |
end |
| 69 |
printf "]" |
| 70 |
printf "\n" |
| 71 |
set $i++ |
| 72 |
end |
| 73 |
end |
| 74 |
|
| 75 |
document dim |
| 76 |
Display it++ integer (ivec or svec) matrix |
| 77 |
end |
| 78 |
|
| 79 |
define dv |
| 80 |
set $i=0 |
| 81 |
|
| 82 |
set $M = $arg0 |
| 83 |
set $rs = $M.datasize |
| 84 |
|
| 85 |
printf "Vector of length %i:\n", $rs |
| 86 |
|
| 87 |
printf "[" |
| 88 |
while $i < $rs |
| 89 |
printf "%g ", *(double*)(((void*)($M.data))+($i)*sizeof(double)) |
| 90 |
set $i++ |
| 91 |
end |
| 92 |
printf "]\n" |
| 93 |
end |
| 94 |
|
| 95 |
document dv |
| 96 |
Display it++ vec |
| 97 |
end |
| 98 |
|
| 99 |
define dcv |
| 100 |
set $i=0 |
| 101 |
|
| 102 |
set $M = $arg0 |
| 103 |
set $rs = $M.datasize |
| 104 |
|
| 105 |
printf "Vector of length %i:\n", $rs |
| 106 |
|
| 107 |
printf "[ " |
| 108 |
while $i < $rs |
| 109 |
printf "%g", *(double*)(((void*)($M.data))+($i)*sizeof(double)*2) |
| 110 |
printf "+" |
| 111 |
printf "%-g", *(double*)(((void*)($M.data))+($i)*sizeof(double)*2+sizeof(double)) |
| 112 |
printf "i, " |
| 113 |
set $i++ |
| 114 |
end |
| 115 |
printf "]\n" |
| 116 |
end |
| 117 |
|
| 118 |
document dcv |
| 119 |
Display it++ cvec |
| 120 |
end |
| 121 |
|
| 122 |
define dm |
| 123 |
set $i=0 |
| 124 |
|
| 125 |
set $M = $arg0 |
| 126 |
set $rs = $M.no_rows |
| 127 |
set $col = $M.no_cols |
| 128 |
|
| 129 |
printf "Matrix of dimension %ix%i:\n", $rs, $col |
| 130 |
|
| 131 |
while $i < $rs |
| 132 |
set $j=0 |
| 133 |
printf "[" |
| 134 |
while $j< $col |
| 135 |
printf "%6g", $M.data[$j*$rs+$i] |
| 136 |
# output $M.data[$j*$rs+$i] |
| 137 |
printf " " |
| 138 |
set $j++ |
| 139 |
end |
| 140 |
printf "]\n" |
| 141 |
set $i++ |
| 142 |
end |
| 143 |
end |
| 144 |
|
| 145 |
document dm |
| 146 |
Display it++ mat |
| 147 |
end |
| 148 |
|
| 149 |
define dcm |
| 150 |
set $i=0 |
| 151 |
|
| 152 |
set $M = $arg0 |
| 153 |
set $rs = $M.no_rows |
| 154 |
set $col = $M.no_cols |
| 155 |
|
| 156 |
printf "Matrix of dimension %ix%i:\n", $rs, $col |
| 157 |
|
| 158 |
while $i < $rs |
| 159 |
set $j=0 |
| 160 |
printf "[" |
| 161 |
while $j< $col |
| 162 |
# printf "%8.3f+%8.3fi ", *(double*)(((void*)($M.data))+($j*$rs+$i)*sizeof(double)*2), *(double*)(((void*)($M.data))+($j*$rs+$i)*sizeof(double)*2+sizeof(double)) |
| 163 |
printf "%5g", *(double*)(((void*)($M.data))+($j*$rs+$i)*sizeof(double)*2) |
| 164 |
printf "+" |
| 165 |
printf "%-5g", *(double*)(((void*)($M.data))+($j*$rs+$i)*sizeof(double)*2+sizeof(double)) |
| 166 |
printf "i, " |
| 167 |
set $j++ |
| 168 |
end |
| 169 |
printf "]\n" |
| 170 |
set $i++ |
| 171 |
end |
| 172 |
end |
| 173 |
|
| 174 |
document dcm |
| 175 |
Display it++ cmat |
| 176 |
end |
| 177 |
|
| 178 |
define dbv |
| 179 |
set $i=0 |
| 180 |
|
| 181 |
set $M = $arg0 |
| 182 |
set $rs = $M.datasize |
| 183 |
|
| 184 |
printf "Vector of length %i:\n", $rs |
| 185 |
|
| 186 |
printf "[" |
| 187 |
while $i < $rs |
| 188 |
printf "%c ", (*(char*)(((void*)($M.data))+($i)*sizeof(char)))+48 |
| 189 |
set $i++ |
| 190 |
end |
| 191 |
printf "]\n" |
| 192 |
end |
| 193 |
|
| 194 |
document dbv |
| 195 |
Display it++ bvec |
| 196 |
end |
| 197 |
|
| 198 |
define dbm |
| 199 |
set $i=0 |
| 200 |
|
| 201 |
set $M = $arg0 |
| 202 |
set $rs = $M.no_rows |
| 203 |
set $col = $M.no_cols |
| 204 |
|
| 205 |
printf "Matrix of dimension %ix%i:\n", $rs, $col |
| 206 |
|
| 207 |
while $i < $rs |
| 208 |
set $j=0 |
| 209 |
printf "[" |
| 210 |
while $j< $col |
| 211 |
printf "%c ", *(char*)(((void*)($M.data))+($j*$rs+$i)*sizeof(char))+48 |
| 212 |
set $j++ |
| 213 |
end |
| 214 |
printf "]\n" |
| 215 |
set $i++ |
| 216 |
end |
| 217 |
end |
| 218 |
|
| 219 |
document dbm |
| 220 |
Display it++ bmat |
| 221 |
end |
| 222 |
|
| 223 |
define _test_dvm_macros_ |
| 224 |
dv a |
| 225 |
dcv b |
| 226 |
div c |
| 227 |
div cs |
| 228 |
dm A |
| 229 |
dcm B |
| 230 |
dim C |
| 231 |
dim Cs |
| 232 |
dbv p |
| 233 |
dbm P |
| 234 |
end |