Changeset 6fb1409 in rtems-tools for linkers/rtems-tld.cpp


Ignore:
Timestamp:
Sep 8, 2014, 10:20:41 PM (7 years ago)
Author:
Chris Johns <chrisj@…>
Branches:
4.10, 4.11, 5, master
Children:
b7ad4a2
Parents:
2126ea7
Message:

rtems-tld: Add entry and exit trace support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • linkers/rtems-tld.cpp

    r2126ea7 r6fb1409  
    136136      rld::strings headers;         /**< Include statements. */
    137137      rld::strings defines;         /**< Define statements. */
     138      std::string  entry_trace;     /**< Code template to trace the function entry. */
    138139      std::string  arg_trace;       /**< Code template to trace an argument. */
     140      std::string  exit_trace;      /**< Code template to trace the function exit. */
    139141      std::string  ret_trace;       /**< Code template to trace the return value. */
    140142      rld::strings code;            /**< Code block inserted before the trace code. */
     
    441443      parse (config, section, "code-blocks", "code",   code, false);
    442444
    443       arg_trace = rld::dequote (section.get_record_item ("arg-trace"));
    444       ret_trace = rld::dequote (section.get_record_item ("ret-trace"));
     445      if (section.has_record ("entry-trace"))
     446        entry_trace = rld::dequote (section.get_record_item ("entry-trace"));
     447      if (section.has_record ("arg-trace"))
     448        arg_trace = rld::dequote (section.get_record_item ("arg-trace"));
     449      if (section.has_record ("exit-trace"))
     450        exit_trace = rld::dequote (section.get_record_item ("exit-trace"));
     451      if (section.has_record ("ret-trace"))
     452        ret_trace = rld::dequote (section.get_record_item ("ret-trace"));
    445453    }
    446454
     
    640648            const signature& sig = (*si).second;
    641649
     650            c.write_line(sig.decl () + ";");
     651
    642652            c.write_line("");
    643653            c.write_line(sig.decl ("__wrap_"));
     
    655665            std::string l;
    656666
    657             for (size_t a = 0; a < sig.args.size (); ++a)
     667            if (!generator_.entry_trace.empty ())
    658668            {
    659               std::string l = ' ' + generator_.arg_trace;
    660               std::string n = rld::to_string ((int) (a + 1));
    661               l = rld::find_replace (l, "@ARG_NUM@", n);
    662               l = rld::find_replace (l, "@ARG_TYPE@", '"' + sig.args[0] + '"');
    663               l = rld::find_replace (l, "@ARG_SIZE@", "sizeof(" + sig.args[0] + ')');
    664               l = rld::find_replace (l, "@ARG_LABEL@", "a" + n);
     669              std::string l = ' ' + generator_.entry_trace;
     670              l = rld::find_replace (l, "@FUNC_NAME@", '"' + sig.name + '"');
     671              l = rld::find_replace (l, "@FUNC_LABEL@", sig.name);
    665672              c.write_line(l);
     673            }
     674
     675            if (!generator_.arg_trace.empty ())
     676            {
     677              for (size_t a = 0; a < sig.args.size (); ++a)
     678              {
     679                std::string l = ' ' + generator_.arg_trace;
     680                std::string n = rld::to_string ((int) (a + 1));
     681                l = rld::find_replace (l, "@ARG_NUM@", n);
     682                l = rld::find_replace (l, "@ARG_TYPE@", '"' + sig.args[0] + '"');
     683                l = rld::find_replace (l, "@ARG_SIZE@", "sizeof(" + sig.args[0] + ')');
     684                l = rld::find_replace (l, "@ARG_LABEL@", "a" + n);
     685                c.write_line(l);
     686              }
    666687            }
    667688
     
    681702            c.write_line(l);
    682703
    683             if (has_ret)
     704            if (!generator_.exit_trace.empty ())
     705            {
     706              std::string l = ' ' + generator_.exit_trace;
     707              l = rld::find_replace (l, "@FUNC_NAME@", '"' + sig.name + '"');
     708              l = rld::find_replace (l, "@FUNC_LABEL@", sig.name);
     709              c.write_line(l);
     710            }
     711
     712            if (has_ret && !generator_.ret_trace.empty ())
    684713            {
    685714              std::string l = ' ' + generator_.ret_trace;
Note: See TracChangeset for help on using the changeset viewer.