gdb/
[external/binutils.git] / gdb / breakpoint.c
index 216ac73..026ce73 100644 (file)
@@ -5694,7 +5694,7 @@ print_breakpoint_location (struct breakpoint *b,
 
   if (b->display_canonical)
     ui_out_field_string (uiout, "what", b->addr_string);
-  else if (loc && loc->source_file)
+  else if (loc && loc->symtab)
     {
       struct symbol *sym 
        = find_pc_sect_function (loc->address, loc->section);
@@ -5707,16 +5707,13 @@ print_breakpoint_location (struct breakpoint *b,
          ui_out_wrap_hint (uiout, wrap_indent_at_field (uiout, "what"));
          ui_out_text (uiout, "at ");
        }
-      ui_out_field_string (uiout, "file", loc->source_file);
+      ui_out_field_string (uiout, "file",
+                          symtab_to_filename_for_display (loc->symtab));
       ui_out_text (uiout, ":");
-      
+
       if (ui_out_is_mi_like_p (uiout))
-       {
-         struct symtab_and_line sal = find_pc_line (loc->address, 0);
-         const char *fullname = symtab_to_fullname (sal.symtab);
-         
-         ui_out_field_string (uiout, "fullname", fullname);
-       }
+       ui_out_field_string (uiout, "fullname",
+                            symtab_to_fullname (loc->symtab));
       
       ui_out_field_int (uiout, "line", loc->line_number);
     }
@@ -8756,11 +8753,8 @@ momentary_breakpoint_from_master (struct breakpoint *orig,
   copy->loc->section = orig->loc->section;
   copy->loc->pspace = orig->loc->pspace;
   copy->loc->probe = orig->loc->probe;
-
-  if (orig->loc->source_file != NULL)
-    copy->loc->source_file = xstrdup (orig->loc->source_file);
-
   copy->loc->line_number = orig->loc->line_number;
+  copy->loc->symtab = orig->loc->symtab;
   copy->frame_id = orig->frame_id;
   copy->thread = orig->thread;
   copy->pspace = orig->pspace;
@@ -8845,10 +8839,8 @@ add_location_to_breakpoint (struct breakpoint *b,
   gdb_assert (loc->pspace != NULL);
   loc->section = sal->section;
   loc->gdbarch = loc_gdbarch;
-
-  if (sal->symtab != NULL)
-    loc->source_file = xstrdup (sal->symtab->filename);
   loc->line_number = sal->line;
+  loc->symtab = sal->symtab;
 
   set_breakpoint_location_function (loc,
                                    sal->explicit_pc || sal->explicit_line);
@@ -9779,7 +9771,7 @@ resolve_sal_pc (struct symtab_and_line *sal)
     {
       if (!find_line_pc (sal->symtab, sal->line, &pc))
        error (_("No line %d in file \"%s\"."),
-              sal->line, sal->symtab->filename);
+              sal->line, symtab_to_filename_for_display (sal->symtab));
       sal->pc = pc;
 
       /* If this SAL corresponds to a breakpoint inserted using a line
@@ -11950,7 +11942,7 @@ clear_command (char *arg, int from_tty)
   make_cleanup (VEC_cleanup (breakpoint_p), &found);
   for (i = 0; i < sals.nelts; i++)
     {
-      int is_abs;
+      const char *sal_fullname;
 
       /* If exact pc given, clear bpts at that pc.
          If line given (pc == 0), clear all bpts on specified line.
@@ -11965,7 +11957,8 @@ clear_command (char *arg, int from_tty)
          1              0             <can't happen> */
 
       sal = sals.sals[i];
-      is_abs = sal.symtab == NULL ? 1 : IS_ABSOLUTE_PATH (sal.symtab->filename);
+      sal_fullname = (sal.symtab == NULL
+                     ? NULL : symtab_to_fullname (sal.symtab));
 
       /* Find all matching breakpoints and add them to 'found'.  */
       ALL_BREAKPOINTS (b)
@@ -11988,19 +11981,13 @@ clear_command (char *arg, int from_tty)
                  int line_match = 0;
 
                  if ((default_match || sal.explicit_line)
-                     && loc->source_file != NULL
-                     && sal.symtab != NULL
+                     && loc->symtab != NULL
+                     && sal_fullname != NULL
                      && sal.pspace == loc->pspace
-                     && loc->line_number == sal.line)
-                   {
-                     if (filename_cmp (loc->source_file,
-                                       sal.symtab->filename) == 0)
-                       line_match = 1;
-                     else if (!IS_ABSOLUTE_PATH (sal.symtab->filename)
-                              && compare_filenames_for_search (loc->source_file,
-                                                               sal.symtab->filename))
-                       line_match = 1;
-                   }
+                     && loc->line_number == sal.line
+                     && filename_cmp (symtab_to_fullname (loc->symtab),
+                                      sal_fullname) == 0)
+                   line_match = 1;
 
                  if (pc_match || line_match)
                    {
@@ -12730,19 +12717,20 @@ say_where (struct breakpoint *b)
     }
   else
     {
-      if (opts.addressprint || b->loc->source_file == NULL)
+      if (opts.addressprint || b->loc->symtab == NULL)
        {
          printf_filtered (" at ");
          fputs_filtered (paddress (b->loc->gdbarch, b->loc->address),
                          gdb_stdout);
        }
-      if (b->loc->source_file)
+      if (b->loc->symtab != NULL)
        {
          /* If there is a single location, we can print the location
             more nicely.  */
          if (b->loc->next == NULL)
            printf_filtered (": file %s, line %d.",
-                            b->loc->source_file, b->loc->line_number);
+                            symtab_to_filename_for_display (b->loc->symtab),
+                            b->loc->line_number);
          else
            /* This is not ideal, but each location may have a
               different file name, and this at least reflects the
@@ -12770,7 +12758,6 @@ bp_location_dtor (struct bp_location *self)
   if (self->cond_bytecode)
     free_agent_expr (self->cond_bytecode);
   xfree (self->function_name);
-  xfree (self->source_file);
 }
 
 static const struct bp_location_ops bp_location_ops =
@@ -13942,7 +13929,8 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
                                   SYMBOL_PRINT_NAME (sym));
              ui_out_text (uiout, " at ");
            }
-         ui_out_field_string (uiout, "file", sal2.symtab->filename);
+         ui_out_field_string (uiout, "file",
+                              symtab_to_filename_for_display (sal2.symtab));
          ui_out_text (uiout, ":");
 
          if (ui_out_is_mi_like_p (uiout))
@@ -13956,16 +13944,11 @@ update_static_tracepoint (struct breakpoint *b, struct symtab_and_line sal)
          ui_out_text (uiout, "\n");
 
          b->loc->line_number = sal2.line;
-
-         xfree (b->loc->source_file);
-         if (sym)
-           b->loc->source_file = xstrdup (sal2.symtab->filename);
-         else
-           b->loc->source_file = NULL;
+         b->loc->symtab = sym != NULL ? sal2.symtab : NULL;
 
          xfree (b->addr_string);
          b->addr_string = xstrprintf ("%s:%d",
-                                      sal2.symtab->filename,
+                                  symtab_to_filename_for_display (sal2.symtab),
                                       b->loc->line_number);
 
          /* Might be nice to check if function changed, and warn if
@@ -15798,6 +15781,18 @@ pc_at_non_inline_function (struct address_space *aspace, CORE_ADDR pc,
   return 0;
 }
 
+/* Remove any references to OBJFILE which is going to be freed.  */
+
+void
+breakpoint_free_objfile (struct objfile *objfile)
+{
+  struct bp_location **locp, *loc;
+
+  ALL_BP_LOCATIONS (loc, locp)
+    if (loc->symtab != NULL && loc->symtab->objfile == objfile)
+      loc->symtab = NULL;
+}
+
 void
 initialize_breakpoint_ops (void)
 {