360 likes | 454 Views
Tracking IV&V Analysis Through Multiple FSW Builds. Jacob T Cox Jacob.t.cox@ivv.nasa.gov. Agenda. An algorithm to remap lines in text file versions Several problems this may help solve Flexelint efficiencies Code assessment tracking Questions.
E N D
Tracking IV&V Analysis Through Multiple FSW Builds Jacob T Cox Jacob.t.cox@ivv.nasa.gov
Agenda • An algorithm to remap lines in text file versions • Several problems this may help solve • Flexelint efficiencies • Code assessment tracking • Questions
Algorithm to Map Source Files in Consecutive Builds of Code Using the Unix ‘diff‘ utility it is possible to map lines in text files from one version to another version of the same file. • Shipped with version 5 of Unix in 1970 • Uses the Hunt–McIlroy algorithm • Produces a format that ‘ed’ can use to recreate the original from the current file version
Diff Utility Output 20,21c20,21 < * \version $Revision: 180847 $ < * \date $Date: 2011-07-15 15:10:34 -0700 (Fri, 15 Jul 2011) $ --- > * \version $Revision: 204123 $ > * \date $Date: 2012-01-10 22:13:26 -0800 (Tue, 10 Jan 2012) $ 50a51 > I32 j ; 53,55c54,59 < for (i=0 ; i<DMS_PDP_NUM_PENDING ; i++) { < if (dms_state->hinfo[i].cix == cix) { < break ; --- > > for (i=0 ; i<DMS_PDP_NUM_RTYPE ; i++) { > for (j=0 ; j<DMS_PDP_NUM_PENDING ; j++) { > if (dms_state->hinfo[i][j].cix == cix) { > return &dms_state->hinfo[i][j] ; > } 58,59c62,63 < FSW_ASSERT_1(i < DMS_PDP_NUM_PENDING, cix) ; < return &dms_state->hinfo[i] ; --- > FSW_ASSERT_1(FALSE, cix) ; > return NULL ; 551a556 > I32 rt ; 556d560 < phi = NULL ; 20,21c20,21 51d50 54,59c53,55 62,63c58,59 556d551 560a556 562c558,569 570,574c577,578 577,579c581 581c583,584 589,592d591 596,607d594 682d668 796,798d781 814c797 845c828 Diff Output Useful Diff Output
Explicit Changes pluto:experiment> ../bin/codeFragment curr/dms/dms_pdp.c 48 65 48: 49: STATIC DmsPdpHandle * dms_pdp_get_handle(DmsCatIndex cix) { 50: I32 i ; 51: I32 j ; 52: 53: FSW_ASSERT_1(cix < DMS_CAPACITY, cix) ; 54: 55: for (i=0 ; i<DMS_PDP_NUM_RTYPE ; i++) { 56: for (j=0 ; j<DMS_PDP_NUM_PENDING ; j++) { 57: if (dms_state->hinfo[i][j].cix == cix) { 58: return &dms_state->hinfo[i][j] ; 59: } 60: } 61: } 62: FSW_ASSERT_1(FALSE, cix) ; 63: return NULL ; 64: } 65: 66: DmsPdpInfo const * dms_pdp_get_info(DmsCatIndex cix) { 67: DmsPdpHandle const * phi ; 68: 69: phi = dms_pdp_get_handle(cix) ; pluto:experiment> ../bin/codeFragment prev/dms/dms_pdp.c 48 65 48: 49: STATIC DmsPdpHandle * dms_pdp_get_handle(DmsCatIndex cix) { 50: I32 i ; 51: 52: FSW_ASSERT_1(cix < DMS_CAPACITY, cix) ; 53: for (i=0 ; i<DMS_PDP_NUM_PENDING ; i++) { 54: if (dms_state->hinfo[i].cix == cix) { 55: break ; 56: } 57: } 58: FSW_ASSERT_1(i < DMS_PDP_NUM_PENDING, cix) ; 59: return &dms_state->hinfo[i] ; 60: } 61: 62: DmsPdpInfo const * dms_pdp_get_info(DmsCatIndex cix) { 63: DmsPdpHandle const * phi ; 64: 65: phi = dms_pdp_get_handle(cix) ; Red text is changed text
The Algorithm • Parse the diff file lines and store on a list • convert Line Number( target line) { • for each parsed line in the diff file { • determine a trigger line in the current files to update line counts • set skips based on whether the diff line is add, change or delete • if target occurs prior to next change, return calculated value • move to trigger line • if at target then return • perform skips • if past target then it is in a deleted section and does not map • } • The target is past the last diff line so calculate and return • }
Assumptions • Lines do not move from file to file • Lines do not change relative order within a file • Internal changes do not make a previous false positive a true positive • Noise from randomly matching lines will be inconsequential
Aids in Solutions to • Identify repeated Static Code Analysis warnings through consecutive builds • Identifying fixed issues in a new build • Identify where changes in software source have invalidated prior implementation verification analysis • Identify source elements that have no reference in project documentation
Common component Mapping lines of source code to their equivalent in successive builds of code. • Given a line of code in a {new, previous} build, what line is it in the {previous, new} build. File.c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9.4.4 File.c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 9.4.3
Repeated Static Code Analysis Warnings • Klocwork can show new warnings on consecutive builds • Klocwork can show when an issue was fixed • It is difficult to show new warnings for consecutive Flexelint builds
Finding if a Warning was in the Previous Build fexelint finds error 313 on line 215. Error 313 File.c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9.4.5 File.c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 9.4.3
Finding if a Warning was in the Previous Build Ctd. Use the algorithm to see what the equivalent to line 215 was in the previous build Error 313 File.c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9.4.5 File.c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 9.4.3
Finding if a Warning was in the Previous Build Ctd. fexelint has the same error on line 204 of the previous Build which is equivalent to line 215. Error 313 Error 313 File.c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9.4.5 File.c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 9.4.3
Identifying a Fixed Warnings The error on line 204 of the previous Build no longer exists. If an issue had been written it may be closed. Error 313 File.c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9.4.5 File.c … 213 float I; 214 215 if (I = j( a, b)) { … 225 } 9.4.3
Fexelint Warnings curr\dms\dms_pdp.c 274 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" curr\dms\dms_pdp.c 289 Info 737 "Loss of sign in promotion from int to unsigned int" curr\dms\dms_pdp.c 289 Info 737 "Loss of sign in promotion from int to unsigned int" curr\dms\dms_pdp.c 289 Info 713 "Loss of precision (assignment) (unsigned int to int)" curr\dms\dms_pdp.c 297 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" curr\dms\dms_pdp.c 305 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" curr\dms\dms_pdp.c 346 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" curr\dms\dms_pdp.c 360 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" curr\dms\dms_pdp.c 375 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" curr\dms\dms_pdp.c 377 Info 713 "Loss of precision (assignment) (unsigned int to int)" curr\dms\dms_pdp.c 377 Warning 613 "Possible use of null pointer 'p_dpo_id' in argument to operator 'unary *' …" curr\dms\dms_pdp.c 327 Info 831 "Reference cited in prior message" curr\dms\dms_pdp.c 378 Warning 613 "Possible use of null pointer 'p_dpo_length' in argument to operator 'unary *' …" curr\dms\dms_pdp.c 328 Info 831 "Reference cited in prior message" curr\dms\dms_pdp.c 379 Warning 613 "Possible use of null pointer 'p_dp_offset' in argument to operator 'unary …" curr\dms\dms_pdp.c 329 Info 831 "Reference cited in prior message" curr\dms\dms_pdp.c 406 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" curr\dms\dms_pdp.c 417 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" curr\dms\dms_pdp.c 417 Info 717 "do ... while(0);" curr\dms\dms_pdp.c 430 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" curr\dms\dms_pdp.c 430 Info 717 "do ... while(0);"
Fexelint Warnings Previous Warnings Flex Filter Algorithm Diff File New Warnings Current Warnings
Results • A test on the DMS module for MSL version 9.4.2 and 9.4.3 gave 69 warnings from an initial 5,846. • With 44,864 C lines of code • Warning with equivalent line numbers and the same error code were removed. {I’m sure some folks can come up with improved heuristics but it seems to work well right now.}
Code Assessments in MSL • The project had a schedule relating requirements to the build in which they were to be implemented • The IV&V project verified that the requirements were implemented in the build • This assessment including the location was captured in clear text • The locations could not be kept current as new builds were delivered
Tracking Code Assessments Semantic assessment that a requirement is implemented on line 204. Assessment File.c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9.4.5 File.c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 9.4.3
Tracking Code Assessments Ctd. Use algorithm to find line 204 in the next build. Assessment File.c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9.4.5 File.c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 9.4.3
Tracking Code Assessments Ctd Assessment now maps to line 215 in the new build. Assessment File.c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9.4.5 File.c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 9.4.3
Identifying an Assessment has been Invalidated Changes in software invalidates the assessment. Assessment File.c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9.4.5 File.c … 213 int I; 214 215 if (I = k( a, b)) { … 225 } 9.4.3
Moving Assessments Forward Build 1 A new build is delivered
Moving Assessments Forward Build 1 Assessment Assessment Assessment Assessments are made
Moving Assessments Forward Build 2 Build 1 Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment A new build arrives
Moving Assessments Forward Build 2 Build 1 Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Use algorithm to bring assessments forward
Moving Assessments Forward Build 2 Build 1 Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Make more assessments
Moving Assessments Forward Build 2 Build 1 Assessment Build 3 Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment
Moving Assessments Forward Build 2 Build 1 Assessment Build 3 Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment
Moving Assessments Forward Build 2 Build 1 Assessment Build 3 Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment
Identifying Un-Assessed Software Final Build Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment Un-assessed Software
To Make This Work • A standard way to store assessments • A way to associate assessments with source code • A process to move the assessments forward
Finale • The ability to remap assessments or warnings to consecutive builds could be useful.