Rossym.gdb

From ReactOS Wiki
Revision as of 07:46, 8 August 2006 by Arty (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

rossym.gdb

{{{

define log_to_file
       set logging file $arg0
       set logging redirect on
       set logging overwrite on
       set logging on
end
define end_log
       set logging off
end
define load-module-nostrip
       set $modname = $arg0
       set $modaddr = $arg1
       printf "Loading module symbols at 0x%x\n", $modaddr
       log_to_file sym.tmp
       printf "%s\n0x%x", ((char *)$name), $modaddr
       end_log
       shell sed -e 's/\..*$//g' < sym.tmp > modname_stripped.txt
       shell find output-i386 -name `head -n 1 modname_stripped.txt`.nostrip.\* > found_mod.txt
       log_to_file loadsym.sh
       printf "echo add-symbol-file `cat found_mod.txt` `tail -n 1 sym.tmp`"
       end_log
       shell sh loadsym.sh > load_module.gdb
       source load_module.gdb
end
define copy-module-name
       set $ndx     = 0
       while (((KDB_MODULE_INFO*)$modinf)->Name[$ndx])
               set ((char *)$name)[$ndx] = ((KDB_MODULE_INFO*)$modinf)->Name[$ndx]
               set $ndx = $ndx + 1
       end
       set ((char *)$name)[$ndx] = 0
end
define load-all-modules
       set $stack_space = $esp - 1024
       set $modinf  = $stack_space
       set $name    = $stack_space + sizeof(KDB_MODULE_INFO)
       set $index   = 1
       set $result = KdbpSymFindModuleByIndex($index,$modinf)
       while ($result != 0)
               copy-module-name
               printf "Loading symbols for %s\n", ((char *)$name)
               load-module-nostrip $name (((PKDB_MODULE_INFO)$modinf)->Base+0x1000)
               set $index = $index + 1
               set $result = KdbpSymFindModuleByIndex($index,$modinf)
       end
end

}}}

.gdbinit

{{{

add-symbol-file output-i386/ntoskrnl/ntoskrnl.nostrip.exe 
source lib/rossym/rossym.gdb
target remote :1234
break RosSymInit
c
fin
fin
fin

}}}

So then you can break at some point later, and when you want to load kernel symbols, do 'load-all-modules'