Annotation of gdb/=emacs, revision 1.1

1.1     ! root        1: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        !             2: ;; gdb code changes
        !             3: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
        !             4: /*
        !             5:  * Core Problem:  when gdb says something like (../src/file.c 1234), the
        !             6:  * real file might be in any of the active dirs in use by gdb and thus
        !             7:  * emacs can not always find the file at "../src".  Emacs cannot just
        !             8:  * scan for GDB dir commands because these might be given in the .gdbinit
        !             9:  * file or other scripts.  The only solution is to have gdb be a bit more
        !            10:  * specific when it prints file names.
        !            11:  * 
        !            12:  * Remaining defects:
        !            13:  * 
        !            14:  * 1. Do I really have to open the file to find out if it exists?
        !            15:  *    There should be a faster way.
        !            16:  * 
        !            17:  * 2. Should there be a bdb command to toggle between short and absolute
        !            18:  * forms of the file name?
        !            19:  */
        !            20: 
        !            21: 
        !            22: /* Add this to ~emacs/gdb/source.c after the openp function */
        !            23: 
        !            24: char *
        !            25: get_absolute_filename(table)
        !            26: /* Added by Lynn Slater, Silvar-Lisco 10/6/87
        !            27:    returns the address of the best possible name to use for the file
        !            28:    in the passed symtab.  Returns the filename if the path cannot be
        !            29:    resolved.
        !            30:    Please remember to free the absolute name after use.*/
        !            31: struct symtab *table;
        !            32: {
        !            33:   register int desc;
        !            34:   char *absolute_name;
        !            35: 
        !            36:   desc = openp (source_path, 0, table->filename, O_RDONLY, 0, &absolute_name);
        !            37:   if (desc < 0)
        !            38:     return( savestring(table->filename, strlen(table->filename)));
        !            39: 
        !            40:   close (desc);
        !            41:   return(absolute_name);
        !            42: }
        !            43: 
        !            44: /* Replace this fcn in ~emacs/gdb/stack.c */
        !            45: void
        !            46: print_frame_info (fi, level, source, args)
        !            47:      struct frame_info *fi;
        !            48:      register int level;
        !            49:      int source;
        !            50:      int args;
        !            51: {
        !            52:   register FRAME frame = fi->frame;
        !            53:   struct symtab_and_line sal;
        !            54:   struct symbol *func;
        !            55:   register char *funname = 0;
        !            56:   int numargs;
        !            57: 
        !            58:   sal = find_pc_line (fi->pc, fi->next_frame);
        !            59:   func = get_frame_function (frame);
        !            60:   if (func)
        !            61:     funname = SYMBOL_NAME (func);
        !            62:   else
        !            63:     {
        !            64:       register int misc_index = find_pc_misc_function (fi->pc);
        !            65:       if (misc_index >= 0)
        !            66:        funname = misc_function_vector[misc_index].name;
        !            67:     }
        !            68: 
        !            69:   if (source >= 0 || !sal.symtab)
        !            70:     {
        !            71:       /* This avoids a bug in cc on the sun.  */
        !            72:       struct frame_info tem;
        !            73:       tem = *fi;
        !            74: 
        !            75:       if (level >= 0)
        !            76:        printf ("#%-2d ", level);
        !            77:       if (fi->pc != sal.pc || !sal.symtab)
        !            78:        printf ("0x%x in ", fi->pc);
        !            79:       printf ("%s (", funname ? funname : "??");
        !            80:       if (args)
        !            81:         {
        !            82:          FRAME_NUM_ARGS (numargs, tem);
        !            83:          print_frame_args (func, FRAME_ARGS_ADDRESS (tem), numargs, stdout);
        !            84:        }
        !            85:       printf (")");
        !            86:       if (sal.symtab)
        !            87:         {
        !            88:          char * absolute_filename;
        !            89:          absolute_filename = (char *) get_absolute_filename(sal.symtab);
        !            90:          printf (" (%s line %d)", absolute_filename, sal.line);
        !            91:          free(absolute_filename);
        !            92:        }
        !            93:       printf ("\n");
        !            94:     }
        !            95: 
        !            96:   if (source != 0 && sal.symtab)
        !            97:     {
        !            98:       if (source < 0 && fi->pc != sal.pc)
        !            99:        printf ("0x%x\t", fi->pc);
        !           100:       print_source_lines (sal.symtab, sal.line, sal.line + 1);
        !           101:       current_source_line = max (sal.line - 5, 1);
        !           102:     }
        !           103:   if (source != 0)
        !           104:     set_default_breakpoint (1, fi->pc, sal.symtab, sal.line);
        !           105: 
        !           106:   fflush (stdout);
        !           107: }
        !           108: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.