LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-08-2012, 09:24 AM   #1
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Rep: Reputation: 70
How do I print a 1d array in gdb and show all the elements...


Here is what I have tried so far.
Code:
(gdb) print *cache_array@1024
$10 = {0, 0, 0, 241426, 16432, 241506, 241013, 241479, 241506, 241013, 241426, 241479, 241506, 241427, 241013, 241479, 
  241013, 16432, 241479, 241506, 241506, 241260, 16432, 16432, 241426, 240850, 241124, 241249, 241506, 241251, 16432, 
  241249, 241251, 16432, 241249, 241506, 240850, 241124, 241495, 241249, 16432, 240850, 241124, 241249, 240850, 241249, 
  16432, 241506, 241495, 16432, 241491, 241506, 241495, 16432, 241506, 241239, 241425, 241239, 376817, 241506, 241251, 
  241425, 376817, 376817, 241506, 16435, 16434, 376817, 241429, 241251, 16435, 241429, 241506, 241491, 241425, 241238, 
  241425, 241506, 376817, 241238, 241506, 376817, 16435, 241491, 16435, 16432, 241255, 241506, 241255, 241491, 16432, 
  241506, 16432, 241257, 241506, 241251, 16432, 241506, 241426, 241506, 241426, 16432, 241251, 241506, 16432, 241401, 
  241506, 241426, 241251, 16435, 16432, 241491, 241506, 241260, 241251, 376817, 16432, 241252, 241506, 376817, 376817, 
  241256, 241253, 241252, 241253, 241481, 241260, 241256, 16437, 241251, 241506, 241426, 16437, 16432, 241506, 241426, 
  241426, 16437, 16432, 241506, 241481, 16437, 241426, 241506, 16437, 16435, 241426, 241506, 16434, 241506, 16437, 241426, 
  16437, 16420, 241471, 241506, 16437, 16420, 241471, 241426, 241506, 16432, 16420, 241426, 16432, 16420, 241506, 241426, 
  16420, 241506, 241426, 16437, 241506, 376817, 241426, 376817, 241506, 241426, 16437, 241426, 16420, 16437, 241506, 376817, 
  241260, 241506, 376817, 241506, 376817, 241426, 16431, 241506, 376817, 241426, 16431, 393214, 16420, 241258, 16431, 
  393214...}
But it only prints about 160 of them instead of 1024, which is the number of elements in the array. How do I print them all? I'm thinking there's a string limit, which is why there is an "..." at the end. How do I increase that?

I thought about it more, and now I know why.

-Tristan

Last edited by trist007; 11-08-2012 at 09:47 AM.
 
Old 11-08-2012, 09:34 AM   #2
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
Nevermind got it. The help function in GDB is quite good.

set print elements 2048

You can print 1 element per line with
set print array on

Or disable it if it's not your bag
set print array off

-Tristan

Last edited by trist007; 11-08-2012 at 09:37 AM.
 
Old 11-08-2012, 09:35 AM   #3
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,052

Original Poster
Rep: Reputation: 70
Actually another question. On my first post, notice the first 3 elements are 0s. Why is that?

-Tristan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl - Regex with Array Elements BarataPT Programming 6 03-14-2011 03:03 PM
c++ array question on non assigned elements davimint Programming 9 11-24-2008 09:43 AM
trimming perl array elements homey Programming 7 02-17-2008 03:48 PM
print array elements in one line bharatbsharma Programming 1 10-29-2007 08:58 AM
syntax for gdb to print elements of 2D array? johnpaulodonnell Programming 4 03-26-2007 07:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration