From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5677 invoked by alias); 17 Jun 2002 19:34:13 -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 5604 invoked from network); 17 Jun 2002 19:34:07 -0000 Received: from unknown (HELO mailhub.lss.emc.com) (168.159.1.79) by sources.redhat.com with SMTP; 17 Jun 2002 19:34:07 -0000 Received: from popimap.lss.emc.com (caduseus-ge.lss.emc.com [10.254.140.132]) by mailhub.lss.emc.com (Switch-2.2.0/Switch-2.2.0) with ESMTP id g5HJY3X20114; Mon, 17 Jun 2002 15:34:03 -0400 (EDT) Received: from emc.com (lul1173.lss.emc.com [168.159.33.173]) by popimap.lss.emc.com (Switch-2.2.0/Switch-2.2.0) with ESMTP id g5HJY2S15764; Mon, 17 Jun 2002 15:34:02 -0400 (EDT) Message-ID: <3D0E39E6.5060701@emc.com> Date: Mon, 17 Jun 2002 12:34:00 -0000 From: Josef Ezra User-Agent: Mozilla/5.0 (Windows; U; WinNT4.0; en-US; rv:1.0.0) Gecko/20020530 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Michael Snyder CC: Josef Ezra , gdb-patches@sources.redhat.com Subject: [RFA] new command: 'maintenance info lines' References: <02ea01c1e6eb$65f850c0$ad219fa8@lss.emc.com> <3CBEFC88.37807AEF@redhat.com> <3D08D15E.7030805@emc.com> <3D08DB87.A8119A1D@redhat.com> Content-Type: multipart/mixed; boundary="------------010805080200080608040900" X-SW-Source: 2002-06/txt/msg00307.txt.bz2 This is a multi-part message in MIME format. --------------010805080200080608040900 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 572 Michael Snyder wrote: > > I like it as maybe a maintainer command (or even a user one, if > you think users might gain something from it. > > I don't like the name, though -- "info orientation" doesn't say > anything to me. Maybe "info lines"? Or, as a maintainer command, > "info sal"? > Following the line of 'maintenance info breakpoints / sections / sol-threads' commands, I'd like to suggest 'maintenance info lines' for this line-address dump. - jezra * printcmd.c (maintenance_info_lines): created (_initialize_printcmd): add command --------------010805080200080608040900 Content-Type: text/plain; name="m-i-lines.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="m-i-lines.patch" Content-length: 3185 Index: printcmd.c =================================================================== RCS file: /cvs/src/src/gdb/printcmd.c,v retrieving revision 1.39 diff -u -5 -r1.39 printcmd.c --- printcmd.c 11 May 2002 23:48:23 -0000 1.39 +++ printcmd.c 17 Jun 2002 18:36:58 -0000 @@ -2383,10 +2383,79 @@ return TARGET_PRINT_INSN (memaddr, TARGET_PRINT_INSN_INFO); } +/* + Print range as 'Address:Line' pairs. This command might be usefull + to associate sources and assembly commands. +*/ + +static void +maintenance_info_lines (char *arg, int from_tty) +{ + CORE_ADDR low, high; + { + char *name; + CORE_ADDR pc, pc_masked; + char *space_index; + name = NULL; + if (!arg) + { + if (!selected_frame) + error ("No frame selected.\n"); + + pc = get_frame_pc (selected_frame); + if (find_pc_partial_function (pc, &name, &low, &high) == 0) + error ("No function contains program counter for selected frame.\n"); + + low += FUNCTION_START_OFFSET; + } + else if (!(space_index = (char *) strchr (arg, ' '))) + { + /* One argument. */ + pc = parse_and_eval_address (arg); + if (find_pc_partial_function (pc, &name, &low, &high) == 0) + error ("No function contains specified address.\n"); + low += FUNCTION_START_OFFSET; + } + else + { + /* Two arguments. */ + *space_index = '\0'; + low = parse_and_eval_address (arg); + high = parse_and_eval_address (space_index + 1); + } + } + /* OK, we got the low-high range, what now? */ + { + struct symtab *symtab ; + struct linetable_entry *le ; + int i, nitems ; + symtab = find_pc_symtab (low ) ; + if (symtab && symtab->linetable) + { + + le = symtab->linetable->item ; + nitems = symtab->linetable->nitems ; + + /* skip to low */ + for (i = 0 ; + (i < nitems - 1) && (le[i + 1].pc < low) ; + i++ ) ; + + /* and print all the way to high */ + for (; (i < nitems -1) && (le[i].pc <= high); i++ ) + { + if (le[i].pc != le[i+1].pc ) + /* optimized line ? */ + printf_filtered ("0x%08x:%d\n", (unsigned) le[i].pc, le[i].line ) ; + } + } + } +} + void _initialize_printcmd (void) { struct cmd_list_element *c; @@ -2561,7 +2630,13 @@ examine_b_type = init_type (TYPE_CODE_INT, 1, 0, "examine_b_type", NULL); examine_h_type = init_type (TYPE_CODE_INT, 2, 0, "examine_h_type", NULL); examine_w_type = init_type (TYPE_CODE_INT, 4, 0, "examine_w_type", NULL); examine_g_type = init_type (TYPE_CODE_INT, 8, 0, "examine_g_type", NULL); + add_cmd ( "lines", class_maintenance, maintenance_info_lines, + concat ("Dump a line-address table a specified section of memory.\n\ +Default is the function surrounding the pc of the selected frame.\n\ +With a single argument, the function surrounding that address is dumped.\n\ +Two arguments are taken as a range of memory to dump.", NULL ), + &maintenanceinfolist) ; } --------------010805080200080608040900--