When I modify hello.c included with g-wan to include a simple header with #define TEST_VALUE 50 and output it in the hello.c file I noticed that a change to the header file did not trigger an update for g-wan to update the servlet. So if I change the header file test value to 51, no change is noted in the output. If I make any change to the hello.c file, it causes g-wan to recompile the servlet including the dependencies and the change in the header is compiled. Is this the expected behavior? I'm curious because that would mean during development with many dependencies, you would need to update just one character in the main servlet file to trigger a re-compile if all the changes being made are in dependency files.
This behavior was noted by Tim Bolton so I decided to also test it, and pose it as a separate question from a previous thread.
Thanks for any input.
G-WAN 3.3.28 64-bit (Mar 28 2012 11:24:16) - the latest version I saw in the download as of Oct 19th, 2012
... running on Ubuntu Server 10.04.4 LTS - 64 bit
Is this the expected behavior?
Yes.
that would mean during development with many dependencies, you would need to update just one character in the main servlet file to trigger a re-compile if all the changes being made are in dependency files.
No. There's a better way used by programmers for (at least) the past 30 years.
The touch Unix command is updating the time stamp of a file without changing its contents.
Just touch the hello.c servlet when you change its headers.
Also note that C headers are supposed to be more 'stable' than C files. What is stored in headers is there to be shared by many C files so you should consider to use C files for defines that change often.
At least you know how to proceed in both cases now.
I am also having this issue so I created a servlet to help me solve it. Using this I don't need to update every file on my CSP folder. I posted the code on my blog.
Update servlet_dependencies
The script just runs touch command on all files under CSP folder.
Related
I'm currently trying to add changes in how the SQLite virtual machine executes its code. To do that, I edit the vdbe.c file from the SQLite source.
The issue is, compiling SQLite consists in generating two huge implementation and header files (sqlite3.c and sqlite3.h) by amalgamating several smaller ones, after parsing some of them to generate code and documentation.
Unfortunately, the amalgamation process takes a relatively long time (about 15 seconds). I was wondering if there would be a somewhat easy way to not compile everything every time like it currently is the case, and possibly save a lot of compile time.
The main difficulty stems from the fact that source files are not valid by themselves (they can only compile once they have been amalgamated so that some types have already been defined earlier in the amalgamated file). After several attempts with a simple hand-written Python script (that would simply extract the virtual machine execution code from the amalgamation and keep the rest together), I came to the conclusion that there are two many edge cases to do it this way. I don't really know how to proceed.
Any suggestions are welcome.
I'd say: check in the amalgamation into your source code repository, treat it as your own artifact, and work on it. Whenever you wish to update the amalgamation, use git to help you.
Create two branches sqlite-upstream and sqlite-local.
Check in upstream amalgamation "v1" to sqlite upstream, then merge that to sqlite-local and do whatever local changes you need in that branch.
When upstream releases "v2", commit that to sqlite-upstream.
Merge or rebase - you may have some conflicts to resolve, but those will be much easier to deal with than manual change tracking.
Merge sqlite-upstream into sqlite-local, or
Duplicate sqlite-local into sqlite-local-v2, then rebase it onto sqlite-upstream, then use sqlite from that branch in dependent code.
So in case anyone needs the answer in the future, here is how I did. You can find the whole discussion on SQLite Forums.
After getting the source:
I have a first make pass where I don't change any file (to compile lemon, possibly among others):
make -f Makefile.linux-gcc
Then, I edit Makefile.linux-gcc and replace all occurrences of gcc with gcc -x none
I change main.mk and change the executable target by adding -lstdc++ at the end:
sqlite3$(EXE): shell.c libsqlite3.a sqlite3.h
$(TCCX) $(READLINE_FLAGS) -o sqlite3$(EXE) $(SHELL_OPT) \
shell.c libsqlite3.a $(LIBREADLINE) $(TLIBS) $(THREADLIB) -lstdc++
I run make again using make -f Makefile.linux-gcc and get my sqlite3 executable as expected.
We have subversion to help us manage our c files (and tortoise svn as front end).
When I want to know the changes in a c module, I (of course) only get the changes in the "body" of the program, not the changes in the include files.
So I wrote a small simple programm finding out all include files of a c module, checking the last subversion change date for each include file and writing the result in an output file.
This way I get a full impression of what has changed recently in the whole module.
But the program is very simple and I would like to know, if there is a solution out there that handles this "full view" of a c module in good way.
As I work on multiple independent change requests at one time in one subversion working folder, it does not help just looking at the result of "check for modifications".
Thanks a lot in advance.
Some handwork (onetime) required, but it can work
Using (file-level type for all files in every "project" /reqiure SVN 1.6+/) create virtual (or real) folders, which will include all files for each project. After it svn log inside such folder in WC will show only related to project-files changes
I am writing a program in C on Linux environment (Debian-Lenny) and would like the program to be updated when an update is available (the program gets notified when a new update is available). I am looking for a way that the program can update itself.
What I am thinking is that the main program invokes a new program to handle the update. The updater program will have(access to) the source code and receive the update information about the changes on the source code, something like that:
edit1: line 20, remove column 5 to 20;
edit2: line25, remove column 4-7 then add "if(x>3){" from the column4
edit3: line 26, enter a new line and insert "x++;"
then kill the main process, recompile the source code, and then replace the new binary with the old one.
or is there a better (easier) and standard way to implement the ability that a program can update itself?
I use the program to control a system with a Linux embedded board. Therefore, I don't want the source code to be accessible to another person (if the system is hacked or something).
If the best way to update a program by using the source code, how do you suggest me to secure the source code? If you suggest me to encrypt the source code, what function (Linux C) can the program use to encrypt and decrypt the source file?
If your target system is Debian, then you should just take advantage of the Debian packaging system to provide updates. Package your compiled application in a .deb package, distribute it on an APT archive which is included in your system's sources.list, and just use cron to schedule a regular update check with apt. The .deb package can include a post-installation script that restarts your application.
You could run an apt-proxy caching proxy on your "gateway" nodes that have internet access, and have the other nodes use that as their apt source.
Distributing source code in this case is probably not appropriate, because then you would need to include a full compiler toolchain on your target system.
What you're describing is very similar to the 80s-style of delivering Unix source code, popularized by the development of PERL. You use diff to get a record of changes between different versions of the source-code, then distribute this "patch" file, and use patch to perform the necessary modifications at the client-end. This doesn't address the network-communication or version-control issues.
A possible downside is that a first-time download may need to apply many patches to bring the version up. This is often the case when investigating old source from nntp:comp.sources.unix.
I noticed in the g-wan User Manual pdf documentation as of 10/19/2012,
http://gwan.ch/download
that it says:
Updating servlets (C, C++, etc.)
When you need to add or update servlets located in the csp directory you can do so without stopping G-WAN (all cached files are updated in real-time).
Yet when I start gwan, it appears to compile everything in the csp directory. That would be down right ugly on a system with 1000's of .c files. Anyway, I tried updating the hello.c file just to see what happens. When I access it again, the changes do not take. I have to restart the server. Also, if I put in a new servlet, like hello2.c, I get "The requested URL was not found on this server." until I restart the server?
what gives?
G-WAN 3.3.28 64-bit (Mar 28 2012 11:24:16) - the latest version I saw in the download as of Oct 19th, 2012
This works for me. I'm running CentOS. The only issue I can find is with header files not updating.
I can't seem to replicate what you're experiencing. What OS are you on?
Gil found the answer. It was permissions. (for the linux newbie like myself) The csp directory must have the same owner/group as how the gwan server is started.
sudo ./gwan -d:www-data:www-data
If started as above, the csp directory must also be www-data as owner and group along with the actual servlet file. In my case it was the hello.c file.
Only applies to the next release which should be soon, version 3.10.x I believe. Search for the tag "g-wan" and you will see other threads where the new version is mentioned.
I'm doing some Linux kernel development, and I'm trying to use Netbeans. Despite declared support for Make-based C projects, I cannot create a fully functional Netbeans project. This is despite compiling having Netbeans analyze a kernel binary that was compiled with full debugging information. Problems include:
files are wrongly excluded: Some files are incorrectly greyed out in the project, which means Netbeans does not believe they should be included in the project, when in fact they are compiled into the kernel. The main problem is that Netbeans will miss any definitions that exist in these files, such as data structures and functions, but also miss macro definitions.
cannot find definitions: Pretty self-explanatory - often times, Netbeans cannot find the definition of something. This is partly a result of the above problem.
can't find header files: self-explanatory
I'm wondering if anyone has had success with setting up Netbeans for Linux kernel development, and if so, what settings they used. Ultimately, I'm looking for Netbeans to be able to either parse the Makefile (preferred) or extract the debug information from the binary (less desirable, since this can significantly slow down compilation), and automatically determine which files are actually compiled and which macros are actually defined. Then, based on this, I would like to be able to find the definitions of any data structure, variable, function, etc. and have complete auto-completion.
Let me preface this question with some points:
I'm not interested in solutions involving Vim/Emacs. I know some people like them, but I'm not one of them.
As the title suggest, I would be also happy to know how to set-up Eclipse to do what I need
While I would prefer perfect coverage, something that only misses one in a million definitions is obviously fine
SO's useful "Related Questions" feature has informed me that the following question is related: https://stackoverflow.com/questions/149321/what-ide-would-be-good-for-linux-kernel-driver-development. Upon reading it, the question is more of a comparison between IDE's, whereas I'm looking for how to set-up a particular IDE. Even so, the user Wade Mealing seems to have some expertise in working with Eclipse on this kind of development, so I would certainly appreciate his (and of course all of your) answers.
Cheers
Eclipse seems to be pretty popular for Linux kernel development:
http://cdtdoug.blogspot.com/2008/12/linux-kernel-debugging-with-cdt.html
http://jakob.engbloms.se/archives/338
http://revver.com/video/606464/debugging-the-linux-kernel-using-eclipsecdt-and-qemu/
I previously wrote up an answer. Now I come up with all the details of the solution and would like to share it. Unfortunately stackoverflow does not allow me to edit the previous answer. So I write it up in this new answer.
It involves a few steps.
[1] The first step is to modify linux scripts to leave dep files in. By default after using them in the build, those dep files are removed. Those dep files contains exact dependency information about which other files a C file depends. We need them to create a list of all the files involved in a build. Thus, modify files under linux-x.y.z/scripts to make them not to remove the dep files like this:
linux-3.1.2/scripts
Kbuild.include: echo do_not_rm1 rm -f $(depfile);
Makefile.build: echo do_not_rm2 rm -f $(depfile);
The other steps are detailed in my github code project file https://github.com/minghuascode/Nbk/blob/master/note-nbkparse. Roughly you do:
[2] Configure with your method of configuration, but be sure use "O=" option to build the obj files into a separate directory.
[3] Then use the same "O=" option and "V=1" option to build linux, and save make output into a file.
[4] Run my nbkparse script from the above github project. It does:
[4.1] Read in the make log file, and the dep files. Generate a mirroring command.
[4.2] Run the mirroring command to hard-link the relevant source files into a separate tree, and generate a make-log file for NetBeans to use.
Now create a NetBeans C project using the mirrored source tree and the generated log file. NetBeans should be able to resolve all the kernel symbols. And you will only see the files involved in the build.
The Eclipse wiki has a page about this: HowTo use the CDT to navigate Linux kernel source
I have been doing some embedded linux development. Including kernel module development and have imported the entire linux kernel source code into Eclipse, as a separate project. I have been building the kernel itself outside of Eclipse(so far), but I don't any reason why I shouldn't be able to set up the build environment within Eclipse to build the kernel. For my projects, as long as I setup the PATH properties to point to the appropriate linux source include directories, it seems to be pretty good about name completion for struct fields, etc.
I can't really comment, on if it is picking up the correct defines and not greying out the correspond sections, as I haven't really paid to much attention to the files within the kernel itself.(so far)
I was also wondering about using Netbeans as a linux 'C' IDE, as I do prefer Netbean's for Java GUI development.
I think this would work (done each step for various projects):
[1] Modify kernel build scripts to leave .d files. By default they are removed.
[2] Log the build process to a file.
[3] Write a script to parse the build log.
[3.1] From the build log, you know every .c files.
[3.2] From the .c file, you know which is the corresponding .d file.
[3.3] Look into .d files to find out all the included .h files.
[3.4] Form a complete .c and .h file list.
[4] Now create a new dir, and use "ln -s" or "ln" to pick files of interest.
Now, create a Netbeans project for existing source code in the [4].
Configure code assistance to use make-log file. You should see
exactly the effective source code as when you build it at [2].
Some explanations to the above steps:
At [2], do a real build so the log file contains the exact files and flags of interest.
Later netbeans will be able to use the exact flags to parse.
At [4], pick only the files you want to see. Incorporating the whole kernel tree into netbeans will be unpractical.
There is a trick to parsing .d files: Many of the depended items are not real paths to a .h file, they are a modified entry for part of the linux config sections in the auto config file. You may need to reverse the modification to figure out which is the real header file.
Actually there is a topic on netbeans site. This is the discussion url: http://forums.netbeans.org/ntopic3075.html . And there is a wiki page linked from the discussion: wiki.netbeans.org/CNDLinuxKernel . Basically it asks you to prefix make with CFLAGS="-g3 -gdwarf-2" .
I found this link very helpful in setting up proper indexing in Eclipse. It requires running a script to alter Eclipse environment to match your kernel options, in my case
$ autoconf-to-eclipse.py ./include/generated/autoconf.h .
An illustrated guide to indexing the linux kernel in eclipse