Where to learn to use debugger

Ty Tower tytower at hotmail.com.au
Sat Mar 15 21:33:30 PDT 2008


I wrote a program and I want to use the debugger on it . I have the debugger console output below and the program file attached .

The digitalmars site is pretty vague . Is there a tute on this anywhere?

Program exited normally.
(gdb) awatch balance
No symbol "balance" in current context.
(gdb) run
Starting program: /home/tytower/Desktop/tango/mystuff/calcLoanRepayments
[Thread debugging using libthread_db enabled]
[New Thread -1210377552 (LWP 5734)]
Month 1   Repaid=2500    Interest=600    Balance =98108
Month 2   Repaid=2452    Interest=588    Balance =96252
Month 3   Repaid=2406    Interest=577    Balance =94431
Month 4   Repaid=2360    Interest=566    Balance =92645
Month 5   Repaid=2316    Interest=555    Balance =90892
Month 6   Repaid=2272    Interest=545    Balance =89174
Month 7   Repaid=2229    Interest=535    Balance =87487
Month 8   Repaid=2187    Interest=524    Balance =85833
Month 9   Repaid=2145    Interest=515    Balance =84210
Month 10   Repaid=2105    Interest=505    Balance =82618
Month 11   Repaid=2065    Interest=495    Balance =81057
Month 12   Repaid=2026    Interest=486    Balance =79525
Month 13   Repaid=1988    Interest=477    Balance =78022
Month 14   Repaid=1950    Interest=468    Balance =76547
Month 15   Repaid=1913    Interest=459    Balance =75101
Month 16   Repaid=1877    Interest=450    Balance =73682
Month 17   Repaid=1842    Interest=442    Balance =72290
Month 18   Repaid=1807    Interest=433    Balance =70925
Month 19   Repaid=1773    Interest=425    Balance =69585
Month 20   Repaid=1739    Interest=417    Balance =68271
Month 21   Repaid=1706    Interest=409    Balance =66982
Month 22   Repaid=1674    Interest=401    Balance =65717
Month 23   Repaid=1642    Interest=394    Balance =64477
Month 24   Repaid=1611    Interest=386    Balance =63260
Month 25   Repaid=1581    Interest=379    Balance =62066
Month 26   Repaid=1551    Interest=372    Balance =60895
Month 27   Repaid=1522    Interest=365    Balance =59746
Month 28   Repaid=1493    Interest=358    Balance =58619
Month 29   Repaid=1465    Interest=351    Balance =57513
Month 30   Repaid=1437    Interest=345    Balance =56428
Month 31   Repaid=1410    Interest=338    Balance =55364
Month 32   Repaid=1384    Interest=332    Balance =54320
Month 33   Repaid=1358    Interest=325    Balance =53296
Month 34   Repaid=1332    Interest=319    Balance =52292
Month 35   Repaid=1307    Interest=313    Balance =51306
Month 36   Repaid=1282    Interest=307    Balance =50339
Month 37   Repaid=1258    Interest=302    Balance =49391
Month 38   Repaid=1234    Interest=296    Balance =48461
Month 39   Repaid=1211    Interest=290    Balance =47548
Month 40   Repaid=1188    Interest=285    Balance =46652
Month 41   Repaid=1166    Interest=279    Balance =45774
Month 42   Repaid=1144    Interest=274    Balance =44912
Month 43   Repaid=1122    Interest=269    Balance =44067
Month 44   Repaid=1101    Interest=264    Balance =43238
Month 45   Repaid=1080    Interest=259    Balance =42424
Month 46   Repaid=1060    Interest=254    Balance =41626
Month 47   Repaid=1040    Interest=249    Balance =40844
Month 48   Repaid=1021    Interest=245    Balance =40076

Totals
  Repaid=       79355.63
  Interest=     19047.71
  Monthly Fee=    384.00
  Balance=      40076.08

  Total to Pay=119431.71

 Actual Average Rate= 6.79


Program exited normally.
(gdb) break 45
No line 45 in file "../sysdeps/i386/dl-procinfo.c".


PS this attachment block on the web mail does not seem to work or it is perhaps size limited so I will copy it in here

module calcLoanRepayments;
import tango.io.Stdout;
import LoanAccount;


	public  void main(char[][] args)
	{  //initial Loan Amount
   		double initialLoan = 100000;
		//create the loan account
		LoanAccount  la = new LoanAccount(initialLoan);
		double totalRepayments=0;
		double totalInterest=0;
	   //set the monthly fee
	   la.setFee(-8.0);//minus because its a loan and adds to the Balance
	   					// Due ,not deducted from balance held by Bank
	    					//	
	   //set the interest rate
	   la.Rate(7.2);
		//set the length of the loan in months
		int months = 48 ;   
						
			//for no of months,repay 2.5% of the O/S balance each month after
		//accruing monthly interest (and fees if appropriate
		int i;
    	
for (i=1;i<months+1;i++)
		{  double dCents = cast (int)(la.Balance()/40*100);
   		double repaymentAmount =dCents/100;
			totalRepayments += repaymentAmount;
   	
   		la.Monthly();
   	
   		totalInterest += la.interestAmount(); 
	   	   
			la.Withdrawal(repaymentAmount);
		
			Stdout.format("Month {} " , i);
			Stdout.format("  Repaid={}  ",cast(int) repaymentAmount);
	   	Stdout.format("  Interest={}  ",cast(int) la.interestAmount()); 
	    Stdout.formatln("  Balance ={}  ",cast(int)	la.Balance());
		}      
	double monthlyCharges = months*la.getFee();
	Stdout.newline;
  Stdout.formatln("Totals" );
	Stdout.formatln("  Repaid=       {}  ",totalRepayments);
  Stdout.formatln("  Interest=     {}  ",totalInterest); 
	Stdout.formatln("  Monthly Fee=    {}  " ,(+cast(int) -1*monthlyCharges)) ;
  Stdout.formatln("  Balance=      {}  ",la.Balance).newline;

  Stdout.formatln("  Total to Pay={}  ",(totalRepayments+la.Balance())).newline;
   

   double averageLoan = ((initialLoan-la.Balance())/2)+la.Balance();
   double years=i/12;
   double averageYearlyInterest=totalInterest/years;
   double actualRate= ((averageYearlyInterest+(1/2*monthlyCharges))/averageLoan)*100;
   int nCents = cast(int) (actualRate * 100);
   actualRate = cast(double) nCents;
   Stdout.formatln(" Actual Average Rate= {}  ", actualRate/100).newline;

	}




More information about the Digitalmars-d-debugger mailing list