gdb pass raw result of evaluation to custom python function -


amd64, register $rdi pointer "/home/il/gammu-git/src/gammu/libgammu/tls/x86_64/libpthread.so.0"

seen here example:

define foo py print gdb.execute("output $arg0", to_string=true).strip('"') end 

expected:

(gdb) foo (char*)$rdi /home/il/gammu-git/src/gammu/libgammu/tls/x86_64/libpthread.so.0 

however, output command prints address of string:

(gdb) foo (char*)$rdi 0x7fffffffe180 "/home/il/gammu-git/src/gammu/libgammu/tls/x86_64/libpthread.so.0 

you can solve doing in python, i.e.

py print gdb.execute("output $arg0", to_string=true).strip('"').split()[1] 

or (and that's i'd prefer) customizing output call. gdb has comprehensive online typing in help output , following leads there:

(gdb) output "print" don't put in value history , don't print newline. useful in user-defined commands. (gdb) print print value of expression exp. variables accessible of lexical environment of selected stack frame, plus scope global or entire file.  $num gets previous value number num.  $ , $$ last 2 values. $$num refers num'th value last one. names starting $ refer registers (with values have if program return stack frame selected, restoring registers saved frames farther in) or else debugger "convenience" variables (any such name not known register). use assignment expressions give values convenience variables.  {type}adrexp refers datum of data type type, located @ address adrexp. @ binary operator treating consecutive data objects anywhere in memory array.  foo@num gives array first element foo, second element stored in space following foo stored, etc.  foo must expression value resides in memory.  exp may preceded /fmt, fmt format letter no count or size letter (see "x" command). (gdb) x examine memory: x/fmt address. address expression memory address examine. fmt repeat count followed format letter , size letter. format letters o(octal), x(hex), d(decimal), u(unsigned decimal),   t(binary), f(float), a(address), i(instruction), c(char), s(string)   , z(hex, 0 padded on left). size letters b(byte), h(halfword), w(word), g(giant, 8 bytes). specified number of objects of specified size printed according format.  defaults format , size letters used. default count 1.  default address following last thing printed command or "print". 

by way: should've mentioned earlier, but: address printing set on reason. so:

set print addr off 

will solve issue.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -