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,6 +17,7 @@ | ||
| 17 | * License along with this library; if not, write to the Free Software | 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ | 19 | */ |
| 20 | +#include "config.h" | ||
| 20 | #ifdef CONFIG_USER_ONLY | 21 | #ifdef CONFIG_USER_ONLY |
| 21 | #include <stdlib.h> | 22 | #include <stdlib.h> |
| 22 | #include <stdio.h> | 23 | #include <stdio.h> |
| @@ -24,6 +25,7 @@ | @@ -24,6 +25,7 @@ | ||
| 24 | #include <string.h> | 25 | #include <string.h> |
| 25 | #include <errno.h> | 26 | #include <errno.h> |
| 26 | #include <unistd.h> | 27 | #include <unistd.h> |
| 28 | +#include <fcntl.h> | ||
| 27 | 29 | ||
| 28 | #include "qemu.h" | 30 | #include "qemu.h" |
| 29 | #else | 31 | #else |
| @@ -680,6 +682,18 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf) | @@ -680,6 +682,18 @@ static int gdb_handle_packet(GDBState *s, CPUState *env, const char *line_buf) | ||
| 680 | goto breakpoint_error; | 682 | goto breakpoint_error; |
| 681 | } | 683 | } |
| 682 | break; | 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 | default: | 697 | default: |
| 684 | // unknown_command: | 698 | // unknown_command: |
| 685 | /* put empty packet */ | 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,6 +783,9 @@ int load_flt_binary(struct linux_binprm * bprm, struct target_pt_regs * regs, | ||
| 783 | info->start_brk = libinfo[0].start_brk; | 783 | info->start_brk = libinfo[0].start_brk; |
| 784 | info->start_stack = sp; | 784 | info->start_stack = sp; |
| 785 | info->entry = start_addr; | 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 | DBG_FLT("start_thread(entry=0x%x, start_stack=0x%x)\n", | 789 | DBG_FLT("start_thread(entry=0x%x, start_stack=0x%x)\n", |
| 787 | (int)info->entry, (int)info->start_stack); | 790 | (int)info->entry, (int)info->start_stack); |
| 788 | 791 |
linux-user/main.c
| @@ -1541,6 +1541,7 @@ int main(int argc, char **argv) | @@ -1541,6 +1541,7 @@ int main(int argc, char **argv) | ||
| 1541 | memset(ts, 0, sizeof(TaskState)); | 1541 | memset(ts, 0, sizeof(TaskState)); |
| 1542 | env->opaque = ts; | 1542 | env->opaque = ts; |
| 1543 | ts->used = 1; | 1543 | ts->used = 1; |
| 1544 | + ts->info = info; | ||
| 1544 | env->user_mode_only = 1; | 1545 | env->user_mode_only = 1; |
| 1545 | 1546 | ||
| 1546 | #if defined(TARGET_I386) | 1547 | #if defined(TARGET_I386) |
linux-user/qemu.h
| @@ -27,6 +27,8 @@ struct image_info { | @@ -27,6 +27,8 @@ struct image_info { | ||
| 27 | unsigned long rss; | 27 | unsigned long rss; |
| 28 | unsigned long start_stack; | 28 | unsigned long start_stack; |
| 29 | unsigned long entry; | 29 | unsigned long entry; |
| 30 | + target_ulong code_offset; | ||
| 31 | + target_ulong data_offset; | ||
| 30 | int personality; | 32 | int personality; |
| 31 | }; | 33 | }; |
| 32 | 34 | ||
| @@ -73,6 +75,7 @@ typedef struct TaskState { | @@ -73,6 +75,7 @@ typedef struct TaskState { | ||
| 73 | uint32_t v86mask; | 75 | uint32_t v86mask; |
| 74 | #endif | 76 | #endif |
| 75 | int used; /* non zero if used */ | 77 | int used; /* non zero if used */ |
| 78 | + struct image_info *info; | ||
| 76 | uint8_t stack[0]; | 79 | uint8_t stack[0]; |
| 77 | } __attribute__((aligned(16))) TaskState; | 80 | } __attribute__((aligned(16))) TaskState; |
| 78 | 81 |