Advertisement
Guest User

Untitled

a guest
Dec 18th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 3.61 KB | None | 0 0
  1. diff --git a/buildrun.cxx b/buildrun.cxx
  2. index 629a6d5d0..9e1b1d066 100644
  3. --- a/buildrun.cxx
  4. +++ b/buildrun.cxx
  5. @@ -224,7 +224,7 @@ compile_dyninst (systemtap_session& s)
  6.  
  7.    vector<string> cmd
  8.      {
  9. -      "gcc", "--std=gnu99", s.translated_source, "-o", module,
  10. +      "gcc", "--std=gnu99", s.translated_source, s.symbols_source, "-o", module,
  11.        "-fvisibility=hidden", "-O2", "-I" + s.runtime_path, "-D__DYNINST__",
  12.        "-Wall", WERROR, "-Wno-unused", "-Wno-strict-aliasing",
  13.        "-pthread", "-lrt", "-fPIC", "-shared",
  14. diff --git a/main.cxx b/main.cxx
  15. index bae367e25..0bf461c23 100644
  16. --- a/main.cxx
  17. +++ b/main.cxx
  18. @@ -541,6 +541,7 @@ passes_0_4 (systemtap_session &s)
  19.    // directory.  Note the _src prefix, explained in
  20.    // buildrun.cxx:compile_pass()
  21.    s.translated_source = string(s.tmpdir) + "/" + s.module_name + "_src.c";
  22. +  s.symbols_source = string(s.tmpdir) + "/stap_symbols.c";
  23.  
  24.    PROBE1(stap, pass0__end, &s);
  25.  
  26. diff --git a/runtime/dyninst/linux_defs.h b/runtime/dyninst/linux_defs.h
  27. index b4c692d9b..85088720c 100644
  28. --- a/runtime/dyninst/linux_defs.h
  29. +++ b/runtime/dyninst/linux_defs.h
  30. @@ -50,9 +50,6 @@
  31.     const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
  32.     (type *)( (char *)__mptr - offsetof(type,member) );})
  33.  
  34. -#define __must_be_array(arr) 0
  35. -#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
  36. -
  37.  #ifndef CLOCK_MONOTONIC_RAW
  38.  #define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC
  39.  #endif
  40. diff --git a/session.h b/session.h
  41. index 9463bd20b..0fc534d2c 100644
  42. --- a/session.h
  43. +++ b/session.h
  44. @@ -337,7 +337,8 @@ public:
  45.    // temporary directory for module builds etc.
  46.    // hazardous - it is "rm -rf"'d at exit
  47.    std::string tmpdir;
  48. -  std::string translated_source; // C source code
  49. +  std::string translated_source; // main C source code
  50. +  std::string symbols_source; // C source code for stap_symbols.c
  51.  
  52.    match_node* pattern_root;
  53.    void register_library_aliases();
  54. diff --git a/translate.cxx b/translate.cxx
  55. index cabcad55a..70a2fbc84 100644
  56. --- a/translate.cxx
  57. +++ b/translate.cxx
  58. @@ -7610,14 +7610,20 @@ prepare_symbol_data (systemtap_session& s)
  59.  void
  60.  emit_symbol_data (systemtap_session& s)
  61.  {
  62. -  string symfile = "stap_symbols.c";
  63. +  ofstream kallsyms_out (s.symbols_source.c_str ());
  64.  
  65. -  ofstream kallsyms_out ((s.tmpdir + "/" + symfile).c_str());
  66. -
  67. -  kallsyms_out << "#include <linux/module.h>\n"
  68. -    "#include <linux/kernel.h>\n"
  69. -    "#include <sym.h>\n"
  70. -    "#include \"stap_common.h\"\n";
  71. +  if (s.runtime_usermode_p ())
  72. +    {
  73. +      kallsyms_out << "#include \"stap_common.h\"\n"
  74. +        "#include <sym.h>\n";
  75. +    }
  76. +  else
  77. +    {
  78. +      kallsyms_out << "#include <linux/module.h>\n"
  79. +        "#include <linux/kernel.h>\n"
  80. +        "#include <sym.h>\n"
  81. +        "#include \"stap_common.h\"\n";
  82. +    }
  83.  
  84.    vector<pair<string,unsigned> > seclist;
  85.    map<unsigned, addrmap_t> addrmap;
  86. @@ -7937,6 +7943,16 @@ translate_pass (systemtap_session& s)
  87.  
  88.        s.op->newline() << "#include \"stap_common.h\"";
  89.  
  90. +      if (s.runtime_usermode_p ())
  91. +        {
  92. +          s.op->hdr->line() << "#include <stdint.h>";
  93. +          s.op->hdr->newline() << "#include <stddef.h>";
  94. +          s.op->hdr->newline() << "struct task_struct;";
  95. +          s.op->hdr->newline() << "#define __must_be_array(arr) 0";
  96. +          s.op->hdr->newline() << "#define ARRAY_SIZE(arr) (sizeof(arr) "
  97. +            "/ sizeof((arr)[0]) + __must_be_array(arr))";
  98. +        }
  99. +
  100.        s.op->hdr->newline() << "#ifndef MAXNESTING";
  101.        s.op->hdr->newline() << "#define MAXNESTING " << nesting;
  102.        s.op->hdr->newline() << "#endif";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement