trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bc...@apache.org
Subject [trafficserver] 01/08: TS-4931: Add process limits to crash logs.
Date Fri, 14 Oct 2016 17:26:09 GMT
This is an automated email from the ASF dual-hosted git repository.

bcall pushed a commit to branch 7.0.x
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 0378d3fe999f1ef63fd513c2004c6b61f34e742a
Author: James Peach <jpeach@apache.org>
AuthorDate: Tue Oct 4 11:22:32 2016 -0700

    TS-4931: Add process limits to crash logs.
    
    Add /proc/$PID/limits to the crash log. This helps give context to
    malloc failures because we can get a reliable snapshot of any process
    limits in effect at the time.
    
    (cherry picked from commit e27aa3f7f2ce110b1e620bc63cf54ed3940a1f23)
---
 cmd/traffic_crashlog/procinfo.cc         | 45 ++++++++++++++++----------------
 cmd/traffic_crashlog/traffic_crashlog.cc |  3 +++
 cmd/traffic_crashlog/traffic_crashlog.h  |  9 ++++---
 3 files changed, 31 insertions(+), 26 deletions(-)

diff --git a/cmd/traffic_crashlog/procinfo.cc b/cmd/traffic_crashlog/procinfo.cc
index 2650543..440d303 100644
--- a/cmd/traffic_crashlog/procinfo.cc
+++ b/cmd/traffic_crashlog/procinfo.cc
@@ -50,23 +50,41 @@ procfd_readlink(pid_t pid, const char *fname)
   return resolved.release();
 }
 
-bool
-crashlog_write_regions(FILE *fp, const crashlog_target &target)
+// Suck in a file from /proc/$PID and write it out with the given label.
+static bool
+write_procfd_file(const char *filename, const char *label, FILE *fp, const crashlog_target
&target)
 {
   ats_scoped_fd fd;
   textBuffer text(0);
-
-  fd = procfd_open(target.pid, "maps");
+  fd = procfd_open(target.pid, filename);
   if (fd != -1) {
     text.slurp(fd);
     text.chomp();
-    fprintf(fp, "Memory Regions:\n%.*s\n", (int)text.spaceUsed(), text.bufPtr());
+    fprintf(fp, "%s:\n%.*s\n", label, (int)text.spaceUsed(), text.bufPtr());
   }
 
   return !text.empty();
 }
 
 bool
+crashlog_write_regions(FILE *fp, const crashlog_target &target)
+{
+  return write_procfd_file("maps", "Memory Regions", fp, target);
+}
+
+bool
+crashlog_write_procstatus(FILE *fp, const crashlog_target &target)
+{
+  return write_procfd_file("status", "Process Status", fp, target);
+}
+
+bool
+crashlog_write_proclimits(FILE *fp, const crashlog_target &target)
+{
+  return write_procfd_file("limits", "Process Limits", fp, target);
+}
+
+bool
 crashlog_write_uname(FILE *fp, const crashlog_target &)
 {
   struct utsname uts;
@@ -124,23 +142,6 @@ crashlog_write_datime(FILE *fp, const crashlog_target &target)
 }
 
 bool
-crashlog_write_procstatus(FILE *fp, const crashlog_target &target)
-{
-  ats_scoped_fd fd;
-  textBuffer text(0);
-
-  fd = procfd_open(target.pid, "status");
-  if (fd != -1) {
-    text.slurp(fd);
-    text.chomp();
-
-    fprintf(fp, "Process Status:\n%s\n", text.bufPtr());
-  }
-
-  return !text.empty();
-}
-
-bool
 crashlog_write_backtrace(FILE *fp, const crashlog_target &)
 {
   TSString trace = NULL;
diff --git a/cmd/traffic_crashlog/traffic_crashlog.cc b/cmd/traffic_crashlog/traffic_crashlog.cc
index 75a62df..fff02f6 100644
--- a/cmd/traffic_crashlog/traffic_crashlog.cc
+++ b/cmd/traffic_crashlog/traffic_crashlog.cc
@@ -205,6 +205,9 @@ main(int /* argc ATS_UNUSED */, const char **argv)
   crashlog_write_procstatus(fp, target);
 
   fprintf(fp, "\n");
+  crashlog_write_proclimits(fp, target);
+
+  fprintf(fp, "\n");
   crashlog_write_regions(fp, target);
 
   fprintf(fp, "\n");
diff --git a/cmd/traffic_crashlog/traffic_crashlog.h b/cmd/traffic_crashlog/traffic_crashlog.h
index 12db3c0..ee49a17 100644
--- a/cmd/traffic_crashlog/traffic_crashlog.h
+++ b/cmd/traffic_crashlog/traffic_crashlog.h
@@ -65,14 +65,15 @@ struct crashlog_target {
 };
 
 bool crashlog_write_backtrace(FILE *, const crashlog_target &);
-bool crashlog_write_regions(FILE *, const crashlog_target &);
-bool crashlog_write_exename(FILE *, const crashlog_target &);
-bool crashlog_write_uname(FILE *, const crashlog_target &);
 bool crashlog_write_datime(FILE *, const crashlog_target &);
+bool crashlog_write_exename(FILE *, const crashlog_target &);
+bool crashlog_write_proclimits(FILE *, const crashlog_target &);
 bool crashlog_write_procname(FILE *, const crashlog_target &);
 bool crashlog_write_procstatus(FILE *, const crashlog_target &);
 bool crashlog_write_records(FILE *, const crashlog_target &);
-bool crashlog_write_siginfo(FILE *, const crashlog_target &);
+bool crashlog_write_regions(FILE *, const crashlog_target &);
 bool crashlog_write_registers(FILE *, const crashlog_target &);
+bool crashlog_write_siginfo(FILE *, const crashlog_target &);
+bool crashlog_write_uname(FILE *, const crashlog_target &);
 
 #endif /* __TRAFFIC_CRASHLOG_H__ */

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>.

Mime
View raw message