Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Fernando Nasser <fnasser@redhat.com>
To: Josef Ezra <sgdb@subdimension.com>
Cc: Michael Snyder <msnyder@redhat.com>, Josef Ezra <jezra@emc.com>,
	gdb-patches@sources.redhat.com
Subject: Re: [RFA] new command: 'maintenance info lines'
Date: Wed, 25 Sep 2002 13:26:00 -0000	[thread overview]
Message-ID: <3D921C02.9020906@redhat.com> (raw)
In-Reply-To: <3D789AF5.4020406@subdimension.com>

Josef,

The maintenance commands are to be used to debug (or test) GDB only.
We could say you'd be dumping the line table but that is hardly what is being 
done and we don't have a real need for that anyway.

As Andrew told you on June 13, 2002:

http://sources.redhat.com/ml/gdb-patches/2002-06/msg00222.html

We already have a mechanism for obtaining that information in GDB.
The MI interface is what you should be using to obtain data.
And you don't even need to create the mixed source+assembler output as that is 
already done for you.

If you really want to use a CLI command, you need to add a set/show variable to 
request that the source lines are included in the 'disassemble' command output.
The newer disassembler code that handles mixed output is still in the MI 
subdirectory (and in an older form in the gdbtk subdir) but it is intended to 
replace the one in printcmd.c.  It shouldn't be too difficult and you can always 
ask if you have any doubts.

Regards,
Fernando


Josef Ezra wrote:> Michael Snyder wrote:
> 
>> Josef Ezra wrote:
>>
>>> 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.
>>
>>
>>
>> Works for me.
>>
>>
> 
> hi
> 
> It took a while to resolve the legal issues, so I'm re-committing ..
> 
> - jezra
> 
> * printcmd.c (maintenance_info_lines): created
>               (_initialize_printcmd): add command
> 
> * doc/gdb.textinfo: add documentation for 'maint info lines'
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Index: doc/gdb.texinfo
> ===================================================================
> RCS file: /cvs/src/src/gdb/doc/gdb.texinfo,v
> retrieving revision 1.120
> diff -u -3 -r1.120 gdb.texinfo
> --- doc/gdb.texinfo	5 Sep 2002 12:13:08 -0000	1.120
> +++ doc/gdb.texinfo	5 Sep 2002 21:01:23 -0000
> @@ -4362,6 +4362,13 @@
>  can set @var{instruction-set} to either @code{intel} or @code{att}.
>  The default is @code{att}, the AT&T flavor used by default by Unix
>  assemblers for x86-based targets.
> +
> +@kindex maint info lines
> +@item maint info lines
> +This command takes same parameters as @code{disassemble}, but only 
> +dumps an @code{@var{address}:@var{line}} pairs.  Every pair means: ``from this 
> +@var{address} forward, the code was generated by that @var{line}''.  
> +
>  @end table
>  
>  
> Index: printcmd.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/printcmd.c,v
> retrieving revision 1.40
> diff -u -3 -r1.40 printcmd.c
> --- printcmd.c	11 Jul 2002 20:46:19 -0000	1.40
> +++ printcmd.c	5 Sep 2002 21:01:23 -0000
> @@ -2390,6 +2390,75 @@
>  }
>  \f
>  
> +/*
> +  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)
>  {
> @@ -2568,5 +2637,11 @@
>    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) ; 
>  
>  }



-- 
Fernando Nasser
Red Hat - Toronto                       E-Mail:  fnasser@redhat.com
2323 Yonge Street, Suite #300
Toronto, Ontario   M4P 2C9


  parent reply	other threads:[~2002-09-25 20:26 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-18  8:11 should gdb require '.text' and '.data' sections? josef ezra
2002-04-18 11:15 ` Michael Snyder
2002-04-22  6:32   ` Josef Ezra
2002-04-24  6:45   ` [RFA] " Josef Ezra
2002-06-13 10:06   ` Request for new gdb command: 'info orientation' Josef Ezra
2002-06-13 10:35     ` Andrew Cagney
2002-06-13 11:06     ` Michael Snyder
2002-06-13 11:20       ` Josef Ezra
2002-06-17 12:34       ` [RFA] new command: 'maintenance info lines' Josef Ezra
2002-06-17 22:26         ` Eli Zaretskii
2002-06-18 13:47           ` josef ezra
2002-06-18 14:42             ` Michael Snyder
2002-06-18 22:42             ` Eli Zaretskii
2002-06-19  7:27               ` Josef Ezra
2002-06-18 14:35         ` Michael Snyder
2002-09-06  5:08           ` Josef Ezra
2002-09-18 22:33             ` Eli Zaretskii
2002-09-23  8:06               ` Josef Ezra
2002-09-23 22:12                 ` Eli Zaretskii
2002-09-25 13:26             ` Fernando Nasser [this message]
2002-09-26  6:49               ` Josef Ezra
2002-09-26 10:45                 ` Fernando Nasser
2002-09-26 19:03                   ` Andrew Cagney
2002-09-06 13:44           ` Josef Ezra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3D921C02.9020906@redhat.com \
    --to=fnasser@redhat.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=jezra@emc.com \
    --cc=msnyder@redhat.com \
    --cc=sgdb@subdimension.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox