This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [Windows]Fix a bug which cause GDB.exe assert when try to run the inferior
- From: Yao Qi <yao at codesourcery dot com>
- To: asmwarrior <asmwarrior at gmail dot com>
- Cc: <gdb-patches at sourceware dot org>
- Date: Mon, 24 Feb 2014 15:47:51 +0800
- Subject: Re: [Windows]Fix a bug which cause GDB.exe assert when try to run the inferior
- Authentication-results: sourceware.org; auth=none
- References: <530612A8 dot 4000903 at gmail dot com> <5306A9BC dot 4080701 at codesourcery dot com> <5306EE2A dot 2060103 at gmail dot com> <5306FA43 dot 1070408 at codesourcery dot com> <83sirc532m dot fsf at gnu dot org> <530706DD dot 8060605 at codesourcery dot com> <530AEA6C dot 8050002 at codesourcery dot com> <530AF067 dot 1010002 at gmail dot com>
On 02/24/2014 03:10 PM, asmwarrior wrote:
> Hi, Yao, thanks. I was thinking that I won't need further change, because it was a tiny patch.
The patch is small, but we still have to make sure it is correct,
documented, and compliant to coding standard, etc. There are something
not very interesting in the procedure, such as writing changelog or
commit log, but they guarantee GDB still maintainable after thousands
of commits in several years.
It is good to see your patch, and better to adjust patch to a
commit-able state as a result of reviews.
> Anyway, would you mind to commit for me? I don't have commit access.
Thanks for testing GDB for windows target, reporting this
regression, and posting your patch.
Patch below is what I pushed in.
--
Yao (éå)
>From 5b8017c1ebd1b8105f6846dc15d5158e8ec3f450 Mon Sep 17 00:00:00 2001
From: Yuanhui Zhang <asmwarrior@gmail.com>
Date: Mon, 24 Feb 2014 15:22:10 +0800
Subject: [PATCH] Fix a GDB assert failure on windows
A GDB internal error is found on native mingw32 target.
(gdb) run
../../binutils-gdb/gdb/target.c:1483: internal-error:
target_xfer_partial: Assertion `*xfered_len > 0' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n)
This error was introduced by the following snippet in commit
9b409511d07fe375284701af34909fb539029caf
> @@ -2536,27 +2538,30 @@ windows_xfer_shared_libraries (struct
target_ops *ops,
> }
>
> obstack_free (&obstack, NULL);
> - return len;
> + *xfered_len = (ULONGEST) len;
> + return TARGET_XFER_OK;
> }
In the original code, len is returned, which could be 0, but after that
commit, only TARGET_XFER_OK is returned, which is wrong. If len is 0,
TARGET_XFER_EOF should be returned. (it is 0 in enum
target_xfer_status declaration).
gdb:
2014-02-23 Yuanhui Zhang <asmwarrior@gmail.com>
* windows-nat.c (windows_xfer_shared_libraries): Return
TARGET_XFER_EOF if LEN is zero to fix an assert failure when
requested object is TARGET_OBJECT_LIBRARIES.
---
gdb/windows-nat.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c
index 4366aab..6c45d0a 100644
--- a/gdb/windows-nat.c
+++ b/gdb/windows-nat.c
@@ -2501,7 +2501,7 @@ windows_xfer_shared_libraries (struct target_ops *ops,
obstack_free (&obstack, NULL);
*xfered_len = (ULONGEST) len;
- return TARGET_XFER_OK;
+ return len != 0 ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
static enum target_xfer_status
--
1.7.7.6