Re: additional questions regarding implementation and test cases | was: Aw: Re: simple? c-coding / gnumeric coding style question ...



On 9/8/21 8:49 AM, newbie nullzwei via gnumeric-list wrote:
thanks for your input, complex stuff, newbies like me would need a simple sample ... will try to find one,
Here's how I would go at what you're doing:

Find a function which is similar to what you want to do. Copy it to a new function (in a new file). Actually you will need to copy more than just one function. Rename the function... so something like "round_down" to "test_round_down". Do all the copying and renaming needed so that you can use test_round_down in the same way as the original. Once you've done that, then you can change the test_round_down code to perform the new functionality that you want.
Developers have a lot of tools to help them.  You can find several in 
'gdb' (GNU Debugger).  With one tool, gdb allows you to "step" through 
the code; i.e., when you execute the code, it shows you the line of the 
source code which is being executed.  As you "step" through the code 
execution, each line in the source code being executed is indicated.  By 
stepping, you can see what the source code is doing, which of course can 
be very informative.
Another tool: gdb can set what's called a "breakpoint".  When you 
execute your code, gdb will run your code and pause execution of code 
where you've set a breakpoint.  This will save you from having to step 
through a lot of code, by jumping to the line of code you are interested 
in.  You can set (and then unset) multiple breakpoints throughout your 
code.  So you can set a breakpoint, run the code, it will stop at your 
breakpoint, then you can step through the code to see what it does.
Finally, you can also set up 'watches' (that's what they were called a 
long time ago).  This means, you specify a variable to display and gdb 
will show the value of that variable as it changes during the execution 
of the code.
There's more to gdb, but those three tools are a good place to start. 
Of course the web has more (and better) documentation on these and other 
tools.
Enjoy!
ken



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]