]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Move get_frame_language from stack.c to frame.c.
authorAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 4 Aug 2015 14:42:03 +0000 (15:42 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 7 Aug 2015 09:55:20 +0000 (11:55 +0200)
The get_frame_language feels like it would be more at home in frame.c
rather than in stack.c, while the declaration, that is currently in
language.h can be moved into frame.h to match.

A couple of new includes are added, but otherwise no substantial change
here.

gdb/ChangeLog:

* stack.c (get_frame_language): Moved ...
* frame.c (get_frame_language): ... to here.
* language.h (get_frame_language): Declaration moved to frame.h.
* frame.h: Add language.h include, for language enum.
(get_frame_language): Declaration moved from language.h.
* language.c: Add frame.h include.
* top.c: Add frame.h include.
* symtab.h (struct obj_section): Declare.
(struct cmd_list_element): Declare.

gdb/ChangeLog
gdb/frame.c
gdb/frame.h
gdb/language.c
gdb/language.h
gdb/stack.c
gdb/symtab.h
gdb/top.c

index 14f363880bcf709e0708a76fd71f71823fc0a40e..ce42136bafa0f15e7ceafcb722bc1e75487b0845 100644 (file)
@@ -1,3 +1,15 @@
+2015-08-07  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * stack.c (get_frame_language): Moved ...
+       * frame.c (get_frame_language): ... to here.
+       * language.h (get_frame_language): Declaration moved to frame.h.
+       * frame.h: Add language.h include, for language enum.
+       (get_frame_language): Declaration moved from language.h.
+       * language.c: Add frame.h include.
+       * top.c: Add frame.h include.
+       * symtab.h (struct obj_section): Declare.
+       (struct cmd_list_element): Declare.
+
 2015-08-07  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * language.c (show_language_command): Find selected frame before
index da5bfb9ee486ce3b409cc694fee1b4e6d2c74a4e..f05f739676684d89609afd69815d539ce0f32025 100644 (file)
@@ -2571,6 +2571,48 @@ frame_unwind_caller_arch (struct frame_info *next_frame)
   return frame_unwind_arch (skip_artificial_frames (next_frame));
 }
 
+/* Gets the language of FRAME.  */
+
+enum language
+get_frame_language (struct frame_info *frame)
+{
+  CORE_ADDR pc = 0;
+  int pc_p = 0;
+
+  gdb_assert (frame!= NULL);
+
+    /* We determine the current frame language by looking up its
+       associated symtab.  To retrieve this symtab, we use the frame
+       PC.  However we cannot use the frame PC as is, because it
+       usually points to the instruction following the "call", which
+       is sometimes the first instruction of another function.  So
+       we rely on get_frame_address_in_block(), it provides us with
+       a PC that is guaranteed to be inside the frame's code
+       block.  */
+
+  TRY
+    {
+      pc = get_frame_address_in_block (frame);
+      pc_p = 1;
+    }
+  CATCH (ex, RETURN_MASK_ERROR)
+    {
+      if (ex.error != NOT_AVAILABLE_ERROR)
+       throw_exception (ex);
+    }
+  END_CATCH
+
+  if (pc_p)
+    {
+      struct compunit_symtab *cust = find_pc_compunit_symtab (pc);
+
+      if (cust != NULL)
+       return compunit_language (cust);
+    }
+
+  return language_unknown;
+}
+
 /* Stack pointer methods.  */
 
 CORE_ADDR
index be64c57ac8833488c28f56198b8650281ebad818..03f38925db583faa89eac70f525c8d5604cceebd 100644 (file)
@@ -69,6 +69,8 @@
 
    */
 
+#include "language.h"
+
 struct symtab_and_line;
 struct frame_unwind;
 struct frame_base;
@@ -814,4 +816,9 @@ extern struct frame_info *create_new_frame (CORE_ADDR base, CORE_ADDR pc);
 extern int frame_unwinder_is (struct frame_info *fi,
                              const struct frame_unwind *unwinder);
 
+/* Return the language of FRAME.  */
+
+extern enum language get_frame_language (struct frame_info *frame);
+
+
 #endif /* !defined (FRAME_H)  */
index ab767c3aaab1f1cdb65df6743e30b727ef5f0323..4937b7d0c8e4633bd7b50c0333e8f61ec235cf58 100644 (file)
@@ -43,6 +43,7 @@
 #include "demangle.h"
 #include "symfile.h"
 #include "cp-support.h"
+#include "frame.h"
 
 extern void _initialize_language (void);
 
index 8782ef0d4ef21116bb26da3a5615c217da61e164..2265afcbfc20fae5c93b6db3266564356828b3a4 100644 (file)
@@ -544,8 +544,6 @@ extern const char *language_str (enum language);
 
 extern void add_language (const struct language_defn *);
 
-extern enum language get_frame_language (struct frame_info *frame);    /* In stack.c */
-
 /* Check for a language-specific trampoline.  */
 
 extern CORE_ADDR skip_language_trampoline (struct frame_info *, CORE_ADDR pc);
index 31a723d71c053801d129fad5b3ce4c76290eb834..ae53ec8b3f3c6aa46fd84ece3591d53fdeff0b30 100644 (file)
@@ -2559,48 +2559,6 @@ func_command (char *arg, int from_tty)
   else if (frame != get_selected_frame (NULL))
     select_and_print_frame (frame);
 }
-
-/* Gets the language of FRAME.  */
-
-enum language
-get_frame_language (struct frame_info *frame)
-{
-  CORE_ADDR pc = 0;
-  int pc_p = 0;
-
-  gdb_assert (frame!= NULL);
-
-    /* We determine the current frame language by looking up its
-       associated symtab.  To retrieve this symtab, we use the frame
-       PC.  However we cannot use the frame PC as is, because it
-       usually points to the instruction following the "call", which
-       is sometimes the first instruction of another function.  So
-       we rely on get_frame_address_in_block(), it provides us with
-       a PC that is guaranteed to be inside the frame's code
-       block.  */
-
-  TRY
-    {
-      pc = get_frame_address_in_block (frame);
-      pc_p = 1;
-    }
-  CATCH (ex, RETURN_MASK_ERROR)
-    {
-      if (ex.error != NOT_AVAILABLE_ERROR)
-       throw_exception (ex);
-    }
-  END_CATCH
-
-  if (pc_p)
-    {
-      struct compunit_symtab *cust = find_pc_compunit_symtab (pc);
-
-      if (cust != NULL)
-       return compunit_language (cust);
-    }
-
-  return language_unknown;
-}
 \f
 
 /* Provide a prototype to silence -Wmissing-prototypes.  */
index 61fc8c5c79dc21a6dd2fe9c0b66ec477d27902bb..e90ce004283e61b453ba67d9fbee8ba1fa085c62 100644 (file)
@@ -38,6 +38,8 @@ struct program_space;
 struct language_defn;
 struct probe;
 struct common_block;
+struct obj_section;
+struct cmd_list_element;
 
 /* Some of the structures in this file are space critical.
    The space-critical structures are:
index 0130acfedaa88c4e33a8682e24bfb82bdaaebbdc..061b52fbaafcefa0e98014e82e72a5c586d8e0d0 100644 (file)
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -49,6 +49,7 @@
 #include "observer.h"
 #include "maint.h"
 #include "filenames.h"
+#include "frame.h"
 
 /* readline include files.  */
 #include "readline/readline.h"