Author Topic: Generate Debug enhancements  (Read 1789 times)

shadm

  • Community Member
  • Posts: 49
  • Hero Points: 0
Generate Debug enhancements
« on: August 04, 2016, 02:25:46 PM »
This is related to the quickrefactor.e code that is invoked when selecting "Generate debug..." from within a C/C++ source file.  I work in a variety of systems that use C, usually embedded, and almost never allow me to use "standard" printf for simple debug/logging.  I have a handful of modifications I make to quickrefactor.e ... every time you release a new SE, major or minor.  So, not sure if this belongs in the user macros or here, but it would be nice if some or all of the changes I use could be added to mainline SE.  I am certain most, if not all of them, would be useful to others that use quickrefactor.e for C/C++ source code.

Here are some notes about what the changes do:

  • Don't format void parameter lists so that void fn(void) results in: printf("fn(void=)\n");
    Without this change, it generates a format specifier and typically GCC will complain (FAIL) and you have to go back manually and fix them all by hand.  In some cases, where printf isn't obvious to the compiler, you end up with an even worse problem: random crashes in your program!
  • Use %p to format pointers when they are printed, rather than %x, because GCC often complains
  • Make unsigned long type use %lu instead of %ul - maybe a GCC vs MS Compiler diff, but on linux/GCC, %ul tells GCC to print an unsigned number with the letter 'l' appended-not what you really wanted, I don't think.
  • Added unsigned char formatter to use 0x%02X, rather than assume char.
  • Create/use new SE variable GEN_DBG_FN to define the debug function to use.  Defaults to printf if not defined to retain current behavior, but allows quickly changing to the printf stand-in of the day for a given environment.  So to change my debug function from printf to say DPRINTF, do: 'set GEN_DBG_FN=DPRINTF' and your all set.

I've attached my latest incarnation, integrated with the v21 B2 version so you can easily diff against your current version and see my changes.  I personally would be thrilled if you added all my changes and maybe some others would be as well, but even if you only take a few, that's less for me to keep track of across multiple systems and/or jobs.

Dennis

  • Senior Community Member
  • Posts: 3961
  • Hero Points: 517
Re: Generate Debug enhancements
« Reply #1 on: August 04, 2016, 06:11:37 PM »
I am integrating your changes, except for the environment variable.  While it is a good solution, it isn't consistent with how we handle other user settings.

shadm

  • Community Member
  • Posts: 49
  • Hero Points: 0
Re: Generate Debug enhancements
« Reply #2 on: August 04, 2016, 06:19:17 PM »
Are you considering an alternate solution for the environment variable, or just leaving it out?  Either way, it's good to have the other changes in there, and it still simplifies my life a lot when new versions come out, so a big thank you from me for taking the changes that fit!