FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 06-30-2010, 11:26 AM
Martin Sivak
 
Default Add better debugging capabilities to loader

- when development ('devel' argument) mode is requested, init enables
core dumping and starts shell in the case of unexpected exit
---
loader/init.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-----
loader/loader.c | 7 -------
2 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/loader/init.c b/loader/init.c
index 175f1d7..820d3ef 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -44,6 +44,7 @@
#include <sys/stat.h>
#include <sys/swap.h>
#include <sys/time.h>
+#include <sys/resource.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
@@ -516,9 +517,11 @@ int main(int argc, char **argv) {
int doShutdown =0;
reboot_action shutdown_method = HALT;
int isSerial = 0;
+ int isDebugMode = 0;
char * console = NULL;
int doKill = 1;
char * argvc[15];
+ char buf[1024];
char ** argvp = argvc;
char twelve = 12;
struct serial_struct si;
@@ -563,6 +566,25 @@ int main(int argc, char **argv) {
fatal_error(1);
printf("done
");

+ /* unless the user specifies that they want utf8 */
+ int fdn;
+ if ((fdn = open("/proc/cmdline", O_RDONLY, 0)) != -1) {
+ int len = read(fdn, buf, sizeof(buf) - 1);
+ close(fdn);
+ if (len > 0 && strstr(buf, "devel")) {
+ printf("Enabling development mode - cores will be dumped
");
+ isDebugMode = 1;
+ }
+ }
+
+ /* these args are only for testing from commandline */
+ for (i = 1; i < argc; i++) {
+ if (!strcmp (argv[i], "serial")) {
+ isSerial = 1;
+ break;
+ }
+ }
+
printf("creating /dev filesystem... ");
fflush(stdout);
if (mount("/dev", "/dev", "tmpfs", 0, NULL))
@@ -618,14 +640,17 @@ int main(int argc, char **argv) {
fatal_error(1);
printf("done
");

- /* these args are only for testing from commandline */
- for (i = 1; i < argc; i++) {
- if (!strcmp (argv[i], "serial")) {
- isSerial = 1;
- break;
+ if (isDebugMode) {
+ /* if anaconda dies suddenly we are doomed, so at least make a coredump */
+ struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
+ int ret = setrlimit(RLIMIT_CORE, &corelimit);
+ if (ret) {
+ perror("setrlimit failed - no coredumps will be available");
}
}

+
+
doKill = getKillPolicy();

#if !defined(__s390__) && !defined(__s390x__)
@@ -872,6 +897,25 @@ int main(int argc, char **argv) {
printf("-- received signal %d", WTERMSIG(waitStatus));
}
printf("
");
+
+ /* If debug mode was requested, spawn shell */
+ if(isDebugMode) {
+ pid_t shellpid;
+
+ printf("Development mode requested spawning shell...
");
+
+ if ((shellpid = fork()) == 0) {
+ execl("/sbin/bash", "/sbin/bash", NULL);
+ }
+ else if (shellpid > 0) {
+ waitpid(shellpid, NULL, 0);
+ }
+ else {
+ perror("Execution of debug shell failed.");
+ }
+
+ }
+
} else {
shutdown_method = REBOOT;
}
diff --git a/loader/loader.c b/loader/loader.c
index 46f6f5e..8287311 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -2385,13 +2385,6 @@ int main(int argc, char ** argv) {
stopNewt();
closeLog();

- /* if anaconda dies suddenly we are doomed, so at least make a coredump */
- struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
- ret = setrlimit(RLIMIT_CORE, &corelimit);
- if (ret) {
- perror("setrlimit failed");
- }
-
if (FL_RESCUE(flags)) {
fmt = _("Running anaconda %s, the %s rescue mode - please wait.
");
} else {
--
1.6.6.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 06-30-2010, 11:57 AM
Steffen Maier
 
Default Add better debugging capabilities to loader

If loader no more dumps but init.c only, s390x won't get anaconda dumps,
since it's got its own init aka linuxrc.s390 which is a shell script and
I don't know from the top of my head if the C code for dumping could be
scripted there as well. That would be a pity from s390x point of view.

In general dumping in init vs. loader seems like a good idea.

On 06/30/2010 01:26 PM, Martin Sivak wrote:
> - when development ('devel' argument) mode is requested, init enables
> core dumping and starts shell in the case of unexpected exit
> ---
> loader/init.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-----
> loader/loader.c | 7 -------
> 2 files changed, 49 insertions(+), 12 deletions(-)
>
> diff --git a/loader/init.c b/loader/init.c
> index 175f1d7..820d3ef 100644
> --- a/loader/init.c
> +++ b/loader/init.c
> @@ -44,6 +44,7 @@
> #include <sys/stat.h>
> #include <sys/swap.h>
> #include <sys/time.h>
> +#include <sys/resource.h>
> #include <sys/types.h>
> #include <sys/un.h>
> #include <sys/wait.h>
> @@ -516,9 +517,11 @@ int main(int argc, char **argv) {
> int doShutdown =0;
> reboot_action shutdown_method = HALT;
> int isSerial = 0;
> + int isDebugMode = 0;
> char * console = NULL;
> int doKill = 1;
> char * argvc[15];
> + char buf[1024];
> char ** argvp = argvc;
> char twelve = 12;
> struct serial_struct si;
> @@ -563,6 +566,25 @@ int main(int argc, char **argv) {
> fatal_error(1);
> printf("done
");
>
> + /* unless the user specifies that they want utf8 */
> + int fdn;
> + if ((fdn = open("/proc/cmdline", O_RDONLY, 0)) != -1) {
> + int len = read(fdn, buf, sizeof(buf) - 1);
> + close(fdn);
> + if (len > 0 && strstr(buf, "devel")) {
> + printf("Enabling development mode - cores will be dumped
");
> + isDebugMode = 1;
> + }
> + }
> +
> + /* these args are only for testing from commandline */
> + for (i = 1; i < argc; i++) {
> + if (!strcmp (argv[i], "serial")) {
> + isSerial = 1;
> + break;
> + }
> + }
> +
> printf("creating /dev filesystem... ");
> fflush(stdout);
> if (mount("/dev", "/dev", "tmpfs", 0, NULL))
> @@ -618,14 +640,17 @@ int main(int argc, char **argv) {
> fatal_error(1);
> printf("done
");
>
> - /* these args are only for testing from commandline */
> - for (i = 1; i < argc; i++) {
> - if (!strcmp (argv[i], "serial")) {
> - isSerial = 1;
> - break;
> + if (isDebugMode) {
> + /* if anaconda dies suddenly we are doomed, so at least make a coredump */
> + struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
> + int ret = setrlimit(RLIMIT_CORE, &corelimit);
> + if (ret) {
> + perror("setrlimit failed - no coredumps will be available");
> }
> }
>
> +
> +
> doKill = getKillPolicy();
>
> #if !defined(__s390__) && !defined(__s390x__)
> @@ -872,6 +897,25 @@ int main(int argc, char **argv) {
> printf("-- received signal %d", WTERMSIG(waitStatus));
> }
> printf("
");
> +
> + /* If debug mode was requested, spawn shell */
> + if(isDebugMode) {
> + pid_t shellpid;
> +
> + printf("Development mode requested spawning shell...
");
> +
> + if ((shellpid = fork()) == 0) {
> + execl("/sbin/bash", "/sbin/bash", NULL);
> + }
> + else if (shellpid > 0) {
> + waitpid(shellpid, NULL, 0);
> + }
> + else {
> + perror("Execution of debug shell failed.");
> + }
> +
> + }
> +
> } else {
> shutdown_method = REBOOT;
> }
> diff --git a/loader/loader.c b/loader/loader.c
> index 46f6f5e..8287311 100644
> --- a/loader/loader.c
> +++ b/loader/loader.c
> @@ -2385,13 +2385,6 @@ int main(int argc, char ** argv) {
> stopNewt();
> closeLog();
>
> - /* if anaconda dies suddenly we are doomed, so at least make a coredump */
> - struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
> - ret = setrlimit(RLIMIT_CORE, &corelimit);
> - if (ret) {
> - perror("setrlimit failed");
> - }
> -
> if (FL_RESCUE(flags)) {
> fmt = _("Running anaconda %s, the %s rescue mode - please wait.
");
> } else {

Steffen

Linux on System z Development

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 06-30-2010, 12:38 PM
Martin Sivak
 
Default Add better debugging capabilities to loader

Without the devel argument, the behaviour won't change. Modifications to init were mostly to start the shell afterwards so we can collect the coredump. This shouldn't be hard to include to linuxrc.s390 as well.

--
Martin Sivák
msivak@redhat.com
Red Hat Czech
Anaconda team / Brno, CZ

----- "Steffen Maier" <maier@linux.vnet.ibm.com> wrote:

> If loader no more dumps but init.c only, s390x won't get anaconda
> dumps,
> since it's got its own init aka linuxrc.s390 which is a shell script
> and
> I don't know from the top of my head if the C code for dumping could
> be
> scripted there as well. That would be a pity from s390x point of
> view.
>
> In general dumping in init vs. loader seems like a good idea.
>
> On 06/30/2010 01:26 PM, Martin Sivak wrote:
> > - when development ('devel' argument) mode is requested, init
> enables
> > core dumping and starts shell in the case of unexpected exit
> > ---
> > loader/init.c | 54
> +++++++++++++++++++++++++++++++++++++++++++++++++-----
> > loader/loader.c | 7 -------
> > 2 files changed, 49 insertions(+), 12 deletions(-)
> >
> > diff --git a/loader/init.c b/loader/init.c
> > index 175f1d7..820d3ef 100644
> > --- a/loader/init.c
> > +++ b/loader/init.c
> > @@ -44,6 +44,7 @@
> > #include <sys/stat.h>
> > #include <sys/swap.h>
> > #include <sys/time.h>
> > +#include <sys/resource.h>
> > #include <sys/types.h>
> > #include <sys/un.h>
> > #include <sys/wait.h>
> > @@ -516,9 +517,11 @@ int main(int argc, char **argv) {
> > int doShutdown =0;
> > reboot_action shutdown_method = HALT;
> > int isSerial = 0;
> > + int isDebugMode = 0;
> > char * console = NULL;
> > int doKill = 1;
> > char * argvc[15];
> > + char buf[1024];
> > char ** argvp = argvc;
> > char twelve = 12;
> > struct serial_struct si;
> > @@ -563,6 +566,25 @@ int main(int argc, char **argv) {
> > fatal_error(1);
> > printf("done
");
> >
> > + /* unless the user specifies that they want utf8 */
> > + int fdn;
> > + if ((fdn = open("/proc/cmdline", O_RDONLY, 0)) != -1) {
> > + int len = read(fdn, buf, sizeof(buf) - 1);
> > + close(fdn);
> > + if (len > 0 && strstr(buf, "devel")) {
> > + printf("Enabling development mode - cores will be
> dumped
");
> > + isDebugMode = 1;
> > + }
> > + }
> > +
> > + /* these args are only for testing from commandline */
> > + for (i = 1; i < argc; i++) {
> > + if (!strcmp (argv[i], "serial")) {
> > + isSerial = 1;
> > + break;
> > + }
> > + }
> > +
> > printf("creating /dev filesystem... ");
> > fflush(stdout);
> > if (mount("/dev", "/dev", "tmpfs", 0, NULL))
> > @@ -618,14 +640,17 @@ int main(int argc, char **argv) {
> > fatal_error(1);
> > printf("done
");
> >
> > - /* these args are only for testing from commandline */
> > - for (i = 1; i < argc; i++) {
> > - if (!strcmp (argv[i], "serial")) {
> > - isSerial = 1;
> > - break;
> > + if (isDebugMode) {
> > + /* if anaconda dies suddenly we are doomed, so at least
> make a coredump */
> > + struct rlimit corelimit = { RLIM_INFINITY,
> RLIM_INFINITY};
> > + int ret = setrlimit(RLIMIT_CORE, &corelimit);
> > + if (ret) {
> > + perror("setrlimit failed - no coredumps will be
> available");
> > }
> > }
> >
> > +
> > +
> > doKill = getKillPolicy();
> >
> > #if !defined(__s390__) && !defined(__s390x__)
> > @@ -872,6 +897,25 @@ int main(int argc, char **argv) {
> > printf("-- received signal %d", WTERMSIG(waitStatus));
> > }
> > printf("
");
> > +
> > + /* If debug mode was requested, spawn shell */
> > + if(isDebugMode) {
> > + pid_t shellpid;
> > +
> > + printf("Development mode requested spawning
> shell...
");
> > +
> > + if ((shellpid = fork()) == 0) {
> > + execl("/sbin/bash", "/sbin/bash", NULL);
> > + }
> > + else if (shellpid > 0) {
> > + waitpid(shellpid, NULL, 0);
> > + }
> > + else {
> > + perror("Execution of debug shell failed.");
> > + }
> > +
> > + }
> > +
> > } else {
> > shutdown_method = REBOOT;
> > }
> > diff --git a/loader/loader.c b/loader/loader.c
> > index 46f6f5e..8287311 100644
> > --- a/loader/loader.c
> > +++ b/loader/loader.c
> > @@ -2385,13 +2385,6 @@ int main(int argc, char ** argv) {
> > stopNewt();
> > closeLog();
> >
> > - /* if anaconda dies suddenly we are doomed, so at least make a
> coredump */
> > - struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
> > - ret = setrlimit(RLIMIT_CORE, &corelimit);
> > - if (ret) {
> > - perror("setrlimit failed");
> > - }
> > -
> > if (FL_RESCUE(flags)) {
> > fmt = _("Running anaconda %s, the %s rescue mode - please
> wait.
");
> > } else {
>
> Steffen
>
> Linux on System z Development
>
> IBM Deutschland Research & Development GmbH
> Vorsitzender des Aufsichtsrats: Martin Jetter
> Geschäftsführung: Dirk Wittkopp
> Sitz der Gesellschaft: Böblingen
> Registergericht: Amtsgericht Stuttgart, HRB 243294
>
>
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@redhat.com
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 06-30-2010, 12:53 PM
Ales Kozumplik
 
Default Add better debugging capabilities to loader

On 06/30/2010 01:26 PM, Martin Sivak wrote:

- when development ('devel' argument) mode is requested, init enables
core dumping and starts shell in the case of unexpected exit
---
loader/init.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-----
loader/loader.c | 7 -------
2 files changed, 49 insertions(+), 12 deletions(-)



Hi,

I applaud to this initiative. No ack yet though:

This:

+ if (isDebugMode) {
+ /* if anaconda dies suddenly we are doomed, so at least make a coredump */
+ struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
+ int ret = setrlimit(RLIMIT_CORE,&corelimit);
+ if (ret) {
+ perror("setrlimit failed - no coredumps will be available");


Together with this:

- /* if anaconda dies suddenly we are doomed, so at least make a coredump */
- struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
- ret = setrlimit(RLIMIT_CORE,&corelimit);
- if (ret) {
- perror("setrlimit failed");
- }
-


Means core won't be dumped if the anaconda process is killed suddenly
for an obscure reason, which was exactly why I introduced this. In other
words: the next time we see strange irregular crashes we want to get the
core file straight away and not ask the QAs to try again with a special
cmdline parameter.


Also, since you are setting the core limit in init.c now, please also
test that sending ABRT to anaconda still results in the core dump.


Ales

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 06-30-2010, 01:21 PM
David Cantrell
 
Default Add better debugging capabilities to loader

Comments below.

On Wed, 30 Jun 2010, Martin Sivak wrote:


- when development ('devel' argument) mode is requested, init enables
core dumping and starts shell in the case of unexpected exit
---
loader/init.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++-----
loader/loader.c | 7 -------
2 files changed, 49 insertions(+), 12 deletions(-)

diff --git a/loader/init.c b/loader/init.c
index 175f1d7..820d3ef 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -44,6 +44,7 @@
#include <sys/stat.h>
#include <sys/swap.h>
#include <sys/time.h>
+#include <sys/resource.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
@@ -516,9 +517,11 @@ int main(int argc, char **argv) {
int doShutdown =0;
reboot_action shutdown_method = HALT;
int isSerial = 0;
+ int isDebugMode = 0;
char * console = NULL;
int doKill = 1;
char * argvc[15];
+ char buf[1024];


Please do not use static buffers. glib provides plenty of utility functions
to read in the contents of files dynamically.


char ** argvp = argvc;
char twelve = 12;
struct serial_struct si;
@@ -563,6 +566,25 @@ int main(int argc, char **argv) {
fatal_error(1);
printf("done
");

+ /* unless the user specifies that they want utf8 */
+ int fdn;
+ if ((fdn = open("/proc/cmdline", O_RDONLY, 0)) != -1) {
+ int len = read(fdn, buf, sizeof(buf) - 1);
+ close(fdn);


g_file_get_contents() makes life easier.


+ if (len > 0 && strstr(buf, "devel")) {
+ printf("Enabling development mode - cores will be dumped
");
+ isDebugMode = 1;
+ }
+ }
+
+ /* these args are only for testing from commandline */
+ for (i = 1; i < argc; i++) {
+ if (!strcmp (argv[i], "serial")) {
+ isSerial = 1;
+ break;
+ }
+ }
+
printf("creating /dev filesystem... ");
fflush(stdout);
if (mount("/dev", "/dev", "tmpfs", 0, NULL))
@@ -618,14 +640,17 @@ int main(int argc, char **argv) {
fatal_error(1);
printf("done
");

- /* these args are only for testing from commandline */
- for (i = 1; i < argc; i++) {
- if (!strcmp (argv[i], "serial")) {
- isSerial = 1;
- break;
+ if (isDebugMode) {
+ /* if anaconda dies suddenly we are doomed, so at least make a coredump */
+ struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
+ int ret = setrlimit(RLIMIT_CORE, &corelimit);
+ if (ret) {
+ perror("setrlimit failed - no coredumps will be available");
}
}

+
+
doKill = getKillPolicy();

#if !defined(__s390__) && !defined(__s390x__)
@@ -872,6 +897,25 @@ int main(int argc, char **argv) {
printf("-- received signal %d", WTERMSIG(waitStatus));
}
printf("
");
+
+ /* If debug mode was requested, spawn shell */
+ if(isDebugMode) {
+ pid_t shellpid;
+
+ printf("Development mode requested spawning shell...
");
+
+ if ((shellpid = fork()) == 0) {
+ execl("/sbin/bash", "/sbin/bash", NULL);
+ }
+ else if (shellpid > 0) {
+ waitpid(shellpid, NULL, 0);
+ }
+ else {
+ perror("Execution of debug shell failed.");
+ }
+
+ }
+
} else {
shutdown_method = REBOOT;
}
diff --git a/loader/loader.c b/loader/loader.c
index 46f6f5e..8287311 100644
--- a/loader/loader.c
+++ b/loader/loader.c
@@ -2385,13 +2385,6 @@ int main(int argc, char ** argv) {
stopNewt();
closeLog();

- /* if anaconda dies suddenly we are doomed, so at least make a coredump */
- struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
- ret = setrlimit(RLIMIT_CORE, &corelimit);
- if (ret) {
- perror("setrlimit failed");
- }
-
if (FL_RESCUE(flags)) {
fmt = _("Running anaconda %s, the %s rescue mode - please wait.
");
} else {



--
David Cantrell <dcantrell@redhat.com>
Red Hat / Honolulu, HI

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 07-02-2010, 02:33 PM
Chris Lumens
 
Default Add better debugging capabilities to loader

I also think this patch set is heading in a very good direction.

> @@ -872,6 +897,25 @@ int main(int argc, char **argv) {
> printf("-- received signal %d", WTERMSIG(waitStatus));
> }
> printf("
");
> +
> + /* If debug mode was requested, spawn shell */
> + if(isDebugMode) {
> + pid_t shellpid;
> +
> + printf("Development mode requested spawning shell...
");
> +
> + if ((shellpid = fork()) == 0) {
> + execl("/sbin/bash", "/sbin/bash", NULL);
> + }
> + else if (shellpid > 0) {
> + waitpid(shellpid, NULL, 0);
> + }
> + else {
> + perror("Execution of debug shell failed.");
> + }
> +
> + }
> +
> } else {
> shutdown_method = REBOOT;
> }

We start a shell on tty2 in various circumstances. I'd love it if we
got rid of all the circumstances and just always had init spawn a shell
on tty2.

I guess the advantage of your way is that we'll have it for serial
console installs, too. Still - I think we should get rid of any
conditions to starting the tty2 shell and just do it as early as
possible.

- Chris

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 07-02-2010, 02:53 PM
John Reiser
 
Default Add better debugging capabilities to loader

> We start a shell on tty2 in various circumstances. I'd love it if we
> got rid of all the circumstances and just always had init spawn a shell
> on tty2.

I agree: always a shell on tty2. Retry every 10 seconds if it exits.

--

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 07-07-2010, 07:16 AM
Martin Sivak
 
Default Add better debugging capabilities to loader

- when development ('devel' argument) mode is requested, init enables
core dumping and starts shell in the case of unexpected exit
---
loader/init.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/loader/init.c b/loader/init.c
index 1a38df3..6d6450e 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -45,6 +45,7 @@
#include <sys/stat.h>
#include <sys/swap.h>
#include <sys/time.h>
+#include <sys/resource.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
@@ -441,13 +442,16 @@ int main(int argc, char **argv) {
int doShutdown =0;
reboot_action shutdown_method = HALT;
int isSerial = 0;
+ int isDevelMode = 0;
char * console = NULL;
int doKill = 1;
char * argvc[15];
+ char buf[1024];
char ** argvp = argvc;
char twelve = 12;
struct serial_struct si;
int i, disable_keys;
+ int ret;

if (!strncmp(basename(argv[0]), "poweroff", 8)) {
printf("Running poweroff...
");
@@ -487,6 +491,25 @@ int main(int argc, char **argv) {
fatal_error(1);
printf("done
");

+ /* unless the user specifies that they want utf8 */
+ int fdn;
+ if ((fdn = open("/proc/cmdline", O_RDONLY, 0)) != -1) {
+ int len = read(fdn, buf, sizeof(buf) - 1);
+ close(fdn);
+ if (len > 0 && strstr(buf, "devel")) {
+ printf("Enabling development mode - cores will be dumped
");
+ isDevelMode = 1;
+ }
+ }
+
+ /* these args are only for testing from commandline */
+ for (i = 1; i < argc; i++) {
+ if (!strcmp (argv[i], "serial")) {
+ isSerial = 1;
+ break;
+ }
+ }
+
printf("creating /dev filesystem... ");
if (mount("/dev", "/dev", "tmpfs", 0, NULL))
fatal_error(1);
@@ -535,12 +558,11 @@ int main(int argc, char **argv) {
fatal_error(1);
printf("done
");

- /* these args are only for testing from commandline */
- for (i = 1; i < argc; i++) {
- if (!strcmp (argv[i], "serial")) {
- isSerial = 1;
- break;
- }
+ /* if anaconda dies suddenly we are doomed, so at least make a coredump */
+ struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
+ ret = setrlimit(RLIMIT_CORE, &corelimit);
+ if (ret) {
+ perror("setrlimit failed - no coredumps will be available");
}

doKill = getKillPolicy();
@@ -658,7 +680,6 @@ int main(int argc, char **argv) {
tcsetattr(0, TCSANOW, &ts);
}

- int ret;
ret = sethostname("localhost.localdomain", 21);
/* the default domainname (as of 2.0.35) is "(none)", which confuses
glibc */
@@ -785,6 +806,25 @@ int main(int argc, char **argv) {
printf("-- received signal %d", WTERMSIG(waitStatus));
}
printf("
");
+
+ /* If debug mode was requested, spawn shell */
+ if(isDevelMode) {
+ pid_t shellpid;
+
+ printf("Development mode requested spawning shell...
");
+
+ if ((shellpid = fork()) == 0) {
+ execl("/sbin/bash", "/sbin/bash", NULL);
+ }
+ else if (shellpid > 0) {
+ waitpid(shellpid, NULL, 0);
+ }
+ else {
+ perror("Execution of debug shell failed.");
+ }
+
+ }
+
} else {
shutdown_method = REBOOT;
}
--
1.6.6.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 07-07-2010, 10:48 AM
Ales Kozumplik
 
Default Add better debugging capabilities to loader

On 07/07/2010 09:16 AM, Martin Sivak wrote:

- when development ('devel' argument) mode is requested, init enables
core dumping and starts shell in the case of unexpected exit
---


Ack, with one nitpick about:


+ /* unless the user specifies that they want utf8 */
+ int fdn;
+ if ((fdn = open("/proc/cmdline", O_RDONLY, 0)) != -1) {
+ int len = read(fdn, buf, sizeof(buf) - 1);
+ close(fdn);
+ if (len> 0&& strstr(buf, "devel")) {
+ printf("Enabling development mode - cores will be dumped
");
+ isDevelMode = 1;
+ }
+ }


The command line parsing is also happening in your second patch and
could be isolated into a function is isys somewhere?


Ales

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 07-14-2010, 02:36 PM
Martin Sivak
 
Default Add better debugging capabilities to loader

- when development ('devel' argument) mode is requested, init enables
core dumping and starts shell in the case of unexpected exit
---
loader/init.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 47 insertions(+), 7 deletions(-)

diff --git a/loader/init.c b/loader/init.c
index 1a38df3..6d6450e 100644
--- a/loader/init.c
+++ b/loader/init.c
@@ -45,6 +45,7 @@
#include <sys/stat.h>
#include <sys/swap.h>
#include <sys/time.h>
+#include <sys/resource.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
@@ -441,13 +442,16 @@ int main(int argc, char **argv) {
int doShutdown =0;
reboot_action shutdown_method = HALT;
int isSerial = 0;
+ int isDevelMode = 0;
char * console = NULL;
int doKill = 1;
char * argvc[15];
+ char buf[1024];
char ** argvp = argvc;
char twelve = 12;
struct serial_struct si;
int i, disable_keys;
+ int ret;

if (!strncmp(basename(argv[0]), "poweroff", 8)) {
printf("Running poweroff...
");
@@ -487,6 +491,25 @@ int main(int argc, char **argv) {
fatal_error(1);
printf("done
");

+ /* unless the user specifies that they want utf8 */
+ int fdn;
+ if ((fdn = open("/proc/cmdline", O_RDONLY, 0)) != -1) {
+ int len = read(fdn, buf, sizeof(buf) - 1);
+ close(fdn);
+ if (len > 0 && strstr(buf, "devel")) {
+ printf("Enabling development mode - cores will be dumped
");
+ isDevelMode = 1;
+ }
+ }
+
+ /* these args are only for testing from commandline */
+ for (i = 1; i < argc; i++) {
+ if (!strcmp (argv[i], "serial")) {
+ isSerial = 1;
+ break;
+ }
+ }
+
printf("creating /dev filesystem... ");
if (mount("/dev", "/dev", "tmpfs", 0, NULL))
fatal_error(1);
@@ -535,12 +558,11 @@ int main(int argc, char **argv) {
fatal_error(1);
printf("done
");

- /* these args are only for testing from commandline */
- for (i = 1; i < argc; i++) {
- if (!strcmp (argv[i], "serial")) {
- isSerial = 1;
- break;
- }
+ /* if anaconda dies suddenly we are doomed, so at least make a coredump */
+ struct rlimit corelimit = { RLIM_INFINITY, RLIM_INFINITY};
+ ret = setrlimit(RLIMIT_CORE, &corelimit);
+ if (ret) {
+ perror("setrlimit failed - no coredumps will be available");
}

doKill = getKillPolicy();
@@ -658,7 +680,6 @@ int main(int argc, char **argv) {
tcsetattr(0, TCSANOW, &ts);
}

- int ret;
ret = sethostname("localhost.localdomain", 21);
/* the default domainname (as of 2.0.35) is "(none)", which confuses
glibc */
@@ -785,6 +806,25 @@ int main(int argc, char **argv) {
printf("-- received signal %d", WTERMSIG(waitStatus));
}
printf("
");
+
+ /* If debug mode was requested, spawn shell */
+ if(isDevelMode) {
+ pid_t shellpid;
+
+ printf("Development mode requested spawning shell...
");
+
+ if ((shellpid = fork()) == 0) {
+ execl("/sbin/bash", "/sbin/bash", NULL);
+ }
+ else if (shellpid > 0) {
+ waitpid(shellpid, NULL, 0);
+ }
+ else {
+ perror("Execution of debug shell failed.");
+ }
+
+ }
+
} else {
shutdown_method = REBOOT;
}
--
1.6.6.1

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 09:34 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org