We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Powerful tools for Linux C C developers based on Eclipse

00:00

Formal Metadata

Title
Powerful tools for Linux C C developers based on Eclipse
Title of Series
Number of Parts
84
Author
License
CC Attribution 2.0 Belgium:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal purpose as long as the work is attributed to the author in the manner specified by the author or licensor.
Identifiers
Publisher
Release Date
Language
Production Year2012

Content Metadata

Subject Area
Genre
Abstract
FOSDEM (Free and Open Source Development European Meeting) is a European event centered around Free and Open Source software development. It is aimed at developers and all interested in the Free and Open Source news in the world. Its goals are to enable developers to meet and to promote the awareness and use of free and open source software.
Software developerJSONXMLUML
Software developerCycle (graph theory)Run time (program lifecycle phase)SoftwareLecture/Conference
BuildingExecution unitProjective planeView (database)Text editorRight angleSoftware developerCodeBinary codeProcess (computing)Multiplication signVariety (linguistics)Video game consoleCycle (graph theory)Computer fontGreatest elementFunction (mathematics)XML
Function (mathematics)View (database)QuicksortPerspective (visual)Cartesian coordinate systemTerm (mathematics)Computer iconLecture/Conference
CodeComplete metric spaceIntegrated development environmentCodeComplete metric spaceFormal languagePerspective (visual)Computer iconComputer programmingView (database)XML
Functional (mathematics)Demo (music)Integrated development environmentComplete metric spaceQuicksortVariable (mathematics)SpacetimeGame controllerLecture/Conference
Computer fileFunctional (mathematics)CodeSpacetimeType theoryFunction (mathematics)Parameter (computer programming)Game controllerElectronic mailing listComplete metric spaceXML
Complete metric spaceCodeCodeElectronic mailing listComplete metric spaceSpacetimeLibrary (computing)File formatRight angleComputer configurationCASE <Informatik>XMLLecture/Conference
outputLibrary (computing)Integrated development environmentComplete metric spaceWeb browserOnline helpXML
Declarative programmingExtension (kinesiology)Functional (mathematics)Library (computing)XMLUML
Presentation of a groupCASE <Informatik>InformationComputer fileFunctional (mathematics)Library (computing)String (computer science)Lecture/Conference
Complete metric spaceString (computer science)QuicksortComputer configurationSource codeRight angleParameter (computer programming)Functional (mathematics)Arrow of timeCursor (computers)InformationInclusion mapXML
BuildingProjective planeBinary codeCodeSubject indexingInformationFunctional (mathematics)Abstract syntax treeLibrary (computing)EmailComputer fileSource codeInclusion mapLecture/Conference
Code refactoringVariable (mathematics)Rule of inferenceLocal ringOrder (biology)Functional (mathematics)Physical systemJava applet1 (number)Statement (computer science)XMLUML
Code refactoringLogical constantLocal ringCASE <Informatik>Variable (mathematics)Functional (mathematics)Multiplication signCode refactoringObject-oriented programmingStatement (computer science)Computer fileRight angleLecture/ConferenceXML
Execution unitSystem callFunctional (mathematics)Square number
Keyboard shortcutGoodness of fitComputer fileSquare numberView (database)Right angleTouchscreenComputer fontCursor (computers)Type theoryOpen setGame controllerReal numberLecture/ConferenceXML
Code refactoringExecution unitSquare numberError messageError messageCovering space1 (number)CompilerImplementationText editorCode refactoringXML
Web pageMathematical analysisRepresentation (politics)BuildingExpressionMathematical analysisBitExtension (kinesiology)Source codeComputer fileCASE <Informatik>Computer animation
Mathematical analysisOpen setElement (mathematics)Shift operatorExtension (kinesiology)Statement (computer science)Software bugSource codeCondition numberMatching (graph theory)Parameter (computer programming)Computer fontLibrary (computing)Type theoryView (database)Subject indexingShift operatorError messageGreatest elementCASE <Informatik>CodeLecture/ConferenceXML
Open setElement (mathematics)Shift operatorBuildingBuildingCovering spaceCodeComputer filePlug-in (computing)Hand fanDifferent (Kate Ryan album)Complete metric spaceCompilerChainComputer animationLecture/Conference
Complete metric spaceConfiguration spaceData managementComputer fileInformationBlogBuildingPhysical systemINTEGRALConfiguration spaceSpacetimeGame controllerThread (computing)XML
User profileFrame problemThread (computing)Variable (mathematics)Process (computing)StatisticsVideo game consoleRepresentation (politics)Profil (magazine)Right angleExpected valueComputer programmingView (database)Covering spaceBefehlsprozessorLecture/ConferenceXML
Functional (mathematics)Line (geometry)Greatest elementMultiplication signView (database)RootPasswordDemonInformationLecture/Conference
User profilePrincipal ideal domainPoint (geometry)Memory managementError messageView (database)Text editorINTEGRALGraph (mathematics)Source codeLine (geometry)Semiconductor memoryPrinciple of maximum entropyProfil (magazine)XMLUML
Online helpSource codePlug-in (computing)Semiconductor memoryAssociative propertyLecture/Conference
Form (programming)Software developerLattice (order)TrailSoftware bugTraffic reportingProfil (magazine)Computer filePhysical systemINTEGRALPlug-in (computing)Computer animation
Hacker (term)XML
Content (media)Computer clusterVideoconferencingJSONXMLUML
Transcript: English(auto-generated)
Good morning, everyone. I'm Andrew. I work for Red Hat. And I'm here to talk about some Eclipse tools specifically for C and C++ developers.
So Gunnar spoke about Eclipse runtime stuff, more server-side things. And he said, Eclipse is not just developer tools. Well, I'm here to continue with saying that Eclipse is just developer tools by showing you only developer tools.
OK. So we'll go through some of the typical cycles of software development, code editing, building the code, debugging the code, and profiling the binaries after we've developed them. So I'll show some screenshots. And then, depending upon time, we can do some live demos
and see how that goes. So for those of you not familiar with Eclipse, this is a typical screenshot. This is what Eclipse generally looks like. So the left-hand side, we have our various projects. In the center, you've got your editor, obviously, an outline view on the right, and then various other ancillary views along the bottom.
The console view shows you a variety of the output of the build process. Or you can run your application, see the output there. You can interact with it. So for a command line application, you could enter input and see the output there. And so all these things with the sort of swoopy title bars,
they're called views. And a collection of them like this is called a perspective. So if I use that term, that's all I mean. And in the top right-hand corner there, you can see there's one, two, three, four, five icons. And those are just icons representing the perspective.
So you can easily switch back and forth between, say, if you were doing programming in one language and programming in another or debugging or things like that. So most of the screenshots that I have coming up are just of one of the particular views. So let's get right into some of it. So when you're writing code, one of the really great features in Eclipse is code completion.
You're probably familiar with this from other development environments or maybe from your use of Eclipse. You press Control-Space, and you get completion on function names or method names or variables or all sorts of things like that. Let's do demos as I go through. Let's make it risky and fun. So here in Eclipse, I've got, can you
see the font size big enough for the people in the back? It's OK? No complaints. So I have a C file here. And I could type, say, PR. And then I press Control-Space. And I get functions in glibc that I could possibly complete with. So let's say I go PRI.
You notice that the list of functions is narrowing as I type. So I could pick printf. And then I get a little hover helping me with what the arguments are to the function. And I could type something in there, and we could see the output of it. So code completion, pretty simple. There's also associated API documentation.
I don't know if you noticed, but when I press Control-Space and we have the completion list there, if I hovered on one of the options, I got to the right of it, I got the API documentation that was coming from the library documentation. So in this case, we've taken the API docs for glibc and I believe libstandard, C++, and a few other libraries
and massaged that documentation into a format that's suitable for the completion engine and the API documentation engine in Eclipse. We've actually also recently done the same thing for the DevHelp API browser, which some of you may be familiar with, typically used in GNOME development environments or GTK.
So any libraries that are available in DevHelp are available in Eclipse for hover, completion, all that kind of thing. So we can see that if I go back and I hover over printf, I get the documentation coming from the glibc documentation.
And that works just as you'd expect, just hovering over it. A really cool extension to this is automatically adding an include declaration for functions that you're making use of. So this requires the library documentation to have references to what header files include
those functions. In the case of glibc, because we've massaged the documentation ourselves, we've made sure that that information where present is available. I can't speak to it being generally available for every library. But in the majority of cases where that information is available, we're able to present it. So let's take a look at that.
We'll get rid of my printf here. And then let's say we use one of the string functions. It's a simple example, right? So I can do like i equals like, well, I'll do completion again. Let's say I get rid of that. And I'll do str. So there's all the functions there. You can see the documentation coming up. I can use the arrow keys to go through the options.
And the documentation reflects that. Let's do strlen. And we can just go abc. Some other nice editing features while we're here. There's a faint vertical green bar. You may not be able to see it. But it's sort of a eclipse guessing where you most likely want to go next with the cursor.
So if you press Tab, you're brought there. And you can see I don't want to pass any more arguments to this function. So the green bar is moved to the end now. And then I can add my semicolon there. So again, I can hover over strlen, whatever. But if I put my cursor into it, and I right click under Source, there's
this option that says Add Include. So I can click that. And you'll see that it actually added the include string.h at the top there. So that's, again, because we have that information from the API documentation. So we were able to provide that to this Add Include functionality.
The same thing would be present, obviously, for code within our projects. So if we had more than one project in Eclipse, like say one was a library project and one was a binary making use of that library, we would be able to automatically add the includes for that and link the two projects together and do the building and that kind of thing. I didn't want to harp on the internals, but the way
that it's working is it's building up its own AST and DOM of all the source files that it knows about. It also includes information on the include files, the header files, and has an index that it allows for the quick searching and quick jumping around between them like that.
So yeah, there was just an example, exactly what I did, of adding an include statement. Yep, we have a question? Yeah, there are some preferences on the include ordering. And there's also some, I've heard some recent work being
done on cleaning up unnecessary ones and stuff. Yeah, it would be worth your while to probably explore it. And yeah, OK, I apologize. The question was if there were rules on ordering of the include system includes, your includes, that kind of thing. OK, so refactoring, another kind of interesting feature.
Maybe not as common in the C and C++ world as it is in the Java world, but we can extract functions or create constants, local variables out of things. So in this case, I could actually take this i times i statement and right click,
refactor, and go extract function. I just need to save the file first. And so, oops, sorry. Back over here, so let's call it square. And yeah, we could just do this. And you can see what it's going to change the, gives you a little preview of what it's going to change
the function to. It's going to create a function called square for me. And then it's going to replace what I had highlighted as a call to that function. So I can just hit Finish there. And then you see that we have this square function at the top and then a call to it where I highlighted it. Some of the other cool features, a lot of people think that you have to use the mouse. You have to click around a lot.
Well, you don't actually have to. There's really good keyboard bindings. So for example, if I wanted to navigate through the file really quickly, I can hold Control and press O. And then it gives me this quick outline view. And it'll narrow as I type. So I could do SQ. And then you'll see that it's highlighted. And I just press Enter. And then my cursor is brought right to the square function. So you'll notice that I don't have the outline view open
because I don't have a big screen. So rather than wasting screen real estate, I can just use Control O. There are many other keyboard bindings. If you want me to show you some later, I'll do that. So anyway, there's just some screenshots of what we did for the refactoring.
There's also error highlighting. The C and C++ tools in Eclipse are actually just calling GCC under the covers to do the actual build. There's no compiler implemented. So the error messages are scraped and reflected in the editor with little red underlines squigglies or orange or yellow ones for warnings.
Some other recent developments in Eclipse include static analysis. So this is being done on the fly. You don't need to save your file. It's not using GCC. It's using the internal representation of the source code to do static analysis without doing a build. So you can see in this case, there's just a little bit of an ambiguous expression. So there's a suggestion around adding some parentheses.
This engine is actually quite extensible. I met somebody yesterday here at the conference who had written an extension for it, and the bug hadn't been looked at. So he asked how to get that in. But a lot of people have written extensions. You can see there's also, in the if statement, the argument is a equals 2, the condition, sorry.
And so in that case, it's a warning saying there's a possible assignment in the condition. So all these are toggleable between warnings and errors, and they're quite extensible. Oh, I mentioned the quick outline view. You can also easily navigate around all your source code with Control-Shift-T. So because it
has this index of all the libraries in your code, you can easily just type in like, well, I can do it here. So if I Control-Shift-T and do like, yeah, you can see I tried to square there. And then it shows me all the matches at the bottom, and I can filter on what kind of types I want to look at or whatever. So it's pretty quick to jump around and navigate a code base. It's a really nice way to learn a code base too.
Like I mentioned, it uses GCC under the covers to do the builds. You can change that if anybody's like an ICC fan or something. You can change the compiler and the tool chain that it's using. There's built-in support for using hand-rolled makefiles if you have your own makefiles. And there's also support for the new auto tools,
so Configure, AutoConf, AutoMake. There's a question over here, yeah. Yep, so the comment was that there's CMake support as well. Eclipse is really extensible. So there's actually support for a lot of things
in a lot of different places. Most of what I'm covering here is just kind of like things that are available from the eclipse.org releases. But there are plugins everywhere. And a lot of them provide really useful functionality, such as CMake. So there's completion for AutoConf files as well. So all those pesky AutoConf macros,
you don't necessarily need to remember them. You can just kind of control space your way through. And you see the hover documentation and that kind of thing. The auto tools integration is pretty nice in that it allows you to go quite quick. It knows when to rebuild which files. In the future, we're looking at adding some stuff for package config and other stuff.
Debugging, as you'd expect, there's multi-threaded debugging support. You can have threads paused. You can jump between the various stack frames. You can have one thread going and the other thread paused. You can look at the variables, look at the registers, modify variable values in the variables
view in the top right there. You can see their representation. This is an example of interacting with the program in the console view. So I was typing something in. And then we can see how it behaves from there, set breakpoints, all that you'd expect. And again, this is using GDB under the covers. It's interacting with GDB.
I have three minutes left. So there is support for O profiles. Has anybody ever used O profile before? Yeah, CPU-based statistical profiling tools. So I am quite proud of this work. The people who did it did a really good job.
It's a simple right-click profile with O profile. It'll ask you for the root password, start up the daemon, run your binary, collect the information, stop the daemon, and then present it in this nice view at the bottom. You've got a hierarchical view of how much time was spent in various functions. You can double-click on the function or even the line if you expand the twisty below that, the line of source code.
And it'll integrate with the editor so you get that kind of nice tie-in with your source code. Also recently, we have integration for Valgrind, or Valgrind, depending on how you want to pronounce it. So memcheck, checking for memory errors. You've got a nice view showing the problems. They're also set up in your source code. So you can easily find the errors
that memcheck is showing you. Valgrind massive, we're doing heap profiling. So you can run it under massive, and then you get this nice chart drawn showing you the heap memory usage. You can actually double-click on the points in the graph, and it'll show you Valgrind takes detailed snapshots.
And when it's detailed, it'll show you the actual trace of what was running when that snapshot was taken. So you can kind of maybe help point out where you have problems with memory usage. It'll associate with the source code if I double-click on that. Recently, we have a perf plugin doing similar stuff to OProfile.
We're always looking for suggestions, bug reports, and users. In this brief 15-minute introduction, which went by a lot faster than I thought, I didn't get a chance to mention that there's plugins integrating with Git, Subversion, CVS, obviously. Some of the tools that I really like or think are cool are integration with bug tracking systems, Bugzilla, Jira, Track, whatever.
There's tools for RPM, working with spec files. If there are Debian people out there, we're looking to expand that to debs. And