How to filter DTrace output for Objective-C? - objective-c

I am learning DTrace, and it is very powerful tool. But one problem is that DTrace outputs too much information and most of those are NS classes.
But my question is how I can filter system classes if users' classes do not have proper prefix?
(There was a similar Stack Overflow question for this topic, [How to detect without the system method or system framework with DTrace on Mac OS X?].)

DTrace uses Filename generation-like syntax to specify probe names. E.g. you could specify first characters of a class name by using brackets [ and ].
E.g. if you want to filter all NS* classes:
objc$target::[ABCDEFGHIJKLMOPQRSTUVWXYZ]*:entry (N is removed)
objc$target::N[ABCDEFGHIJKLMNOPQRTUVWXYZ]*:entry (S is removed)
But you have to repeat it for each prefix Apple uses, like CA, IK etc.

Related

What unique features does Felix programming language have? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Felix is yet another programming language so what special features does it have?
Felix is a high performance scripting language which generates efficient C++. It's motto is hyperlight meaning it is intended to run faster than C. This is achieved by extensive static whole program analysis and inlining.
The language is used like Python by simply running scripts:
flx hello.flx
but underneath your code is translated to C++ and compiled to machine binary and then run. Extensive dependency checking and caching optimises build time automatically, and a pkgconfig like database is used to fully automate linking external libraries, including the Felix run time. C, Objective C, C++, and Objective C++ can also be compiled and linked, and can also use the autolinking feature, allowing C++ code to be run like a script too: say goodbye to makefiles and build systems!
The language provides an optional garbage collector, but also supports manual memory management, it conforms to your system C++ compiler ABI and allows embedding C++ types and functions easily:
type Int = "int";
const One : Int = "1";
fun +: Int * Int -> Int = "$1+$2";
proc show: Int = "::std::cout << $1 << ::std::endl;"
requires header '#include <iostream>'
;
show (One + One + One);
Felix has a sophisticated high power first order type system including explicit kinding constraints, parametric polymorphism, Haskell style type classes, Ocaml style polymorphic variants, and supports polyadic (rank independent) array programming using compact linear types.
Felix appears as a traditional Algol like procedural language with a very strong functional programming subsystem, including support for Monads. However the procedural coding model is based on coroutines using channels to communicate. The resulting lightweight threading model can be elevated to true concurrency, achieving Go-lang performance without sacrificing C/C++ compatibility.
Whilst many programming language now provide operator overloading, and some even allow user defined operators, Felix goes a lot further by placing the whole grammar in the user library. This allows the programmer to design Domain Specific Sub-Languages (DSSLs). For example the Regular Definition DSSL allows one to write:
regdef cident = (underscore | letter) (underscore | letter | digit)*;
using a BNF like syntax, the grammar for which is defined in user space. Similarly bindings to objective C can be conveniently expressed using the ObjC DSSL.
Source: https://github.com/felix-lang/felix
Homepage: http://felix-lang.org
Some docs: https://felix.readthedocs.io/en/latest/index.html

systemverilog module namespaces

I am combining two designs into a single chip design. The RTL code is written in SystemVerilog for synthesis. Unfortunately, the two designs contain a number of modules with identical names but slightly different logic.
Is there a namespace or library capability in SystemVerilog that would allow me to specify different modules with the same name? In other words is there a lib1::module1, lib2::module1 syntax I could use to specify which module I want? How is this sort of module namespace pollution best handled?
Thanks
Look into config and library. See IEEE Std 1800-2017 § 33. Configuring the contents of a design
library will map this files to target libraries based on file paths (IEEE Std 1800-2017 § 33.3. Libraries)
config will map which library to use for paralytic module (global, instances, subscope) (IEEE Std 1800-2017 § 33.4. Configurations)
Examples are provided in the section 33.8.
Note: some simulators want -libmap <configfile> in the command line. Refer to your simulators manual.
Unfortunately, neither verilog nor system verilog provide a comprehensive solution for the namespaces problem for design element (which include modules). V2K libraries and config statements (yes,they were introduced in verilog v2k) can partially help you solving this issue for modules only, and only if you plan for this in advance and use correct methodology to implement it. Not many people try to use v2k libs to solve it.
There are other parts of this as well, which you might discover. It include other design elements, macro names, file names, package names, ... System verilog makes it even worse with introducing of the global scopes.
So, depending on the complexity of your design you might be able to fix it with v2k libs. But in general, the solution always lies in the methodology and having those names uniquified upfront. Some companies even try to use on-fly uniquification by automatically rewriting verilog code in order to make those names unique.
You might also be able to solve some of the issues like that using compilation units, as defined in the SV standard and which are implemented at least by major tool vendors.

How to strip Objective-C symbols from OS X binary?

OK, I know there have been other posts about how you can't actually strip Objective-C symbols from an OS X binary because they're necessary for Obj-C to work at all, but my case is a bit different.
I have a single binary which is a bundle. It is intended to be used as either a VST plugin, or an AudioUnit plugin. The idea is that the binary contains all the entry points for both formats, and you just compile it once, and then name one copy with ".vst" for the VST version, and ".component" for the AU version. (This is using the JUCE framework BTW.)
The problem is that for the AU side, you must export an Obj-C class for creating the Cocoa UI view. On the VST side, this class will never be used. But if you have a host like Ableton Live which allows you to simultaneously load both AU and VST versions of the same plugin, now we run into the typical Obj-C namespace collision issue.
On the VST side, that particular Obj-C class will never get used. So what I'd like to do is to strip those Obj-C classes from the resulting binary using "strip". This still maintains the advantage of just compiling everything once for both formats.
Anyway, I've tried using "strip -R stripfile.txt <path to binary>", where stripfile.txt contains the symbols I want to strip, but it always fails saying that the symbols can't be found in the binary. I've tried mangling the names in the strip file, but that doesn't help (or I'm doing it wrong).
Here are the relevant symbols that I want to strip, as output by "nm -m":
000000000003bb00 (__TEXT,__text) non-external -[JuceDemoProjectAU description]
000000000003bb60 (__TEXT,__text) non-external -[JuceDemoProjectAU interfaceVersion]
000000000003ba00 (__TEXT,__text) non-external -[JuceDemoProjectAU uiViewForAudioUnit:withSize:]
0000000000b02398 (__DATA,__objc_data) external _OBJC_CLASS_$_JuceDemoProjectAU
0000000000b023c0 (__DATA,__objc_data) external _OBJC_METACLASS_$_JuceDemoProjectAU
Any ideas?
BTW, I have subsequently been able to dynamically register the class in question (using a unique name), which also solves the problem. However, if I could get strip working, I could potentially deploy a solution for already existing binaries in the field.
You can not just simply strip a class from a binary. What you can do however is to trick the Objective-C runtime into believing your plugin does not contain any Objective-C code. Just change __objc_imageinfo into __objc_imageinfX for example in your VST plugin binary. You can do it easily with perl:
perl -pi -e 's/__objc_imageinfo/__objc_imageinfX/g' <path to binary>
After patching the VST plugin, all the Objective-C initialization will be bypassed and you won’t see this error message: Class JuceDemoProjectAU is implemented in both …/VSTPlugin and …/AUPlugin. One of the two will be used. Which one is undefined.
Beware, you should really not use this trick! The appropriate solution to your problem is either to compile two different version of your plugin or to register classes dynamically as others suggested.
There was a thread about something similar to this on the coreaudio-list last year: Collision between Cocoa classes for AU and VST plugins.
The solution offered was to register the classes dynamically which is what you say you already have working. If there was a way to strip the symbols like you wanted, I'm sure these guys would have known about it.

List of already used objective-c Prefixes

I'm looking to choose a namespace for a library I'm writing and I'd like to avoid conflicts with other namespaces.
Does anyone know of a website that lists all of the class prefixes in use?
https://cocoadev.github.io/ChooseYourOwnPrefix/ is probably your best bet. It's not "official", but it's a place a lot of devs would look.
In practice, as long as you don't use one that Apple uses, you'll probably be fine.
According to the Apple "Programming in Objective C" document of 2012-12-13, Apple reserves all 2 character prefixes for use in their frameworks. Users are encouraged to employ 3 character prefixes when naming their classes to avoid conflicts with Apple. See the "Conventions" section for details.
As an alternative to initial-letters prefixes:
If you're writing an application, use no prefix. You're unlikely to encounter another class named AppController in your app.
Otherwise, use the product name as the prefix. For example, if you've written a color picker named “Whizbang”, name its principal class “WhizbangColorPicker”.
"You should try to choose namesthat clearly associate each symbol with your framework. For example, consider
adding a short prefix to all external symbol names. Prefixes help differentiate the symbols in your framework
from those in other frameworks and libraries. They also make it clear to other developers which framework is
being used. Typical prefixes include the first couple of letters or an acronym of your framework name. For
example, functions in the Core Graphics framework use the prefix “CG”
https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/BPFrameworks.pdf

Is there a free library for morphological analysis of the German language?

I'm looking for a library which can perform a morphological analysis on German words, i.e. it converts any word into its root form and providing meta information about the analysed word.
For example:
gegessen -> essen
wurde [...] gefasst -> fassen
Häuser -> Haus
Hunde -> Hund
My wishlist:
It has to work with both nouns and verbs.
I'm aware that this is a very hard task given the complexity of the German language, so I'm also looking for libaries which provide only approximations or may only be 80% accurate.
I'd prefer libraries which don't work with dictionaries, but again I'm open to compromise given the cirumstances.
I'd also prefer C/C++/Delphi Windows libraries, because that would make them easier to integrate but .NET, Java, ... will also do.
It has to be a free library. (L)GPL, MPL, ...
EDIT: I'm aware that there is no way to perform a morphological analysis without any dictionary at all, because of the irregular words.
When I say, I prefer a library without a dictionary I mean those full blown dictionaries which map each and every word:
arbeite -> arbeiten
arbeitest -> arbeiten
arbeitet -> arbeiten
arbeitete -> arbeiten
arbeitetest -> arbeiten
arbeiteten -> arbeiten
arbeitetet -> arbeiten
gearbeitet -> arbeiten
arbeite -> arbeiten
...
Those dictionaries have several drawbacks, including the huge size and the inability to process unknown words.
Of course all exceptions can only be handled with a dictionary:
esse -> essen
isst -> essen
eßt -> essen
aß -> essen
aßt -> essen
aßen -> essen
...
(My mind is spinning right now :) )
I think you are looking for a "stemming algorithm".
Martin Porter's approach is well known among linguists. The Porter stemmer is basically an affix stripping algorithm, combined with a few substitution rules for those special cases.
Most stemmers deliver stems that are linguistically "incorrect". For example: both "beautiful" and "beauty" can result in the stem "beauti", which, of course, is not a real word. This doesn't matter, though, if you're using those stems to improve search results in information retrieval systems. Lucene comes with support for the Porter stemmer, for instance.
Porter also devised a simple programming language for developing stemmers, called Snowball.
There are also stemmers for German available in Snowball. A C version, generated from the Snowball source, is also available on the website, along with a plain text explanation of the algorithm.
Here's the German stemmer in Snowball: http://snowball.tartarus.org/algorithms/german/stemmer.html
If you're looking for the corresponding stem of a word as you would find it in a dictionary, along with information on the part of speech, you should Google for "lemmatization".
(Disclaimer: I'm linking my own Open Source projects here)
This data in form of a word list is available at http://www.danielnaber.de/morphologie/. It could be combined with a word splitter library (like jwordsplitter) to cover compound nouns not in the list.
Or just use LanguageTool from Java, which has the word list embedded in form of a compact finite state machine (plus it also includes compound splitting).
You asked this a while ago, but you might still give it a try with morphisto.
Here's an example on how to do it in Ubuntu:
Install the Stuttgart finite-state transducer tools
$ sudo apt-get install sfst
Download the morphisto morphology, e.g. morphisto-02022011.a
Compact it, e.g.
$ fst-compact morphisto-02022011.a morphisto-02022011.ac
Use it! Here are some examples:
$ echo Hochzeit | fst-proc morphisto-02022011.ac
^Hochzeit/hohZeit<+NN>/hohZeit<+NN>/hohZeit<+NN>/hohZeit<+NN>/HochZeit<+NN>/HochZeit<+NN>/HochZeit<+NN>/HochZeit<+NN>/Hochzeit<+NN>/Hochzeit<+NN>/Hochzeit<+NN>/Hochzeit<+NN>$
$ echo gearbeitet | fst-proc morphisto-02022011.ac
^gearbeitet/arbeiten<+ADJ>/arbeiten<+ADJ>/arbeiten<+V>$
Have a look at LemmaGen (http://lemmatise.ijs.si/) which is a project that aims at providing standardized open source multilingual platform for lemmatisation. It is doing exactly what you want.
I don't think that this can be done without a dictionary.
Rules-based approaches will invariably trip over things like
gegessen -> essen
gegangen -> angen
(note to people who don't speak german: the correct solution in the second case is "gehen").
Have a look at Leo.
They offer the data which you are after, maybe it gives you some ideas.
One can use morphisto with ParZu (https://github.com/rsennrich/parzu). ParZu is a dependency parser for German.
This means that the ParZu also disambiguate the output from morphisto
There are some tools out there which you could use like the morph. component in the Matetools, Morphisto etc. But the pain is to integrate them in your tool chain. A very good wrapper around quite a lot of these linguistic tools is DKpro (https://dkpro.github.io/dkpro-core/), a framework using UIMA. It allows you to write your own preprocessing pipeline using different linguistic tools from different resources which are all downloaded automatically on your computer and speak to each other. You can use Java or Groovy or even Jython to use it. DKPro provides you easy access to two morphological analyzers, MateMorphTagger and SfstAnnotator.
You don't want to use a stemmer like Porter, it will reduce the word form in a way which does not make any sense linguistically and does not have the behaviour you describe. If you only want to find the basic form, for a verb that would be the infinitive and for a noun the nominative singular, then you should use a lemmatizer. You can find a list of German lemmatizers here. Treetagger is widely used. You can also use a more complex analysis provided by a morphological analyzer like SMORS. It will give you something like this (example from the SMORS website):
And here is the analysis of "unübersetzbarstes" showing prefixation, suffixation and >gradation:
un<PREF>übersetzen<V>bar<SUFF><+ADJ><Sup><Neut><Nom><Sg><St>