This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[djgpp/commit] Test results of __dpmi_get_capabilities before using
- From: Eli Zaretskii <eliz at gnu dot org>
- To: gdb-patches at sourceware dot org
- Date: Sat, 18 Apr 2009 11:20:15 +0300
- Subject: [djgpp/commit] Test results of __dpmi_get_capabilities before using
- Reply-to: Eli Zaretskii <eliz at gnu dot org>
This patch avoids displaying random garbage by "info dos sysinfo"
because __dpmi_get_capabilities silently does not return any info.
Committed.
2009-04-18 Eli Zaretskii <eliz@gnu.org>
* go32-nat.c (go32_sysinfo): Check if the call to
__dpmi_get_capabilities fills the buffer with information, and
don't use the buffer if not.
Index: gdb/go32-nat.c
===================================================================
RCS file: /cvs/src/src/gdb/go32-nat.c,v
retrieving revision 1.69
diff -u -r1.69 go32-nat.c
--- gdb/go32-nat.c 17 Apr 2009 11:59:35 -0000 1.69
+++ gdb/go32-nat.c 18 Apr 2009 08:15:55 -0000
@@ -983,6 +983,10 @@
static void
go32_sysinfo (char *arg, int from_tty)
{
+ static const char test_pattern[] =
+ "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"
+ "deadbeafdeadbeafdeadbeafdeadbeafdeadbeaf"
+ "deadbeafdeadbeafdeadbeafdeadbeafdeadbeafdeadbeaf";
struct utsname u;
char cpuid_vendor[13];
unsigned cpuid_max = 0, cpuid_eax, cpuid_ebx, cpuid_ecx, cpuid_edx;
@@ -990,8 +994,7 @@
unsigned advertized_dos_version = ((unsigned int)_osmajor << 8) | _osminor;
int dpmi_flags;
char dpmi_vendor_info[129];
- int dpmi_vendor_available =
- __dpmi_get_capabilities (&dpmi_flags, dpmi_vendor_info);
+ int dpmi_vendor_available;
__dpmi_version_ret dpmi_version_data;
long eflags;
__dpmi_free_mem_info mem_info;
@@ -1218,7 +1221,15 @@
else if (true_dos_version == 0x532 && advertized_dos_version == 0x500)
printf_filtered ("Windows Version................Windows NT family (W2K/XP/W2K3/Vista/W2K8)\n");
puts_filtered ("\n");
- if (dpmi_vendor_available == 0)
+ /* On some versions of Windows, __dpmi_get_capabilities returns
+ zero, but the buffer is not filled with info, so we fill the
+ buffer with a known pattern and test for it afterwards. */
+ memcpy (dpmi_vendor_info, test_pattern, sizeof(dpmi_vendor_info));
+ dpmi_vendor_available =
+ __dpmi_get_capabilities (&dpmi_flags, dpmi_vendor_info);
+ if (dpmi_vendor_available == 0
+ && memcmp (dpmi_vendor_info, test_pattern,
+ sizeof(dpmi_vendor_info)) != 0)
{
/* The DPMI spec says the vendor string should be ASCIIZ, but
I don't trust the vendors to follow that... */
@@ -1230,6 +1241,8 @@
(unsigned)dpmi_vendor_info[1],
((unsigned)dpmi_flags & 0x7f));
}
+ else
+ printf_filtered ("DPMI Host......................(Info not available)\n");
__dpmi_get_version (&dpmi_version_data);
printf_filtered ("DPMI Version...................%d.%02d\n",
dpmi_version_data.major, dpmi_version_data.minor);