Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7540045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:32:29+00:00 2026-05-30T07:32:29+00:00

I have a large code base of quite old C code on an embedded

  • 0

I have a large code base of quite old C code on an embedded system and unfortunately there are no automated test cases/suites. This makes restructuring and refactoring code a dangerous task.

Manually writing test cases is very time consuming, so I thought that it should be possible to automate at least some part of this process for instance by tracing all the function calls and recording of the input and output values. I could then use these values in the test cases (this would not work for all but at least for some functions). It would probably also be possible to create mock functions based on the gathered data.

Having such test cases would make refactoring a less dangerous activity.

Are there any solutions that already can do this? What would be the easiest way to get this to work if I had to code it myself?

I thought about using ctags to find the function definitions, and wrapping them in a function that records the parameter values. Another possibility would probably be a gcc compiler plugin.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:32:31+00:00Added an answer on May 30, 2026 at 7:32 am

    There is a gcc option “-finstrument-functions”, which mechanism you can use to define your own callbacks for each funtion’s entry/exit.

    Google it and you can find many good examples.

    [Edit] with this gcc option’s call back you can only track the function’s entry/exit,not the params. but with some tricks you may also track the params. (walk through the current frame pointer to get the param on the stack).

    Here is an article talk about the idea of the implementation:

    http://linuxgazette.net/151/melinte.html

    Furthermore, depends on your embedded system, on linux you can try something like ltrace to show the params(like the strace way). There are many tools do the function trace work either in userspace or kernelspace on linux, ftrace/ust/ltrace/utrace/strace/systemtap/. Anyway, if you do not add any hard debugging code, it’s not possible to display the params in the correct way. If you accept the efforts to add entry/exit debugging infomation, then it’s much easier.

    Also here is a similar thread talk about this problem.

    Tool to trace local function calls in Linux

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large C# code base. It seems quite buggy at times, and
We have a large code base in MFC and VB. A few applications are
I have a very large code base that contains extensive unit tests (using CppUnit).
I have taken over a large code base and would like to get an
We have a large ASP classic code base but I'm looking to do future
I have a really large VB6 code base with a ton of 3rd party
I have started working with a large code base, and a lot of the
I have large C code base for a micro-controller. I am working on a
We have rather large code base (150+ projects, 400000+ lines of Java code, some
I have a very large code base whose build.xml consists of so many jar,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.