Commit 978efd6aac65bc1e025472859eb738839425318b
1 parent
e6de1bad
Respond to qOffsets gdb packet (for debugging bFLT binaries).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1986 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
21 additions
and
0 deletions
gdbstub.c
| ... | ... | @@ -17,6 +17,7 @@ |
| 17 | 17 | * License along with this library; if not, write to the Free Software |
| 18 | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | 19 | */ |
| 20 | +#include "config.h" | |
| 20 | 21 | #ifdef CONFIG_USER_ONLY |
| 21 | 22 | #include <stdlib.h> |
| 22 | 23 | #include <stdio.h> |
| ... | ... | @@ -24,6 +25,7 @@ |
| 24 | 25 | #include <string.h> |
| 25 | 26 | #include <errno.h> |
| 26 | 27 | #include <unistd.h> |
| 28 | +#include <fcntl.h> | |
| 27 | 29 | |
| 28 | 30 | #include "qemu.h" |
| 29 | 31 | #else |
| ... | ... | @@ -680,6 +682,18 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf) |
| 680 | 682 | goto breakpoint_error; |
| 681 | 683 | } |
| 682 | 684 | break; |
| 685 | +#ifdef CONFIG_USER_ONLY | |
| 686 | + case 'q': | |
| 687 | + if (strncmp(p, "Offsets", 7) == 0) { | |
| 688 | + TaskState *ts = env->opaque; | |
| 689 | + | |
| 690 | + sprintf(buf, "Text=%x;Data=%x;Bss=%x", ts->info->code_offset, | |
| 691 | + ts->info->data_offset, ts->info->data_offset); | |
| 692 | + put_packet(s, buf); | |
| 693 | + break; | |
| 694 | + } | |
| 695 | + /* Fall through. */ | |
| 696 | +#endif | |
| 683 | 697 | default: |
| 684 | 698 | // unknown_command: |
| 685 | 699 | /* put empty packet */ | ... | ... |
linux-user/flatload.c
| ... | ... | @@ -783,6 +783,9 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, |
| 783 | 783 | info->start_brk = libinfo[0].start_brk; |
| 784 | 784 | info->start_stack = sp; |
| 785 | 785 | info->entry = start_addr; |
| 786 | + info->code_offset = info->start_code; | |
| 787 | + info->data_offset = info->start_data - libinfo[0].text_len; | |
| 788 | + | |
| 786 | 789 | DBG_FLT("start_thread(entry=0x%x, start_stack=0x%x)\n", |
| 787 | 790 | (int)info->entry, (int)info->start_stack); |
| 788 | 791 | ... | ... |
linux-user/main.c
linux-user/qemu.h
| ... | ... | @@ -27,6 +27,8 @@ struct image_info { |
| 27 | 27 | unsigned long rss; |
| 28 | 28 | unsigned long start_stack; |
| 29 | 29 | unsigned long entry; |
| 30 | + target_ulong code_offset; | |
| 31 | + target_ulong data_offset; | |
| 30 | 32 | int personality; |
| 31 | 33 | }; |
| 32 | 34 | |
| ... | ... | @@ -73,6 +75,7 @@ typedef struct TaskState { |
| 73 | 75 | uint32_t v86mask; |
| 74 | 76 | #endif |
| 75 | 77 | int used; /* non zero if used */ |
| 78 | + struct image_info *info; | |
| 76 | 79 | uint8_t stack[0]; |
| 77 | 80 | } __attribute__((aligned(16))) TaskState; |
| 78 | 81 | ... | ... |