From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by sourceware.org (Postfix) with ESMTPS id 89328385841A for ; Thu, 10 Feb 2022 13:53:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 89328385841A X-IronPort-AV: E=McAfee;i="6200,9189,10253"; a="310231224" X-IronPort-AV: E=Sophos;i="5.88,358,1635231600"; d="scan'208";a="310231224" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 05:53:07 -0800 X-IronPort-AV: E=Sophos;i="5.88,358,1635231600"; d="scan'208";a="633670793" Received: from sugan-001.iul.intel.com (HELO localhost) ([172.28.48.31]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Feb 2022 05:53:06 -0800 From: Ari Hannula To: gdb-patches@sourceware.org Cc: "ravitheja.addepally" , Ari Hannula Subject: [PATCH 2/5] [func_call] New tests for a btrace crash. Date: Thu, 10 Feb 2022 14:52:40 +0100 Message-Id: <20220210135243.3127629-3-ari.hannula@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220210135243.3127629-1-ari.hannula@intel.com> References: <20220210135243.3127629-1-ari.hannula@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Feb 2022 13:53:10 -0000 From: "ravitheja.addepally" During remote debugging when stoppin in the start-routine of a pthread, GDB crashes when attempting to display function-call-history. gdb/testsuite/ChangeLog: 2015-04-27 ravitheja.addepally * gdb.btrace/server-multithreaded-function-call-history.c: New file. * gdb.btrace/server-multithreaded-function-call-history.exp: New file. Signed-off-by: ravitheja.addepally Signed-off-by: Ari Hannula --- ...rver-multithreaded-function-call-history.c | 70 +++++++++++++++++++ ...er-multithreaded-function-call-history.exp | 61 ++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 gdb/testsuite/gdb.btrace/server-multithreaded-function-call-history.c create mode 100644 gdb/testsuite/gdb.btrace/server-multithreaded-function-call-history.exp diff --git a/gdb/testsuite/gdb.btrace/server-multithreaded-function-call-history.c b/gdb/testsuite/gdb.btrace/server-multithreaded-function-call-history.c new file mode 100644 index 0000000000..4dbe4c1fe8 --- /dev/null +++ b/gdb/testsuite/gdb.btrace/server-multithreaded-function-call-history.c @@ -0,0 +1,70 @@ +/* Manythreads test program. + Copyright 2004-2022 Free Software Foundation, Inc. + + This file is part of GDB. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + + Copied from gdb.threads/manythreads.c */ + +#include +#ifdef DEBUG +#include +#endif +#include + +void * +thread_function (void *arg) +{ + int x = * (int *) arg; + +#ifdef DEBUG + printf ("Thread <%d> executing\n", x); +#endif /* DEBUG */ + + return NULL; +} + +int +main (int argc, char **argv) +{ + pthread_attr_t attr; + pthread_t threads[256]; + int args[256]; + int i, j; + + pthread_attr_init (&attr); + +#ifdef PTHREAD_STACK_MIN + pthread_attr_setstacksize (&attr, 2*PTHREAD_STACK_MIN); +#endif + + /* Create a ton of quick-executing threads, then wait for them to + complete. */ + for (i = 0; i < 1000; ++i) + { + for (j = 0; j < 256; ++j) + { + args[j] = i * 1000 + j; + pthread_create (&threads[j], &attr, thread_function, &args[j]); + } + + for (j = 0; j < 256; ++j) + pthread_join (threads[j], NULL); + } + + pthread_attr_destroy (&attr); + + return 0; +} diff --git a/gdb/testsuite/gdb.btrace/server-multithreaded-function-call-history.exp b/gdb/testsuite/gdb.btrace/server-multithreaded-function-call-history.exp new file mode 100644 index 0000000000..3af51c4228 --- /dev/null +++ b/gdb/testsuite/gdb.btrace/server-multithreaded-function-call-history.exp @@ -0,0 +1,61 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2005-2022 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +load_lib gdbserver-support.exp + +standard_testfile + +if { [skip_gdbserver_tests] } { + return 0 +} + +if { [skip_btrace_tests] } { + return -1 +} + +set opts { debug } +if [info exists DEBUG] { + lappend opts "additional_flags=-DDEBUG" +} + +if {[gdb_compile_pthreads "${srcdir}/${subdir}/${srcfile}" "${binfile}" executable $opts] != "" } { + return -1 +} + +gdb_exit +gdb_start +gdb_load $binfile + +# Make sure we're disconnected, in case we're testing with an +# extended-remote board, therefore already connected. +gdb_test "disconnect" ".*" + +gdbserver_run "" +gdb_reinitialize_dir $srcdir/$subdir + +gdb_breakpoint main +gdb_test "continue" "Breakpoint.* main .*" "continue to main" + +gdb_test_no_output "record btrace" + +gdb_breakpoint thread_function +gdb_test "continue" "Breakpoint.* thread_function .*" "continue to thread_function one" + +# test passes if this does not crash +gdb_test "record function-call-history" ".*" + +gdb_test "continue" "Breakpoint.* thread_function .*" "continue to thread_function two" -- 2.25.1 Intel Deutschland GmbH Registered Address: Am Campeon 10, 85579 Neubiberg, Germany Tel: +49 89 99 8853-0, www.intel.de Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva Chairperson of the Supervisory Board: Nicole Lau Registered Office: Munich Commercial Register: Amtsgericht Muenchen HRB 186928