Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: [commit/Ada] delete ada-lang.c:extract_string and use 	target_read_string instead
Date: Thu, 16 Apr 2009 17:19:00 -0000	[thread overview]
Message-ID: <20090416171914.GM7557@adacore.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

Just a minor cleanup of ada-lang.c to remove a function that
duplicates another function implemented elsewhere.

2009-04-16  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-lang.c (extract_string): Delete.
        (ada_main_name): Reimplement using target_read_string instead of
        extract_string.

This is exercised everytime we do a "start", which looks for the name
of the main routine.

Tested on x86_64-linux, no regression. Checked in.

-- 
Joel

[-- Attachment #2: string.diff --]
[-- Type: text/x-diff, Size: 1357 bytes --]

commit 04d8d0167590b9132f9a0f1e4c06476dbe892bb2
Author: Joel Brobecker <brobecker@adacore.com>
Date:   Wed Apr 8 14:55:02 2009 -0700

        * ada-lang.c (extract_string): Delete.
        (ada_main_name): Reimplement using target_read_string instead of
        extract_string.

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 54f2590..814a793 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -679,8 +679,7 @@ char *
 ada_main_name (void)
 {
   struct minimal_symbol *msym;
-  CORE_ADDR main_program_name_addr;
-  static char main_program_name[1024];
+  static char *main_program_name = NULL;
 
   /* For Ada, the name of the main procedure is stored in a specific
      string constant, generated by the binder.  Look for that symbol,
@@ -691,11 +690,19 @@ ada_main_name (void)
 
   if (msym != NULL)
     {
+      CORE_ADDR main_program_name_addr;
+      int err_code;
+
       main_program_name_addr = SYMBOL_VALUE_ADDRESS (msym);
       if (main_program_name_addr == 0)
         error (_("Invalid address for Ada main program name."));
 
-      extract_string (main_program_name_addr, main_program_name);
+      xfree (main_program_name);
+      target_read_string (main_program_name_addr, &main_program_name,
+                          1024, &err_code);
+
+      if (err_code != 0)
+        return NULL;
       return main_program_name;
     }
 

             reply	other threads:[~2009-04-16 17:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-16 17:19 Joel Brobecker [this message]
2009-04-16 22:19 ` Tom Tromey
2009-04-16 22:45   ` Joel Brobecker
2009-04-16 22:49     ` Tom Tromey
2009-04-16 23:32       ` Joel Brobecker

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=20090416171914.GM7557@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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