when I am trying to debug the pset3 binary search, I want to use generate to have large numbers to test because my program works fine when I manually enter the values, but only for large values (i.e. 10000) it sometimes does not find the value when it is indeed there

however, I have searched how to use a standard input when running the program in gdb but it just does not work

so first I use this approach pset3 find - gdb with generate as pipe

./generate 10000 0 > testNumbers10000.txt to generate the input file

than I use run args 65516 < testNumbers10000.txt (also tried just run 65516 < testNumbers10000.txt but gave the same error) which just provides me with gibberish information on what went wrong

error message

how can I solve this? My computer still is a laptop 32-bit so is this the problem?: https://www.cygwin.com/ml/cygwin/1999-04/msg00308.html

but I thought that in the virtual environment this should not matter? And I do not understand how I can implement the solution proposed there so I really need some help


If your program is called find do the following.

  1. make find
  2. gdb find
  3. break main
  4. run 65516 < testNumbers10000.txt
  5. next
  • why is there a difference if you put a breakpoint or not? Aug 12 '15 at 8:39
  • No you didn't. You typed: run args 65516 < testNumbers10000.txt. If you payed a little closer attention to what you type, what you copy-paste from sites, and what others tell you, you would have figured it out. Since including the string args makes your argc equal to 3, your program exits.
    – ChrisG
    Aug 12 '15 at 8:41
  • I have included in the question: (also tried just run 65516 < testNumbers10000.txt but gave the same error) Aug 12 '15 at 8:42
  • If you don't include a breakpoint the gdb will just execute the whole code, without stopping to show you step by step what it's doing. You may have edited your comment by I will leave mine as a reminder.
    – ChrisG
    Aug 12 '15 at 8:44
  • I know, but it should still run without an error, no? Anyways, luckily it works now, thanks Aug 12 '15 at 8:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .