From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32167 invoked by alias); 8 Mar 2004 18:23:49 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 32136 invoked from network); 8 Mar 2004 18:23:47 -0000 Received: from unknown (HELO rwcrmhc12.comcast.net) (216.148.227.85) by sources.redhat.com with SMTP; 8 Mar 2004 18:23:47 -0000 Received: from new.localdomain (h00e098094f32.ne.client2.attbi.com[24.60.234.83]) by comcast.net (rwcrmhc12) with ESMTP id <20040308182345014007049fe> (Authid: houston.jim); Mon, 8 Mar 2004 18:23:45 +0000 Date: Fri, 19 Mar 2004 00:09:00 -0000 Message-ID: From: Jim Houston To: gdb-patches@sources.redhat.com Subject: [patch] thread info - automatic skip frames Reply-to: jim.houston@comcast.net X-SW-Source: 2004-03/txt/msg00169.txt.bz2 Message-ID: <20040319000900.dBC4jLd_iUpg_Ko6C0UyK3ugpWoCItKAivJGYIAPfgY@z> Hi Everyone, I developed this patch to support using kgdb on the x86-64 linux kernel. The patch adds an option to gdb to skip over boring frames in the "thread info" results. This is useful when most of the threads are stopped in the context switch code. It lets you see the frame which shows why the the thread blocked. Use: set skip-frame thread_return,schedule_timeout Jim Houston - Concurrent Computer Corp. -- --- old/gdb-6.0/gdb/thread.c 2004-01-06 12:34:14.786496352 -0500 +++ new/gdb-6.0/gdb/thread.c 2004-01-06 12:34:28.804365312 -0500 @@ -404,6 +404,43 @@ } } +/* + * When using gdb as a kernel debugger, its really boring to + * see every thread is blocked in schedule. By setting a + * list of functions with "set skip-frame schedule,thread_return" + * we can display the frame that called into the scheduler. + */ +static char *skip_frame_string; + +int +skip_frame(struct frame_info *fi) +{ + struct minimal_symbol *msym; + CORE_ADDR pc; + char *name; + char *s, *r; + int n; + + pc = get_frame_pc (fi); + msym = lookup_minimal_symbol_by_pc_section(pc, NULL); + if (!msym) + return 0; + name = SYMBOL_LINKAGE_NAME(msym); + + for (s = skip_frame_string; s && *s ; ) { + if ((r = strchr(s, ','))) + n = r - s - 1; + else + n = strlen(s); + if (n && strncmp(s, name, n) == 0) + return 1; + if (!r) + break; + s = r + 1; + } + return 0; +} + /* Print information about currently known threads * Note: this has the drawback that it _really_ switches @@ -416,7 +453,7 @@ { struct thread_info *tp; ptid_t current_ptid; - struct frame_info *cur_frame; + struct frame_info *cur_frame, *fi; int saved_frame_level = frame_relative_level (get_selected_frame ()); int counter; char *extra_info; @@ -448,6 +485,18 @@ puts_filtered (" "); switch_to_thread (tp->ptid); + + if (skip_frame_string) { + /* skip up the stack to an interesting frame. */ + fi = get_selected_frame (); + while (fi) { + if (!skip_frame(fi)) + break; + fi = get_prev_frame(fi); + if (fi) + select_frame(fi); + } + } print_stack_frame (get_selected_frame (), -1, 0); } @@ -740,4 +789,12 @@ if (!xdb_commands) add_com_alias ("t", "thread", class_run, 1); + + add_show_from_set (add_set_cmd ("skip-frame", class_obscure, + var_string_noescape, (char *)&skip_frame_string, "\ +Set list of functions to skip when choosing the frame to display\n\ +for a info-thread command. When gdb is used for kernel debug this option\n\ +allows the frame which calls the scheduler to be displayed rather than\n\ +having all blocked threads showing the same function in the scheduler.", + &setlist), &showlist); }