X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gdb%2Flinux-nat.c;h=0679173764cf3f6593b3b930ef081d8f3f862f6e;hb=5d3b6af6f9b3416184e5b87e5fd3fc4483cf6f81;hp=cc5d3e796410240c0cf7a40639cfaa94d51140ac;hpb=7d85a9c0e3639345cb6d19c139ccb9da5095fc76;p=deliverable%2Fbinutils-gdb.git diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index cc5d3e7964..0679173764 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -2623,9 +2623,9 @@ linux_nat_filter_event (int lwpid, int status, int options) /* Check if the thread has exited. */ if ((WIFEXITED (status) || WIFSIGNALED (status)) && num_lwps > 1) { - /* If this is the main thread, we must stop all threads and - verify if they are still alive. This is because in the nptl - thread model, there is no signal issued for exiting LWPs + /* If this is the main thread, we must stop all threads and verify + if they are still alive. This is because in the nptl thread model + on Linux 2.4, there is no signal issued for exiting LWPs other than the main thread. We only get the main thread exit signal once all child threads have already exited. If we stop all the threads and use the stop_wait_callback to check @@ -2644,13 +2644,14 @@ linux_nat_filter_event (int lwpid, int status, int options) "LLW: %s exited.\n", target_pid_to_str (lp->ptid)); - exit_lwp (lp); - - /* If there is at least one more LWP, then the exit signal was - not the end of the debugged application and should be - ignored. */ - if (num_lwps > 0) - return NULL; + if (num_lwps > 1) + { + /* If there is at least one more LWP, then the exit signal + was not the end of the debugged application and should be + ignored. */ + exit_lwp (lp); + return NULL; + } } /* Check if the current LWP has previously exited. In the nptl @@ -3454,7 +3455,7 @@ linux_nat_find_memory_regions (int (*func) (CORE_ADDR, unsigned long, int, int, int, void *), void *obfd) { - long long pid = PIDGET (inferior_ptid); + int pid = PIDGET (inferior_ptid); char mapsfilename[MAXPATHLEN]; FILE *mapsfile; long long addr, endaddr, size, offset, inode; @@ -3464,7 +3465,7 @@ linux_nat_find_memory_regions (int (*func) (CORE_ADDR, struct cleanup *cleanup; /* Compose the filename for the /proc memory map, and open it. */ - sprintf (mapsfilename, "/proc/%lld/maps", pid); + sprintf (mapsfilename, "/proc/%d/maps", pid); if ((mapsfile = fopen (mapsfilename, "r")) == NULL) error (_("Could not open %s."), mapsfilename); cleanup = make_cleanup_fclose (mapsfile); @@ -3717,7 +3718,9 @@ linux_nat_make_corefile_notes (bfd *obfd, int *note_size) static void linux_nat_info_proc_cmd (char *args, int from_tty) { - long long pid = PIDGET (inferior_ptid); + /* A long is used for pid instead of an int to avoid a loss of precision + compiler warning from the output of strtoul. */ + long pid = PIDGET (inferior_ptid); FILE *procfile; char **argv = NULL; char buffer[MAXPATHLEN]; @@ -3781,14 +3784,14 @@ linux_nat_info_proc_cmd (char *args, int from_tty) if (pid == 0) error (_("No current process: you must name one.")); - sprintf (fname1, "/proc/%lld", pid); + sprintf (fname1, "/proc/%ld", pid); if (stat (fname1, &dummy) != 0) error (_("No /proc directory: '%s'"), fname1); - printf_filtered (_("process %lld\n"), pid); + printf_filtered (_("process %ld\n"), pid); if (cmdline_f || all) { - sprintf (fname1, "/proc/%lld/cmdline", pid); + sprintf (fname1, "/proc/%ld/cmdline", pid); if ((procfile = fopen (fname1, "r")) != NULL) { struct cleanup *cleanup = make_cleanup_fclose (procfile); @@ -3803,7 +3806,7 @@ linux_nat_info_proc_cmd (char *args, int from_tty) } if (cwd_f || all) { - sprintf (fname1, "/proc/%lld/cwd", pid); + sprintf (fname1, "/proc/%ld/cwd", pid); memset (fname2, 0, sizeof (fname2)); if (readlink (fname1, fname2, sizeof (fname2)) > 0) printf_filtered ("cwd = '%s'\n", fname2); @@ -3812,7 +3815,7 @@ linux_nat_info_proc_cmd (char *args, int from_tty) } if (exe_f || all) { - sprintf (fname1, "/proc/%lld/exe", pid); + sprintf (fname1, "/proc/%ld/exe", pid); memset (fname2, 0, sizeof (fname2)); if (readlink (fname1, fname2, sizeof (fname2)) > 0) printf_filtered ("exe = '%s'\n", fname2); @@ -3821,7 +3824,7 @@ linux_nat_info_proc_cmd (char *args, int from_tty) } if (mappings_f || all) { - sprintf (fname1, "/proc/%lld/maps", pid); + sprintf (fname1, "/proc/%ld/maps", pid); if ((procfile = fopen (fname1, "r")) != NULL) { long long addr, endaddr, size, offset, inode; @@ -3883,7 +3886,7 @@ linux_nat_info_proc_cmd (char *args, int from_tty) } if (status_f || all) { - sprintf (fname1, "/proc/%lld/status", pid); + sprintf (fname1, "/proc/%ld/status", pid); if ((procfile = fopen (fname1, "r")) != NULL) { struct cleanup *cleanup = make_cleanup_fclose (procfile); @@ -3896,7 +3899,7 @@ linux_nat_info_proc_cmd (char *args, int from_tty) } if (stat_f || all) { - sprintf (fname1, "/proc/%lld/stat", pid); + sprintf (fname1, "/proc/%ld/stat", pid); if ((procfile = fopen (fname1, "r")) != NULL) { int itmp; @@ -4161,7 +4164,7 @@ linux_nat_xfer_osdata (struct target_ops *ops, enum target_object object, char procentry[sizeof ("/proc/4294967295")]; if (!isdigit (dp->d_name[0]) - || strlen (dp->d_name) > sizeof ("4294967295") - 1) + || NAMELEN (dp) > sizeof ("4294967295") - 1) continue; sprintf (procentry, "/proc/%s", dp->d_name);