From patchwork Fri Apr 8 06:58:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 11669 Received: (qmail 56978 invoked by alias); 8 Apr 2016 06:58:50 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 56964 invoked by uid 89); 8 Apr 2016 06:58:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=MAIN, 2016-04-08, registration X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 08 Apr 2016 06:58:48 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D731385A00 for ; Fri, 8 Apr 2016 06:58:46 +0000 (UTC) Received: from host1.jankratochvil.net (ovpn-116-59.ams2.redhat.com [10.36.116.59]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u386whX3009085 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Fri, 8 Apr 2016 02:58:45 -0400 Date: Fri, 8 Apr 2016 08:58:43 +0200 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [testsuite patch] Fix for gcc-4.8: gdb.base/jit.exp gdb.base/jit-so.exp Message-ID: <20160408065843.GA6843@host1.jankratochvil.net> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi Pedro, on CentOS-7.2 I get Running /home/jkratoch/redhat/gdb-test-reg/gdb/testsuite/gdb.base/jit.exp ... FAIL: gdb.base/jit.exp: one_jit_test-1: continue to breakpoint: break here 2 (the program exited) FAIL: gdb.base/jit.exp: one_jit_test-2: continue to breakpoint: break here 2 (the program exited) FAIL: gdb.base/jit.exp: attach: one_jit_test-2: continue to breakpoint: break here 2 (the program exited) FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: set var wait_for_gdb = 1 FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: detach (the program is no longer running) FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: attach FAIL: gdb.base/jit.exp: attach: one_jit_test-2: break here 2: set var wait_for_gdb = 0 FAIL: gdb.base/jit.exp: PIE: one_jit_test-1: continue to breakpoint: break here 2 (the program exited) Running /home/jkratoch/redhat/gdb-test-reg/gdb/testsuite/gdb.base/jit-so.exp ... FAIL: gdb.base/jit-so.exp: one_jit_test-1: continue to breakpoint: break here 2 (the program exited) FAIL: gdb.base/jit-so.exp: one_jit_test-2: continue to breakpoint: break here 2 (the program exited) since: 85af34ee0211eedf8d30a5c44dfc59dddf8b512a is the first bad commit commit 85af34ee0211eedf8d30a5c44dfc59dddf8b512a Author: Pedro Alves Date: Thu Mar 31 19:28:47 2016 +0100 Add regression test for PR gdb/19858 (JIT code registration on attach) The compiled code's .debug_line is wrong (for the simplistic approach of GDB to put a breakpoint on the first address belonging to that source line) and so GDB misses the breakpoint at the last line: WAIT_FOR_GDB; return 0; /* gdb break here 2 */ OK for check-in? Most of the patch is just about reindentation, no changes there. Jan gdb/testsuite/ChangeLog 2016-04-08 Jan Kratochvil Fix compatibility with gcc-4.8.5-4.el7.x86_64. * gdb.base/jit-main.c: Use exit after usage. diff --git a/gdb/testsuite/gdb.base/jit-main.c b/gdb/testsuite/gdb.base/jit-main.c index 63dd1a1..1c7e45e 100644 --- a/gdb/testsuite/gdb.base/jit-main.c +++ b/gdb/testsuite/gdb.base/jit-main.c @@ -138,7 +138,8 @@ MAIN (int argc, char *argv[]) { /* These variables are here so they can easily be set from jit.exp. */ const char *libname = NULL; - int count = 0; + int count = 0, i, fd; + struct stat st; alarm (300); @@ -147,90 +148,89 @@ MAIN (int argc, char *argv[]) count = count; /* gdb break here 0 */ if (argc < 2) - usage (argv[0]); - else { - int i, fd; - struct stat st; + usage (argv[0]); + exit (1); + } - if (libname == NULL) - /* Only set if not already set from GDB. */ - libname = argv[1]; + if (libname == NULL) + /* Only set if not already set from GDB. */ + libname = argv[1]; - if (argc > 2 && count == 0) - /* Only set if not already set from GDB. */ - count = atoi (argv[2]); + if (argc > 2 && count == 0) + /* Only set if not already set from GDB. */ + count = atoi (argv[2]); - printf ("%s:%d: libname = %s, count = %d\n", __FILE__, __LINE__, - libname, count); + printf ("%s:%d: libname = %s, count = %d\n", __FILE__, __LINE__, + libname, count); - if ((fd = open (libname, O_RDONLY)) == -1) - { - fprintf (stderr, "open (\"%s\", O_RDONLY): %s\n", libname, - strerror (errno)); - exit (1); - } + if ((fd = open (libname, O_RDONLY)) == -1) + { + fprintf (stderr, "open (\"%s\", O_RDONLY): %s\n", libname, + strerror (errno)); + exit (1); + } - if (fstat (fd, &st) != 0) - { - fprintf (stderr, "fstat (\"%d\"): %s\n", fd, strerror (errno)); - exit (1); - } + if (fstat (fd, &st) != 0) + { + fprintf (stderr, "fstat (\"%d\"): %s\n", fd, strerror (errno)); + exit (1); + } - for (i = 0; i < count; ++i) - { - const void *const addr = mmap (0, st.st_size, PROT_READ|PROT_WRITE, - MAP_PRIVATE, fd, 0); - struct jit_code_entry *const entry = calloc (1, sizeof (*entry)); - - if (addr == MAP_FAILED) - { - fprintf (stderr, "mmap: %s\n", strerror (errno)); - exit (1); - } - - update_locations (addr, i); - - /* Link entry at the end of the list. */ - entry->symfile_addr = (const char *)addr; - entry->symfile_size = st.st_size; - entry->prev_entry = __jit_debug_descriptor.relevant_entry; - __jit_debug_descriptor.relevant_entry = entry; - - if (entry->prev_entry != NULL) - entry->prev_entry->next_entry = entry; - else - __jit_debug_descriptor.first_entry = entry; - - /* Notify GDB. */ - __jit_debug_descriptor.action_flag = JIT_REGISTER_FN; - __jit_debug_register_code (); - } + for (i = 0; i < count; ++i) + { + const void *const addr = mmap (0, st.st_size, PROT_READ|PROT_WRITE, + MAP_PRIVATE, fd, 0); + struct jit_code_entry *const entry = calloc (1, sizeof (*entry)); + + if (addr == MAP_FAILED) + { + fprintf (stderr, "mmap: %s\n", strerror (errno)); + exit (1); + } + + update_locations (addr, i); + + /* Link entry at the end of the list. */ + entry->symfile_addr = (const char *)addr; + entry->symfile_size = st.st_size; + entry->prev_entry = __jit_debug_descriptor.relevant_entry; + __jit_debug_descriptor.relevant_entry = entry; + + if (entry->prev_entry != NULL) + entry->prev_entry->next_entry = entry; + else + __jit_debug_descriptor.first_entry = entry; + + /* Notify GDB. */ + __jit_debug_descriptor.action_flag = JIT_REGISTER_FN; + __jit_debug_register_code (); + } - WAIT_FOR_GDB; i = 0; /* gdb break here 1 */ + WAIT_FOR_GDB; i = 0; /* gdb break here 1 */ - /* Now unregister them all in reverse order. */ - while (__jit_debug_descriptor.relevant_entry != NULL) - { - struct jit_code_entry *const entry = - __jit_debug_descriptor.relevant_entry; - struct jit_code_entry *const prev_entry = entry->prev_entry; - - if (prev_entry != NULL) - { - prev_entry->next_entry = NULL; - entry->prev_entry = NULL; - } - else - __jit_debug_descriptor.first_entry = NULL; - - /* Notify GDB. */ - __jit_debug_descriptor.action_flag = JIT_UNREGISTER_FN; - __jit_debug_register_code (); - - __jit_debug_descriptor.relevant_entry = prev_entry; - free (entry); - } + /* Now unregister them all in reverse order. */ + while (__jit_debug_descriptor.relevant_entry != NULL) + { + struct jit_code_entry *const entry = + __jit_debug_descriptor.relevant_entry; + struct jit_code_entry *const prev_entry = entry->prev_entry; + + if (prev_entry != NULL) + { + prev_entry->next_entry = NULL; + entry->prev_entry = NULL; + } + else + __jit_debug_descriptor.first_entry = NULL; + + /* Notify GDB. */ + __jit_debug_descriptor.action_flag = JIT_UNREGISTER_FN; + __jit_debug_register_code (); + + __jit_debug_descriptor.relevant_entry = prev_entry; + free (entry); } + WAIT_FOR_GDB; return 0; /* gdb break here 2 */ }