Segfaults if $^P
authorIlya Zakharevich <ilya@math.berkeley.edu>
Tue, 13 Jul 1999 05:44:28 +0000 (01:44 -0400)
committerGurusamy Sarathy <gsar@cpan.org>
Sat, 17 Jul 1999 20:21:01 +0000 (20:21 +0000)
Message-Id: <199907130944.FAA04473@monk.mps.ohio-state.edu>

p4raw-id: //depot/perl@3683

embed.h
embed.pl
global.sym
mg.c
objXSUB.h
perl.c
perlapi.c
proto.h

diff --git a/embed.h b/embed.h
index 7789679fa75b258c6f42df874705d7c77ef90c43..c90f50dced3584a83e4c9c481d433ed46d3ca86d 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define ibcmp                  Perl_ibcmp
 #define ibcmp_locale           Perl_ibcmp_locale
 #define ingroup                        Perl_ingroup
+#define init_debugger          Perl_init_debugger
 #define init_stacks            Perl_init_stacks
 #define intro_my               Perl_intro_my
 #define instr                  Perl_instr
 #define incpush                        S_incpush
 #define init_interp            S_init_interp
 #define init_ids               S_init_ids
-#define init_debugger          S_init_debugger
 #define init_lexer             S_init_lexer
 #define init_main_stash                S_init_main_stash
 #define init_perllib           S_init_perllib
 #define ibcmp(a,b,c)           Perl_ibcmp(aTHX_ a,b,c)
 #define ibcmp_locale(a,b,c)    Perl_ibcmp_locale(aTHX_ a,b,c)
 #define ingroup(a,b)           Perl_ingroup(aTHX_ a,b)
+#define init_debugger()                Perl_init_debugger(aTHX)
 #define init_stacks()          Perl_init_stacks(aTHX)
 #define intro_my()             Perl_intro_my(aTHX)
 #define instr(a,b)             Perl_instr(aTHX_ a,b)
 #define incpush(a,b)           S_incpush(aTHX_ a,b)
 #define init_interp()          S_init_interp(aTHX)
 #define init_ids()             S_init_ids(aTHX)
-#define init_debugger()                S_init_debugger(aTHX)
 #define init_lexer()           S_init_lexer(aTHX)
 #define init_main_stash()      S_init_main_stash(aTHX)
 #define init_perllib()         S_init_perllib(aTHX)
 #define ibcmp_locale           Perl_ibcmp_locale
 #define Perl_ingroup           CPerlObj::Perl_ingroup
 #define ingroup                        Perl_ingroup
+#define Perl_init_debugger     CPerlObj::Perl_init_debugger
+#define init_debugger          Perl_init_debugger
 #define Perl_init_stacks       CPerlObj::Perl_init_stacks
 #define init_stacks            Perl_init_stacks
 #define Perl_intro_my          CPerlObj::Perl_intro_my
 #define init_interp            S_init_interp
 #define S_init_ids             CPerlObj::S_init_ids
 #define init_ids               S_init_ids
-#define S_init_debugger                CPerlObj::S_init_debugger
-#define init_debugger          S_init_debugger
 #define S_init_lexer           CPerlObj::S_init_lexer
 #define init_lexer             S_init_lexer
 #define S_init_main_stash      CPerlObj::S_init_main_stash
index 1af25adc21f17e5810120ad4f83011148de72a2f..cbd22946334ed0299fde60f7f5a267f5f48d1edb 100755 (executable)
--- a/embed.pl
+++ b/embed.pl
@@ -1192,6 +1192,7 @@ p |void   |hv_undef       |HV* tb
 p      |I32    |ibcmp          |const char* a|const char* b|I32 len
 p      |I32    |ibcmp_locale   |const char* a|const char* b|I32 len
 p      |I32    |ingroup        |I32 testgid|I32 effective
+p      |void   |init_debugger
 p      |void   |init_stacks
 p      |U32    |intro_my
 p      |char*  |instr          |const char* big|const char* little
@@ -1820,7 +1821,6 @@ s |void   |forbid_setid   |char *
 s      |void   |incpush        |char *|int
 s      |void   |init_interp
 s      |void   |init_ids
-s      |void   |init_debugger
 s      |void   |init_lexer
 s      |void   |init_main_stash
 s      |void   |init_perllib
index 8a3e7256ae3c83379f170114ea0a6fd165cd8a19..fba03069d88a7d1ab415cc191ad326de7e430a70 100644 (file)
@@ -179,6 +179,7 @@ Perl_hv_undef
 Perl_ibcmp
 Perl_ibcmp_locale
 Perl_ingroup
+Perl_init_debugger
 Perl_init_stacks
 Perl_intro_my
 Perl_instr
diff --git a/mg.c b/mg.c
index 2b6459f785d76c9dca96d8c742cfdea33af8a08e..695272dc9f04644bb75c141e931f661313413056 100644 (file)
--- a/mg.c
+++ b/mg.c
@@ -1676,6 +1676,8 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
        break;
     case '\020':       /* ^P */
        PL_perldb = SvIOK(sv) ? SvIVX(sv) : sv_2iv(sv);
+       if (PL_perldb && !PL_DBsingle)
+           init_debugger();
        break;
     case '\024':       /* ^T */
 #ifdef BIG_TIME
index 97284820892d2a4a7c3b584e9ad2a0fdfb0b79fc..8134c177a58c61b2c5e2b20f82f56be864f02bd3 100644 (file)
--- a/objXSUB.h
+++ b/objXSUB.h
 #define Perl_ingroup           pPerl->Perl_ingroup
 #undef  ingroup
 #define ingroup                        Perl_ingroup
+#undef  Perl_init_debugger
+#define Perl_init_debugger     pPerl->Perl_init_debugger
+#undef  init_debugger
+#define init_debugger          Perl_init_debugger
 #undef  Perl_init_stacks
 #define Perl_init_stacks       pPerl->Perl_init_stacks
 #undef  init_stacks
diff --git a/perl.c b/perl.c
index 8db7c217647426edbbc10742a689cce06c57b6f7..23aec9705ed403d6f08dbd4577b71f33cb22039d 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -2478,23 +2478,26 @@ S_forbid_setid(pTHX_ char *s)
         Perl_croak(aTHX_ "No %s allowed while running setgid", s);
 }
 
-STATIC void
-S_init_debugger(pTHX)
+void
+Perl_init_debugger(pTHX)
 {
     dTHR;
+    HV *ostash = PL_curstash;
+
     PL_curstash = PL_debstash;
     PL_dbargs = GvAV(gv_AVadd((gv_fetchpv("args", GV_ADDMULTI, SVt_PVAV))));
     AvREAL_off(PL_dbargs);
     PL_DBgv = gv_fetchpv("DB", GV_ADDMULTI, SVt_PVGV);
     PL_DBline = gv_fetchpv("dbline", GV_ADDMULTI, SVt_PVAV);
     PL_DBsub = gv_HVadd(gv_fetchpv("sub", GV_ADDMULTI, SVt_PVHV));
+    sv_upgrade(GvSV(PL_DBsub), SVt_IV);        /* IVX accessed if PERLDB_SUB_NN */
     PL_DBsingle = GvSV((gv_fetchpv("single", GV_ADDMULTI, SVt_PV)));
     sv_setiv(PL_DBsingle, 0); 
     PL_DBtrace = GvSV((gv_fetchpv("trace", GV_ADDMULTI, SVt_PV)));
     sv_setiv(PL_DBtrace, 0); 
     PL_DBsignal = GvSV((gv_fetchpv("signal", GV_ADDMULTI, SVt_PV)));
     sv_setiv(PL_DBsignal, 0); 
-    PL_curstash = PL_defstash;
+    PL_curstash = ostash;
 }
 
 #ifndef STRESS_REALLOC
index 037ad3d77a97ba49ca25929ee7138eebf5a7af70..fb078f3ce958be38ee96d1542b015ee5d4496075 100755 (executable)
--- a/perlapi.c
+++ b/perlapi.c
@@ -1349,6 +1349,13 @@ Perl_ingroup(pTHXo_ I32 testgid, I32 effective)
     return ((CPerlObj*)pPerl)->Perl_ingroup(testgid, effective);
 }
 
+#undef  Perl_init_debugger
+void
+Perl_init_debugger(pTHXo)
+{
+    ((CPerlObj*)pPerl)->Perl_init_debugger();
+}
+
 #undef  Perl_init_stacks
 void
 Perl_init_stacks(pTHXo)
diff --git a/proto.h b/proto.h
index e4a9db8b934ffbd85cbdb0a6f68e05eedc8ebd94..ed2fdb14f59612fcafa5d4dc233b030bed9ef701 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -198,6 +198,7 @@ VIRTUAL void        Perl_hv_undef(pTHX_ HV* tb);
 VIRTUAL I32    Perl_ibcmp(pTHX_ const char* a, const char* b, I32 len);
 VIRTUAL I32    Perl_ibcmp_locale(pTHX_ const char* a, const char* b, I32 len);
 VIRTUAL I32    Perl_ingroup(pTHX_ I32 testgid, I32 effective);
+VIRTUAL void   Perl_init_debugger(pTHX);
 VIRTUAL void   Perl_init_stacks(pTHX);
 VIRTUAL U32    Perl_intro_my(pTHX);
 VIRTUAL char*  Perl_instr(pTHX_ const char* big, const char* little);
@@ -791,7 +792,6 @@ STATIC void S_forbid_setid(pTHX_ char *);
 STATIC void    S_incpush(pTHX_ char *, int);
 STATIC void    S_init_interp(pTHX);
 STATIC void    S_init_ids(pTHX);
-STATIC void    S_init_debugger(pTHX);
 STATIC void    S_init_lexer(pTHX);
 STATIC void    S_init_main_stash(pTHX);
 STATIC void    S_init_perllib(pTHX);