1########################################################################## 2# Copyright (c) 2007, 2008, 2009, 2013, ETH Zurich. 3# All rights reserved. 4# 5# This file is distributed under the terms in the attached LICENSE file. 6# If you do not find this file, copies can be found by writing to: 7# ETH Zurich D-INFK, Haldeneggsteig 4, CH-8092 Zurich. Attn: Systems Group. 8########################################################################## 9 10set architecture i386:x86-64 11 12# Command to debug a kernel on hardware connected through conserver 13# $arg0 is the name of the relevant console 14define debug_hw 15 target remote | console -f $arg0 16end 17 18# Resets kernel symbols previously set with debug_kernel_at. 19# Used when context switching to a different user binary. 20define reset_kernel_symbols_fn 21 file $arg0 22 symbol-file 23 add-symbol-file $arg0 $text_addr -s .rodata $rodata_addr -s .data $data_addr -s .data.rel $data_rel_addr -s .data.rel.local $data_rel_local_addr -s .bss $bss_addr 24end 25 26# Helper function that uses the stored kernel filename. 27define reset_kernel_symbols 28 source barrelfish_reset_kernel_symbols.tmp 29end 30 31# Command to debug kernel at an arbitrary location. $arg0 specifies 32# kernel binary file name. $arg1 specifies position of kernel in 33# memory (kernel prints this at startup). 34define debug_kernel_at 35 set $rodata_offset = 0x0000000000121000 - 0x100000 36 set $data_offset = 0x0000000000127638 - 0x100000 37 set $data_rel_offset = 0x0000000000127840 - 0x100000 38 set $data_rel_local_offset = 0x0000000000127828 - 0x100000 39 set $bss_offset = 0x0000000000128a68 - 0x100000 40 41 set $text_addr = $arg1 42 set $rodata_addr = $arg1 + $rodata_offset 43 set $data_addr = $arg1 + $data_offset 44 set $data_rel_addr = $arg1 + $data_rel_offset 45 set $data_rel_local_addr = $arg1 + $data_rel_local_offset 46 set $bss_addr = $arg1 + $bss_offset 47 48 shell echo reset_kernel_symbols_fn $arg0 > barrelfish_reset_kernel_symbols.tmp 49 reset_kernel_symbols 50end 51 52define get_section_start 53 shell echo set \$cur_section_start = 0x`objdump -h $arg1 | awk "\\$2 == \"$arg0\" { print \\$4 }"` > barrelfish_debug.tmp 54 source barrelfish_debug.tmp 55end 56 57define switch-user-binary 58 reset_kernel_symbols 59 get_section_start .text $arg0 60 add-symbol-file $arg0 $cur_section_start 61end 62