Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Hui Zhu <hui_zhu@mentor.com>
To: Tom Tromey <tromey@redhat.com>
Cc: gdb-patches ml <gdb-patches@sourceware.org>
Subject: Re: [PATCH] Make "backtrace" doesn't print python stack if init python dir get fail
Date: Tue, 03 Dec 2013 07:30:00 -0000	[thread overview]
Message-ID: <529D8865.80503@mentor.com> (raw)
In-Reply-To: <8761r7w85h.fsf@fleche.redhat.com>

On 12/03/13 00:05, Tom Tromey wrote:
>>>>>> "Hui" == Hui Zhu <hui_zhu@mentor.com> writes:
>
> Hui> So if init python dir get fail, "backtrace" will print python
> Hui> stack.  But GDB already output error when it start.  I make a patch
> Hui> let it doesn't print python stack if init python dir get fail.
>
> Perhaps instead the setting of gdb_python_initialized should be moved to
> finish_python_initialization.
>
> Tom
>

Hi Tom,

I make a new patch according to your comments.
It setup gdb_python_initialized in finish_python_initialization.

I got a issue is ensure_python_env check gdb_python_initialized and throw error if it is 0.
So gdb_python_initialized to 0 will make some commands throw error when python dir has something error.
I removed this check in the patch.

This patch pass the regression test in x86_64 linux.

Please help me review it.

Thanks,
Hui

2013-12-03  Hui Zhu  <hui@codesourcery.com>

	* python/python.c (ensure_python_env): Remove check for
	"gdb_python_initialized".
	(_initialize_python): Remove setup of "gdb_python_initialized".
	(finish_python_initialization): Add setup of
	"gdb_python_initialized".

--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -150,10 +150,6 @@ ensure_python_env (struct gdbarch *gdbar
  {
    struct python_env *env = xmalloc (sizeof *env);
  
-  /* We should not ever enter Python unless initialized.  */
-  if (!gdb_python_initialized)
-    error (_("Python not initialized"));
-
    env->state = PyGILState_Ensure ();
    env->gdbarch = python_gdbarch;
    env->language = python_language;
@@ -1717,7 +1713,6 @@ message == an error message without a st
  
    make_final_cleanup (finalize_python, NULL);
  
-  gdb_python_initialized = 1;
    return;
  
   fail:
@@ -1807,6 +1802,9 @@ finish_python_initialization (void)
       variable.  */
  
    do_cleanups (cleanup);
+
+  gdb_python_initialized = 1;
+
    return;
  
   fail:


  reply	other threads:[~2013-12-03  7:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-28 17:35 Hui Zhu
2013-12-02 16:05 ` Tom Tromey
2013-12-03  7:30   ` Hui Zhu [this message]
2013-12-03 20:27     ` Tom Tromey
2013-12-04  7:41       ` Hui Zhu
2013-12-11 17:07         ` Tom Tromey
2013-12-13 11:49           ` Hui Zhu
2014-01-14 16:09             ` Tom Tromey
2014-01-14 17:41               ` Tom Tromey
2014-01-14 21:32                 ` Phil Muldoon
2014-01-15 20:06                   ` Tom Tromey

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=529D8865.80503@mentor.com \
    --to=hui_zhu@mentor.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@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