Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 169699
b: refs/heads/master
c: 9f6b3c2
h: refs/heads/master
i:
  169697: 60638a1
  169695: 716a34d
v: v3
  • Loading branch information
Frederic Weisbecker committed Nov 10, 2009
1 parent 9685b23 commit 74a967b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 676c0dbe6e514fdd8e434a9e623c781aa9b40b15
refs/heads/master: 9f6b3c2c30cfbb1166ce7e74a8f9fd93ae19d2de
10 changes: 2 additions & 8 deletions trunk/arch/x86/include/asm/a.out-core.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <linux/user.h>
#include <linux/elfcore.h>
#include <asm/debugreg.h>

/*
* fill in the user structure for an a.out core dump
Expand All @@ -32,14 +33,7 @@ static inline void aout_dump_thread(struct pt_regs *regs, struct user *dump)
>> PAGE_SHIFT;
dump->u_dsize -= dump->u_tsize;
dump->u_ssize = 0;
dump->u_debugreg[0] = current->thread.debugreg[0];
dump->u_debugreg[1] = current->thread.debugreg[1];
dump->u_debugreg[2] = current->thread.debugreg[2];
dump->u_debugreg[3] = current->thread.debugreg[3];
dump->u_debugreg[4] = 0;
dump->u_debugreg[5] = 0;
dump->u_debugreg[6] = current->thread.debugreg6;
dump->u_debugreg[7] = current->thread.debugreg7;
aout_dump_debugregs(dump);

if (dump->start_stack < TASK_SIZE)
dump->u_ssize = ((unsigned long)(TASK_SIZE - dump->start_stack))
Expand Down
2 changes: 2 additions & 0 deletions trunk/arch/x86/include/asm/debugreg.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ static inline void hw_breakpoint_disable(void)
set_debugreg(0UL, 3);
}

extern void aout_dump_debugregs(struct user *dump);

#ifdef CONFIG_KVM
extern void hw_breakpoint_restore(void);
#endif
Expand Down
35 changes: 35 additions & 0 deletions trunk/arch/x86/kernel/hw_breakpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,41 @@ int arch_validate_hwbkpt_settings(struct perf_event *bp,
return 0;
}

/*
* Dump the debug register contents to the user.
* We can't dump our per cpu values because it
* may contain cpu wide breakpoint, something that
* doesn't belong to the current task.
*
* TODO: include non-ptrace user breakpoints (perf)
*/
void aout_dump_debugregs(struct user *dump)
{
int i;
int dr7 = 0;
struct perf_event *bp;
struct arch_hw_breakpoint *info;
struct thread_struct *thread = &current->thread;

for (i = 0; i < HBP_NUM; i++) {
bp = thread->ptrace_bps[i];

if (bp && !bp->attr.disabled) {
dump->u_debugreg[i] = bp->attr.bp_addr;
info = counter_arch_bp(bp);
dr7 |= encode_dr7(i, info->len, info->type);
} else {
dump->u_debugreg[i] = 0;
}
}

dump->u_debugreg[4] = 0;
dump->u_debugreg[5] = 0;
dump->u_debugreg[6] = current->thread.debugreg6;

dump->u_debugreg[7] = dr7;
}

/*
* Release the user breakpoints used by ptrace
*/
Expand Down

0 comments on commit 74a967b

Please sign in to comment.