From 33bc82476eb92308590d03407cb1597eca8b0079 Mon Sep 17 00:00:00 2001 From: Egor Duda Date: Thu, 30 Aug 2001 16:47:51 +0000 Subject: * dumper.h: Update copyright notice. * dumper.cc: Ditto. * dumper.cc: (dumper::print_core_section_list): New function. * dumper.h: (dumper::print_core_section_list): Declare it. * dumper.cc (print_section_name): New function. (dumper::collect_process_information): Augment debugging output. Stop debugee processing if it posts double exception. (usage): Fix typo in option name. --- winsup/utils/dumper.cc | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'winsup/utils/dumper.cc') diff --git a/winsup/utils/dumper.cc b/winsup/utils/dumper.cc index 9f8257b98..dfa0a7df5 100644 --- a/winsup/utils/dumper.cc +++ b/winsup/utils/dumper.cc @@ -1,6 +1,6 @@ /* dumper.cc - Copyright 1999 Cygnus Solutions. + Copyright 1999,2001 Red Hat Inc. Written by Egor Duda @@ -114,6 +114,20 @@ dumper::sane () return 1; } +void +print_section_name (bfd* abfd, asection* sect, PTR obj) +{ + deb_printf ( " %s", bfd_get_section_name (abfd, sect)); +} + +void +dumper::print_core_section_list () +{ + deb_printf ("current sections:"); + bfd_map_over_sections (core_bfd, &print_section_name, NULL); + deb_printf ("\n"); +} + process_entity * dumper::add_process_entity_to_list (process_entity_type type) { @@ -476,6 +490,8 @@ out: int dumper::collect_process_information () { + int exception_level = 0; + if (!sane ()) return 0; @@ -496,6 +512,8 @@ dumper::collect_process_information () if (!WaitForDebugEvent (¤t_event, 20000)) return 0; + deb_printf ("got debug event %d\n", current_event.dwDebugEventCode); + switch (current_event.dwDebugEventCode) { case CREATE_THREAD_DEBUG_EVENT: @@ -535,6 +553,12 @@ dumper::collect_process_information () case EXCEPTION_DEBUG_EVENT: + exception_level++; + if (exception_level == 2) + break; + else if (exception_level > 2) + return 0; + collect_memory_sections (); /* got all info. time to dump */ @@ -670,14 +694,22 @@ dumper::prepare_core_dump () deb_printf ("creating section (type%u) %s(%u), flags=%08x\n", p->type, sect_name, sect_size, sect_flags); + bfd_set_error (bfd_error_no_error); char *buf = strdup (sect_name); new_section = bfd_make_section (core_bfd, buf); + if (new_section == NULL) + { + if (bfd_get_error () == bfd_error_no_error) + fprintf (stderr, "error creating new section (%s), section already exists.\n", buf); + else + bfd_perror ("creating section"); + goto failed; + } - if (new_section == NULL || - !bfd_set_section_flags (core_bfd, new_section, sect_flags) || + if (!bfd_set_section_flags (core_bfd, new_section, sect_flags) || !bfd_set_section_size (core_bfd, new_section, sect_size)) { - bfd_perror ("creating section"); + bfd_perror ("setting section attributes"); goto failed; }; @@ -736,7 +768,7 @@ dumper::write_core_dump () static void usage () { - fprintf (stderr, "Usage: dumper [-v] [-c filename] pid\n"); + fprintf (stderr, "Usage: dumper [-d] [-c filename] pid\n"); fprintf (stderr, "-c filename -- dump core to filename.core\n"); fprintf (stderr, "-d -- print some debugging info while dumping\n"); fprintf (stderr, "pid -- win32-pid of process to dump\n"); -- cgit v1.2.3