Tracking IVV Analysis Through Multiple FSW Builds Jacob
Tracking IV&V Analysis Through Multiple FSW Builds Jacob T Cox Jacob. t. cox@ivv. nasa. gov 1
Agenda • An algorithm to remap lines in text file versions • Several problems this may help solve – Flexelint efficiencies – Code assessment tracking • Questions 2
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–Mc. Ilroy algorithm • Produces a format that ‘ed’ can use to recreate the original from the current file version 3
Diff Utility Output 20, 21 c 20, 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) $ 50 a 51 > I 32 j ; 53, 55 c 54, 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, 59 c 62, 63 < FSW_ASSERT_1(i < DMS_PDP_NUM_PENDING, cix) ; < return &dms_state->hinfo[i] ; --> FSW_ASSERT_1(FALSE, cix) ; > return NULL ; 551 a 556 > I 32 rt ; 556 d 560 < phi = NULL ; Diff Output 20, 21 c 20, 21 51 d 50 54, 59 c 53, 55 62, 63 c 58, 59 556 d 551 560 a 556 562 c 558, 569 570, 574 c 577, 578 577, 579 c 581 c 583, 584 589, 592 d 591 596, 607 d 594 682 d 668 796, 798 d 781 814 c 797 845 c 828 Useful Diff Output 4
Explicit Changes pluto: experiment>. . /bin/code. Fragment curr/dms_pdp. c 48 65 pluto: experiment>. . /bin/code. Fragment prev/dms_pdp. c 48 65 48: 49: STATIC Dms. Pdp. Handle * dms_pdp_get_handle(Dms. Cat. Index cix) { 50: I 32 i ; 51: I 32 j ; 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: for (i=0 ; i<DMS_PDP_NUM_RTYPE ; i++) { 55: break ; 56: for (j=0 ; j<DMS_PDP_NUM_PENDING ; j++) { 56: } 57: if (dms_state->hinfo[i][j]. cix == cix) { 57: } 58: return &dms_state->hinfo[i][j] ; 58: FSW_ASSERT_1(i < DMS_PDP_NUM_PENDING, cix) ; 59: } 59: return &dms_state->hinfo[i] ; 60: } 61: 62: FSW_ASSERT_1(FALSE, cix) ; 62: Dms. Pdp. Info const * dms_pdp_get_info(Dms. Cat. Index cix) { 63: return NULL ; 63: Dms. Pdp. Handle const * phi ; 64: } 64: 65: phi = dms_pdp_get_handle(cix) ; 66: Dms. Pdp. Info const * dms_pdp_get_info(Dms. Cat. Index cix) { 67: Dms. Pdp. Handle const * phi ; 68: 69: phi = dms_pdp_get_handle(cix) ; Red text is changed text 5
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 • } 6
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 7
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 8
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. 3 9. 4. 4 File. c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 9
Some Possible Uses 10
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 11
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. 3 9. 4. 5 File. c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 12
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. 3 9. 4. 5 File. c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 13
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 File. c … 202 int I; 203 204 if (I = j( a, b)) { … 214 } 9. 4. 3 Error 313 9. 4. 5 File. c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 14
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. 3 9. 4. 5 File. c … 213 float I; 214 215 if (I = j( a, b)) { … 225 } 15
Fexelint Warnings currdms_pdp. c 274 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" currdmsdms_pdp. c 289 Info 737 "Loss of sign in promotion from int to unsigned int" currdms_pdp. c 289 Info 713 "Loss of precision (assignment) (unsigned int to int)" currdms_pdp. c 297 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" currdms_pdp. c 305 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" currdms_pdp. c 346 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" currdms_pdp. c 360 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" currdms_pdp. c 375 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" currdms_pdp. c 377 Info 713 "Loss of precision (assignment) (unsigned int to int)" currdms_pdp. c 377 Warning 613 "Possible use of null pointer 'p_dpo_id' in argument to operator 'unary *' …" currdms_pdp. c 327 Info 831 "Reference cited in prior message" currdms_pdp. c 378 Warning 613 "Possible use of null pointer 'p_dpo_length' in argument to operator 'unary *' …" currdms_pdp. c 328 Info 831 "Reference cited in prior message" currdms_pdp. c 379 Warning 613 "Possible use of null pointer 'p_dp_offset' in argument to operator 'unary …" currdms_pdp. c 329 Info 831 "Reference cited in prior message" currdms_pdp. c 406 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" currdmsdms_pdp. c 417 Info 717 "do. . . while(0); " currdms_pdp. c 430 Warning 570 "Loss of sign (arg. no. 2) (int to unsigned int)" currdms_pdp. c 430 Info 717 "do. . . while(0); " 16
Fexelint Warnings Previous Warnings Algorithm Diff File Flex Filter New Warnings Current Warnings 17
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. } 18
New Topic: Assessment Tracking 19
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 20
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. 3 9. 4. 5 File. c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 21
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. 3 9. 4. 5 File. c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 22
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. 3 9. 4. 5 File. c … 213 int I; 214 215 if (I = j( a, b)) { … 225 } 23
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. 3 9. 4. 5 File. c … 213 int I; 214 215 if (I = k( a, b)) { … 225 } 24
Moving Assessments Forward Build 1 A new build is delivered
Moving Assessments Forward Build 1 Assessments are made
Moving Assessments Forward Build 2 Build 1 Assessment Assessment A new build arrives Assessment 27
Moving Assessments Forward Build 2 Build 1 Assessment Assessment Assessment Assessment Use algorithm to bring assessments forward 28
Moving Assessments Forward Build 2 Build 1 Assessment Assessment Assessment Assessment Assessment Make more assessments 29
Moving Assessments Forward Build 2 Build 1 Assessment Assessment Build 3 Assessment Assessment Assessment Assessment 30
Moving Assessments Forward Build 1 Build 2 Build 3 Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment 31
Moving Assessments Forward Build 1 Build 2 Build 3 Assessment Assessment Assessment Assessment Assessment Assessment Assessment Assessment 32
Identifying Un-Assessed Software Final Build Assessment Assessment Un-assessed Software Assessment Assessment 33
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 34
Finale • The ability to remap assessments or warnings to consecutive builds could be useful. 35
Questions? 36
- Slides: 36