From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12222 invoked by alias); 1 Nov 2005 14:11:03 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 12194 invoked by uid 22791); 1 Nov 2005 14:11:01 -0000 Received: from c-24-61-23-223.hsd1.ma.comcast.net (HELO cgf.cx) (24.61.23.223) by sourceware.org (qpsmtpd/0.30-dev) with ESMTP; Tue, 01 Nov 2005 14:11:01 +0000 Received: by cgf.cx (Postfix, from userid 201) id 9FF1313C762; Tue, 1 Nov 2005 09:10:59 -0500 (EST) Date: Tue, 01 Nov 2005 14:11:00 -0000 From: Christopher Faylor To: gdb-patches@sourceware.org Subject: [commit] cygwin shared library cleanup, round 3 Message-ID: <20051101141059.GC3098@trixie.casa.cgf.cx> Mail-Followup-To: gdb-patches@sourceware.org References: <20051101050845.GA15136@trixie.casa.cgf.cx> <20051101052817.GA15599@nevyn.them.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051101052817.GA15599@nevyn.them.org> User-Agent: Mutt/1.5.8i X-SW-Source: 2005-11/txt/msg00008.txt.bz2 Random fixes, the most thrilling of which is the addition of solib_add in a couple of places to properly catch dll load and unload. Hopefully this will be fixed "the right way" by the implementation of solib breakpoints sometime soon, unless I run out of steam. I also added the beginnings of cygwin signal handling (not to be confused with the anemic Windows signal handling). cgf 2005-11-01 Christopher Faylor * win32-nat.c (CYGWIN_SIGNAL_STRING): Delete. (_CYGWIN_SIGNAL_STRING): Define if not already defined in cygwin.h. (win32_add_thread): Use XZALLOC rather than xmalloc/memset. (register_loaded_dll): Ditto. (handle_load_dll): Call solib_add here. (handle_unload_dll): Ditto. (info_dll_command): Delete. (handle_output_debug_string): Use official _CYGWIN_SIGNAL_STRING. (win32_current_sos): Duplicate table to pass off to caller rather than deleting our version. (set_win32_aliases): New function. (_initialize_win32_nat): Remove local handling of "info shared". Set deprecated_init_ui_hook to allow late setting of "info dll" alias. Index: win32-nat.c =================================================================== RCS file: /cvs/uberbaum/gdb/win32-nat.c,v retrieving revision 1.115 diff -u -p -r1.115 win32-nat.c --- win32-nat.c 1 Nov 2005 05:08:28 -0000 1.115 +++ win32-nat.c 1 Nov 2005 14:06:28 -0000 @@ -84,7 +84,9 @@ static int debug_registers_used; /* The string sent by cygwin when it processes a signal. FIXME: This should be in a cygwin include file. */ -#define CYGWIN_SIGNAL_STRING "cygwin: signal" +#ifndef _CYGWIN_SIGNAL_STRING +#define _CYGWIN_SIGNAL_STRING "cYgSiGw00f" +#endif #define CHECK(x) check (x, __FILE__,__LINE__) #define DEBUG_EXEC(x) if (debug_exec) printf_unfiltered x @@ -263,8 +265,7 @@ win32_add_thread (DWORD id, HANDLE h) if ((th = thread_rec (id, FALSE))) return th; - th = (thread_info *) xmalloc (sizeof (*th)); - memset (th, 0, sizeof (*th)); + th = XZALLOC (thread_info); th->id = id; th->h = h; th->next = thread_head.next; @@ -722,8 +723,7 @@ register_loaded_dll (const char *name, D GetSystemDirectory (buf, sizeof (buf)); strcat (buf, "\\ntdll.dll"); } - so = (struct so_list *) xmalloc (sizeof (struct so_list)); - memset (so, 0, sizeof (*so)); + so = XZALLOC (struct so_list); so->lm_info = (struct lm_info *) xmalloc (sizeof (struct lm_info)); so->lm_info->load_addr = load_addr; cygwin_conv_to_posix_path (buf, so->so_name); @@ -803,6 +803,7 @@ handle_load_dll (void *dummy) return 1; register_loaded_dll (dll_name, (DWORD) event->lpBaseOfDll + 0x1000, auto_solib_add); + solib_add (NULL, 0, NULL, auto_solib_add); return 1; } @@ -843,8 +844,10 @@ handle_unload_dll (void *dummy) if (!so->next) solib_end = so; free_so (sodel); + solib_add (NULL, 0, NULL, auto_solib_add); return 1; } + error (_("Error: dll starting at 0x%lx not found."), (DWORD) lpBaseOfDll); return 0; @@ -887,22 +890,6 @@ dll_symbol_command (char *args, int from safe_symbol_file_add (args, from_tty, NULL, 0, OBJF_SHARED | OBJF_USERLOADED); } -/* List currently loaded DLLs. */ -static void -info_dll_command (char *ignore, int from_tty) -{ - struct so_list *so = &solib_start; - - if (!so->next) - return; - - printf_filtered ("%*s Load Address\n", -max_dll_name_len, "DLL Name"); - while ((so = so->next) != NULL) - printf_filtered ("%*s %08lx\n", -max_dll_name_len, so->so_name, so->lm_info->load_addr); - - return; -} - /* Handle DEBUG_STRING output from child process. Cygwin prepends its messages with a "cygwin:". Interpret this as a Cygwin signal. Otherwise just print the string as a warning. */ @@ -917,7 +904,7 @@ handle_output_debug_string (struct targe || !s || !*s) return gotasig; - if (strncmp (s, CYGWIN_SIGNAL_STRING, sizeof (CYGWIN_SIGNAL_STRING) - 1) != 0) + if (strncmp (s, _CYGWIN_SIGNAL_STRING, sizeof (_CYGWIN_SIGNAL_STRING) - 1) != 0) { if (strncmp (s, "cYg", 3) != 0) warning (("%s"), s); @@ -925,7 +912,7 @@ handle_output_debug_string (struct targe else { char *p; - int sig = strtol (s + sizeof (CYGWIN_SIGNAL_STRING) - 1, &p, 0); + int sig = strtol (s + sizeof (_CYGWIN_SIGNAL_STRING) - 1, &p, 0); gotasig = target_signal_from_host (sig); ourstatus->value.sig = gotasig; if (gotasig) @@ -2237,16 +2224,32 @@ out: static struct so_list * win32_current_sos (void) { - struct so_list *head = solib_start.next; - win32_clear_solib (); - if (!head && core_bfd) + struct so_list *sop; + struct so_list *start = NULL; + struct so_list *last; + + if (!solib_start.next && core_bfd) { + win32_clear_solib (); bfd_map_over_sections (core_bfd, &core_section_load_dll_symbols, &win32_ops); - head = solib_start.next; - win32_clear_solib (); } - return head; + + for (sop = solib_start.next; sop; sop = sop->next) + { + struct so_list *new = XZALLOC (struct so_list); + strcpy (new->so_name, sop->so_name); + strcpy (new->so_original_name, sop->so_original_name); + if (!start) + last = start = new; + else + { + last->next = new; + last = new; + } + } + + return start; } static void @@ -2319,6 +2322,12 @@ init_win32_ops (void) current_target_so_ops = &win32_so_ops; } +static void +set_win32_aliases (char *argv0) +{ + add_info_alias ("dll", "sharedlibrary", 1); +} + void _initialize_win32_nat (void) { @@ -2382,9 +2391,6 @@ Show whether to display kernel exception NULL, /* FIXME: i18n: */ &setlist, &showlist); - add_info ("dll", info_dll_command, _("Status of loaded DLLs.")); - add_info_alias ("sharedlibrary", "dll", 1); - add_prefix_cmd ("w32", class_info, info_w32_command, _("Print information specific to Win32 debugging."), &info_w32_cmdlist, "info w32 ", 0, &infolist); @@ -2393,6 +2399,7 @@ Show whether to display kernel exception _("Display selectors infos."), &info_w32_cmdlist); add_target (&win32_ops); + deprecated_init_ui_hook = set_win32_aliases; } /* Hardware watchpoint support, adapted from go32-nat.c code. */