----- Original Message -----
> Hi Dave,
> 
> No functionality change (hopefully). This patch is essentially a clean up
> in preparation to introduce the "-f" option.
> 
> Please let me know your thoughts.

Honestly, I've looked at the patch both in text mode and in a graphical diff, 
and I have
to say, it's really difficult to understand exactly what the patch 
accomplishes.  Things
seem to work as expected AFAICT.

I don't understand why it requires so much churn?  It would seemingly be a 
simple
enough task to capture the -f and starting address, and then simply do a 
disassembly
of the entire function, but only display the output when it arrives at the 
target
address.

Dave

> 
> Signed-off-by: Aaron Tomlin <[email protected]>
> ---
>  kernel.c | 265
>  ++++++++++++++++++++++-----------------------------------------
>  1 file changed, 91 insertions(+), 174 deletions(-)
> 
> diff --git a/kernel.c b/kernel.c
> index 73d1983..3107014 100644
> --- a/kernel.c
> +++ b/kernel.c
> @@ -1589,212 +1589,129 @@ cmd_dis(void)
>                       return;
>               }
>  
> -             do_load_module_filter = module_symbol(req->addr, NULL, NULL,
> -                     NULL, *gdb_output_radix);
> +             req->command = GNU_RESOLVE_TEXT_ADDR;
> +             gdb_interface(req);
> +             req->flags &= ~GNU_COMMAND_FAILED;
> +             if (reverse || req->flags & GNU_FUNCTION_ONLY) {
> +                     if (sp) {
> +                             savename = sp->name;
> +                             if ((sp = next_symbol(NULL, sp)))
> +                                     req->addr2 = sp->value;
> +                             else
> +                                     error(FATAL,
> +                             "unable to determine symbol after %s\n",
> +                                             savename);
> +                     } else {
> +                             if ((sp = value_search(req->addr, NULL))
> +                                  && (sp = next_symbol(NULL, sp)))
> +                                     req->addr2 = sp->value;
> +                             else
> +                                     error(FATAL, dis_err, req->addr);
> +                     }
> +             }
>  
> -             if (!reverse) {
> -                     req->command = GNU_RESOLVE_TEXT_ADDR;
> -                     gdb_interface(req);
> -                        if ((req->flags & GNU_COMMAND_FAILED) ||
> -                         do_load_module_filter ||
> -                         (req->flags & GNU_FUNCTION_ONLY)) {
> -                             req->flags &= ~GNU_COMMAND_FAILED;
> -                             if (sp) {
> -                                     savename = sp->name;
> -                                        if ((sp = next_symbol(NULL, sp)))
> -                                                req->addr2 = sp->value;
> -                                     else
> -                                             error(FATAL,
> -                                     "unable to determine symbol after %s\n",
> -                                                     savename);
> -                             } else {
> -                                     if ((sp = value_search(req->addr, NULL))
> -                                             && (sp = next_symbol(NULL,
> sp)))
> -                                             req->addr2 = sp->value;
> -                                     else
> -                                             error(FATAL, dis_err, 
> req->addr);
> -                             }
> -                        }
> +             if (reverse) {
> +                     revtarget = req->addr;
> +                     if ((sp = value_search(revtarget, NULL)) == NULL)
> +                             error(FATAL, "cannot resolve address: %lx\n", 
> revtarget);
>  
> -                     do_machdep_filter = machdep->dis_filter(req->addr, 
> NULL, radix);
> +                     sprintf(buf1, "0x%lx", revtarget);
> +                     req->addr = sp->value;
> +             } else
>                       count = 0;
> -                     open_tmpfile();
> +             do_load_module_filter = module_symbol(req->addr, NULL, NULL,
> +                     NULL, *gdb_output_radix);
> +
> +             do_machdep_filter = machdep->dis_filter(req->addr, NULL, radix);
> +             open_tmpfile();
>  #ifdef OLDWAY
> -                     req->command = GNU_DISASSEMBLE;
> -                     req->fp = pc->tmpfile;
> -                     gdb_interface(req);
> +             req->command = GNU_DISASSEMBLE;
> +             req->fp = pc->tmpfile;
> +             gdb_interface(req);
>  #else
> -                     sprintf(buf1, "x/%ldi 0x%lx",
> -                                count_entered && req->count ? req->count :
> +             if (reverse)
> +                     sprintf(buf5, "x/%ldi 0x%lx",
> +                             (revtarget - req->addr) ? revtarget - req->addr 
> : 1,
> +                             req->addr);
> +             else
> +                     sprintf(buf5, "x/%ldi 0x%lx",
> +                             count_entered && req->count ? req->count :
>                               req->flags & GNU_FUNCTION_ONLY ?
>                               req->addr2 - req->addr : 1,
>                               req->addr);
> -                     gdb_pass_through(buf1, NULL, GNU_RETURN_ON_ERROR);
> +             gdb_pass_through(buf5, NULL, GNU_RETURN_ON_ERROR);
>  #endif
> -                     if (req->flags & GNU_COMMAND_FAILED) {
> -                             close_tmpfile();
> -                             error(FATAL, dis_err, req->addr);
> -                     }
> +             if (req->flags & GNU_COMMAND_FAILED) {
> +                     close_tmpfile();
> +                     error(FATAL, dis_err, req->addr);
> +             }
>  
> -                     rewind(pc->tmpfile);
> -                     while (fgets(buf2, BUFSIZE, pc->tmpfile)) {
> -                             if (STRNEQ(buf2, "Dump of") ||
> -                                 STRNEQ(buf2, "End of"))
> -                                     continue;
> +             rewind(pc->tmpfile);
> +             while (fgets(buf2, BUFSIZE, pc->tmpfile)) {
> +                     if (STRNEQ(buf2, "Dump of") ||
> +                         STRNEQ(buf2, "End of"))
> +                             continue;
>  
> -                             strip_beginning_whitespace(buf2);
> +                     strip_beginning_whitespace(buf2);
>  
> -                             if (do_load_module_filter)
> -                                     load_module_filter(buf2, LM_DIS_FILTER);
> +                     if (do_load_module_filter)
> +                             load_module_filter(buf2, LM_DIS_FILTER);
>  
> -                             if (STRNEQ(buf2, "0x"))
> -                                     extract_hex(buf2, &curaddr, ':', TRUE);
> +                     if (STRNEQ(buf2, "0x"))
> +                             extract_hex(buf2, &curaddr, ':', TRUE);
>  
> +                     if (!reverse)
>                               if ((req->flags & GNU_FUNCTION_ONLY) &&
>                                   (curaddr >= req->addr2))
>                                       break;
>  
> -                             if (do_machdep_filter)
> -                                     machdep->dis_filter(curaddr, buf2, 
> radix);
> -
> -                             if (req->flags & GNU_FUNCTION_ONLY) {
> -                                        if (req->flags &
> -                                            GNU_PRINT_LINE_NUMBERS) {
> -                                                get_line_number(curaddr,
> buf3,
> -                                                        FALSE);
> -                                                if (!STREQ(buf3, buf4)) {
> -                                                        print_verbatim(
> -                                                            pc->saved_fp,
> buf3);
> -                                                        print_verbatim(
> -                                                            pc->saved_fp,
> "\n");
> -                                                        strcpy(buf4, buf3);
> -                                                }
> -                                        }
> -
> -                                     print_verbatim(pc->saved_fp, buf2);
> -                                     continue;
> -                             } else {
> -                                     if (curaddr < req->addr)
> -                                             continue;
> +                     if (do_machdep_filter)
> +                             machdep->dis_filter(curaddr, buf2, radix);
>  
> -                                     if (req->flags &
> -                                         GNU_PRINT_LINE_NUMBERS) {
> -                                             get_line_number(curaddr, buf3,
> -                                                     FALSE);
> -                                             if (!STREQ(buf3, buf4)) {
> -                                                     print_verbatim(
> -                                                         pc->saved_fp, buf3);
> -                                                     print_verbatim(
> -                                                         pc->saved_fp, "\n");
> -                                                     strcpy(buf4, buf3);
> -                                             }
> -                                     }
> -
> -                                     print_verbatim(pc->saved_fp, buf2);
> -
> -                                     if (LASTCHAR(clean_line(buf2))
> -                                             != ':') {
> -                                             if (++count == req->count)
> -                                                     break;
> -                                     }
> +                     if (req->flags & GNU_PRINT_LINE_NUMBERS) {
> +                             get_line_number(curaddr, buf3,
> +                                     FALSE);
> +                             if (!STREQ(buf3, buf4)) {
> +                                     print_verbatim(
> +                                         pc->saved_fp, buf3);
> +                                     print_verbatim(
> +                                         pc->saved_fp, "\n");
> +                                     strcpy(buf4, buf3);
>                               }
> -                     }
> -                     close_tmpfile();
> -             }
> -        }
> -        else if (bug_bytes_entered)
> -             return;
> -     else cmd_usage(pc->curcmd, SYNOPSIS);
> -
> -     if (!reverse) {
> -             FREEBUF(req->buf);
> -             FREEBUF(req);
> -             return;
> -     }
> -
> -        revtarget = req->addr;
> -        if ((sp = value_search(revtarget, NULL)) == NULL)
> -                error(FATAL, "cannot resolve address: %lx\n", revtarget);
> -
> -        sprintf(buf1, "0x%lx", revtarget);
> -
> -        open_tmpfile();
> -
> -        req->addr = sp->value;
> -        req->flags |= GNU_FUNCTION_ONLY;
> -        req->command = GNU_RESOLVE_TEXT_ADDR;
> -        gdb_interface(req);
> -        req->flags &= ~GNU_COMMAND_FAILED;
> -     savename = sp->name;
> -        if ((sp = next_symbol(NULL, sp)))
> -                req->addr2 = sp->value;
> -        else {
> -             close_tmpfile();
> -                error(FATAL, "unable to determine symbol after %s\n",
> savename);
> -     }
> -
> -     do_machdep_filter = machdep->dis_filter(req->addr, NULL, radix);
> -#ifdef OLDWAY
> -     req->command = GNU_DISASSEMBLE;
> -     req->fp = pc->tmpfile;
> -     gdb_interface(req);
> -#else
> -        sprintf(buf5, "x/%ldi 0x%lx",
> -             (revtarget - req->addr) ? revtarget - req->addr : 1,
> -             req->addr);
> -        gdb_pass_through(buf5, NULL, GNU_RETURN_ON_ERROR);
> -#endif
> -        if (req->flags & GNU_COMMAND_FAILED) {
> -             close_tmpfile();
> -             error(FATAL, dis_err, req->addr);
> -     }
> -
> -        rewind(pc->tmpfile);
> -        while (fgets(buf2, BUFSIZE, pc->tmpfile)) {
> -                if (STRNEQ(buf2, "Dump of") || STRNEQ(buf2, "End of"))
> -                     continue;
> +                     }
>  
> -             strip_beginning_whitespace(buf2);
> +                     print_verbatim(pc->saved_fp, buf2);
> +                     if (reverse) {
> +                             if (STRNEQ(buf2, buf1)) {
> +                                     if (LASTCHAR(clean_line(buf2)) != ':')
> +                                             break;
>  
> -                if (do_load_module_filter)
> -                        load_module_filter(buf2, LM_DIS_FILTER);
> +                                     ret = fgets(buf2, BUFSIZE, pc->tmpfile);
>  
> -                if (STRNEQ(buf2, "0x"))
> -                     extract_hex(buf2, &curaddr, ':', TRUE);
> +                                     if (do_load_module_filter)
> +                                             load_module_filter(buf2, 
> LM_DIS_FILTER);
>  
> -             if (do_machdep_filter)
> -                     machdep->dis_filter(curaddr, buf2, radix);
> +                                     if (do_machdep_filter)
> +                                             machdep->dis_filter(curaddr, 
> buf2, radix);
>  
> -             if (req->flags & GNU_PRINT_LINE_NUMBERS) {
> -                     get_line_number(curaddr, buf3, FALSE);
> -                     if (!STREQ(buf3, buf4)) {
> -                             print_verbatim(pc->saved_fp, buf3);
> -                             print_verbatim(pc->saved_fp, "\n");
> -                             strcpy(buf4, buf3);
> +                                     print_verbatim(pc->saved_fp, buf2);
> +                                     break;
> +                             }
>                       }
> -             }
>  
> -                print_verbatim(pc->saved_fp, buf2);
> -                if (STRNEQ(buf2, buf1)) {
> -                     if (LASTCHAR(clean_line(buf2)) != ':')
> -                             break;
> -
> -                     ret = fgets(buf2, BUFSIZE, pc->tmpfile);
> -
> -                     if (do_load_module_filter)
> -                             load_module_filter(buf2, LM_DIS_FILTER);
> -
> -                     if (do_machdep_filter)
> -                             machdep->dis_filter(curaddr, buf2, radix);
> -
> -                     print_verbatim(pc->saved_fp, buf2);
> -                     break;
> +                     if (count_entered && LASTCHAR(clean_line(buf2)) != ':')
> +                             if (++count == req->count)
> +                                     break;
>               }
> +             close_tmpfile();
>          }
> +        else if (bug_bytes_entered)
> +             return;
> +     else cmd_usage(pc->curcmd, SYNOPSIS);
>  
> -        close_tmpfile();
>       FREEBUF(req->buf);
>       FREEBUF(req);
> +     return;
>  }
>  
>  /*
> --
> 2.4.3
> 
> --
> Crash-utility mailing list
> [email protected]
> https://www.redhat.com/mailman/listinfo/crash-utility
> 

--
Crash-utility mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/crash-utility

Reply via email to