From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 2/2] gdb: Move get_frame_language from stack.c to frame.c.
Date: Fri, 07 Aug 2015 08:57:00 -0000 [thread overview]
Message-ID: <20150807085723.GB30204@embecosm.com> (raw)
In-Reply-To: <55C0E229.7050003@redhat.com>
* Pedro Alves <palves@redhat.com> [2015-08-04 17:02:49 +0100]:
> On 08/04/2015 04:40 PM, Andrew Burgess wrote:
>
> > --- a/gdb/frame.h
> > +++ b/gdb/frame.h
> > @@ -814,4 +814,10 @@ 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. */
> > +
> > +enum language;
>
> No new forward declarations of enums please. That doesn't work in C++.
OK.
New version includes the language.h header file, which showed up a few
places where we were missing forward declarations of structs,
otherwise, no significant changes.
Thanks,
Andrew
--
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 | 12 ++++++++++++
gdb/frame.c | 42 ++++++++++++++++++++++++++++++++++++++++++
gdb/frame.h | 7 +++++++
gdb/language.c | 1 +
gdb/language.h | 2 --
gdb/stack.c | 42 ------------------------------------------
gdb/symtab.h | 2 ++
gdb/top.c | 1 +
8 files changed, 65 insertions(+), 44 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 223d2e5..d510c3d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,17 @@
2015-08-04 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-04 Andrew Burgess <andrew.burgess@embecosm.com>
+
* language.c (show_language_command): Find selected frame before
asking for the language of that frame.
(set_language_command): Likewise.
diff --git a/gdb/frame.c b/gdb/frame.c
index da5bfb9..f05f739 100644
--- a/gdb/frame.c
+++ b/gdb/frame.c
@@ -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
diff --git a/gdb/frame.h b/gdb/frame.h
index be64c57..03f3892 100644
--- a/gdb/frame.h
+++ b/gdb/frame.h
@@ -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) */
diff --git a/gdb/language.c b/gdb/language.c
index 75d4497..715efe5 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -43,6 +43,7 @@
#include "demangle.h"
#include "symfile.h"
#include "cp-support.h"
+#include "frame.h"
extern void _initialize_language (void);
diff --git a/gdb/language.h b/gdb/language.h
index 8782ef0..2265afc 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -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);
diff --git a/gdb/stack.c b/gdb/stack.c
index 31a723d..ae53ec8 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -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. */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 61fc8c5..e90ce00 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -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:
diff --git a/gdb/top.c b/gdb/top.c
index 0130acf..061b52f 100644
--- 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"
--
2.4.0
next prev parent reply other threads:[~2015-08-07 8:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 15:40 [PATCH 0/2] Make get_frame_langauge take a frame argument Andrew Burgess
2015-08-04 15:40 ` [PATCH 1/2] gdb: get_frame_language now takes a frame parameter Andrew Burgess
2015-08-04 16:02 ` Pedro Alves
2015-08-07 8:56 ` Andrew Burgess
2015-08-07 9:45 ` Pedro Alves
2015-08-04 15:40 ` [PATCH 2/2] gdb: Move get_frame_language from stack.c to frame.c Andrew Burgess
2015-08-04 16:02 ` Pedro Alves
2015-08-07 8:57 ` Andrew Burgess [this message]
2015-08-07 9:45 ` Pedro Alves
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=20150807085723.GB30204@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.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