The compounds of formula or pharmaceutically acceptable salts thereof: wherein: A and B are taken together with the attached carbon atoms to form aryl, wherein said aryl is optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, -C OR 5, -OC R 5, -O(CH 2) n C OR 5, -C R 5, -NHC R 5, -NR 6 R 7, -OC NR 6 R 7 and -C NR 6 R 7; R 1, R 2, R 3 or R 4 is each independently selected from the group consisting of hydrogen, halogen, alkyl, cyano and alkoxyl, wherein said alkyl or alkoxyl is each independently and optionally substituted with one or more groups selected from the group consisting of halogen, hydroxyl, alkyl and alkoxyl; D, E, or G is each independently selected from the group consisting of nitrogen atom and C(R 8); R 5 is selected from the group consisting of hydrogen, alkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl, wherein said alkyl, cycloalkyl, heterocyclyl, aryl or heteroaryl is each independently and optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, carboxyl and alkoxycarbonyl; R 6 or R 7 is each independently selected from the group consisting of hydrogen, alkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl, wherein said alkyl, cycloalkyl, heterocyclyl, aryl or heteroaryl is each independently and optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, carboxyl and alkoxycarbonyl; or, R 6 and R 7 are taken together with the attached N atom to form heterocyclyl, wherein said heterocyclyl contains one or more N, O or S m heteratoms, and said heterocyclyl is optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, carboxyl and alkoxycarbonyl; R 8 is selected from the group consisting of hydrogen, alkyl, halogen, hydroxyl, cyano, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, benzyl, -C OR 5, -OC R 5, -O(CH 2) n C OR 5, -(CH 2) n NR 6 R 7, -C R 5, -NHC R 5, -NR 6 R 7, -OC NR 6 R 7 and -C NR 6 R 7, wherein said alkyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl or benzyl is each independently and optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, oxo, -C OR 5, -OC R 5, -O(CH 2) n C OR 5, -C R 5, -NHC R 5, -NR 6 R 7, -OC NR 6 R 7 and -C NR 6 R 7; m is selected from the group consisting of 0, 1 and 2; and n is selected from the group consisting of 0, 1 and 2. A and B are taken together with the attached carbon atoms to form aryl, wherein said aryl is optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, -C OR 5, -OC R 5, -O(CH 2) n C OR 5, -C R 5, -NHC R 5, -NR 6 R 7, -OC NR 6 R 7 and -C NR 6 R 7; R 1, R 2, R 3 or R 4 is each independently selected from the group consisting of hydrogen, halogen, alkyl, cyano and alkoxyl, wherein said alkyl or alkoxyl is each independently and optionally substituted with one or more groups selected from the group consisting of halogen, hydroxyl, alkyl and alkoxyl; D, E, or G is each independently selected from the group consisting of nitrogen atom and C(R 8); R 5 is selected from the group consisting of hydrogen, alkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl, wherein said alkyl, cycloalkyl, heterocyclyl, aryl or heteroaryl is each independently and optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, carboxyl and alkoxycarbonyl; R 6 or R 7 is each independently selected from the group consisting of hydrogen, alkyl, cycloalkyl, heterocyclyl, aryl and heteroaryl, wherein said alkyl, cycloalkyl, heterocyclyl, aryl or heteroaryl is each independently and optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, carboxyl and alkoxycarbonyl; or, R 6 and R 7 are taken together with the attached N atom to form heterocyclyl, wherein said heterocyclyl contains one or more N, O or S m heteratoms, and said heterocyclyl is optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, carboxyl and alkoxycarbonyl; R 8 is selected from the group consisting of hydrogen, alkyl, halogen, hydroxyl, cyano, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, benzyl, -C OR 5, -OC R 5, -O(CH 2) n C OR 5, -(CH 2) n NR 6 R 7, -C R 5, -NHC R 5, -NR 6 R 7, -OC NR 6 R 7 and -C NR 6 R 7, wherein said alkyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl or benzyl is each independently and optionally substituted with one or more groups selected from the group consisting of alkyl, halogen, hydroxyl, alkoxyl, cycloalkyl, heterocyclyl, aryl, heteroaryl, oxo, -C OR 5, -OC R 5, -O(CH 2) n C OR 5, -C R 5, -NHC R 5, -NR 6 R 7, -OC NR 6 R 7 and -C NR 6 R 7; m is selected from the group consisting of 0, 1 and 2; and n is selected from the group consisting of 0, 1 and 2.