From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9620 invoked by alias); 9 Aug 2008 17:54:55 -0000 Received: (qmail 9607 invoked by uid 22791); 9 Aug 2008 17:54:53 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 09 Aug 2008 17:54:00 +0000 Received: (qmail 15211 invoked from network); 9 Aug 2008 17:53:57 -0000 Received: from unknown (HELO orlando.local) (pedro@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Aug 2008 17:53:57 -0000 From: Pedro Alves To: gdb-patches@sourceware.org, Eli Zaretskii Subject: Re: go32-nat, always a thread Date: Sat, 09 Aug 2008 17:54:00 -0000 User-Agent: KMail/1.9.9 References: <200808080439.17254.pedro@codesourcery.com> In-Reply-To: MIME-Version: 1.0 Content-Type: Multipart/Mixed; boundary="Boundary-00=_omdnIlZRli6ZU3+" Message-Id: <200808091853.44771.pedro@codesourcery.com> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-08/txt/msg00246.txt.bz2 --Boundary-00=_omdnIlZRli6ZU3+ Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Content-length: 7291 On Fri, 8 Aug 2008 04:39:17 +0100, Pedro Alves wrote: > Anyone able to test this? Eli? So, I took a few hours today to build a GDB on DJGPP. After some hacks and patches, I succeeded. This is what is looks like with the attached patches installed: bash-2.04$ ./gdb ./gdb GNU gdb (GDB) 6.8.50.20080808-cvs Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "--host=i586-pc-msdosdjgpp --target=djgpp". For bug reporting instructions, please see: ... (gdb) start Temporary breakpoint 1 at 0x1f8c: file ../../gdb/gdb.c, line 28. Starting program: c:/djgdb/src/djgpp/gdb/./gdb.exe Temporary breakpoint 1, main (argc=1, argv=0x36da0c) at ../../gdb/gdb.c:28 28 memset (&args, 0, sizeof args); (gdb) info threads * 1 Thread
main (argc=1, argv=0x36da0c) at ../../gdb/gdb.c:28 (gdb) kill Kill the program being debugged? (y or n) y (gdb) info threads (gdb) n The program is not being run. (gdb) Here is a description of what I've done to build gdb on DJGPP: I used a Windows XP machine. Downloaded DJGPP 2.03, bash 2.04, and all the needed dependencies to build GDB from djgpp's ftp archive. These are all the zips I downloaded and installed. Most likelly a couple aren't needed, though. bnu217b.zip djlsr203.zip fil41d.zip gwk316b.zip rhid15ab.zip bnu217s.zip djtst203.zip find41b.zip gwk316d.zip rhid15as.zip bsh204br2.zip em2005b.zip find41d.zip m4-149b.zip sed415b.zip bsh204d.zip em2005li.zip flx254b.zip m4-149d.zip sed415d.zip bsn23b.zip em2005s1.zip gcc423b.zip mak3791b.zip shl2011b.zip bsn23s.zip em2005s2.zip gdb611b.zip objc423b.zip shl2011d.zip dif287b.zip faq230b.zip gpp423b.zip pakk023b.zip txi412b.zip dif287d.zip faq230s.zip grep253b.zip pakk023s.zip txt20b.zip djdev203.zip fil41b.zip grep253d.zip pdcur33b.zip txt20d.zip I didn't need to use the special djunpack to rename gdb's sources to 8.3 format, since I was under bash + winxp, which sees long filenames. bash-2.04$ gcc -v Using built-in specs. Target: djgpp Configured with: /v203/gcc-4.23/configure djgpp --prefix=/dev/env/DJDIR --disable-nls --disable-werror --enable-languages=c,c++,fortran,objc,obj-c++,ada Thread model: single gcc version 4.2.3 I configured gdb out of tree with: ../src/configure \ --target=i586-pc-msdosdjgpp \ --host=i586-pc-msdosdjgpp \ --build=i586-pc-msdosdjgpp I to pass target,host to force a native build. The default of not passing any argument to configure, ended up building with target=i586-pc-msdosdjgpp host=i386-pc-msdosdjgpp, which, being different, triggeres a cross build, which excludes go32-nat.c. About the first patch: - The readline bits, the patch explains what's needed. Here's the error log gcc -DHAVE_CONFIG_H -I. -I../../readline -DRL_LIBRARY_VERSION='"5.1"' -O0 -g3 -c ../../readline/support/wcwidth.c In file included from ../../readline/support/wcwidth.c:9: c:/djgpp/include/wchar.h:24: error: expected '=', ',', ';', 'asm' or '__attribut e__' before 'typedef' ../../readline/support/wcwidth.c: In function 'wcwidth': ../../readline/support/wcwidth.c:130: warning: comparison is always false due to limited range of data type ../../readline/support/wcwidth.c:130: warning: comparison is always true due to limited range of data type make.exe: *** [wcwidth.o] Error 1 - libbfd cc1.exe: warnings being treated as errors ../../bfd/archive.c: In function '_bfd_archive_bsd_update_armap_timestamp': ../../bfd/archive.c:2314: warning: comparison between signed and unsigned time_t in djgpp is unsigned int, armap_timestamp is long. There's a comment at the definition of armap_timestamp, claiming that it isn't time_t until more compilers support it. - libiberty: I get this error when building libiberty: rm -f needed-list; touch needed-list; \ for f in atexit calloc memchr memcmp memcpy memmove memset rename strchr strerro r strncmp strrchr strstr strtol strtoul tmpnam vfprintf vprintf vfork waitpid bc mp bcopy bzero; do \ for g in ; do \ case "$g" in \ *$f*) echo $g >> needed-list ;; \ esac; \ done; \ done c:\djgpp\tmp/dj750000: line 1: syntax error near unexpected token `;' c:\djgpp\tmp/dj750000: line 1: `rm -f needed-list; touch needed-list; for f in atexit calloc memchr memcmp memcpy memmove memset rename strchr strerror strncmp strrchr strstr strtol strtoul tmpnam vfprintf vprintf vfork waitpid bcmp bcopy bzero; do for g in ; do case "$g" in *$f*) echo $g >> needed-list ;; esac; done; done' make.exe[2]: *** [needed-list] Error 2 I can't tell what's going on here. Maybe it's related to using make 3.79.1. I just hacked the Makefile to just touch the needed-list file and do nothing else with it. There's a comment in the makefile claining this is needed for libstdc++. For some reason, maybe related to the above, a few libiberty objects are not being built and archived: I manually added snprintf.o, vasprintf.o, asprintf.o and vsnprintf.o to REQUIRED_OFILES to libiberty's generated Makefile. I don't plan to persue to proper fix for these issues. GDB changes: - DJGPP 2.03 doesn't come bundled with stdint.h, but I downloaded it djgpp's cvs (from the web frontend to CVS actually), and install it manually. Seems to work fine. The build complains about not finding stdint.h. DJGPP 2.03 doesn't come bundled with stdint.h, but we should be picking up stdint.h from gdb/gnulib. There seems to be a build order dependency going wrong. We configure gdb/gnulib before starting to build gdb/, but we build gdb/ before gdb/gnulib. I had to cd to build/gdb/gnulib, and "make" it. This creates a gdb/gnulib/stdint.h, and also gdb/gnulib/string.h with memmem declared in it, which is needed to compile target.c, due Then I can come back to build/gdb, and continue building. This is using GNU Make 3.79.1, which is what prebuilt at djgpp's download site. It seems to be that even if we don't support auto-dependencies with this make version, it should still build gnulib before gdb. Actually, I just tried with GNU Make 3.81 on linux, and I see the same issue. - "missing sentinel in function calls" warnings: NULL is not a pointer in djgpp. GCC was barking on a few concat calls. - cp-name-parse.y Needed to include config.h, so HAVE_DECL_SNPRINTF was defined, so libiberty.h declares snprintf. - go32-nat.c: There was a bit of bit rot around. GCC complains about attribute packed like so: cc1.exe: warnings being treated as errors ../../gdb/go32-nat.c:1292: warning: 'packed' attribute ignored for field of type 'unsigned char' ../../gdb/go32-nat.c:1301: warning: 'packed' attribute ignored for field of type 'unsigned char' make.exe: *** [go32-nat.o] Error 1 Just removed the attribute from the offending fields. Are the GDB parts of patches OK? I checked that x86_64-unknown-linux-gnu still builds OK. -- Pedro Alves --Boundary-00=_omdnIlZRli6ZU3+ Content-Type: text/x-diff; charset="utf-8"; name="go32_fixes.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="go32_fixes.diff" Content-length: 7829 bfd/ 2008-08-09 Pedro Alves * archive.c (_bfd_archive_bsd_update_armap_timestamp): Cast stat st_mtime to long before comparison. gdb/ 2008-08-09 Pedro Alves * buildsym.c (start_subfile): Cast sentinel NULL to void*. * cp-name-parser.y: Include "config.h". * posix-hdep.c [__GO32__]: Include time.h. * xml-tdesc.c (fetch_xml_from_file): Cast sentinel NULL to void*. * gdb_select.h: Include sys/types.h if available. * go32-nat.c (fetch_register, store_register): Pass the regcache gdbarch to i386_fp_regnum_p and i386_fpc_regnum_p. (go32_xfer_memory): Change type of myaddr parameter to gdb_byte. (struct seg_descr, struct seg_descr): Don't pack byte sized members. readline/ 2008-08-09 Pedro Alves * signals.c (rl_set_sighandler): Guard access to SIGWINCH. * wcwidth.c [__GO32__]: Include wctype.h before wchar.h. --- bfd/archive.c | 2 +- gdb/buildsym.c | 2 +- gdb/cp-name-parser.y | 1 + gdb/gdb_select.h | 4 ++++ gdb/go32-nat.c | 18 ++++++++++-------- gdb/posix-hdep.c | 6 ++++++ gdb/xml-tdesc.c | 2 +- readline/signals.c | 4 ++++ readline/support/wcwidth.c | 5 +++++ 9 files changed, 33 insertions(+), 11 deletions(-) Index: src/gdb/buildsym.c =================================================================== --- src.orig/gdb/buildsym.c +++ src/gdb/buildsym.c @@ -547,7 +547,7 @@ start_subfile (char *name, char *dirname && !IS_ABSOLUTE_PATH (subfile->name) && subfile->dirname != NULL) subfile_name = concat (subfile->dirname, SLASH_STRING, - subfile->name, NULL); + subfile->name, (void*) NULL); else subfile_name = subfile->name; Index: src/gdb/cp-name-parser.y =================================================================== --- src.orig/gdb/cp-name-parser.y +++ src/gdb/cp-name-parser.y @@ -36,6 +36,7 @@ Boston, MA 02110-1301, USA. */ #include #include +#include "config.h" #include "safe-ctype.h" #include "libiberty.h" #include "demangle.h" Index: src/gdb/posix-hdep.c =================================================================== --- src.orig/gdb/posix-hdep.c +++ src/gdb/posix-hdep.c @@ -24,6 +24,12 @@ #include "gdb_select.h" +#ifdef __GO32__ +/* DJGPP defines the fd_set type in sys/types.h, but `select' goes + here. */ +# include +#endif + /* The strerror() function can return NULL for errno values that are out of range. Provide a "safe" version that always returns a printable string. */ Index: src/gdb/xml-tdesc.c =================================================================== --- src.orig/gdb/xml-tdesc.c +++ src/gdb/xml-tdesc.c @@ -443,7 +443,7 @@ fetch_xml_from_file (const char *filenam if (dirname && *dirname) { - char *fullname = concat (dirname, "/", filename, NULL); + char *fullname = concat (dirname, "/", filename, (void*) NULL); if (fullname == NULL) nomem (0); file = fopen (fullname, FOPEN_RT); Index: src/readline/signals.c =================================================================== --- src.orig/readline/signals.c +++ src/readline/signals.c @@ -251,7 +251,11 @@ rl_set_sighandler (sig, handler, ohandle struct sigaction act; act.sa_handler = handler; +#if defined (SIGWINCH) act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0; +#else + act.sa_flags = 0; +#endif sigemptyset (&act.sa_mask); sigemptyset (&ohandler->sa_mask); sigaction (sig, &act, &old_handler); Index: src/readline/support/wcwidth.c =================================================================== --- src.orig/readline/support/wcwidth.c +++ src/readline/support/wcwidth.c @@ -6,6 +6,11 @@ * Markus Kuhn -- 2001-09-08 -- public domain */ +#ifdef __GO32__ +/* DJGPP needs to include this before including wchar.h. */ +# include +#endif + #include struct interval { Index: src/bfd/archive.c =================================================================== --- src.orig/bfd/archive.c +++ src/bfd/archive.c @@ -2311,7 +2311,7 @@ _bfd_archive_bsd_update_armap_timestamp /* Can't read mod time for some reason. */ return TRUE; } - if (archstat.st_mtime <= bfd_ardata (arch)->armap_timestamp) + if (((long) archstat.st_mtime) <= bfd_ardata (arch)->armap_timestamp) /* OK by the linker's rules. */ return TRUE; Index: src/gdb/gdb_select.h =================================================================== --- src.orig/gdb/gdb_select.h +++ src/gdb/gdb_select.h @@ -24,6 +24,10 @@ #include #endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif + #ifdef USE_WIN32API #include #endif Index: src/gdb/go32-nat.c =================================================================== --- src.orig/gdb/go32-nat.c +++ src/gdb/go32-nat.c @@ -176,7 +176,7 @@ static void go32_fetch_registers (struct static void store_register (const struct regcache *, int regno); static void go32_store_registers (struct regcache *, int regno); static void go32_prepare_to_store (struct regcache *); -static int go32_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, +static int go32_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, struct mem_attrib *attrib, struct target_ops *target); @@ -465,10 +465,11 @@ go32_wait (ptid_t ptid, struct target_wa static void fetch_register (struct regcache *regcache, int regno) { - if (regno < gdbarch_fp0_regnum (get_regcache_arch (regcache))) + struct gdbarch *gdbarch = get_regcache_arch (regcache); + if (regno < gdbarch_fp0_regnum (gdbarch)) regcache_raw_supply (regcache, regno, (char *) &a_tss + regno_mapping[regno].tss_ofs); - else if (i386_fp_regnum_p (regno) || i386_fpc_regnum_p (regno)) + else if (i386_fp_regnum_p (gdbarch, regno) || i386_fpc_regnum_p (gdbarch, regno)) i387_supply_fsave (regcache, regno, &npx); else internal_error (__FILE__, __LINE__, @@ -493,10 +494,11 @@ go32_fetch_registers (struct regcache *r static void store_register (const struct regcache *regcache, int regno) { - if (regno < gdbarch_fp0_regnum (get_regcache_arch (regcache))) + struct gdbarch *gdbarch = get_regcache_arch (regcache); + if (regno < gdbarch_fp0_regnum (gdbarch)) regcache_raw_collect (regcache, regno, (char *) &a_tss + regno_mapping[regno].tss_ofs); - else if (i386_fp_regnum_p (regno) || i386_fpc_regnum_p (regno)) + else if (i386_fp_regnum_p (gdbarch, regno) || i386_fpc_regnum_p (gdbarch, regno)) i387_collect_fsave (regcache, regno, &npx); else internal_error (__FILE__, __LINE__, @@ -524,7 +526,7 @@ go32_prepare_to_store (struct regcache * } static int -go32_xfer_memory (CORE_ADDR memaddr, char *myaddr, int len, int write, +go32_xfer_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len, int write, struct mem_attrib *attrib, struct target_ops *target) { if (write) @@ -1263,7 +1265,7 @@ go32_sysinfo (char *arg, int from_tty) struct seg_descr { unsigned short limit0 __attribute__((packed)); unsigned short base0 __attribute__((packed)); - unsigned char base1 __attribute__((packed)); + unsigned char base1; unsigned stype:5 __attribute__((packed)); unsigned dpl:2 __attribute__((packed)); unsigned present:1 __attribute__((packed)); @@ -1272,7 +1274,7 @@ struct seg_descr { unsigned dummy:1 __attribute__((packed)); unsigned bit32:1 __attribute__((packed)); unsigned page_granular:1 __attribute__((packed)); - unsigned char base2 __attribute__((packed)); + unsigned char base2; }; struct gate_descr { --Boundary-00=_omdnIlZRli6ZU3+ Content-Type: text/x-diff; charset="utf-8"; name="go32-always_a_thread.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="go32-always_a_thread.diff" Content-length: 2062 2008-08-09 Pedro Alves * go32-nat.c: Include "gdbthread.h". (go32_stop, go32_kill_inferior): Delete the main thread. (go32_create_inferior): Add it. (go32_thread_alive, go32_pid_to_str): New. (init_go32_ops): Register go32_thread_alive and go32_pid_to_str. --- gdb/go32-nat.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) Index: src/gdb/go32-nat.c =================================================================== --- src.orig/gdb/go32-nat.c +++ src/gdb/go32-nat.c @@ -22,6 +22,7 @@ #include "defs.h" #include "inferior.h" +#include "gdbthread.h" #include "gdb_wait.h" #include "gdbcore.h" #include "command.h" @@ -566,7 +567,9 @@ go32_stop (ptid_t ptid) { normal_stop (); cleanup_client (); + ptid = inferior_ptid; inferior_ptid = null_ptid; + delete_thread_silent (ptid); prog_has_started = 0; } @@ -576,6 +579,8 @@ go32_kill_inferior (void) redir_cmdline_delete (&child_cmd); resume_signal = -1; resume_is_step = 0; + if (!ptid_equal (inferior_ptid, null_ptid)) + delete_thread_silent (inferior_ptid); unpush_target (&go32_ops); } @@ -658,6 +663,9 @@ go32_create_inferior (char *exec_file, c inferior_ptid = pid_to_ptid (SOME_PID); push_target (&go32_ops); + + add_thread_silent (inferior_ptid); + clear_proceed_status (); insert_breakpoints (); prog_has_started = 1; @@ -848,6 +856,20 @@ go32_terminal_ours (void) } } +static int +go32_thread_alive (ptid_t ptid) +{ + return 1; +} + +static char * +go32_pid_to_str (ptid_t ptid) +{ + static char buf[64]; + xsnprintf (buf, sizeof buf, "Thread
"); + return buf; +} + static void init_go32_ops (void) { @@ -878,6 +900,8 @@ init_go32_ops (void) go32_ops.to_mourn_inferior = go32_mourn_inferior; go32_ops.to_can_run = go32_can_run; go32_ops.to_stop = go32_stop; + go32_ops.to_thread_alive = go32_thread_alive; + go32_ops.to_pid_to_str = go32_pid_to_str; go32_ops.to_stratum = process_stratum; go32_ops.to_has_all_memory = 1; go32_ops.to_has_memory = 1; --Boundary-00=_omdnIlZRli6ZU3+--