On 01/03/16(Tue) 16:27, Mike Larkin wrote:
> On Tue, Mar 01, 2016 at 11:58:57PM +0100, Martin Pieuchot wrote:
> > As explained previously I'm implementing an instrumentation system based
> > on ddb(4) and relying on breakpoints to execute kernel probes.
> > 
> > For debugging purposes I need a way to dump the content of the registers
> > when a breakpoint-not-for-ddb(4) fired.  So I hacked the "show regs" to
> > dump the registers at a specified address if one was given.
> > 
> > I'd like to put this in, any objection?  Comment?
> > 
> > While here I merged db_print.c into db_command.c, I'm making some room
> > before adding new files ;)
> > 
> > If I get any ok I'll update the manual.
> > 
> 
> Can you give an example of how this would be used and what the output
> would look like?

Sure, see below for an example on i386.  Now I just realized that the
order of the registers on some unfamous archs are not respecting the
trapframe layout.  So I'll fix that first before pushing this diff.

You can see that below the values of ds/es/fs/gs should be fs/gs/es/ds.

# kgmon -b                      ## enable probe-based profiling
# sysctl ddb.trigger=1          ## enter ddb(4)

Stopped at      db_read_bytes+0x17:     movzbl  0(%esi,%ecx,1),%eax
ddb> tr
db_read_bytes(800,4,f4055d9c,f4055dc4,d037e448) at db_read_bytes+0x17
db_get_value(800,4,0,f4055e04,d03cbf48) at db_get_value+0x38
db_prof_hook(f4055dfc) at db_prof_hook+0xd3
Xbpt(0,10,10,d03835d0,f4055f5c) at Xbpt+0x38
ddb_sysctl(f4055ecc,1,cf7f6784,f4055ef8,cf7f6778) at ddb_sysctl+0x179
sys_sysctl(d56022e0,f4055f5c,f4055f7c,d03b1f50,0) at sys_sysctl+0x20e
syscall() at syscall+0x219
--- syscall (number 2) ---
0x14:
ddb> br db_prof_hook
ddb> c
uvm_fault(0xd5745140, 0x0, 0, 1) -> e
kernel: page fault trap, code=0
Stopped at      db_read_bytes+0x17:     movzbl  0(%esi,%ecx,1),%eax
ddb> tr
db_read_bytes(800,4,f4055d9c,f4055dc4,d037e448) at db_read_bytes+0x17
db_get_value(800,4,0,f4055e04,d03cbf48) at db_get_value+0x38
db_prof_hook(f4055dfc) at db_prof_hook+0xd3
Xbpt(0,10,10,d03835d0,f4055f5c) at Xbpt+0x38
ddb_sysctl(f4055ecc,1,cf7f6784,f4055ef8,cf7f6778) at ddb_sysctl+0x179
sys_sysctl(d56022e0,f4055f5c,f4055f7c,d03b1f50,0) at sys_sysctl+0x20e
syscall() at syscall+0x219
--- syscall (number 2) ---
0x14:
ddb> show reg 0xf4055dfc
ds                  0x20
es                     0
fs                  0x10
gs                  0x10
edi           0xcf7f6784
esi           0xf4055ef8
ebp           0xf4055e4c
ebx           0xcf7f6778
edx           0xd1405a00        end+0x786a00
ecx           0xd0b5af20        constab+0x20
eax                0x800
eip                  0x1
cs                     0
eflags        0xd05590b7        Debugger+0x7
esp                  0x8
ss                 0x286
db_read_bytes+0x17:     movzbl  0(%esi,%ecx,1),%eax

Reply via email to