1

I maintain a shared object written in c/c++. I would like to be able to log all calls to the library's methods in order to replay the same sequence of method calls for debug and testing.

I can use ltrace to record all calls to the library but am looking to some tools or library to help replay the trace. I basically just need to parse the trace and call the same functions with the same inputs and do some special handling for the pointers. Here is an example of the trace info after some filtering:

27105 sv_sxp_bfm_CreateSxpMemoryChannelBfm@libsxpbfmall.so(0x1397668, 1, 1, 15) = 0x1a53080
27105 sv_sxp_bfm_ConnectDPICallbacks@libsxpbfmall.so(0x1a53080, 0, 0x1a53080, 1) = 0x2aaaafe4918e
27105 sv_sxp_bfm_GetPhy@libsxpbfmall.so(0x1a53080, 0, 0x1a53080, 1) = 0x1a571a0
27105 sv_sxp_bfm_LoadRegisters@libsxpbfmall.so(0x1a53080, 0, 0x13bb3b0, 0x1a53080) = 6
27105 sv_sxp_bfm_ReadCfg@libsxpbfmall.so(0x1a53080, 0x13913d0, 0x1a53080, 0x13913d0) = 5
27105 sv_sxp_phy_SetTime@libsxpbfmall.so(0x1a571a0, 2500, 0x1a571a0, 2500) = 2500
27105 sv_sxp_phy_SetCLK@libsxpbfmall.so(0x1a571a0, 1, 0x1a571a0, 1) = 1
27105 sv_sxp_phy_SetRst@libsxpbfmall.so(0x1a571a0, 0, 0x1a571a0, 0) = 0
27105 sv_sxp_phy_SetCA@libsxpbfmall.so(0x1a571a0, 0, 0x1a571a0, 0) = 0
27105 sv_sxp_phy_SetSELIN@libsxpbfmall.so(0x1a571a0, 1, 0x1a571a0, 1) = 1
cphurley82
  • 64
  • 7
  • 1
    "and do some special handling for the pointers" - and there's the problem. Wouldn't you have to archive all the states of the pointed-to objects in the log? Otherwise how can you build the objects in order to replay the log? – Richard Hodges Dec 16 '15 at 18:15
  • The library is a behavioral model of hardware so it doesn't point to any external objects. The only pointers are to the model's instantiation itself and all the inputs and outputs are just integers. – cphurley82 Dec 16 '15 at 20:08
  • Ok, so a simple parser to figure out the call and parameters, and a big switch should do it shouldn't it? If you want to get fancy, boost::spirit is probably a good first port of call. – Richard Hodges Dec 16 '15 at 20:49
  • Thanks, for the suggestion to use boost::spirit to parse. I was thinking the same thing about using a giant switch statement but thought I'd ask the question to see if there was a more elegant way. I figured that doing this would be more common than my googling revealed but I suppose being a hardware model my library is actually much simpler than most in terms of the interaction with external classes. – cphurley82 Dec 17 '15 at 23:53

0 Answers0