background preloader

The Penguin!

Facebook Twitter

Assembly - tell gdb to disassemble "unknown" code. Secondary Expansion - GNU `make' 3.8 Secondary Expansion In the previous section we learned that GNU make works in two distinct phases: a read-in phase and a target-update phase (see How make Reads a Makefile). GNU make also has the ability to enable a second expansion of the prerequisites (only) for some or all targets defined in the makefile. In order for this second expansion to occur, the special target .SECONDEXPANSION must be defined before the first prerequisite list that makes use of this feature. If that special target is defined then in between the two phases mentioned above, right at the end of the read-in phase, all the prerequisites of the targets defined after the special target are expanded a second time. In most circumstances this secondary expansion will have no effect, since all variable and function references will have been expanded during the initial parsing of the makefiles. .SECONDEXPANSION: ONEVAR = onefile TWOVAR = twofile myfile: $(ONEVAR) $$(TWOVAR) Secondary Expansion of Explicit Rules.

What is the colon equals sign ( := ) in makefiles? In Linux makefiles, you will often see a notation which looks like this: This is called "expansion assignment". So what is the difference between expansion assignment and ordinary variable assignment ( = )? Let's get straight into a coding example: So nothing unexpected or unusual here! But lets try the same thing using expansion assignment ( := ): Oh no! It appears that we have a frog instead of the porcupine we wanted. In the second example we used ":=". Automatic Variables - GNU `make' 10.5.3 Automatic Variables Suppose you are writing a pattern rule to compile a ‘ .c ’ file into a ‘ .o ’ file: how do you write the ‘ cc ’ command so that it operates on the right source file name? You cannot write the name in the recipe, because the name is different each time the implicit rule is applied. What you do is use a special feature of make , the automatic variables .

These variables have values computed afresh for each rule that is executed, based on the target and prerequisites of the rule. It's very important that you recognize the limited scope in which automatic variable values are available: they only have values within the recipe. Here is a table of automatic variables: The file name of the target of the rule. The target member name, when the target is an archive member. The name of the first prerequisite. The names of all the prerequisites that are newer than the target, with spaces between them. The names of all the prerequisites, with spaces between them. . ‘ $? Install CERN’s ROOT on Linux (Ubuntu 12.04) « Particle Physics and Code.

There comes a time when all particle physicists must grab and install ROOT, and if I may say so what an amazing piece of kit it is. You can do whole manner of things; plotting simple to more complex graphs using 3D visual libriaies, using the numerous built-in mathematics libraries including RooFit for advanced statistics analyses, utilising the parallel PROOF tools, to the powerful TMVA for multivariate analyses. Oh did I mention this is all FREE and I have barely scratched the surface with that pitiful list just mentioned. Of course it can ‘do your head in’ but that is just one of those things. Having around experienced users is always helpful and once you get used to it, well it becomes like driving, but instead of pollution you leave behind pretty plots and colourful rainbows.

I have supplied a shell script for Linux Ubuntu 12.04 users which installs the head development version of ROOT if you supply a parameter to the script called head. Like this: Like Loading... 4.2.2. Externally Managed Build — C/C++ Software Development with Eclipse. Build systems not managed by Eclipse. Recommended (needed) for existing projects.Any build system that supports command line build can be covered using this mechanism. (e.g. Using MSVC) It involves these steps: Add the source within EclipseTell Eclipse how to build it. Since we are covering Zlib source in this book, let’s have a walk through how that code is imported / built into Eclipse. Tip For our example, Zlib is present in C:\sw\src\zlib\1.2.3\zlib-1.2.3 And the build commands is make -f win32/Makefile.gcc LOC="-DDEBUG -g" all Follow the steps as shown below to import any Makefile based project into Eclipse.

The parameters in steps marked [X] might have to be adapted other projects. Programming Comments - How to install and use GCC g++ v4.7 and C++11 on Ubuntu 12.04. Summary I had a bit of extra spare time over the 2011 holiday season, and I wanted to test out some of the new C++11 features. But I know the old GCC C++ compiler I have installed in my usual LTS Ubuntu 10.04 development environment is out-of-date, so the first thing I needed to do is upgrade my OS and GCC to something decent. Here is how I accomplished this task. Ubuntu 12.04 (beta) First thing was to change my operating system. From Canonical, I downloaded the latest daily live .iso file. Here is a decent place to start looking: Installing GCC v4.6 When Ubuntu 12.04 is first installed, it defaults to GCC v4.6.

. $ which g++ gcc /usr/bin/gcc $ gcc --version gcc (Ubuntu/Linaro 4.6.2-9ubuntu1) 4.6.2 A number of development tools are referenced by the meta-package named build-essential, so I started by making sure this package is installed: $ sudo apt-get install build-essential Installing GCC v4.7 Switching compilers. SmashTheStack IO - Level 5: Writing my first buffer overflow. Smashing the Stack for Fun and Profit by Aleph One. Why do environment variables not show up in Makefiles? Where does gcc look for C and C++ header files. Version control - Aborting a merge in Git. Use reentrant functions for safer signal handling. In the early days of programming, non-reentrancy was not a threat to programmers; functions did not have concurrent access and there were no interrupts.

In many older implementations of the C language, functions were expected to work in an environment of single-threaded processes. Now, however, concurrent programming is common practice, and you need to be aware of the pitfalls. This article describes some potential problems due to non-reentrancy of the function in parallel and concurrent programming. Signal generation and handling in particular add extra complexity. This article: Defines reentrancy and includes a POSIX listing of a reentrant functionProvides examples to show problems caused by non-reentrancySuggests ways to ensure reentrancy of the underlying functionDiscusses dealing with reentrancy at the compiler level What is reentrancy?

A reentrant function is one that can be used by more than one task concurrently without fear of data corruption. A reentrant function: Back to top. Dave Korn - RE: malloc mutex and exceptions. This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project. From: "Dave Korn" <dk at artimi dot com>To: <gcc at gcc dot gnu dot org>Date: Mon, 22 Mar 2004 12:44:16 -0000Subject: RE: malloc mutex and exceptions > -----Original Message----- > From: gcc-owner On Behalf Of Ignasi Villagrasa > Sent: 21 March 2004 19:31 > Hi everyone, > > I have been migrating to gcc a server C/C++ based software > and I' like to control SIGSEGV signal exceptions.

So I use > sigaction and the corresponding handlers to accomplish this target. > > The problem arises when a SIGSEGV happens inside a new > operator. Fix the bug in your program that trashes the heap. References: Create a new Git Remote Repository from some local files (or local git repository) at A Waage Blog. So you have some files or a new Rails application, and you want to add this to a new shared remote Git repository. (I’m assuming you have access to your server and are setting up a remote repo over ssh.) I know I can never remember how to do it, so here’s a post for me and hopefully you! Create a local Git repository in your application for your local files. #On local machine cd foo_project git init git add * git commit -m "My initial commit message" Now, create the repository on your Git server.

#On remote machine (Git remote repository)sudo su - gitcd /usr/local/git_root/ Create your new project git repo as a bare Git repository mkdir foo-project.gitcd foo-project.git/git --bare init Make sure permissions are set properly. Git config core.sharedrepository 1git config receive.denyNonFastforwards truefind objects -type d -exec chmod 02770 {} \;#The core.sharedrepository flag tells git to keep everything group readable and writable. ### UPDATED: If you are on git 1.7+ you can simply do this:

Push to only bare repositories. Committed 01 Feb 2009 Typically Git allows you to build whatever kind of workflow you’d like. Instead of saying “you must use it this way”, Git lets you figure out what best works for you and your organization. Like every system though, there are caveats and gotchas, and this tip goes over one of them. Let’s go over some definitions about the subject first: bare repository: a repository cloned using the --bare option, only includes the files/folders inside of the .git directorynon-bare repository: a normal clone, has a working directory with checked out files There’s easy ways to share your changes with Git, but sometimes you want to push and pull from a repository instead.

The best practice here is when you want to push changes, don’t push to a non-bare repository. A quick rule of thumb is to never push into a repository that has a work tree attached to it, until you know what you are doing. Q & A: The difference between hard and soft links LG #105. By Lew Pitcher I participate in about 30 usenet newsgroups, and in a virtual LUG, and a number of questions keep coming up. I've answered a few of these questions often enough to have 'canned' an answer, which I modify, depending on the circumstances. Here's one, now... Q: Can someone give me a simple explanation of the difference between a soft link and a hard link?

The documentation I've read mention these links but make no strong explanations of their meaning and how/when to use them. Thanks! A: OK, I'll give it a try... Unix files consist of two parts: the data part and the filename part. The data part is associated with something called an 'inode'. . ---------------> ! The filename part carries a name and an associated inode number. . --------------> ! More than one filename can reference the same inode number; these files are said to be 'hard linked' together. !

On the other hand, there's a special file type whose data part carries a path to another file. ! Ln in action We see that: How do I close the stdout-pipe when killing a process started with python subprocess Popen. Stack unwinding (stack trace) with GCC | A blog just like many others. I always liked the nice stack trace you get in some languages like java, c#, etc, with a nice clean trace of where the issue happent. Can we have this in C/C++ with gcc? Of course we can. Let’s use the following code in which we try to display our stack trace (assumes you are building it with -g to enable debug symbols): #include void dummy_function2() { // here will call our back_trace function to // display the back_trace } void dummy_function1() { dummy_function2 (); } int main(int argc, char **argv) { dummy_function1 (); } On some platforms, gcc has a built-in function called __builtin_return_address.

The info file says something like: __builtin_return_address (LEVEL)’ This function returns the return address of the current function, or of one of its callers. The availability and useability of this buil-in depends on platform, compiler,etc. Running this will display something like: $ . running the code we get a listing like the following: $ . Sounds good. . $ . There is an easier approach. The libunwind project - Bugs: bug #28397, compilation fails with gcc 4.4.2... [Savannah] Assembly Language Reference Manual. High Level Structure Module Structure LLVM programs are composed of Module‘s, each of which is a translation unit of the input programs. Each module consists of functions, global variables, and symbol table entries. Modules may be combined together with the LLVM linker, which merges function (and global variable) definitions, resolves forward declarations, and merges symbol table entries. Here is an example of the “hello world” module: ; Declare the string constant as a global constant. @.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00" ; External declaration of the puts function declare i32 @puts(i8* nocapture) nounwind ; Definition of main function define i32 @main() { ; i32()* ; Convert [13 x i8]* to i8 *...

This example is made up of a global variable named “.str”, an external declaration of the “puts” function, a function definition for “main” and named metadata “foo”. Calling Conventions “ccc” - The C calling convention “fastcc” - The fast calling convention dllimport. Profiling shared library on Linux using sprof. Ough. It's not as easy as one would expect. (Read here about valgrind if you don't want to use sprof.) First - FORGET ABOUT gprof. gprof is used for the applications but will NOT WORK for shared libraries. Sorry about that. I learned about it the hard way. Second - sprof may make you bite your fingers if your glibc library is not up-to-date. Third - Yes, as it is not enough, there is an other surprize! So, at the end, what do? Assuming you have the patch installed or you have glibc-2.5-34 or newer version installed do as follows (the best, in my opinion, way, assuming you have write access to the current directory.) 1) Compile your shared library (libmylib.so) in debug (-g) mode.

I hope it will help you. Chapter 5: Building shared libraries with Libtool. The person who invented the concept of shared libraries should be given a raise... and a bonus. The person who decided that shared library management and naming conventions should be left to the implementation should be flogged. This opinion is the result of too much negative experience on my part with building shared libraries for multiple platforms without the aid of Libtool.

The very existence of Libtool stands as a witness to the truth of this sentiment. Libtool exists for one purpose only--to provide a standardized, abstract interface for developers desiring to create portable shared libraries. It abstracts both the shared library build process, and the programming interfaces used to dynamically load and access shared libraries at run time. This chapter has downloads! The interfaces between the program executable and modules defined as shared libraries must be well-designed by virtue of the fact that shared library interfaces must be well-specified. Dynamic linking at load time. Bitcoin 的基本原理. Bash String Examples | HACKTUX. Timeout a command in bash without unnecessary delay. Does python have a string contains method. 5 simple ways to troubleshoot using Strace.

EECS 380: gprof Quick-Start Guide.